diff options
Diffstat (limited to 'ace/Filecache.h')
-rw-r--r-- | ace/Filecache.h | 110 |
1 files changed, 109 insertions, 1 deletions
diff --git a/ace/Filecache.h b/ace/Filecache.h index 6f81bdd2aaa..19fc3551cc3 100644 --- a/ace/Filecache.h +++ b/ace/Filecache.h @@ -24,9 +24,117 @@ #include "ace/SString.h" // = Forward declarations. -class ACE_Filecache_Object; class ACE_Filecache; + +class ACE_Filecache_Object + // = TITLE + // Abstraction over a real file. This is what the Virtual + // Filesystem contains. This class is not intended for general + // consumption. Please consult a physician before attempting to + // use this class. +{ + friend class ACE_Filecache; + +public: + ACE_Filecache_Object (const char *filename, + ACE_SYNCH_RW_MUTEX &lock); + // Creates a file for reading. + + ACE_Filecache_Object (const char *filename, + int size, + ACE_SYNCH_RW_MUTEX &lock); + // Creates a file for writing. + + ~ACE_Filecache_Object (void); + // Only if reference count is zero should this be called. + + int acquire (void); + // Increment the reference_count_. + + int release (void); + // Decrement the reference_count_. + + // = error_ accessors + int error (void) const; + int error (int error_value, + const char *s = "ACE_Filecache_Object"); + + const char *filename (void) const; + // filename_ accessor + + ACE_HANDLE handle (void) const; + // handle_ accessor. + + void *address (void) const; + // Base memory address for memory mapped file. + + size_t size (void) const; + // size_ accessor. + + int update (void) const; + // True if file on disk is newer than cached file. + +protected: + ACE_Filecache_Object (void); + // Prevent from being called. + + void init (void); + // Common initialization code, + +private: + int error_i (int error_value, + const char *s = "ACE_Filecache_Object"); + // Internal error logging method, no locking. + +public: + + enum + { + READING = 1, + WRITING = 2 + }; + + enum + { + SUCCESS = 0, + ACCESS_FAILED, + OPEN_FAILED, + COPY_FAILED, + STAT_FAILED, + MEMMAP_FAILED, + WRITE_FAILED + }; + +private: + char *tempname_; + char filename_[MAXPATHLEN + 1]; + // The temporary file name and the real file name. The real file is + // copied into the temporary file for safety reasons. + + ACE_Mem_Map mmap_; + ACE_HANDLE handle_; + // mmap_ holds the memory mapped version of the temporary file. + // handle_ is the descriptor to the temporary file. + + struct stat stat_; + size_t size_; + // Used to compare against the real file to test if an update is needed. + + int action_; + int error_; + // Status indicators. + + int stale_; + // If set to 1, means the object is flagged for removal. + + ACE_SYNCH_RW_MUTEX junklock_; + ACE_SYNCH_RW_MUTEX &lock_; + // lock_ provides a bookkeeping mechanism for users of this object. + // junklock_ is the default initializer +}; + + class ACE_Export ACE_Filecache_Handle // = TITLE // Abstraction over a real file. This is meant to be the entry |