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 Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | Private Attributes | List of all members
lsst::pex.policy::PolicyString Class Reference

a representation of a string containing Policy parameter data More...

#include <PolicyString.h>

Inheritance diagram for lsst::pex.policy::PolicyString:
lsst::pex.policy::PolicySource lsst::daf::base::Persistable lsst::daf::base::Citizen

Public Member Functions

 PolicyString (const std::string &data, const SupportedFormats::Ptr &fmts=defaultFormats)
 
 PolicyString (const SupportedFormats::Ptr &fmts=defaultFormats)
 
const std::string & getData () const
 
virtual const std::string & getFormatName ()
 
const std::string & getFormatName () const
 
virtual void load (Policy &policy)
 
void load (Policy &policy) const
 
- Public Member Functions inherited from lsst::pex.policy::PolicySource
 PolicySource (SupportedFormats::Ptr fmts=defaultFormats)
 
virtual ~PolicySource ()
 
- 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...
 
- Public Member Functions inherited from lsst::daf::base::Persistable
 Persistable (void)
 
virtual ~Persistable (void)
 
template<class Archive >
void serialize (Archive &, unsigned int const)
 

Static Public Attributes

static const boost::regex SPACE_RE
 
static const boost::regex COMMENT
 reg-exp for an empty line More...
 
static const boost::regex CONTENTID
 reg-exp for the start of a comment More...
 
- Static Public Attributes inherited from lsst::pex.policy::PolicySource
static SupportedFormats::Ptr defaultFormats
 

Protected Attributes

std::string _data
 
- Protected Attributes inherited from lsst::pex.policy::PolicySource
SupportedFormats::Ptr _formats
 

Private Member Functions

const std::string & cacheName (const std::string &name)
 

Private Attributes

std::string _format
 
PolicyParserFactory::Ptr _pfact
 

Additional Inherited Members

- 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 Types inherited from lsst::daf::base::Persistable
typedef boost::shared_ptr
< Persistable
Ptr
 
- 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...
 

Detailed Description

a representation of a string containing Policy parameter data

This class facilitates reading data from a string. This class is especially useful for supporting string I/O from Python. The data is encoded in a supported format (just like the contents of a policy file).

Definition at line 52 of file PolicyString.h.

Constructor & Destructor Documentation

lsst::pex.policy::PolicyString::PolicyString ( const std::string &  data,
const SupportedFormats::Ptr fmts = defaultFormats 
)
explicit

create a PolicyString that's wrapped around a given string.

Parameters
datathe path to the file, either as a string or a boost::filesystem::path instance
fmtsa SupportedFormats object to use. An instance encapsulates a configured set of known formats.
lsst::pex.policy::PolicyString::PolicyString ( const SupportedFormats::Ptr fmts = defaultFormats)

create a "null" Policy formed from an empty string.

Parameters
fmtsa SupportedFormats object to use. An instance encapsulates a configured set of known formats.

Member Function Documentation

const std::string& lsst::pex.policy::PolicyString::cacheName ( const std::string &  name)
inlineprivate

Definition at line 121 of file PolicyString.h.

121  {
122  _format = name;
123  return _format;
124  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
const std::string& lsst::pex.policy::PolicyString::getData ( ) const
inline

return the wrapped policy data as a string

Definition at line 75 of file PolicyString.h.

75 { return _data; }
virtual const std::string& lsst::pex.policy::PolicyString::getFormatName ( )
virtual

return the name of the format that the data is stored in. This may cause the first few records of the source to be read. In this implementation, once the format is definitely determined, the format name is cached internally, preventing re-determination on the next call to this function.

Exceptions
IOErrorif an error occurs while reading the first few characters of the source stream.

Implements lsst::pex.policy::PolicySource.

const std::string& lsst::pex.policy::PolicyString::getFormatName ( ) const
inline

return the name of the format that the data is stored in. This may cause the first few records of the source to be read. In this implementation, once the format is definitely determined, the format name is cached internally, preventing re-determination on the next call to this function.

Exceptions
IOErrorif an error occurs while reading the first few characters of the source stream.

Definition at line 88 of file PolicyString.h.

88  {
89  return const_cast<PolicyString*>(this)->getFormatName();
90  }
virtual const std::string & getFormatName()
PolicyString(const std::string &data, const SupportedFormats::Ptr &fmts=defaultFormats)
virtual void lsst::pex.policy::PolicyString::load ( Policy policy)
virtual

load the data from this Policy source into a Policy object

Parameters
policythe policy object to load the data into
Exceptions
ParserExceptionif an error occurs while parsing the data
IOErrorif an I/O error occurs while reading from the source stream.

Implements lsst::pex.policy::PolicySource.

void lsst::pex.policy::PolicyString::load ( Policy policy) const
inlinevirtual

load the data from this Policy source into a Policy object

Parameters
policythe policy object to load the data into
Exceptions
ParserExceptionif an error occurs while parsing the data
IOErrorif an I/O error occurs while reading from the source stream.

Implements lsst::pex.policy::PolicySource.

Definition at line 102 of file PolicyString.h.

102  {
103  const_cast<PolicyString*>(this)->load(policy);
104  }
virtual void load(Policy &policy)
PolicyString(const std::string &data, const SupportedFormats::Ptr &fmts=defaultFormats)

Member Data Documentation

std::string lsst::pex.policy::PolicyString::_data
protected

the policy data

Definition at line 118 of file PolicyString.h.

std::string lsst::pex.policy::PolicyString::_format
private

Definition at line 126 of file PolicyString.h.

PolicyParserFactory::Ptr lsst::pex.policy::PolicyString::_pfact
private

Definition at line 127 of file PolicyString.h.

const boost::regex lsst::pex.policy::PolicyString::COMMENT
static

reg-exp for an empty line

Definition at line 108 of file PolicyString.h.

const boost::regex lsst::pex.policy::PolicyString::CONTENTID
static

reg-exp for the start of a comment

reg-exp for a Policy content identifier, "<?cfg [format] [content] ?>"

Definition at line 112 of file PolicyString.h.

const boost::regex lsst::pex.policy::PolicyString::SPACE_RE
static

Definition at line 107 of file PolicyString.h.


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