Storable.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Storable.h
00006  *
00007  *  $Id: Storable.h 77276 2007-02-21 08:26:36Z johnnyw $
00008  *
00009  *  @author Bruce Trask <trask_b@ociweb.com>
00010  *  @author Chanaka Liyanaarachchi <chanaka@ociweb.com>
00011  */
00012 //=============================================================================
00013 
00014 
00015 #ifndef TAO_NAMING_STORABLE_H
00016 #define TAO_NAMING_STORABLE_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 "tao/Versioned_Namespace.h"
00025 #include "ace/SString.h"
00026 
00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 static const int szInt =  sizeof(int);
00030 static const int szChar = sizeof(char);
00031 static const int szBool = sizeof(int);
00032 
00033 class TAO_NS_Persistence_Header
00034 {
00035  public:
00036   void size (unsigned int size);
00037   unsigned int size () const ;
00038 
00039   void destroyed (int flag);
00040   int destroyed () const ;
00041 
00042   private:
00043   unsigned int size_;
00044   int destroyed_;
00045 };
00046 
00047 class TAO_NS_Persistence_Record
00048 {
00049  public:
00050   enum Record_Type {LOCAL_NCONTEXT, OBJREF, REMOTE_NCONTEXT};
00051 
00052   Record_Type type () const;
00053   void type (Record_Type type);
00054 
00055   ACE_CString id () const;
00056   void id (const ACE_CString& id);
00057 
00058   ACE_CString kind () const;
00059   void kind (const ACE_CString& kind);
00060 
00061   ACE_CString ref () const;
00062   void ref (const ACE_CString& ior);
00063 
00064  private:
00065   Record_Type type_;
00066   ACE_CString id_;
00067   ACE_CString kind_;
00068   ACE_CString ref_;
00069 };
00070 
00071 class TAO_NS_Persistence_Global
00072 {
00073  public:
00074   void counter (unsigned int counter);
00075   unsigned int counter () const ;
00076 
00077   private:
00078   unsigned int counter_;
00079 };
00080 
00081 class TAO_Storable_Base
00082 {
00083 public:
00084   TAO_Storable_Base();
00085 
00086   virtual ~TAO_Storable_Base();
00087 
00088   virtual void remove() = 0;
00089 
00090   virtual int exists() = 0;
00091 
00092   virtual int open () = 0;
00093 
00094   virtual int close () = 0;
00095 
00096   virtual int flock (int whence, int start, int len) = 0;
00097 
00098   virtual int funlock (int whence, int start, int len) = 0;
00099 
00100   virtual time_t last_changed(void) = 0;
00101 
00102   // Mimic a portion of the std::ios interface.  We need to be able
00103   // to indicate error states from the extraction operators below.
00104   enum Storable_State { goodbit = 0,
00105                         badbit  = 1,
00106                         eofbit  = 2,
00107                         failbit = 4
00108                       };
00109 
00110   void clear (Storable_State state = goodbit);
00111 
00112   void setstate (Storable_State state);
00113 
00114   Storable_State rdstate (void) const;
00115 
00116   bool good (void) const;
00117 
00118   bool bad (void) const;
00119 
00120   bool eof (void) const;
00121 
00122   bool fail (void) const;
00123 
00124   virtual TAO_Storable_Base& operator << (
00125               const TAO_NS_Persistence_Header& header) = 0;
00126 
00127   virtual TAO_Storable_Base& operator << (
00128               const TAO_NS_Persistence_Record& record) = 0;
00129 
00130   virtual TAO_Storable_Base& operator >> (
00131               TAO_NS_Persistence_Header& header)  = 0;
00132 
00133   virtual TAO_Storable_Base& operator >> (
00134               TAO_NS_Persistence_Record& record) = 0;
00135 
00136   virtual TAO_Storable_Base& operator << (
00137               const TAO_NS_Persistence_Global& global) = 0;
00138 
00139   virtual TAO_Storable_Base& operator >> (
00140               TAO_NS_Persistence_Global& global)  = 0;
00141 
00142 private:
00143   Storable_State state_;
00144 };
00145 
00146 class TAO_Naming_Service_Persistence_Factory
00147 {
00148 public:
00149   TAO_Naming_Service_Persistence_Factory();
00150 
00151   virtual ~TAO_Naming_Service_Persistence_Factory();
00152 
00153   // Factory Methods
00154 
00155   virtual TAO_Storable_Base *create_stream(const ACE_CString & file,
00156                                            const ACE_TCHAR * mode) = 0;
00157 };
00158 
00159 TAO_END_VERSIONED_NAMESPACE_DECL
00160 
00161 #if defined (__ACE_INLINE__)
00162 #include "orbsvcs/Naming/Storable.inl"
00163 #endif /* __ACE_INLINE_ */
00164 
00165 #endif  /* TAO_NAMING_STORABLE_H */

Generated on Sun Jan 27 16:15:31 2008 for TAO_CosNaming by doxygen 1.3.6