ulxr::FileResource Class Reference
[General helper classes]

A resource that caches a file. More...

#include <ulxr_file_resource.h>

Inheritance diagram for ulxr::FileResource:

Inheritance graph
[legend]
Collaboration diagram for ulxr::FileResource:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FileResource (const CppString &res_name, const CppString &file_name, bool do_read=true)
 Creates the resource.
virtual ~FileResource ()
 Destroys the resource.
virtual void open ()
 Opens the resource and loads the file if it exists.
virtual void open (bool do_read)
 Opens the resource and loads the file if it exists.
virtual void close ()
 Closes the resource and writes the current cache content to the file.
virtual bool good ()
 Tests the state of the resource and the success of the transfers from and to the corresponding file.
CppString getFilename () const
 Gets the filename.
virtual void clear ()
 Clears the cache and removes the associated file.
virtual void reset ()
 Resets the read pointer and internal states.

Private Attributes

CppString filename
bool error
bool opened

Detailed Description

A resource that caches a file.

Definition at line 43 of file ulxr_file_resource.h.


Constructor & Destructor Documentation

ulxr::FileResource::FileResource ( const CppString res_name,
const CppString file_name,
bool  do_read = true 
)

Creates the resource.

Parameters:
res_name the name of the resource
file_name the name of the corresponding file
do_read true: actually read file, otherwise just create internal structures

Definition at line 48 of file ulxr_file_resource.cpp.

References open().

ulxr::FileResource::~FileResource (  )  [virtual]

Destroys the resource.

Definition at line 60 of file ulxr_file_resource.cpp.

References close().


Member Function Documentation

void ulxr::FileResource::open (  )  [virtual]

Opens the resource and loads the file if it exists.

Implements ulxr::CachedResource.

Definition at line 72 of file ulxr_file_resource.cpp.

Referenced by FileResource().

void ulxr::FileResource::open ( bool  do_read  )  [virtual]

Opens the resource and loads the file if it exists.

Parameters:
do_read true: actually read file, otherwise just create internal structures

Definition at line 78 of file ulxr_file_resource.cpp.

References ulxr::getLatin1(), ulxr_access, ulxr_fclose, ulxr_feof, ulxr_ferror, ulxr_FILE, ulxr_fopen, ulxr_fread, ULXR_PCHAR, and ULXR_TRACE.

void ulxr::FileResource::close (  )  [virtual]

Closes the resource and writes the current cache content to the file.

Implements ulxr::CachedResource.

Definition at line 115 of file ulxr_file_resource.cpp.

References ulxr::CachedResource::clear(), ulxr::getLatin1(), ulxr_fclose, ulxr_ferror, ulxr_FILE, ulxr_fopen, ulxr_fwrite, ULXR_PCHAR, and ULXR_TRACE.

Referenced by ~FileResource().

bool ulxr::FileResource::good (  )  [virtual]

Tests the state of the resource and the success of the transfers from and to the corresponding file.

Returns:
true: state is ok

false: an error occured

Implements ulxr::CachedResource.

Definition at line 167 of file ulxr_file_resource.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

CppString ulxr::FileResource::getFilename (  )  const

Gets the filename.

Definition at line 66 of file ulxr_file_resource.cpp.

void ulxr::FileResource::clear (  )  [virtual]

Clears the cache and removes the associated file.

The resource is also closed and has to be reopened for further use.

Reimplemented from ulxr::CachedResource.

Definition at line 151 of file ulxr_file_resource.cpp.

References ulxr::CachedResource::clear(), ulxr::getLatin1(), ulxr_access, ULXR_PCHAR, ulxr_remove, and ULXR_TRACE.

void ulxr::FileResource::reset (  )  [virtual]

Resets the read pointer and internal states.

Reimplemented from ulxr::CachedResource.

Definition at line 143 of file ulxr_file_resource.cpp.

References ulxr::CachedResource::reset(), ULXR_PCHAR, and ULXR_TRACE.


Member Data Documentation

CppString ulxr::FileResource::filename [private]

Definition at line 95 of file ulxr_file_resource.h.

bool ulxr::FileResource::error [private]

Definition at line 96 of file ulxr_file_resource.h.

bool ulxr::FileResource::opened [private]

Definition at line 97 of file ulxr_file_resource.h.


The documentation for this class was generated from the following files:
Generated on Sun Aug 19 20:09:04 2007 for ulxmlrpcpp by  doxygen 1.5.1