summaryrefslogtreecommitdiff
path: root/TAO/examples/Simulator/DOVEMIB/Node.h
blob: d8029a4fa5e9098378f70e5c67f8d669a9b29e18 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// $Id$
// ============================================================================
//
// = LIBRARY
//
// = FILENAME
//    Node.h
//
// = AUTHOR
//    Michael Kircher 
//
// = DESCRIPTION
//    This file descibes the various node types for analysing 
//    an CORBA::Any. It is no memory allocated, that means
//    The values are not really contained by the nodes, but the
//    nodes refer to the values via pointers.
//
// ============================================================================

#include "tao/corba.h"
#include "ace/Containers.h"
#include "NodeVisitor.h"

#if !defined (NODE_H)
#define NODE_H


// base class for nodes
class Node {
public: 
  virtual ~Node () {}
  virtual void Accept (NodeVisitor *NodeVisitor) = 0;
  virtual unsigned int getRecursionLevel () = 0;

protected:
  Node () {}
};



// Node to store information about a Struct
class StructNode : public Node {
public:
  StructNode (const char *Name_ptr, 
	      unsigned int recursion_level);
  ~StructNode ();

  // accpet a visitor
  void Accept (NodeVisitor *nodeVisitor);

  // add a new child
  int addChild (Node *node);

  // retrieve the nth Child starting at 0
  Node *getChild (unsigned int n);

  // get the number of children
  unsigned int getChildNumber ();
  
  // get the name of the struct
  const char *getName ();  

  // get recursion level
  unsigned int getRecursionLevel ();
    

private: 
  ACE_Unbounded_Queue<Node *> *queue_ptr_;
  ACE_Unbounded_Queue_Iterator<Node *> *queue_iterator_ptr_;
  unsigned int queue_position_;
  const char *Name_ptr_;
  unsigned int recursion_level_;
};


// Node to store information about a Double
class DoubleNode : public Node {
public:
  DoubleNode (CORBA::Double *Double_ptr, 
	      const char *Name_ptr,
	      unsigned int recursion_level);
  ~DoubleNode () {}

  // accpet a visitor
  void Accept (NodeVisitor *nodeVisitor);

  // get the name of the double node
  const char *getName ();

  // get the value
  CORBA::Double getValue ();

  // get recursion level
  unsigned int getRecursionLevel ();
  
private:
  CORBA::Double *Double_ptr_; 
  const char *Name_ptr_;
  unsigned int recursion_level_;
};


// Node to store information about a Long
class LongNode : public Node {
public:
  LongNode (CORBA::Long *Long_ptr, 
	    const char *Name_ptr,
	    unsigned int recursion_level);
  ~LongNode () {}

  // accpet a visitor
  void Accept (NodeVisitor *nodeVisitor);

  //get the name of the long node
  const char *getName ();

  // get the value
  CORBA::Long getValue ();

  // get recursion level
  unsigned int getRecursionLevel ();

private:
  CORBA::Long *Long_ptr_; 
  const char *Name_ptr_;
  unsigned int recursion_level_;
};


// Node to store information about a ULong
class ULongNode : public Node {
public:
  ULongNode (CORBA::ULong *Long_ptr, 
	     const char *Name_ptr,
	     unsigned int recursion_level);
  ~ULongNode () {} 
  
  // accpet a visitor
  void Accept (NodeVisitor *nodeVisitor);

  // get the name of the ulong node
  const char *getName ();

  // get the value
  CORBA::ULong getValue ();

  // get recursion level
  unsigned int getRecursionLevel ();

private:
  CORBA::ULong *ULong_ptr_;
  const char *Name_ptr_;
  unsigned int recursion_level_;
};


// Node to store information about a String
class StringNode : public Node {
public:
  StringNode (CORBA::String_var String_var, 
	      const char *Name_ptr,
	      unsigned int recursion_level);
  ~StringNode () {}
  
  // accpet a visitor
  void Accept (NodeVisitor *nodeVisitor);

  // get the name
  const char *getName ();

  // get the value
  CORBA::String_var getValue ();

  // get recursion level
  unsigned int getRecursionLevel ();

private:
  CORBA::String_var String_var_;
  const char *Name_ptr_;
  unsigned int recursion_level_;
};

#endif // NODE_H