#include <ace/Filecache.h>
class ACE_Filecache_Handle {
public:
ACE_Filecache_Handle ( const char *filename, ACE_Filecache_Flag mapit = MAPIT );
ACE_Filecache_Handle ( const char *filename, int size, ACE_Filecache_Flag mapit = MAPIT );
~ACE_Filecache_Handle (void);
void *address (void) const;
ACE_HANDLE handle (void) const;
int error (void) const;
size_t size (void) const;
enum{ SUCCESS = 0, ACCESS_FAILED, OPEN_FAILED, COPY_FAILED, STAT_FAILED, MEMMAP_FAILED, WRITE_FAILED };protected:
ACE_Filecache_Handle (void);
void init (void);
private:
ACE_Filecache_Object *file_;
ACE_HANDLE handle_;
int mapit_;
};
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:
ACE_Filecache_Handle (
const char *filename,
ACE_Filecache_Flag mapit = MAPIT
);
ACE_Filecache_Handle (
const char *filename,
int size,
ACE_Filecache_Flag mapit = MAPIT
);
~ACE_Filecache_Handle (void);
void *address (void) const;
ACE_HANDLE handle (void) const;
int error (void) const;
size_t size (void) const;
ACE_Filecache_Handle (void);
void init (void);
ACE_Filecache_Object *file_;
ACE_HANDLE handle_;
int mapit_;