summaryrefslogtreecommitdiff
path: root/ace/Name_Space.h
blob: 58ebeb110f66ca536c54cdb199c35b9e710017ee (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
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    Name_Space.h
 *
 *  $Id$
 *
 *  @author Prashant Jain
 */
//=============================================================================


#ifndef ACE_NAME_SPACE_H
#define ACE_NAME_SPACE_H
#include "ace/pre.h"

#include "ace/ACE.h"

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

#include "ace/SString.h"
#include "ace/Containers.h"
#include "ace/Name_Proxy.h"

typedef ACE_Unbounded_Set<ACE_WString> ACE_WSTRING_SET;

/**
 * @class ACE_Name_Binding
 *
 * @brief Maintains a mapping from name to value and type.
 */
class ACE_Export ACE_Name_Binding
{
public:
  // = Initialization and termination.
  /// Main constructor that initializes all the fields.
  ACE_Name_Binding (const ACE_WString &n,
                    const ACE_WString &v,
                    const char *t);

  /// Default constructor.
  ACE_Name_Binding (void);

  /// Copy constructor.
  ACE_Name_Binding (const ACE_Name_Binding &);

  /// Assignment operator.
  void operator= (const ACE_Name_Binding &);

  /// Destructor.
  ~ACE_Name_Binding (void);

  /// Test for equality.
  int operator == (const ACE_Name_Binding &s) const;

  /// Name of the binding.
  ACE_WString name_;

  /// Value of the binding.
  ACE_WString value_;

  /// Type of the binding.
  char *type_;
};

typedef ACE_Unbounded_Set<ACE_Name_Binding> ACE_BINDING_SET;
typedef ACE_Unbounded_Set_Iterator<ACE_Name_Binding> ACE_BINDING_ITERATOR;

typedef ACE_Unbounded_Set<ACE_WString> ACE_PWSTRING_SET;
typedef ACE_Unbounded_Set_Iterator<ACE_WString> ACE_PWSTRING_ITERATOR;

/**
 * @class ACE_Name_Space
 *
 * @brief Abstract base class that provides an abstract interface to
 * the database without exposing any implemenation details.
 *
 * Manages a Naming Service Name Space. Provides the basic
 * methods -- bind, unbind, rebind, find, and listnames.
 */
class ACE_Export ACE_Name_Space
{
public:

  /// virtual destructor to ensure destructors of subclasses get
  /// called.
  virtual ~ACE_Name_Space (void);

  /// Bind a new name to a naming context (Wide character strings).
  virtual int bind (const ACE_WString &name_in,
                    const ACE_WString &value_in,
                    const char *type_in = "") = 0;


  /**
   * Overwrite the value or type of an existing name in a
   * ACE_Name_Space or bind a new name to the context, if it didn't
   * exist yet. (Wide charcter strings interface).
   */
  virtual int rebind (const ACE_WString &name_in,
                      const ACE_WString &value_in,
                      const char *type_in = "") = 0;

  /// Delete a name from a ACE_Name_Space (Wide charcter strings
  /// Interface).
  virtual int unbind (const ACE_WString &name_in) = 0;

  /// Get value and type of a given name binding (Wide chars).  The
  /// caller is responsible for deleting both <value_out> and <type_out>!
  virtual int resolve (const ACE_WString &name_in,
                       ACE_WString &value_out,
                       char *&type_out) = 0;

  /// Get a set of names matching a specified pattern (wchars). Matching
  /// means the names must begin with the pattern string.
  virtual int list_names (ACE_WSTRING_SET &set_out,
                          const ACE_WString &pattern_in) = 0;

  /// Get a set of values matching a specified pattern (wchars). Matching
  /// means the values must begin with the pattern string.
  virtual int list_values (ACE_WSTRING_SET &set_out,
                           const ACE_WString &pattern_in) = 0;

  /// Get a set of types matching a specified pattern (wchars). Matching
  /// means the types must begin with the pattern string.
  virtual int list_types (ACE_WSTRING_SET &set_out,
                          const ACE_WString &pattern_in) = 0;

  /**
   * Get a set of names matching a specified pattern (wchars). Matching
   * means the names must begin with the pattern string. Returns the
   * complete binding associated each pattern match.
   */
  virtual int list_name_entries (ACE_BINDING_SET &set,
                                 const ACE_WString &pattern) = 0;

  /**
   * Get a set of values matching a specified pattern (wchars). Matching
   * means the values must begin with the pattern string. Returns the
   * complete binding associated each pattern match.
   */
  virtual int list_value_entries (ACE_BINDING_SET &set,
                                  const ACE_WString &pattern) = 0;

  /**
   * Get a set of types matching a specified pattern (wchars). Matching
   * means the types must begin with the pattern string. Returns the
   * complete binding associated each pattern match.
   */
  virtual int list_type_entries (ACE_BINDING_SET &set,
                                 const ACE_WString &pattern) = 0;

  /// Dump the state of the object
  virtual void dump (void) const = 0;
};

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