Capabilities.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Capabilities.h
00006  *
00007  *  Capabilities.h,v 4.20 2006/04/27 11:17:55 jwillemsen Exp
00008  *
00009  *  @author Arturo Montes <mitosys@colomsat.net.co>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_CAPABILITIES_H
00015 #define ACE_CAPABILITIES_H
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/config-all.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/Null_Mutex.h"
00025 #include "ace/Hash_Map_Manager_T.h"
00026 #include "ace/Containers.h"
00027 #include "ace/SString.h"
00028 #include "ace/Functor_String.h"
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 /**
00033  * @class ACE_CapEntry
00034  *
00035  * @brief This class is the base class for all ACE Capabilities entry
00036  * subclasses.
00037  *
00038  * This class is not instantiable and does not provide accessors
00039  * or methods.  If you want to add a new kind of attribute subclass
00040  * this class and dynamic_cast to proper subclass.
00041  */
00042 class ACE_Export ACE_CapEntry
00043 {
00044 public:
00045 
00046    virtual ~ACE_CapEntry (void);
00047 
00048 protected:
00049 
00050   enum
00051   {
00052     ACE_INTCAP = 0,
00053     ACE_STRINGCAP = 1,
00054     ACE_BOOLCAP = 2
00055   };
00056 
00057   ACE_CapEntry (int captype);
00058 
00059 protected:
00060 
00061   int captype_;
00062 
00063 };
00064 
00065 /**
00066  * @class ACE_IntCapEntry
00067  *
00068  * @brief This class implement the ACE Integer Capability subclass.
00069  *
00070  * This is a container class for ACE Capabilities integer container
00071  * values.
00072  */
00073 class ACE_Export ACE_IntCapEntry : public ACE_CapEntry
00074 {
00075 public:
00076   ACE_IntCapEntry (int val);
00077   int getval (void) const;
00078 
00079 protected:
00080   int val_;
00081 };
00082 
00083 /**
00084  * @class ACE_StringCapEntry
00085  *
00086  * @brief This class implement the ACE String Capability subclass.
00087  *
00088  * This is a container class for ACE Capabilities String container
00089  * values.
00090  */
00091 class ACE_Export ACE_StringCapEntry : public ACE_CapEntry
00092 {
00093 public:
00094   ACE_StringCapEntry (const ACE_TString &val);
00095   ACE_TString getval (void) const;
00096 
00097 protected:
00098   ACE_TString val_;
00099 };
00100 
00101 /**
00102  * @class ACE_BoolCapEntry
00103  *
00104  * @brief This class implement the ACE Bool Capability subclass.
00105  *
00106  * This is a container class for ACE Capabilities bool container
00107  * values.
00108  */
00109 class ACE_Export ACE_BoolCapEntry : public ACE_CapEntry
00110 {
00111 public:
00112   ACE_BoolCapEntry (int val);
00113   int getval (void) const;
00114 
00115 protected:
00116   int val_;
00117 };
00118 
00119 /**
00120  * @class ACE_Capabilities
00121  *
00122  * @brief This class implement the ACE Capabilities.
00123  *
00124  * This is a container class for ACE Capabilities
00125  * values. Currently exist three different capability values:
00126  * <ACE_IntCapEntry> (integer), <ACE_BoolCapEntry> (bool) and
00127  * <ACE_StringCapEntry> (String).  An ACE_Capabilities is a
00128  * unordered set of pair = (<String>, <ACE_CapEntry> *).  Where
00129  * the first component is the name of capability and the second
00130  * component is a pointer to the capability value container.  A
00131  * <FILE> is a container for ACE_Capabilities, the
00132  * ACE_Capabilities has a name in the file, as a termcap file.
00133  */
00134 class ACE_Export ACE_Capabilities
00135 {
00136 public:
00137 
00138   typedef  ACE_Hash_Map_Manager_Ex<ACE_TString, ACE_CapEntry *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex> CAPABILITIES_MAP;
00139 
00140   /// The Constructor
00141   ACE_Capabilities (void);
00142 
00143   /// The Destructor
00144   ~ACE_Capabilities(void);
00145 
00146 public:
00147 
00148   /// Get a string entry.
00149   int getval (const ACE_TCHAR *ent, ACE_TString &val);
00150 
00151   /// Get an integer entry.
00152   int getval (const ACE_TCHAR *ent, int &val);
00153 
00154   /// Get the ACE_Capabilities name from FILE fname and load the
00155   /// associated capabitily entries in map.
00156   int getent (const ACE_TCHAR *fname, const ACE_TCHAR *name);
00157 
00158 protected:
00159 
00160   /// Parse an integer property
00161   const ACE_TCHAR *parse (const ACE_TCHAR *buf, int &cap);
00162 
00163   /// Parse a string property
00164   const ACE_TCHAR *parse (const ACE_TCHAR *buf, ACE_TString &cap);
00165 
00166   /// Fill the ACE_Capabilities with description in ent.
00167   int fillent(const ACE_TCHAR *ent);
00168 
00169   /// Parse a cap entry
00170   int parseent (const ACE_TCHAR *name, ACE_TCHAR *line);
00171 
00172   /// Get a line from FILE input stream
00173   int getline (FILE* fp,
00174                ACE_TString &line);
00175 
00176   /// Is a valid entry
00177   int is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line);
00178 
00179   /// Reset the set of capabilities
00180   void resetcaps (void);
00181 
00182 private:
00183 
00184   /// This is the set of ACE_CapEntry.
00185   CAPABILITIES_MAP caps_;
00186 
00187 };
00188 
00189 #if defined (ACE_IS_SPLITTING)
00190 int
00191 is_empty (const ACE_TCHAR *line)
00192 {
00193   while (*line && isspace (*line))
00194     ++line;
00195 
00196   return *line == ACE_LIB_TEXT ('\0') || *line == ACE_LIB_TEXT ('#');
00197 }
00198 
00199 int
00200 is_line (const ACE_TCHAR *line)
00201 {
00202   while (*line && isspace (*line))
00203     ++line;
00204 
00205   return *line != ACE_LIB_TEXT ('\0');
00206 }
00207 #endif /* ACE_IS_SPLITTING */
00208 
00209 ACE_END_VERSIONED_NAMESPACE_DECL
00210 
00211 #if defined (__ACE_INLINE__)
00212 #include "ace/Capabilities.inl"
00213 #endif /* __ACE_INLINE__ */
00214 
00215 #include /**/ "ace/post.h"
00216 #endif /* __ACE_CAPABILITIES_H__ */

Generated on Thu Nov 9 09:41:48 2006 for ACE by doxygen 1.3.6