Public Member Functions

Celartem::StorageRewinder Class Reference

#include <cel_storage.h>

List of all members.

Public Member Functions

 StorageRewinder (Storage *inStorage)
 StorageRewinder ()
void setStorage (Storage *inStorage)
void rewind ()
void releaseStorage ()
 ~StorageRewinder ()

Detailed Description

StorageRewinder class memorizes the storage pointer position on the construction and rewinds the storage pointer to the position on the destruction. This class is useful when a function/method should be rewind the storage pointer to the first position although it reads and seeks the storage in it. The following code illustrates how to use this class:

            void someFunction(Storage *inStorage)
            {
                // rewinder remember the current storage pointer position
                StorageRewinder rewinder(inStorage);

                u8 someBuffer[256];
                inStorage->readBytes(someBuffer, 256);
                if(!some_validation_function(someBuffer, 256))
                {
                    // StorageRewinder automatically rewinds the storage
                    // even if you are canceling the process by some
                    // exception.
                    throw someError;
                }

                // some process...
                do_something(...);

                // StorageRewinder also works on the end of the function.
            }
See also:
Storage

Constructor & Destructor Documentation

Celartem::StorageRewinder::StorageRewinder ( Storage inStorage  )  [inline]

This constructor creates the StorageRewinder on the specified storage. The instance memorizes the current storage position of the storage.

Parameters:
inStorage A storage on which the StorageRewinder is built on.
Celartem::StorageRewinder::StorageRewinder (  )  [inline]

This constructor creates the StorageRewinder that does not hold any storage. This version of constructor is usually used with setStorage method.

Celartem::StorageRewinder::~StorageRewinder (  )  [inline]

This method rewinds the storage to the initial position and delete the StorageRewinder instance.


Member Function Documentation

void Celartem::StorageRewinder::releaseStorage (  )  [inline]

This method releases the storage instance that is held by this instance. Please note that this method does not rewind the storage.

Referenced by setStorage().

void Celartem::StorageRewinder::rewind (  )  [inline]

This method rewinds the storage to the initial position.

Referenced by ~StorageRewinder().

void Celartem::StorageRewinder::setStorage ( Storage inStorage  )  [inline]

This method associates the specified storage instance to this StorageRewinder instance. Please note that the previous one is not to be rewound but only released.

Parameters:
inStorage A storage on which the StorageRewinder is built on.

The documentation for this class was generated from the following file:

This document is made with doxygen 1.7.1 at Thu Feb 17 2011 15:40:18.
Caminova Logo