Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

ContainerBase< ContainerType, ObjectType > Class Template Reference

GaiaFS - Gaia Files System Containers. More...

Inherits GenericContainer.

List of all members.

Public Methods

virtual ~ContainerBase ()
void close ()
 Close the container and release all memory.

void satt (const char *name, const char *value)
 Set an attribute.

int get (ObjectType &buf, int count)
 Get some objects from the container.

bool eof ()
 Report if at end of container.

int put (ObjectType &buf, int count)
 Put some objects in the container.

bool operator! () const
 Test whether this container is valid.

bool isValid ()
 Test whether this container is valid.

 operator GaiaFS::Container * () const
 Convert to native container.

int size ()
 Tell the number of data objects in the container.

void seek (unsigned long position)
 Set the current object index pointer.

unsigned long tell ()
 Tell what object index currently pointing to.


Protected Methods

 ContainerBase ()
 ContainerBase (const char *name, const char *kind, int mode, int index)
 Open a container of the specified type.

 ContainerBase (GenericContainer *container, const char *kind)
 Adapt a container interface to a new interface.

 ContainerBase (GaiaFS::Container *container)
 Create a new container wrapper for a remote reference.

void open (const char *name, const char *kind, int mode, int index=0)
 ContainerBase (ContainerBase &c)
ContainerBase & operator= (ContainerBase &c)

Protected Attributes

ContainerType * _container


Detailed Description

template<class ContainerType, class ObjectType>
class ContainerBase< ContainerType, ObjectType >

GaiaFS - Gaia Files System Containers.

This is the base class is used by all containers to manipulate the objects in a container. Please refer to the particular concrete container for the type of objects that they contain. Use the methods described to below to access the data objects. The ObjectType defined by the container type you are using becomes the template argument. See the Examples directory for usage.

Container Type (Object Type)

  1. BitmapContainer (Bitmaps)
  2. ByteContainer (Bytes)
  3. DirectoryContainer (Dirents)
  4. GIFContainer (GIFs)
  5. PageContainer (Pages)
  6. PixmapContainer (Pixmaps)

Example:

int main(int argc, char **argv)
{
    Gaia::init();

    try {

        int count;
        Dirents dirents;
        DirectoryContainer c("/temp", GaiaFS::Read);

        while (!c.eof()) {
        count = c.get(dirents, 32);

        for (int i = 0; i < count; i++) {
            printf("%-12d%-12d%-8ds"
                dirents[i].mtime,
                dirents[i].size,
                dirents[i].index,
                dirents[i].name
            );
        }
    }

    c.close();

    } catch (GaiaFS::IOError) {
        cerr << "network error" << endl;
    } catch (GaiaFS::NotReachable) {
        cerr << "server hosting data not reachable" << endl;
    } catch (...) {
        cerr << "unknown error" << endl;
    }

    Gaia::fini();

    return 0;
}


Constructor & Destructor Documentation

template<class ContainerType, class ObjectType>
ContainerBase< ContainerType, ObjectType >::ContainerBase const char *    name,
const char *    kind,
int    mode,
int    index
[protected]
 

Open a container of the specified type.

Parameters:
name  the name of the file to open
kind  the kind of container type
mode  the mode to open the container as
index  the index for aggregated directories
Exceptions:
GaiaFS::NotReachable 
GaiaFS::NotFound 
GaiaFS::NotAvailable 
GaiaFS::NotSupported 
GaiaFS::SecurityCheck 
GaiaFS::MemoryLimit 
GaiaFS::IllegalArgument 
GaiaFS::IOError 

template<class ContainerType, class ObjectType>
ContainerBase< ContainerType, ObjectType >::ContainerBase GenericContainer *    container,
const char *    kind
[protected]
 

Adapt a container interface to a new interface.

Parameters:
name  the name of the file to open
kind  the kind of container type
mode  the mode to open the container as
index  the index for aggregated directories
Example:

ByteContainer b(...);

GIFContainer g(&b);

Exceptions:
GaiaFS::NotReachable 
GaiaFS::NotFound 
GaiaFS::NotAvailable 
GaiaFS::NotSupported 
GaiaFS::SecurityCheck 
GaiaFS::MemoryLimit 
GaiaFS::IllegalArgument 
GaiaFS::IOError 

template<class ContainerType, class ObjectType>
ContainerBase< ContainerType, ObjectType >::ContainerBase GaiaFS::Container *    container [protected]
 

Create a new container wrapper for a remote reference.

Parameters:
container  the native container to wrap
Exceptions:
GaiaFS::IllegalArgument 


Member Function Documentation

template<class ContainerType, class ObjectType>
void ContainerBase< ContainerType, ObjectType >::close  
 

Close the container and release all memory.

template<class ContainerType, class ObjectType>
bool ContainerBase< ContainerType, ObjectType >::eof  
 

Report if at end of container.

Returns:
true if no more objects in container

template<class ContainerType, class ObjectType>
int ContainerBase< ContainerType, ObjectType >::get ObjectType &    buf,
int    count
 

Get some objects from the container.

Parameters:
buf  the buffer of container objects to get
count  the number of objects to get
Returns:
the number of objects retrieved

template<class ContainerType, class ObjectType>
bool ContainerBase< ContainerType, ObjectType >::isValid  
 

Test whether this container is valid.

Returns:
true if container can be used

template<class ContainerType, class ObjectType>
ContainerBase< ContainerType, ObjectType >::operator GaiaFS::Container *   const
 

Convert to native container.

This can be used to pass it to another object and then wrap in the new object.

Returns:
the native container handle

template<class ContainerType, class ObjectType>
bool ContainerBase< ContainerType, ObjectType >::operator!   const
 

Test whether this container is valid.

Returns:
true if container can be used

template<class ContainerType, class ObjectType>
int ContainerBase< ContainerType, ObjectType >::put ObjectType &    buf,
int    count
 

Put some objects in the container.

Parameters:
buf  the buffer of container objects to get
count  the number of objects to get
Returns:
the number of objects put

template<class ContainerType, class ObjectType>
void ContainerBase< ContainerType, ObjectType >::satt const char *    name,
const char *    value
 

Set an attribute.

If the name already exists, overwrite the old value. If the name does not exist, create a new entry. Expand the length of the seqence if there is not enough room for a new entry.

Parameters:
name  the name of the attribute
value  the value of the attribute

template<class ContainerType, class ObjectType>
void ContainerBase< ContainerType, ObjectType >::seek unsigned long    position
 

Set the current object index pointer.

Parameters:
position  the new position

template<class ContainerType, class ObjectType>
int ContainerBase< ContainerType, ObjectType >::size  
 

Tell the number of data objects in the container.

Returns:
the number of objects

template<class ContainerType, class ObjectType>
unsigned long ContainerBase< ContainerType, ObjectType >::tell  
 

Tell what object index currently pointing to.

Returns:
the current object position


The documentation for this class was generated from the following file:
Generated on Wed Sep 18 18:10:51 2002 for Gaia by doxygen1.2.16