LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Attributes | List of all members
lsst::daf::persistence::BoostStorage Class Reference

Class for boost::serialization storage. More...

#include <BoostStorage.h>

Inheritance diagram for lsst::daf::persistence::BoostStorage:
lsst::daf::persistence::Storage lsst::daf::base::Citizen

Public Types

typedef boost::shared_ptr
< BoostStorage
Ptr
 
- Public Types inherited from lsst::daf::persistence::Storage
typedef boost::shared_ptr
< Storage
Ptr
 
typedef std::vector< PtrList
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 

Public Member Functions

 BoostStorage (void)
 
virtual ~BoostStorage (void)
 
virtual void setPolicy (lsst::pex::policy::Policy::Ptr policy)
 
virtual void setPersistLocation (LogicalLocation const &location)
 
virtual void setRetrieveLocation (LogicalLocation const &location)
 
virtual void startTransaction (void)
 
virtual void endTransaction (void)
 
virtual
boost::archive::text_oarchive & 
getOArchive (void)
 
virtual
boost::archive::text_iarchive & 
getIArchive (void)
 
- Public Member Functions inherited from lsst::daf::persistence::Storage
virtual ~Storage (void)
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 

Private Attributes

boost::scoped_ptr< std::ofstream > _ostream
 Output stream. More...
 
boost::scoped_ptr< std::ifstream > _istream
 Input stream. More...
 
boost::scoped_ptr
< boost::archive::text_oarchive > 
_oarchive
 boost::serialization archive wrapper for output stream. More...
 
boost::scoped_ptr
< boost::archive::text_iarchive > 
_iarchive
 boost::serialization archive wrapper for input stream. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst::daf::persistence::Storage
static Ptr createInstance (std::string const &name, LogicalLocation const &location, bool persist, lsst::pex::policy::Policy::Ptr policy)
 
- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 
- Protected Member Functions inherited from lsst::daf::persistence::Storage
 Storage (std::type_info const &type)
 
void verifyPathName (std::string const &pathName)
 

Detailed Description

Class for boost::serialization storage.

Uses boost::serialization to persist to files.

Definition at line 58 of file BoostStorage.h.

Member Typedef Documentation

Definition at line 60 of file BoostStorage.h.

Constructor & Destructor Documentation

lsst::daf::persistence::BoostStorage::BoostStorage ( void  )

Constructor.

Definition at line 57 of file BoostStorage.cc.

57  : Storage(typeid(*this)),
58  _ostream(0), _istream(0), _oarchive(0), _iarchive(0) {
59 }
boost::scoped_ptr< std::ofstream > _ostream
Output stream.
Definition: BoostStorage.h:76
boost::scoped_ptr< boost::archive::text_oarchive > _oarchive
boost::serialization archive wrapper for output stream.
Definition: BoostStorage.h:78
boost::scoped_ptr< boost::archive::text_iarchive > _iarchive
boost::serialization archive wrapper for input stream.
Definition: BoostStorage.h:80
boost::scoped_ptr< std::ifstream > _istream
Input stream.
Definition: BoostStorage.h:77
Storage(std::type_info const &type)
Definition: Storage.cc:60
lsst::daf::persistence::BoostStorage::~BoostStorage ( void  )
virtual

Destructor.

Definition at line 63 of file BoostStorage.cc.

63  {
64 }

Member Function Documentation

void lsst::daf::persistence::BoostStorage::endTransaction ( void  )
virtual

End a transaction. No transaction support for now.

Implements lsst::daf::persistence::Storage.

Definition at line 104 of file BoostStorage.cc.

104  {
105  _oarchive.reset(0);
106  _ostream.reset(0);
107  _iarchive.reset(0);
108  _istream.reset(0);
109 }
boost::scoped_ptr< std::ofstream > _ostream
Output stream.
Definition: BoostStorage.h:76
boost::scoped_ptr< boost::archive::text_oarchive > _oarchive
boost::serialization archive wrapper for output stream.
Definition: BoostStorage.h:78
boost::scoped_ptr< boost::archive::text_iarchive > _iarchive
boost::serialization archive wrapper for input stream.
Definition: BoostStorage.h:80
boost::scoped_ptr< std::ifstream > _istream
Input stream.
Definition: BoostStorage.h:77
boost::archive::text_iarchive & lsst::daf::persistence::BoostStorage::getIArchive ( void  )
virtual

Get a boost::serialization archive suitable for input.

Returns
Reference to a text input archive

Definition at line 121 of file BoostStorage.cc.

121  {
122  return *_iarchive;
123 }
boost::scoped_ptr< boost::archive::text_iarchive > _iarchive
boost::serialization archive wrapper for input stream.
Definition: BoostStorage.h:80
boost::archive::text_oarchive & lsst::daf::persistence::BoostStorage::getOArchive ( void  )
virtual

Get a boost::serialization archive suitable for output.

Returns
Reference to a text output archive

Definition at line 114 of file BoostStorage.cc.

114  {
115  return *_oarchive;
116 }
boost::scoped_ptr< boost::archive::text_oarchive > _oarchive
boost::serialization archive wrapper for output stream.
Definition: BoostStorage.h:78
void lsst::daf::persistence::BoostStorage::setPersistLocation ( LogicalLocation const &  location)
virtual

Set the destination of the serialization file for persistence.

Parameters
[in]locationPathname to write to.

Implements lsst::daf::persistence::Storage.

Definition at line 75 of file BoostStorage.cc.

75  {
76  verifyPathName(location.locString());
77  _ostream.reset(new std::ofstream(location.locString().c_str()));
78  _oarchive.reset(new boost::archive::text_oarchive(*_ostream));
79 }
boost::scoped_ptr< std::ofstream > _ostream
Output stream.
Definition: BoostStorage.h:76
boost::scoped_ptr< boost::archive::text_oarchive > _oarchive
boost::serialization archive wrapper for output stream.
Definition: BoostStorage.h:78
void verifyPathName(std::string const &pathName)
Definition: Storage.cc:93
void lsst::daf::persistence::BoostStorage::setPolicy ( lsst::pex::policy::Policy::Ptr  policy)
virtual

Allow a Policy to be used to configure the BoostStorage.

Parameters
[in]policy

Implements lsst::daf::persistence::Storage.

Definition at line 69 of file BoostStorage.cc.

69  {
70 }
void lsst::daf::persistence::BoostStorage::setRetrieveLocation ( LogicalLocation const &  location)
virtual

Set the source of the serialization file for retrieval.

Parameters
[in]locationPathname to read from.

Implements lsst::daf::persistence::Storage.

Definition at line 84 of file BoostStorage.cc.

84  {
85  char const* fname = location.locString().c_str();
86  if (::access(fname, R_OK | F_OK) != 0) {
87  throw LSST_EXCEPT(pexExcept::NotFoundError,
88  (boost::format("Unable to access file: %1%")
89  % fname).str());
90  }
91  _istream.reset(new std::ifstream(fname));
92  _iarchive.reset(new boost::archive::text_iarchive(*_istream));
93 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::scoped_ptr< boost::archive::text_iarchive > _iarchive
boost::serialization archive wrapper for input stream.
Definition: BoostStorage.h:80
boost::scoped_ptr< std::ifstream > _istream
Input stream.
Definition: BoostStorage.h:77
void lsst::daf::persistence::BoostStorage::startTransaction ( void  )
virtual

Start a transaction. No transaction support for now.

Implements lsst::daf::persistence::Storage.

Definition at line 98 of file BoostStorage.cc.

98  {
99 }

Member Data Documentation

boost::scoped_ptr<boost::archive::text_iarchive> lsst::daf::persistence::BoostStorage::_iarchive
private

boost::serialization archive wrapper for input stream.

Definition at line 80 of file BoostStorage.h.

boost::scoped_ptr<std::ifstream> lsst::daf::persistence::BoostStorage::_istream
private

Input stream.

Definition at line 77 of file BoostStorage.h.

boost::scoped_ptr<boost::archive::text_oarchive> lsst::daf::persistence::BoostStorage::_oarchive
private

boost::serialization archive wrapper for output stream.

Definition at line 78 of file BoostStorage.h.

boost::scoped_ptr<std::ofstream> lsst::daf::persistence::BoostStorage::_ostream
private

Output stream.

Definition at line 76 of file BoostStorage.h.


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