summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/Config_Handlers/DnC_Dump_T.cpp
blob: dff9365ceb7d436f700731d129720cba70159384 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// $Id$
#ifndef DNC_DUMP_T_C
#define DNC_DUMP_T_C
#include "DnC_Dump.h"
#include "DnC_Dump_T.h"
#include "Dump_Obj.h"

ACE_RCSID (Config_Handlers,
           DnC_Dump_T,
           "$Id$")
namespace Deployment
{
  namespace DnC_Dump_T
  {
    // Dumps a reference
    template <typename ROOT, typename REFERENCE, typename DATA_TYPE,
              typename CLASS>
    void
    dump_ref (const char* caption, REFERENCE& ref,
              const char* root, DATA_TYPE CLASS::*data)
    {
      ACE_DEBUG ((LM_DEBUG, "%s%s:\n",
                  Dump_Obj::indent(), caption));

      const CORBA::Any &val = Dump_Obj::desc (root);

      ROOT *t = 0;

      val >>= t;

      const ROOT &root_obj = *t;

      int value = ref;
      ACE_DEBUG ((LM_DEBUG, "%s%s.name: %s\n",
                  Dump_Obj::indent(), caption,
                  (root_obj.*data)[value].name.in()));
    }

    // Dumps a reference sequence
    template <typename ROOT, typename SEQUENCE, typename DATA_TYPE,
              typename CLASS>
    void
    dump_ref_seq (const char* caption, SEQUENCE& seq, 
                  const char* root, DATA_TYPE CLASS::*data)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "%s%s:\n",
                  Dump_Obj::indent(), caption));

      CORBA::Any val;
      val <<= root;

      for (size_t i = 0; i < seq.length(); ++i)
        {
          const CORBA::Any &val = Dump_Obj::desc (root);

          ROOT *t = 0;

          val >>= t;

          const ROOT &root_obj = *t;
          int value = seq[i];
          ACE_DEBUG ((LM_DEBUG, "%s%s[%d].name: %s\n",
                      Dump_Obj::indent(), caption, i,
                      (root_obj.*data)[value].name.in()));
        }
    }

    // Dumps a sequence
    template <typename SEQUENCE>
    void
    dump_sequence (const char* caption, const SEQUENCE &seq)
    {
      CORBA::ULong size = seq.length ();

      if (size != 0)
        {
          Dump_Obj dump_obj(caption);

          for (CORBA::ULong i = 0; i < size; ++i)
            {
              ACE_DEBUG ((LM_DEBUG, "%s%s %d: \n", Dump_Obj::indent(),
                          caption, i));
              DnC_Dump::dump (seq[i]);
            }
        }
    }
  }
}
#endif /* DNC_DUMP_C */