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

Sct::IOManager Class Reference

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

#include <IOManager.h>

Inheritance diagram for Sct::IOManager:

noncopyable Sct::File::IOManagerFile Sct::IS::IOManagerIS Sct::ISProxy::IOManagerISProxy

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 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 void readImpl (IStream &in, Streamable &ob, bool readClassName) const
 Read a Streamable from an input stream.

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.

StreamerMapgetMap () throw ()

Public Member Functions

virtual ~IOManager ()
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 Typedef Documentation

typedef map<string, shared_ptr<Streamer> > Sct::IOManager::StreamerMap [protected]
 

Definition at line 153 of file IOManager.h.


Constructor & Destructor Documentation

virtual Sct::IOManager::~IOManager   [inline, virtual]
 

Definition at line 45 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 16 of file IOManager.cpp.

References Sct::StreamerMap.

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

Definition at line 24 of file IOManager.cpp.

References Sct::StreamerMap.

Referenced by getStreamer().

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.

Definition at line 29 of file IOManager.cpp.

References getMap(), and Sct::StreamerMap.

Referenced by readImpl(), and writeImpl().

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::File::IOManagerFile, 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

Definition at line 82 of file IOManager.cpp.

Referenced by readImpl().

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.

Definition at line 63 of file IOManager.cpp.

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

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 58 of file IOManager.cpp.

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

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.

Definition at line 52 of file IOManager.cpp.

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

Referenced by Sct::IS::detail::ISAdapter::refreshGuts().

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::File::IOManagerFile, Sct::IS::IOManagerIS, and Sct::ISProxy::IOManagerISProxy.

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.

Definition at line 78 of file IOManager.cpp.

Referenced by writeImpl().

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::ISProxy::IOManagerISProxy.

Definition at line 46 of file IOManager.cpp.

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

Referenced by Sct::IS::detail::ISAdapter::publishGuts().


The documentation for this class was generated from the following files:
Generated on Mon Dec 15 19:37:18 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3