summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Naming/Persistent_Entries.h
blob: 59a65b3dd85777a592e0208fc605f9affe339f2d (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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file   Persistent_Entries.h
 *
 *  $Id$
 *
 *  @author Marina Spivak <marina@cs.wustl.edu>
 */
//=============================================================================


#ifndef TAO_PERSISTENT_ENTRIES_H
#define TAO_PERSISTENT_ENTRIES_H
#include /**/ "ace/pre.h"

#include "ace/Hash_Map_With_Allocator_T.h"
#include "orbsvcs/CosNamingC.h"
#include "naming_serv_export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

/**
 * @class TAO_Persistent_IntId
 *
 * @brief Helper class for TAO_Persistent_Bindings_Map: unifies several
 * data items, so they can be stored together as a  <value>
 * for a <key> in a hash table holding the state of a Persistent
 * Naming Context.
 *
 * This class holds a strigified IOR and a binding type, so
 * they can be stored together as a <value> for a <key> in a
 * hash table holding the state of a Persistent Naming Context.
 * Memory for the ior isn't allocated/deallocated, this class just
 * copies a pointer.
 */
class TAO_Naming_Serv_Export TAO_Persistent_IntId
{
public:
  // = Initialization and termination methods.
  /// Constructor.
  TAO_Persistent_IntId (void);

  /// Constructor.
  TAO_Persistent_IntId (char * obj_ref,
                        CosNaming::BindingType type /* = CosNaming::nobject */);

  /// Copy constructor.
  TAO_Persistent_IntId (const TAO_Persistent_IntId & rhs);

  /// Destructor.
  ~TAO_Persistent_IntId (void);

  /// Assignment operator.
  void operator= (const TAO_Persistent_IntId & rhs);

  // = Data members.

  /// Stringified IOR to be stored in a Persistent Naming Context.
  const char *ref_;

  /// Binding type for <ref_>.
  CosNaming::BindingType type_;
};

/**
 * @class TAO_Persistent_ExtId
 *
 * @brief Helper class for TAO_Persistent_Bindings_Map: unifies several
 * data items, so they can be stored together as a  <key>
 * for a <value> in a hash table holding the state of a Persistent
 * Naming Context.
 *
 * This class holds id and kind strings, so
 * they can be stored together as a <key> for a <value> in a
 * hash table holding the state of a Persistent Naming Context.
 * Memory for id and kind isn't allocated/deallocated, this
 * class just copies pointers.
 */
class TAO_Naming_Serv_Export TAO_Persistent_ExtId
{
public:
  // = Initialization and termination methods.

  /// Constructor.
  TAO_Persistent_ExtId (void);

  /// Constructor.
  TAO_Persistent_ExtId (const char *id,
                        const char *kind);

  /// Copy constructor.
  TAO_Persistent_ExtId (const TAO_Persistent_ExtId & rhs);

  /// Destructor.
  ~TAO_Persistent_ExtId (void);

  // = Assignment and comparison methods.

  /// Assignment operator (does copy memory).
  void operator= (const TAO_Persistent_ExtId & rhs);

  /// Equality comparison operator (must match both id_ and kind_).
  bool operator== (const TAO_Persistent_ExtId &rhs) const;

  /// Inequality comparison operator.
  bool operator!= (const TAO_Persistent_ExtId &rhs) const;

  /// <hash> function is required in order for this class to be usable by
  /// ACE_Hash_Map_Manager.
  u_long hash (void) const;

  // = Data members.

  /// <id> portion of the name to be associated with some object
  /// reference in a Persistent Naming Context.
  const char * id_;

  /// <kind> portion of the name to be associated with some object
  /// reference in a Persistent Naming Context.
  const char * kind_;

  // Accessors.

  const char * id (void);
  const char * kind (void);
};

/**
 * @class TAO_Persistent_Index_IntId
 *
 * @brief Helper class for TAO_Persistent_Context_Index: unifies several
 * data items, so they can be stored together as a  <value>
 * for a <key> in a hash table holding the state of a Persistent
 * Context Index.  (Persistent Context Index is like directory
 * that stores info about every active Naming Context).
 *
 * This class holds a counter and a hash map pointers, so
 * they can be stored together as a <value> for a <key> in a
 * hash table holding the state of a Persistent Context Index.
 */
class TAO_Naming_Serv_Export TAO_Persistent_Index_IntId
{
public:
  // = Initialization and termination methods.
  /// Constructor.
  TAO_Persistent_Index_IntId (void);

  /// Constructor.
  TAO_Persistent_Index_IntId (ACE_UINT32 *counter,
                              ACE_Hash_Map_With_Allocator<TAO_Persistent_ExtId,
                              TAO_Persistent_IntId> * hash_map);

  /// Copy constructor.
  TAO_Persistent_Index_IntId (const TAO_Persistent_Index_IntId & rhs);

  /// Destructor.
  ~TAO_Persistent_Index_IntId (void);

  /// Assignment operator (does copy memory).
  void operator= (const TAO_Persistent_Index_IntId & rhs);

  // = Data members.

  /// Pointer to a Persistent Naming Context's counter.
  ACE_UINT32 *counter_;

  /// Pointer to a Persistent Naming Context's hash map.
  ACE_Hash_Map_With_Allocator<TAO_Persistent_ExtId,
    TAO_Persistent_IntId> * hash_map_;
};

/**
 * @class TAO_Persistent_Index_ExtId
 *
 * @brief Helper class for TAO_Persistent_Context_Index: holds
 * Persistent Naming Context POA id, so it can be stored as a <key>
 * for a <value> in a hash table holding state of a Persistent
 * Context Index.  (Persistent Context Index is like directory
 * that stores info about every active Naming Context).
 *
 * We need this wrapper class around the actual data because we must
 * provide <hash> function for it to work with
 * ACE_Hash_Map_Manager.
 */
class TAO_Naming_Serv_Export TAO_Persistent_Index_ExtId
{
public:
  // = Initialization and termination methods.

  /// Constructor.
  TAO_Persistent_Index_ExtId (void);

  /// Constructor.
  TAO_Persistent_Index_ExtId (const char *poa_id);

  /// Copy constructor.
  TAO_Persistent_Index_ExtId (const TAO_Persistent_Index_ExtId & rhs);

  /// Destructor.
  ~TAO_Persistent_Index_ExtId (void);

  // = Assignment and comparison methods.

  /// Assignment operator (does copy memory).
  void operator= (const TAO_Persistent_Index_ExtId & rhs);

  /// Equality comparison operator (must match both id_ and kind_).
  bool operator== (const TAO_Persistent_Index_ExtId &rhs) const;

  /// Inequality comparison operator.
  bool operator!= (const TAO_Persistent_Index_ExtId &rhs) const;

  /// <hash> function is required in order for this class to be usable by
  /// ACE_Hash_Map_Manager.
  u_long hash (void) const;

  // = Data member.

  /// POA id to be associated with the rest of the info for some
  /// Persistent Naming Context in the Persistent Context Index.
  const char * poa_id_;
};

#include /**/ "ace/post.h"
#endif /* TAO_PERSISTENT_ENTRIES_H */