LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
lsst::daf::persistence::Storage Class Referenceabstract

Abstract base class for storage implementations. More...

#include <Storage.h>

Inheritance diagram for lsst::daf::persistence::Storage:
lsst::daf::base::Citizen lsst::daf::persistence::BoostStorage lsst::daf::persistence::DbStorage lsst::daf::persistence::FitsStorage lsst::daf::persistence::XmlStorage lsst::daf::persistence::DbTsvStorage

Public Types

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

virtual ~Storage (void)
 
virtual void setPolicy (lsst::pex::policy::Policy::Ptr policy)=0
 
virtual void setPersistLocation (LogicalLocation const &location)=0
 
virtual void setRetrieveLocation (LogicalLocation const &location)=0
 
virtual void startTransaction (void)=0
 
virtual void endTransaction (void)=0
 
- 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...
 

Static Public Member Functions

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

 Storage (std::type_info const &type)
 
void verifyPathName (std::string const &pathName)
 

Private Member Functions

 Storage (Storage const &)
 
Storageoperator= (Storage const &)
 

Detailed Description

Abstract base class for storage implementations.

All subclasses of this base class must be added to StorageRegistry.

Definition at line 60 of file Storage.h.

Member Typedef Documentation

Definition at line 63 of file Storage.h.

typedef boost::shared_ptr<Storage> lsst::daf::persistence::Storage::Ptr

Definition at line 62 of file Storage.h.

Constructor & Destructor Documentation

lsst::daf::persistence::Storage::~Storage ( void  )
virtual

Minimal destructor

Definition at line 65 of file Storage.cc.

65  {
66 }
lsst::daf::persistence::Storage::Storage ( std::type_info const &  type)
explicitprotected

Constructor.

Parameters
[in]typetypeid() of subclass

Definition at line 60 of file Storage.cc.

60  : lsst::daf::base::Citizen(type) {
61 }
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
lsst::daf::persistence::Storage::Storage ( Storage const &  )
private

Member Function Documentation

Storage::Ptr lsst::daf::persistence::Storage::createInstance ( std::string const &  name,
LogicalLocation const &  location,
bool  persist,
lsst::pex::policy::Policy::Ptr  policy 
)
static

Create and configure a Storage subclass instance.

Parameters
[in]nameName of subclass
[in]locationLocation to persist to or retrieve from
[in]persistTrue if persisting, false if retrieving
[in]policyPolicy used to configure the Storage
Returns
Shared pointer to Storage subclass instance

Definition at line 75 of file Storage.cc.

77  {
79  storage->setPolicy(policy);
80  if (persist) {
81  storage->setPersistLocation(location);
82  }
83  else {
84  storage->setRetrieveLocation(location);
85  }
86  return storage;
87 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< Storage > Ptr
Definition: Storage.h:62
static StorageRegistry & getRegistry(void)
Storage::Ptr createInstance(std::string const &name)
virtual void lsst::daf::persistence::Storage::endTransaction ( void  )
pure virtual
Storage& lsst::daf::persistence::Storage::operator= ( Storage const &  )
private
virtual void lsst::daf::persistence::Storage::setPersistLocation ( LogicalLocation const &  location)
pure virtual

Set the destination for persistence.

Parameters
[in]locationLocation to persist to.

Exclusive with setRetrieveLocation().

Implemented in lsst::daf::persistence::DbTsvStorage, lsst::daf::persistence::DbStorage, lsst::daf::persistence::BoostStorage, lsst::daf::persistence::XmlStorage, and lsst::daf::persistence::FitsStorage.

virtual void lsst::daf::persistence::Storage::setPolicy ( lsst::pex::policy::Policy::Ptr  policy)
pure virtual

Allow a Policy to be used to configure the Storage.

Parameters
[in]policyShould be called first, after construction.

Implemented in lsst::daf::persistence::DbTsvStorage, lsst::daf::persistence::DbStorage, lsst::daf::persistence::BoostStorage, lsst::daf::persistence::XmlStorage, and lsst::daf::persistence::FitsStorage.

virtual void lsst::daf::persistence::Storage::setRetrieveLocation ( LogicalLocation const &  location)
pure virtual

Set the source for retrieval.

Parameters
[in]locationLocation to retrieve from.

Exclusive with setPersistLocation().

Implemented in lsst::daf::persistence::DbTsvStorage, lsst::daf::persistence::DbStorage, lsst::daf::persistence::BoostStorage, lsst::daf::persistence::XmlStorage, and lsst::daf::persistence::FitsStorage.

virtual void lsst::daf::persistence::Storage::startTransaction ( void  )
pure virtual
void lsst::daf::persistence::Storage::verifyPathName ( std::string const &  name)
protected

Ensure that all directories along a path exist, creating them if necessary.

Parameters
[in]namePathname to file to be created

Definition at line 93 of file Storage.cc.

93  {
94  // Get the directory by stripping off anything after the last slash.
95  std::string::size_type pos = name.find_last_of('/');
96  if (pos == std::string::npos) return;
97  std::string dirName = name.substr(0, pos);
98 
99  // Check to see if the directory exists.
100  struct stat buf;
101  int ret = ::stat(dirName.c_str(), &buf);
102 
103  if (ret == -1 && errno == ENOENT) {
104  // It doesn't; check its parent and then create it.
105  verifyPathName(dirName);
106 
107  ret = ::mkdir(dirName.c_str(), 0777);
108 
109  // If it already exists, we're OK; otherwise, throw an exception.
110  if (ret == -1 && errno != EEXIST) {
111  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
112  dirName + ": Error creating directory = " + std::strerror(errno));
113  }
114  }
115  else if (ret == -1) {
116  // We couldn't read the (existing) directory for some reason.
117  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
118  dirName + ": Error searching for directory = " + std::strerror(errno));
119  }
120  else if (!S_ISDIR(buf.st_mode)) {
121  // It's not a directory.
122  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
123  dirName + ": Non-directory in path");
124  }
125 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void verifyPathName(std::string const &pathName)
Definition: Storage.cc:93

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