3 //=============================================================================
7 * $Id: Capabilities.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Arturo Montes <mitosys@colomsat.net.co>
11 //=============================================================================
14 #ifndef ACE_CAPABILITIES_H
15 #define ACE_CAPABILITIES_H
16 #include /**/ "ace/pre.h"
18 #include /**/ "ace/config-all.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/Null_Mutex.h"
25 #include "ace/Hash_Map_Manager_T.h"
26 #include "ace/Containers.h"
27 #include "ace/SString.h"
28 #include "ace/Functor_String.h"
30 #if defined (ACE_IS_SPLITTING)
31 # include "ace/OS_NS_ctype.h"
32 #endif /* ACE_IS_SPLITTING */
35 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
40 * @brief This class is the base class for all ACE Capabilities entry
43 * This class is not instantiable and does not provide accessors
44 * or methods. If you want to add a new kind of attribute subclass
45 * this class and dynamic_cast to proper subclass.
47 class ACE_Export ACE_CapEntry
51 virtual ~ACE_CapEntry (void);
62 ACE_CapEntry (int captype
);
71 * @class ACE_IntCapEntry
73 * @brief This class implement the ACE Integer Capability subclass.
75 * This is a container class for ACE Capabilities integer container
78 class ACE_Export ACE_IntCapEntry
: public ACE_CapEntry
81 ACE_IntCapEntry (int val
);
82 int getval (void) const;
89 * @class ACE_StringCapEntry
91 * @brief This class implement the ACE String Capability subclass.
93 * This is a container class for ACE Capabilities String container
96 class ACE_Export ACE_StringCapEntry
: public ACE_CapEntry
99 ACE_StringCapEntry (const ACE_TString
&val
);
100 ACE_TString
getval (void) const;
107 * @class ACE_BoolCapEntry
109 * @brief This class implement the ACE Bool Capability subclass.
111 * This is a container class for ACE Capabilities bool container
114 class ACE_Export ACE_BoolCapEntry
: public ACE_CapEntry
117 ACE_BoolCapEntry (int val
);
118 int getval (void) const;
125 * @class ACE_Capabilities
127 * @brief This class implement the ACE Capabilities.
129 * This is a container class for ACE Capabilities
130 * values. Currently exist three different capability values:
131 * <ACE_IntCapEntry> (integer), <ACE_BoolCapEntry> (bool) and
132 * <ACE_StringCapEntry> (String). An ACE_Capabilities is a
133 * unordered set of pair = (<String>, <ACE_CapEntry> *). Where
134 * the first component is the name of capability and the second
135 * component is a pointer to the capability value container. A
136 * <FILE> is a container for ACE_Capabilities, the
137 * ACE_Capabilities has a name in the file, as a termcap file.
139 class ACE_Export ACE_Capabilities
143 typedef ACE_Hash_Map_Manager_Ex
<ACE_TString
, ACE_CapEntry
*, ACE_Hash
<ACE_TString
>, ACE_Equal_To
<ACE_TString
>, ACE_Null_Mutex
> CAPABILITIES_MAP
;
146 ACE_Capabilities (void);
149 ~ACE_Capabilities(void);
153 /// Get a string entry.
154 int getval (const ACE_TCHAR
*ent
, ACE_TString
&val
);
156 /// Get an integer entry.
157 int getval (const ACE_TCHAR
*ent
, int &val
);
159 /// Get the ACE_Capabilities name from FILE fname and load the
160 /// associated capabitily entries in map.
161 int getent (const ACE_TCHAR
*fname
, const ACE_TCHAR
*name
);
165 /// Parse an integer property
166 const ACE_TCHAR
*parse (const ACE_TCHAR
*buf
, int &cap
);
168 /// Parse a string property
169 const ACE_TCHAR
*parse (const ACE_TCHAR
*buf
, ACE_TString
&cap
);
171 /// Fill the ACE_Capabilities with description in ent.
172 int fillent(const ACE_TCHAR
*ent
);
174 /// Parse a cap entry
175 int parseent (const ACE_TCHAR
*name
, ACE_TCHAR
*line
);
177 /// Get a line from FILE input stream
178 int getline (FILE* fp
,
182 int is_entry (const ACE_TCHAR
*name
, const ACE_TCHAR
*line
);
184 /// Reset the set of capabilities
185 void resetcaps (void);
189 /// This is the set of ACE_CapEntry.
190 CAPABILITIES_MAP caps_
;
194 #if defined (ACE_IS_SPLITTING)
196 is_empty (const ACE_TCHAR
*line
)
198 while (*line
&& ACE_OS::ace_isspace (*line
))
201 return *line
== ACE_TEXT ('\0') || *line
== ACE_TEXT ('#');
205 is_line (const ACE_TCHAR
*line
)
207 while (*line
&& ACE_OS::ace_isspace (*line
))
210 return *line
!= ACE_TEXT ('\0');
212 #endif /* ACE_IS_SPLITTING */
214 ACE_END_VERSIONED_NAMESPACE_DECL
216 #if defined (__ACE_INLINE__)
217 #include "ace/Capabilities.inl"
218 #endif /* __ACE_INLINE__ */
220 #include /**/ "ace/post.h"
221 #endif /* __ACE_CAPABILITIES_H__ */