Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Capabilities.h

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

Generated on Mon Jun 16 11:19:19 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002