Flat_File_Persistence.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Flat_File_Persistence.h
00006  *
00007  *  $Id: Flat_File_Persistence.h 71526 2006-03-14 06:14:35Z jtc $
00008  *
00009  *  @author Marina Spivak <marina@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef TAO_FLAT_FILE_PERSISTENCE_H
00014 #define TAO_FLAT_FILE_PERSISTENCE_H
00015 
00016 #include "orbsvcs/Naming/Storable.h"
00017 #include "ace/OS_NS_stdio.h"
00018 
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020 
00021 //------------------------------------------------------------------------
00022 // The Flat File concrete classes
00023 //------------------------------------------------------------------------
00024 class TAO_NS_FlatFileStream : public TAO_Storable_Base
00025 {
00026 public:
00027 
00028   TAO_NS_FlatFileStream(const ACE_CString & file, const char * mode);
00029   virtual ~TAO_NS_FlatFileStream();
00030 
00031   /// Remove a file by name (file is not open)
00032   virtual void remove();
00033 
00034   /// Check if a file exists on disk (file is not open)
00035   virtual int exists();
00036 
00037   /// Open a file (the remaining methods below all require an open file)
00038   virtual int open();
00039 
00040   /// Close an open file
00041   virtual int close();
00042 
00043   /// Acquire a file lock
00044   virtual int flock (int whence, int start, int len);
00045 
00046   /// Release a file lock
00047   virtual int funlock (int whence, int start, int len);
00048 
00049   /// Returns the last time an open file was changed
00050   virtual time_t last_changed(void);
00051 
00052   /// Write a header to disk
00053   virtual TAO_Storable_Base& operator << (
00054               const TAO_NS_Persistence_Header& header);
00055 
00056   /// Read a header from disk
00057   virtual TAO_Storable_Base& operator >> (
00058               TAO_NS_Persistence_Header& header);
00059 
00060   /// Write a record to disk
00061   virtual TAO_Storable_Base& operator << (
00062               const TAO_NS_Persistence_Record& record);
00063 
00064   /// Read a record from disk
00065   virtual TAO_Storable_Base& operator >> (
00066               TAO_NS_Persistence_Record& record);
00067 
00068   /// Write the global data to disk
00069   virtual TAO_Storable_Base& operator << (
00070               const TAO_NS_Persistence_Global& global);
00071 
00072   /// Read the global data from disk
00073   virtual TAO_Storable_Base& operator >> (
00074               TAO_NS_Persistence_Global& global);
00075 
00076 private:
00077   ACE_OS::ace_flock_t filelock_;
00078   FILE* fl_;
00079   ACE_CString file_;
00080   ACE_CString mode_;
00081 };
00082 
00083 class TAO_NS_FlatFileFactory : public TAO_Naming_Service_Persistence_Factory
00084 {
00085 public:
00086   // Factory Methods
00087 
00088   /// Create the stream that can operate on a disk file
00089   virtual TAO_Storable_Base *create_stream(const ACE_CString & file, 
00090                                            const ACE_TCHAR * mode);
00091 };
00092 
00093 TAO_END_VERSIONED_NAMESPACE_DECL
00094 
00095 #endif

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