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

ACE_Filecache_Handle Class Reference

Abstraction over a real file. This is meant to be the entry point into the Cached Virtual Filesystem. More...

#include <Filecache.h>

Collaboration diagram for ACE_Filecache_Handle:

Collaboration graph
[legend]
List of all members.

Public Types

enum  {
  ACE_SUCCESS = 0, ACE_ACCESS_FAILED, ACE_OPEN_FAILED, ACE_COPY_FAILED,
  ACE_STAT_FAILED, ACE_MEMMAP_FAILED, ACE_WRITE_FAILED
}
 These come from ACE_Filecache_Object, which is an internal class. More...


Public Methods

 ACE_Filecache_Handle (const ACE_TCHAR *filename, ACE_Filecache_Flag mapit=ACE_MAPIT)
 Query cache for file, and acquire it. Assumes the file is being opened for reading. More...

 ACE_Filecache_Handle (const ACE_TCHAR *filename, int size, ACE_Filecache_Flag mapit=ACE_MAPIT)
 ~ACE_Filecache_Handle (void)
 Closes any open handles, release acquired file. More...

void * address (void) const
 Base address of memory mapped file. More...

ACE_HANDLE handle (void) const
 A handle (e.g., UNIX file descriptor, or NT file handle). More...

int error (void) const
 Any associated error in handle creation and acquisition. More...

off_t size (void) const
 The size of the file. More...


Protected Methods

 ACE_Filecache_Handle (void)
 Default do nothing constructor. Prevent it from being called. More...

void init (void)
 Common initializations for constructors. More...


Private Attributes

ACE_Filecache_Objectfile_
 A reference to the low level instance. More...

ACE_HANDLE handle_
 A <dup>'d version of the one from <file_>. More...

int mapit_

Detailed Description

Abstraction over a real file. This is meant to be the entry point into the Cached Virtual Filesystem.

This is a cached filesystem implementation based loosely on the implementation of JAWS_File. The interfaces will be nearly the same. The under-the-hood implementation should hopefully be a much faster thing. These will be given their own implementations later. For now, we borrow the implementation provided by JAWS. On creation, the cache is checked, and reference count is incremented. On destruction, reference count is decremented. If the reference count is 0, the file is removed from the cache. E.g. 1, { ACE_Filecache_Handle foo("foo.html"); this->peer ().send (foo.address (), foo.size ()); } E.g. 2, { ACE_Filecache_Handle foo("foo.html"); io->transmitfile (foo.handle (), this->peer ().handle ()); } E.g. 3, { ACE_Filecache_Handle foo("foo.html", content_length); this->peer ().recv (foo.address (), content_length); } TODO:

Definition at line 68 of file Filecache.h.


Member Enumeration Documentation

anonymous enum
 

These come from ACE_Filecache_Object, which is an internal class.

Enumeration values:
ACE_SUCCESS 
ACE_ACCESS_FAILED 
ACE_OPEN_FAILED 
ACE_COPY_FAILED 
ACE_STAT_FAILED 
ACE_MEMMAP_FAILED 
ACE_WRITE_FAILED 

Definition at line 126 of file Filecache.h.

00127   {
00128     ACE_SUCCESS = 0,
00129     ACE_ACCESS_FAILED,
00130     ACE_OPEN_FAILED,
00131     ACE_COPY_FAILED,
00132     ACE_STAT_FAILED,
00133     ACE_MEMMAP_FAILED,
00134     ACE_WRITE_FAILED
00135   };


Constructor & Destructor Documentation

ACE_Filecache_Handle::ACE_Filecache_Handle const ACE_TCHAR   filename,
ACE_Filecache_Flag    mapit = ACE_MAPIT
 

Query cache for file, and acquire it. Assumes the file is being opened for reading.

Definition at line 54 of file Filecache.cpp.

References ACE_Filecache_Flag, ACE_TCHAR, ACE_Filecache::fetch, file_, init, and ACE_Filecache::instance.

00056   : file_ (0), handle_ (0), mapit_ (mapit)
00057 {
00058   this->init ();
00059   // Fetch the file from the Virtual_Filesystem let the
00060   // Virtual_Filesystem do the work of cache coherency.
00061 
00062   // Filecache will also do the acquire, since it holds the lock at
00063   // that time.
00064   this->file_ = ACE_Filecache::instance ()->fetch (filename, mapit);
00065 }

ACE_Filecache_Handle::ACE_Filecache_Handle const ACE_TCHAR   filename,
int    size,
ACE_Filecache_Flag    mapit = ACE_MAPIT
 

Create new entry, and acquire it. Presence of SIZE assumes the file is being opened for writing. If SIZE is zero, assumes the file is to be removed from the cache.

Definition at line 67 of file Filecache.cpp.

References ACE_Filecache_Flag, ACE_TCHAR, ACE_Filecache::create, file_, init, ACE_Filecache::instance, ACE_Filecache::remove, and size.

00070   : file_ (0), handle_ (0), mapit_ (mapit)
00071 {
00072   this->init ();
00073 
00074   if (size == 0)
00075     ACE_Filecache::instance ()->remove (filename);
00076   else
00077     {
00078       // Since this is being opened for a write, simply create a new
00079       // ACE_Filecache_Object now, and let the destructor add it into CVF
00080       // later
00081 
00082       // Filecache will also do the acquire, since it holds the lock at
00083       // that time.
00084       this->file_ = ACE_Filecache::instance ()->create (filename, size);
00085     }
00086 }

ACE_Filecache_Handle::~ACE_Filecache_Handle void   
 

Closes any open handles, release acquired file.

Definition at line 88 of file Filecache.cpp.

References ACE_OS::close, ACE_Filecache::finish, handle_, and ACE_Filecache::instance.

00089 {
00090   if (this->handle_ != ACE_INVALID_HANDLE)
00091     // this was dup ()'d
00092     ACE_OS::close (this->handle_);
00093 
00094   ACE_Filecache::instance ()->finish (this->file_);
00095 }

ACE_Filecache_Handle::ACE_Filecache_Handle void    [protected]
 

Default do nothing constructor. Prevent it from being called.

Definition at line 48 of file Filecache.cpp.

References init.

00049   : file_ (0), handle_ (0), mapit_ (0)
00050 {
00051   this->init ();
00052 }


Member Function Documentation

void * ACE_Filecache_Handle::address void    const
 

Base address of memory mapped file.

Definition at line 98 of file Filecache.cpp.

References ACE_Filecache_Object::address, and file_.

00099 {
00100   return this->file_ == 0 ? 0 : this->file_->address ();
00101 }

int ACE_Filecache_Handle::error void    const
 

Any associated error in handle creation and acquisition.

Definition at line 116 of file Filecache.cpp.

References ACE_Filecache_Object::error, and file_.

00117 {
00118   if (this->file_ == 0)
00119     return -1;
00120   else
00121     return this->file_->error ();
00122 }

ACE_HANDLE ACE_Filecache_Handle::handle void    const
 

A handle (e.g., UNIX file descriptor, or NT file handle).

Definition at line 104 of file Filecache.cpp.

References ACE_OS::dup, file_, and handle_.

00105 {
00106   if (this->handle_ == ACE_INVALID_HANDLE && this->file_ != 0)
00107     {
00108       ACE_Filecache_Handle *mutable_this =
00109         (ACE_Filecache_Handle *) this;
00110       mutable_this->handle_ = ACE_OS::dup (this->file_->handle ());
00111     }
00112   return this->handle_;
00113 }

void ACE_Filecache_Handle::init void    [protected]
 

Common initializations for constructors.

Definition at line 42 of file Filecache.cpp.

References file_, and handle_.

Referenced by ACE_Filecache_Handle.

00043 {
00044   this->file_ = 0;
00045   this->handle_ = ACE_INVALID_HANDLE;
00046 }

off_t ACE_Filecache_Handle::size void    const
 

The size of the file.

Definition at line 125 of file Filecache.cpp.

References file_, and ACE_Filecache_Object::size.

Referenced by ACE_Filecache_Handle.

00126 {
00127   if (this->file_ == 0)
00128     return -1;
00129   else
00130     return this->file_->size ();
00131 }


Member Data Documentation

ACE_Filecache_Object* ACE_Filecache_Handle::file_ [private]
 

A reference to the low level instance.

Definition at line 139 of file Filecache.h.

Referenced by ACE_Filecache_Handle, address, error, handle, init, and size.

ACE_HANDLE ACE_Filecache_Handle::handle_ [private]
 

A <dup>'d version of the one from <file_>.

Definition at line 142 of file Filecache.h.

Referenced by handle, init, and ~ACE_Filecache_Handle.

int ACE_Filecache_Handle::mapit_ [private]
 

Definition at line 144 of file Filecache.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:47:57 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002