Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

Sct::IOManager Class Reference

An abstract class that represents an I/O backend. More...

#include <IOManager.h>

Inheritance diagram for Sct::IOManager:

Inheritance graph
[legend]

Methods for Streamable implementors

Note:
These methods are named readImpl and writeImpl to avoid a gcc 2.9x bug.


virtual void writeImpl (OStream &out, const Streamable &ob, bool writeClassName) const
 Writes a Streamable to an output stream.

virtual void writeImpl (OStream &out, const Streamable &ob, const string &className) const
 Writes a Streamable to an output stream with a different name - to be used for base classes.

virtual void writeImpl (OStream &out, const Streamable &ob, const char *className) const
 explicitly calls same with string as final argument, to prevent implicit conversion to bool

virtual shared_ptr< StreamablereadImpl (IStream &in) const
 Read a Streamable from an input stream.

virtual shared_ptr< StreamablereadImpl (IStream &in, const string &className) const
 Read a Streamable from an input stream.

virtual shared_ptr< StreamablereadImpl (IStream &in, const char *className) const
 explicit conversion to string for the final argument prevents accidental implicit conversion to bool.

virtual void readImpl (IStream &in, Streamable &ob, bool readClassName) const
 Read a Streamable from an input stream.

virtual void readImpl (IStream &in, Streamable &ob, const string &className) const
 Read a Streamable from an input stream with different classname - to be used for derrived classes.

virtual void readImpl (IStream &in, Streamable &ob, const char *className) const
 calls method with explicit string in last arg to prevent implicit conversion to bool

virtual void writeClassName (OStream &out, const string &className) const
 Writes a class name to an OStream.

virtual string readClassName (IStream &in) const
 Read a class name from an IStream.

bool addToMap (const std::string &className, std::auto_ptr< Streamer > s) throw ()
 Add a Streamer to the map.


Methods for sub-class authors

Note:
These methods are named readImpl and writeImpl to avoid a gcc 2.9x bug.


typedef map< string, shared_ptr<
Streamer > > 
StreamerMap
virtual StreamergetStreamer (const string &className) const
 A sub-class can override this if it wants to influence the Streamer that will be used for a particular class.

virtual StreamergetStreamer (const string &className, const unsigned version) const
 Get a particular verion of a streamer, to be used e.g.

StreamerMap & getMap () throw ()
 map of classname, streamer

StreamerMap & getFullVersionMap () throw ()
 map of mapname (=classname/version), streamer

std::string getMapName (const std::string &classname, const unsigned version) throw ()
class Streamer

Public Member Functions

Methods for users
{

virtual void write (const Serializable &ob, const IOParams *params=0) const=0
 Write an object.

virtual shared_ptr< Serializableread (const string &name, const IOParams *params=0) const=0
 Read an object.


Detailed Description

An abstract class that represents an I/O backend.

Possibilities are raw file, IS, some other form of persistency. Perhaps even a viewer.

Some methods here deal with a name. This is a backend specific identifier - e.g. a filename or an IS name. In order to retrieve a name, a backend specific method or an appropriate IOName sub-class should be used.

shared_ptr is returned sometimes, rather than auto_ptr to allow singletons to be returned which might be indicated by some numeric ID for instance.

Author:
Matthew Palmer
Date:
15 July 2003

Definition at line 43 of file IOManager.h.


Member Function Documentation

bool Sct::IOManager::addToMap const std::string &  className,
std::auto_ptr< Streamer s
throw () [static]
 

Add a Streamer to the map.

The Streamer will be used to do IO on classes named className.

Parameters:
className The name of the class that s can do IO on.
s An Streamer capable of doing IO on classes named className.
Returns:
True if successful

Definition at line 17 of file IOManager.cpp.

References Sct::AbstractThrowable::sendToMrs().

Here is the call graph for this function:

StreamerMap & Sct::IOManager::getFullVersionMap  )  throw () [static, protected]
 

map of mapname (=classname/version), streamer

Definition at line 55 of file IOManager.cpp.

Referenced by getStreamer().

StreamerMap & Sct::IOManager::getMap  )  throw () [static, protected]
 

map of classname, streamer

Definition at line 60 of file IOManager.cpp.

Referenced by getStreamer().

Streamer & Sct::IOManager::getStreamer const string &  className,
const unsigned  version
const [protected, virtual]
 

Get a particular verion of a streamer, to be used e.g.

by archival when reading data saved with old streamers.

Definition at line 82 of file IOManager.cpp.

References getFullVersionMap().

Here is the call graph for this function:

Streamer & Sct::IOManager::getStreamer const string &  className  )  const [protected, virtual]
 

A sub-class can override this if it wants to influence the Streamer that will be used for a particular class.

Returns:
an appropriate Streamer.
Exceptions:
InvalidArgumentError if an appropriate Streamer can't be found.

Reimplemented in Sct::Archive::IOManagerStreamerVersioned.

Definition at line 65 of file IOManager.cpp.

References getMap().

Referenced by readImpl(), Sct::IOManagerDummy::testStreaming1(), Sct::IOManagerDummy::testStreaming2(), and writeImpl().

Here is the call graph for this function:

virtual shared_ptr<Serializable> Sct::IOManager::read const string &  name,
const IOParams params = 0
const [pure virtual]
 

Read an object.

Will determine the class by first reading a string assumed to contain the className.

Parameters:
name The name of the object to read
params A backend specific sub-class of IOParams.
Exceptions:
IoException if there is a problem with the I/O

Implemented in Sct::Archive::IOManagerArchiveFile, Sct::IOManagerDummy, and Sct::IS::IOManagerIS.

string Sct::IOManager::readClassName IStream in  )  const [virtual]
 

Read a class name from an IStream.

Should only be overriden if absolutely necessary. Sub-classes should use this method if ever they need to write a class name and avoid proprietry solutions as they may break Java compatability.

Parameters:
in the IStream to be written to
Returns:
the className
Exceptions:
IoException if something bad happens in OStream or there is no className to be read

Reimplemented in Sct::Archive::IOManagerStreamerVersioned.

Definition at line 170 of file IOManager.cpp.

Referenced by readImpl().

void Sct::IOManager::readImpl IStream in,
Streamable ob,
const char *  className
const [virtual]
 

calls method with explicit string in last arg to prevent implicit conversion to bool

Definition at line 142 of file IOManager.cpp.

References readImpl().

Here is the call graph for this function:

void Sct::IOManager::readImpl IStream in,
Streamable ob,
const string &  className
const [virtual]
 

Read a Streamable from an input stream with different classname - to be used for derrived classes.

Parameters:
in the IStream to read from.
ob the object to read into.
readClassName if true, read a string that should match ob.getClassName() first
Exceptions:
IoException if something bad happens in the back-end.

Definition at line 132 of file IOManager.cpp.

References getStreamer(), and Sct::Streamer::read().

Here is the call graph for this function:

void Sct::IOManager::readImpl IStream in,
Streamable ob,
bool  readClassName
const [virtual]
 

Read a Streamable from an input stream.

Parameters:
in the IStream to read from.
ob the object to read into.
readClassName if true, read a string that should match ob.getClassName() first
Exceptions:
IoException if something bad happens in the back-end.

Reimplemented in Sct::Archive::IOManagerStreamerVersioned.

Definition at line 151 of file IOManager.cpp.

References Sct::Streamable::getClassName(), getStreamer(), Sct::Streamer::read(), and readClassName().

Here is the call graph for this function:

shared_ptr< Streamable > Sct::IOManager::readImpl IStream in,
const char *  className
const [virtual]
 

explicit conversion to string for the final argument prevents accidental implicit conversion to bool.

Definition at line 146 of file IOManager.cpp.

References readImpl().

Here is the call graph for this function:

shared_ptr< Streamable > Sct::IOManager::readImpl IStream in,
const string &  className
const [virtual]
 

Read a Streamable from an input stream.

Corresponds to write with writeClassName=false.

Parameters:
in the IStream to read from
className 
Returns:
the newly created Streamable
Exceptions:
IoException if something bad happens in the back-end.

Definition at line 137 of file IOManager.cpp.

References getStreamer(), and Sct::Streamer::read().

Here is the call graph for this function:

shared_ptr< Streamable > Sct::IOManager::readImpl IStream in  )  const [virtual]
 

Read a Streamable from an input stream.

Reads the class name from the stream first. Corresponds to write with writeClassName=true.

Parameters:
in the IStream to read from
Returns:
the newly created Streamable
Exceptions:
IoException if something bad happens in the back-end.

Reimplemented in Sct::Archive::IOManagerStreamerVersioned.

Definition at line 126 of file IOManager.cpp.

References getStreamer(), Sct::Streamer::read(), and readClassName().

Referenced by SctData::IO::RawScanResultStreamer_v2::read(), SctData::IO::RawScanResultStreamer_v1::read(), and readImpl().

Here is the call graph for this function:

virtual void Sct::IOManager::write const Serializable ob,
const IOParams params = 0
const [pure virtual]
 

Write an object.

Parameters:
ob The Serializable to write
params A backend specific sub-class of IOParams.
Exceptions:
IoException if there is a problem with the I/O

Implemented in Sct::Archive::IOManagerArchiveFile, Sct::IOManagerDummy, and Sct::IS::IOManagerIS.

void Sct::IOManager::writeClassName OStream out,
const string &  className
const [virtual]
 

Writes a class name to an OStream.

Should only be overriden if absolutely necessary. Sub-classes should use this method if ever they need to write a class name and avoid proprietry solutions as they may break Java compatability.

Parameters:
out the OStream to be written to
className the class name to write
Exceptions:
IoException if something bad happens in OStream.

Reimplemented in Sct::Archive::IOManagerStreamerVersioned.

Definition at line 166 of file IOManager.cpp.

Referenced by writeImpl().

void Sct::IOManager::writeImpl OStream out,
const Streamable ob,
const char *  className
const [virtual]
 

explicitly calls same with string as final argument, to prevent implicit conversion to bool

Definition at line 117 of file IOManager.cpp.

References writeImpl().

Here is the call graph for this function:

void Sct::IOManager::writeImpl OStream out,
const Streamable ob,
const string &  className
const [virtual]
 

Writes a Streamable to an output stream with a different name - to be used for base classes.

Parameters:
ob the Streamable to write.
out the OStream to write to.
writeClassName if true, write the class name, otherwise don't.
Exceptions:
IoException if something bad happens in the back-end.

Definition at line 121 of file IOManager.cpp.

References getStreamer(), and Sct::Streamer::write().

Here is the call graph for this function:

void Sct::IOManager::writeImpl OStream out,
const Streamable ob,
bool  writeClassName
const [virtual]
 

Writes a Streamable to an output stream.

Parameters:
ob the Streamable to write.
out the OStream to write to.
writeClassName if true, write the class name, otherwise don't.
Exceptions:
IoException if something bad happens in the back-end.

Reimplemented in Sct::Archive::IOManagerStreamerVersioned.

Definition at line 111 of file IOManager.cpp.

References Sct::Streamable::getClassName(), getStreamer(), Sct::Streamer::write(), and writeClassName().

Referenced by SctData::IO::RawScanResultStreamer_v2::write(), SctData::IO::RawScanResultStreamer_v1::write(), and writeImpl().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Thu Jul 15 09:51:18 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5