Capabilities.h

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

Generated on Tue Feb 2 17:18:38 2010 for ACE by  doxygen 1.4.7