LSSTApplications  16.0-1-gce273f5+20,16.0-10-gc1446dd+20,16.0-12-g569485f+3,16.0-13-g5e87145+4,16.0-13-g5f20d24,16.0-13-g80874fd+2,16.0-13-gb122224+11,16.0-13-gd9b1b71+20,16.0-14-g08f9460+3,16.0-15-g77ef378+6,16.0-17-g6a7bfb3b+20,16.0-17-ged3ab9d,16.0-18-gdf247dd+1,16.0-2-g0febb12+16,16.0-2-g839ba83+58,16.0-2-g9d5294e+45,16.0-2-gc6e0ed0+4,16.0-23-ge8a9b866+2,16.0-3-g404ea43+12,16.0-3-gbc759ec+18,16.0-3-gcfd6c53+43,16.0-4-g03cf288+34,16.0-4-g13a27c5+20,16.0-4-g5f3a788+15,16.0-4-g8a0f11a+42,16.0-4-ga3eb747+5,16.0-5-g1991253+20,16.0-5-g1e9226d+3,16.0-5-g865efd9+22,16.0-5-gb3f8a4b+52,16.0-5-gd0f1235+9,16.0-51-gb4b4a8566+2,16.0-7-g6043bfc+8,16.0-7-gd2eeba5+2,16.0-7-gde5bd64+2,16.0-8-g0e813a6,16.0-8-g4dec96c+33,16.0-8-gfd407c0+5,16.0-9-g2f60796+2,master-g5768c874b9+4,w.2018.41
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::daf::persistence::PropertySetFormatter Class Referenceabstract

Formatter for persistence of PropertySet instances. More...

#include <PropertySetFormatter.h>

Inheritance diagram for lsst::daf::persistence::PropertySetFormatter:
lsst::daf::persistence::Formatter lsst::daf::base::Citizen

Public Types

typedef std::shared_ptr< FormatterPtr
 
typedef Ptr(* FactoryPtr) (lsst::pex::policy::Policy::Ptr)
 Pointer to a (static) factory function for a Formatter subclass. More...
 
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 ~PropertySetFormatter (void)
 Minimal destructor. More...
 
virtual void write (dafBase::Persistable const *persistable, dafPersist::FormatterStorage::Ptr storage, dafBase::PropertySet::Ptr additionalData)
 
virtual dafBase::Persistableread (dafPersist::FormatterStorage::Ptr storage, dafBase::PropertySet::Ptr additionalData)
 
virtual void update (dafBase::Persistable *persistable, dafPersist::FormatterStorage::Ptr storage, dafBase::PropertySet::Ptr additionalData)
 
virtual void write (lsst::daf::base::Persistable const *persistable, FormatterStorage::Ptr storage, lsst::daf::base::PropertySet::Ptr additionalData)=0
 Write a Persistable instance to a FormatterStorage instance. More...
 
virtual lsst::daf::base::Persistableread (FormatterStorage::Ptr storage, lsst::daf::base::PropertySet::Ptr additionalData)=0
 Read a Persistable instance from a FormatterStorage instance. More...
 
virtual void update (lsst::daf::base::Persistable *persistable, FormatterStorage::Ptr storage, lsst::daf::base::PropertySet::Ptr additionalData)=0
 Update an existing Persistable instance with information from an additional FormatterStorage instance. More...
 
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

template<class Archive >
static void delegateSerialize (Archive &ar, unsigned int const version, dafBase::Persistable *persistable)
 Serialize a PropertySet to a Boost archive. More...
 
static Formatter::Ptr lookupFormatter (std::string const &persistableType, lsst::pex::policy::Policy::Ptr policy)
 Lookup Formatter subclass by name of Persistable subclass. More...
 
static Formatter::Ptr lookupFormatter (std::type_info const &persistableType, lsst::pex::policy::Policy::Ptr policy)
 Lookup Formatter subclass by its type_info from typeid(). More...
 
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...
 
Census

Provide a list of current Citizens

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...
 
callbackIDs

Set callback Ids.

The old Id is returned

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...
 
callbacks

Set the New/Delete callback functions; in each case the previously installed callback is returned.

These callback functions return a value which is Added to the previously registered id.

The default callback functions are called default{New,Delete}Callback; you may want to set a break point in these callbacks from your favourite debugger

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...
 

Detailed Description

Formatter for persistence of PropertySet instances.

Definition at line 58 of file PropertySetFormatter.h.

Member Typedef Documentation

◆ FactoryPtr

typedef Ptr(* lsst::daf::persistence::Formatter::FactoryPtr) (lsst::pex::policy::Policy::Ptr)
inherited

Pointer to a (static) factory function for a Formatter subclass.

Definition at line 85 of file Formatter.h.

◆ memCallback

typedef memId(* lsst::daf::base::Citizen::memCallback) (const Citizen *ptr)
inherited

Definition at line 61 of file Citizen.h.

◆ memId

typedef unsigned long lsst::daf::base::Citizen::memId
inherited

Type of the block's ID.

Definition at line 58 of file Citizen.h.

◆ memNewCallback

typedef memId(* lsst::daf::base::Citizen::memNewCallback) (const memId cid)
inherited

A function used to register a callback.

Definition at line 60 of file Citizen.h.

◆ Ptr

Definition at line 81 of file Formatter.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
magicSentinel 

Definition at line 88 of file Citizen.h.

Constructor & Destructor Documentation

◆ ~PropertySetFormatter()

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

Minimal destructor.

Definition at line 92 of file PropertySetFormatter.cc.

92  {
93 }

Member Function Documentation

◆ census() [1/3]

int lsst::daf::base::Citizen::census ( int  ,
memId  startingMemId = 0 
)
staticinherited

How many active Citizens are there?

Parameters
startingMemIdDon't print Citizens with lower IDs

Definition at line 238 of file Citizen.cc.

240  {
241  if (startingMemId == 0) { // easy
242  ReadGuard guard(citizenLock);
243  return _activeCitizens.size();
244  }
245 
246  int n = 0;
247  ReadGuard guard(citizenLock);
248  for (table::iterator cur = _activeCitizens.begin(); cur != _activeCitizens.end(); cur++) {
249  if (cur->first->_CitizenId >= startingMemId) {
250  n++;
251  }
252  }
253 
254  return n;
255 }
T end(T... args)
T size(T... args)
T begin(T... args)

◆ census() [2/3]

void lsst::daf::base::Citizen::census ( std::ostream stream,
memId  startingMemId = 0 
)
staticinherited

Print a list of all active Citizens to stream, sorted by ID.

Parameters
streamstream to print to
startingMemIdDon't print Citizens with lower IDs

Definition at line 259 of file Citizen.cc.

261  {
262  ReadGuard guard(citizenLock);
263 
265 
266  for (std::vector<Citizen const*>::const_iterator citizen = leaks->begin(), end = leaks->end();
267  citizen != end; ++citizen) {
268  if ((*citizen)->getId() >= startingMemId) {
269  stream << (*citizen)->repr() << "\n";
270  }
271  }
272 }
STL class.
STL class.
T begin(T... args)
int end
static const std::vector< const Citizen * > * census()
Return a (newly allocated) std::vector of active Citizens sorted by ID.
Definition: Citizen.cc:287

◆ census() [3/3]

std::vector< dafBase::Citizen const * > const * lsst::daf::base::Citizen::census ( )
staticinherited

Return a (newly allocated) std::vector of active Citizens sorted by ID.

You are responsible for deleting it; or you can say std::unique_ptr<std::vector<Citizen const*> const> leaks(Citizen::census()); and not bother (that becomes std::unique_ptr in C++11)

Definition at line 287 of file Citizen.cc.

287  {
289  ReadGuard guard(citizenLock);
290  vec->reserve(_activeCitizens.size());
291 
292  for (table::iterator cur = _activeCitizens.begin(); cur != _activeCitizens.end(); cur++) {
293  vec->push_back(dynamic_cast<Citizen const*>(cur->first));
294  }
295 
296  std::sort(vec->begin(), vec->end(), cmpId);
297 
298  return vec;
299 }
T end(T... args)
T push_back(T... args)
T size(T... args)
STL class.
T begin(T... args)
T sort(T... args)
T reserve(T... args)

◆ delegateSerialize()

template<class Archive >
void lsst::daf::persistence::PropertySetFormatter::delegateSerialize ( Archive &  ar,
unsigned int const  version,
dafBase::Persistable persistable 
)
static

Serialize a PropertySet to a Boost archive.

Handles text or XML archives, input or output.

Parameters
[in,out]arBoost archive
[in]versionVersion of the PropertySet class
[in,out]persistablePointer to the PropertySet as a Persistable

Definition at line 114 of file PropertySetFormatter.cc.

115  {
117  dynamic_cast<dafBase::PropertySet*>(persistable);
118  if (ps == 0) {
119  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Serializing non-PropertySet");
120  }
121  ar & make_nvp("base",
122  boost::serialization::base_object<dafBase::Persistable>(*ps));
123 
125  size_t nNames;
126  if (Archive::is_saving::value) {
127  names = ps->paramNames(false);
128  nNames = names.size();
129  }
130  ar & make_nvp("nitems", nNames);
131 
132  char type;
134  for (size_t i = 0; i < nNames; ++i) {
135  if (Archive::is_saving::value) {
136  name = names[i];
137  std::type_info const& id(ps->typeOf(name));
138 
139  if (id == typeid(bool)) type = 'b';
140  else if (id == typeid(char)) type = 'c';
141  else if (id == typeid(signed char)) type = 'y';
142  else if (id == typeid(unsigned char)) type = 'C';
143  else if (id == typeid(short)) type = 'w';
144  else if (id == typeid(unsigned short)) type = 'W';
145  else if (id == typeid(int)) type = 'i';
146  else if (id == typeid(unsigned int)) type = 'I';
147  else if (id == typeid(long)) type = 'l';
148  else if (id == typeid(unsigned long)) type = 'L';
149  else if (id == typeid(long long)) type = 'x';
150  else if (id == typeid(unsigned long long)) type = 'X';
151  else if (id == typeid(float)) type = 'f';
152  else if (id == typeid(double)) type = 'd';
153  else if (id == typeid(std::string)) type = 's';
154  else if (id == typeid(dafBase::DateTime)) type = 'T';
155  else if (id == typeid(dafBase::Persistable::Ptr)) type = 'p';
156  else {
158  name +
159  ": Unknown type in PropertySet serialize");
160  }
161  }
162 
163  ar & make_nvp("name", name);
164  ar & make_nvp("type", type);
165  switch (type) {
166  case 'b': serializeItem<Archive, bool>(ar, name, ps); break;
167  case 'c': serializeItem<Archive, char>(ar, name, ps); break;
168  case 'y': serializeItem<Archive, signed char>(ar, name, ps); break;
169  case 'C': serializeItem<Archive, unsigned char>(ar, name, ps); break;
170  case 'w': serializeItem<Archive, short>(ar, name, ps); break;
171  case 'W': serializeItem<Archive, unsigned short>(ar, name, ps); break;
172  case 'i': serializeItem<Archive, int>(ar, name, ps); break;
173  case 'I': serializeItem<Archive, unsigned int>(ar, name, ps); break;
174  case 'l': serializeItem<Archive, long>(ar, name, ps); break;
175  case 'L': serializeItem<Archive, unsigned long>(ar, name, ps); break;
176  case 'x': serializeItem<Archive, long long>(ar, name, ps); break;
177  case 'X': serializeItem<Archive, unsigned long long>(ar, name, ps); break;
178  case 'f': serializeItem<Archive, float>(ar, name, ps); break;
179  case 'd': serializeItem<Archive, double>(ar, name, ps); break;
180  case 's': serializeItem<Archive, std::string>(ar, name, ps); break;
181  case 'T': serializeDateTime<Archive>(ar, name, ps); break;
182  case 'p': serializeItem<Archive, dafBase::Persistable::Ptr>(ar, name, ps); break;
183  default:
185  std::string("Unknown type reading PropertySet") +
186  type + ", name = " + name);
187  }
188  }
189 }
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:64
std::vector< std::string > paramNames(bool topLevelOnly=true) const
A variant of names that excludes the names of subproperties.
STL class.
int id
Definition: CR.cc:143
T size(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Class for storing generic metadata.
Definition: PropertySet.h:73
std::shared_ptr< Persistable > Ptr
Definition: Persistable.h:77
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104
std::type_info const & typeOf(std::string const &name) const
Get the type of values for a property name (possibly hierarchical).

◆ getId()

dafBase::Citizen::memId lsst::daf::base::Citizen::getId ( ) const
inherited

Return the Citizen's ID.

Definition at line 206 of file Citizen.cc.

206 { return _CitizenId; }

◆ getNextMemId()

dafBase::Citizen::memId lsst::daf::base::Citizen::getNextMemId ( )
staticinherited

Return the memId of the next object to be allocated.

Definition at line 209 of file Citizen.cc.

209 { return _nextMemId(); }

◆ hasBeenCorrupted()

bool lsst::daf::base::Citizen::hasBeenCorrupted ( )
staticinherited

Check all allocated blocks for corruption.

Definition at line 316 of file Citizen.cc.

316  {
317  ReadGuard guard(citizenLock);
318  for (table::iterator cur = _activeCitizens.begin(); cur != _activeCitizens.end(); cur++) {
319  if (cur->first->_hasBeenCorrupted()) {
320  return true;
321  }
322  }
323  for (table::iterator cur = _persistentCitizens.begin(); cur != _persistentCitizens.end(); cur++) {
324  if (cur->first->_hasBeenCorrupted()) {
325  return true;
326  }
327  }
328 
329  return false;
330 }
T end(T... args)
T begin(T... args)

◆ init()

int lsst::daf::base::Citizen::init ( )
staticinherited

Called once when the memory system is being initialised.

Definition at line 196 of file Citizen.cc.

196  {
197  volatile int dummy = 1;
198  return dummy;
199 }

◆ lookupFormatter() [1/2]

Formatter::Ptr lsst::daf::persistence::Formatter::lookupFormatter ( std::string const &  name,
lsst::pex::policy::Policy::Ptr  policy 
)
staticinherited

Lookup Formatter subclass by name of Persistable subclass.

Parameters
[in]nameName of Persistable subclass
[in]policyPolicy for configuring the Formatter
Returns
Shared pointer to Formatter instance

Returned pointer is not owned and should not be deleted.

Definition at line 84 of file Formatter.cc.

85  {
87 }
static FormatterRegistry & getInstance(void)
Get a reference to the singleton instance of the FormatterRegistry.
Formatter::Ptr lookupFormatter(std::type_info const &persistableType, lsst::pex::policy::Policy::Ptr policy)
Create a new instance of a Formatter subclass given the typeid() of its corresponding Persistable sub...

◆ lookupFormatter() [2/2]

Formatter::Ptr lsst::daf::persistence::Formatter::lookupFormatter ( std::type_info const &  type,
lsst::pex::policy::Policy::Ptr  policy 
)
staticinherited

Lookup Formatter subclass by its type_info from typeid().

Parameters
[in]typestd::type_info of Formatter subclass from typeid()
[in]policyPolicy for configuring the Formatter
Returns
Shared pointer to Formatter instance

Definition at line 94 of file Formatter.cc.

95  {
97 }
static FormatterRegistry & getInstance(void)
Get a reference to the singleton instance of the FormatterRegistry.
Formatter::Ptr lookupFormatter(std::type_info const &persistableType, lsst::pex::policy::Policy::Ptr policy)
Create a new instance of a Formatter subclass given the typeid() of its corresponding Persistable sub...

◆ markPersistent()

void lsst::daf::base::Citizen::markPersistent ( void  )
inherited

Mark a Citizen as persistent and not destroyed until process end.

Definition at line 225 of file Citizen.cc.

225  {
226  WriteGuard guard(citizenLock);
227  _persistentCitizens[this] = _activeCitizens[this];
228  _activeCitizens.erase(this);
229 }
T erase(T... args)

◆ read() [1/2]

dafBase::Persistable * lsst::daf::persistence::PropertySetFormatter::read ( dafPersist::FormatterStorage::Ptr  storage,
dafBase::PropertySet::Ptr  additionalData 
)
virtual

Definition at line 125 of file PropertySetFormatter.cc.

126  {
127  LOGLS_TRACE(_log, "PropertySetFormatter read start");
129  if (typeid(*storage) == typeid(dafPersist::BoostStorage)) {
130  LOGLS_TRACE(_log, "PropertySetFormatter read BoostStorage");
132  dynamic_cast<dafPersist::BoostStorage*>(storage.get());
133  boost->getIArchive() & *ps;
134  LOGLS_TRACE(_log, "PropertySetFormatter read end");
135  return ps;
136  }
137  else if (typeid(*storage) == typeid(dafPersist::XmlStorage)) {
138  LOGLS_TRACE(_log, "PropertySetFormatter read XmlStorage");
140  dynamic_cast<dafPersist::XmlStorage*>(storage.get());
141  xml->getIArchive() & make_nvp("propertySet", *ps);
142  LOGLS_TRACE(_log, "PropertySetFormatter read end");
143  return ps;
144  }
145  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Unrecognized FormatterStorage for PropertySet");
146 }
Class for XML file storage.
Definition: XmlStorage.h:58
Definition: Polygon.cc:24
virtual boost::archive::text_iarchive & getIArchive(void)
Get a boost::serialization archive suitable for input.
virtual boost::archive::xml_iarchive & getIArchive(void)
Get a boost::serialization XML archive suitable for input.
Definition: XmlStorage.cc:114
#define LOGLS_TRACE(logger, message)
Log a trace-level message using an iostream-based interface.
Definition: Log.h:597
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Class for storing generic metadata.
Definition: PropertySet.h:73
Class for boost::serialization storage.
Definition: BoostStorage.h:59
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104

◆ read() [2/2]

virtual lsst::daf::base::Persistable* lsst::daf::persistence::Formatter::read ( FormatterStorage::Ptr  storage,
lsst::daf::base::PropertySet::Ptr  additionalData 
)
pure virtualinherited

Read a Persistable instance from a FormatterStorage instance.

Parameters
[in]storagePointer to the FormatterStorage instance.
[in]additionalDataAdditional data used to find the proper instance within the FormatterStorage.
Returns
Shared pointer to the new Persistable instance.

◆ repr()

std::string lsst::daf::base::Citizen::repr ( ) const
inherited

Return a string representation of a Citizen.

Definition at line 219 of file Citizen.cc.

219  {
220  return boost::str(boost::format("%d: %08x %s") % _CitizenId % this %
221  lsst::utils::demangleType(_typeName));
222 }
std::string demangleType(std::string const _typeName)
Definition: Demangle.cc:113
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:129

◆ setCorruptionCallback()

dafBase::Citizen::memCallback lsst::daf::base::Citizen::setCorruptionCallback ( Citizen::memCallback  func)
staticinherited

Set the CorruptionCallback function.

Parameters
funcfunction be called when block is found to be corrupted

Definition at line 391 of file Citizen.cc.

393  {
394  Citizen::memCallback old = _corruptionCallback;
395  _corruptionCallback = func;
396 
397  return old;
398 }
memId(* memCallback)(const Citizen *ptr)
Definition: Citizen.h:61

◆ setDeleteCallback()

dafBase::Citizen::memCallback lsst::daf::base::Citizen::setDeleteCallback ( Citizen::memCallback  func)
staticinherited

Set the DeleteCallback function.

Parameters
funcfunction be called when desired block is deleted

Definition at line 381 of file Citizen.cc.

383  {
384  Citizen::memCallback old = _deleteCallback;
385  _deleteCallback = func;
386 
387  return old;
388 }
memId(* memCallback)(const Citizen *ptr)
Definition: Citizen.h:61

◆ setDeleteCallbackId()

dafBase::Citizen::memId lsst::daf::base::Citizen::setDeleteCallbackId ( Citizen::memId  id)
staticinherited

Call the current DeleteCallback when block is deleted.

Parameters
idDesired ID

Definition at line 347 of file Citizen.cc.

348  {
349  WriteGuard guard(citizenLock);
350  Citizen::memId oldId = _deleteId;
351  _deleteId = id;
352 
353  return oldId;
354 }
unsigned long memId
Type of the block&#39;s ID.
Definition: Citizen.h:58
int id
Definition: CR.cc:143

◆ setNewCallback()

dafBase::Citizen::memNewCallback lsst::daf::base::Citizen::setNewCallback ( Citizen::memNewCallback  func)
staticinherited

Set the NewCallback function.

Parameters
funcThe new function to be called when a designated block is allocated

Definition at line 371 of file Citizen.cc.

373  {
374  Citizen::memNewCallback old = _newCallback;
375  _newCallback = func;
376 
377  return old;
378 }
memId(* memNewCallback)(const memId cid)
A function used to register a callback.
Definition: Citizen.h:60

◆ setNewCallbackId()

dafBase::Citizen::memId lsst::daf::base::Citizen::setNewCallbackId ( Citizen::memId  id)
staticinherited

Call the NewCallback when block is allocated.

Parameters
idDesired ID

Definition at line 337 of file Citizen.cc.

338  {
339  WriteGuard guard(citizenLock);
340  Citizen::memId oldId = _newId;
341  _newId = id;
342 
343  return oldId;
344 }
unsigned long memId
Type of the block&#39;s ID.
Definition: Citizen.h:58
int id
Definition: CR.cc:143

◆ update() [1/2]

void lsst::daf::persistence::PropertySetFormatter::update ( dafBase::Persistable persistable,
dafPersist::FormatterStorage::Ptr  storage,
dafBase::PropertySet::Ptr  additionalData 
)
virtual

Definition at line 148 of file PropertySetFormatter.cc.

150  {
151  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Unexpected call to update for PropertySet");
152 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104

◆ update() [2/2]

virtual void lsst::daf::persistence::Formatter::update ( lsst::daf::base::Persistable persistable,
FormatterStorage::Ptr  storage,
lsst::daf::base::PropertySet::Ptr  additionalData 
)
pure virtualinherited

Update an existing Persistable instance with information from an additional FormatterStorage instance.

Parameters
[in,out]persistablePointer to the Persistable instance.
[in]storageShared pointer to the additional FormatterStorage instance.
[in]additionalDataAdditional data used to find the proper instance within the FormatterStorage.

◆ write() [1/2]

void lsst::daf::persistence::PropertySetFormatter::write ( dafBase::Persistable const *  persistable,
dafPersist::FormatterStorage::Ptr  storage,
dafBase::PropertySet::Ptr  additionalData 
)
virtual

Definition at line 95 of file PropertySetFormatter.cc.

98  {
99  LOGLS_TRACE(_log, "PropertySetFormatter write start");
100  dafBase::PropertySet const* ps =
101  dynamic_cast<dafBase::PropertySet const*>(persistable);
102  if (ps == 0) {
103  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Persisting non-PropertySet");
104  }
105  if (typeid(*storage) == typeid(dafPersist::BoostStorage)) {
106  LOGLS_TRACE(_log, "PropertySetFormatter write BoostStorage");
108  dynamic_cast<dafPersist::BoostStorage*>(storage.get());
109  boost->getOArchive() & *ps;
110  LOGLS_TRACE(_log, "PropertySetFormatter write end");
111  return;
112  }
113  else if (typeid(*storage) == typeid(dafPersist::XmlStorage)) {
114  LOGLS_TRACE(_log, "PropertySetFormatter write XmlStorage");
116  dynamic_cast<dafPersist::XmlStorage*>(storage.get());
117  xml->getOArchive() & make_nvp("propertySet", *ps);
118  LOGLS_TRACE(_log, "PropertySetFormatter write end");
119  return;
120  }
121 
122  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Unrecognized FormatterStorage for PropertySet");
123 }
Class for XML file storage.
Definition: XmlStorage.h:58
Definition: Polygon.cc:24
#define LOGLS_TRACE(logger, message)
Log a trace-level message using an iostream-based interface.
Definition: Log.h:597
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
virtual boost::archive::text_oarchive & getOArchive(void)
Get a boost::serialization archive suitable for output.
virtual boost::archive::xml_oarchive & getOArchive(void)
Get a boost::serialization XML archive suitable for output.
Definition: XmlStorage.cc:107
Class for storing generic metadata.
Definition: PropertySet.h:73
Class for boost::serialization storage.
Definition: BoostStorage.h:59
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104

◆ write() [2/2]

virtual void lsst::daf::persistence::Formatter::write ( lsst::daf::base::Persistable const *  persistable,
FormatterStorage::Ptr  storage,
lsst::daf::base::PropertySet::Ptr  additionalData 
)
pure virtualinherited

Write a Persistable instance to a FormatterStorage instance.

Parameters
[in]persistablePointer to the Persistable instance.
[in]storageShared pointer to the FormatterStorage instance.
[in]additionalDataAdditional data used to find the proper place to put the instance into the FormatterStorage.

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