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::PolicyFile Class Reference

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

#include <PolicyFile.h>

Inheritance diagram for lsst::pex.policy::PolicyFile:
lsst::pex.policy::PolicySource lsst::daf::base::Persistable lsst::daf::base::Citizen lsst::pex.policy::DefaultPolicyFile lsst::pex.policy::UrnPolicyFile

Public Member Functions

 PolicyFile (const SupportedFormats::Ptr &fmts=defaultFormats)
 
const std::string getPath () const
 
bool exists () const
 
virtual const std::string & getFormatName ()
 
const std::string & getFormatName () const
 
 PolicyFile (const std::string &filepath, const SupportedFormats::Ptr &fmts=defaultFormats)
 
 PolicyFile (const char *filepath, const SupportedFormats::Ptr &fmts=defaultFormats)
 
 PolicyFile (const boost::filesystem::path &filepath, const SupportedFormats::Ptr &fmts=defaultFormats)
 
 PolicyFile (const std::string &filepath, const PolicyParserFactory::Ptr &parserFactory)
 
 PolicyFile (const boost::filesystem::path &filepath, const PolicyParserFactory::Ptr &parserFactory)
 
 PolicyFile (const std::string &filepath, const boost::filesystem::path &reposDir, const SupportedFormats::Ptr &fmts=defaultFormats)
 
 PolicyFile (const boost::filesystem::path &filepath, const boost::filesystem::path &reposDir, const SupportedFormats::Ptr &fmts=defaultFormats)
 
 PolicyFile (const std::string &filepath, const boost::filesystem::path &reposDir, const PolicyParserFactory::Ptr &parserFactory)
 
 PolicyFile (const boost::filesystem::path &filepath, const boost::filesystem::path &reposDir, const PolicyParserFactory::Ptr &parserFactory)
 
virtual void load (Policy &policy) const
 
virtual void load (Policy &policy)
 
- 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 std::string EXT_PAF
 
static const std::string EXT_XML
 the PAF file extension, ".paf" More...
 
static const boost::regex SPACE_RE
 the XML file extension, ".xml" More...
 
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

boost::filesystem::path _file
 
- 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 file containing Policy parameter data.

When this class represents a file that actually exists on disk, then it can determine which format it is in and load its contents into a Policy.

Definition at line 58 of file PolicyFile.h.

Constructor & Destructor Documentation

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

create a Policy file that points a file with given path. Typically, one need only provide a file path; this class will determine the type automatically using the default set of supported formats. If you want to control what formats (and the particular parsers) to allow, you can provide your own SupportedFormats instance. To force interpretation as a particular format, you can a PolicyParserFactory instance in lieu of a SupportedFormats (see PolicyFile(const std::string&, const SupportedFormats::Ptr&) ).

Parameters
filepaththe 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::PolicyFile::PolicyFile ( const char *  filepath,
const SupportedFormats::Ptr fmts = defaultFormats 
)
explicit

create a Policy file that points a file with given path. Typically, one need only provide a file path; this class will determine the type automatically using the default set of supported formats. If you want to control what formats (and the particular parsers) to allow, you can provide your own SupportedFormats instance. To force interpretation as a particular format, you can a PolicyParserFactory instance in lieu of a SupportedFormats (see PolicyFile(const std::string&, const SupportedFormats::Ptr&) ).

Parameters
filepaththe 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::PolicyFile::PolicyFile ( const boost::filesystem::path &  filepath,
const SupportedFormats::Ptr fmts = defaultFormats 
)
explicit

create a Policy file that points a file with given path. Typically, one need only provide a file path; this class will determine the type automatically using the default set of supported formats. If you want to control what formats (and the particular parsers) to allow, you can provide your own SupportedFormats instance. To force interpretation as a particular format, you can a PolicyParserFactory instance in lieu of a SupportedFormats (see PolicyFile(const std::string&, const SupportedFormats::Ptr&) ).

Parameters
filepaththe 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::PolicyFile::PolicyFile ( const std::string &  filepath,
const PolicyParserFactory::Ptr parserFactory 
)

create a Policy file that points a file with given path. These constructors allow you to force interpretation as a particular format by passing in the PolicyParserFactory to use.

Parameters
filepaththe path to the file, either as a string or a boost::filesystem::path instance
parserFactorya PolicyParserFactory implementation to be used in parsing the file, assuming a particular format.
lsst::pex.policy::PolicyFile::PolicyFile ( const boost::filesystem::path &  filepath,
const PolicyParserFactory::Ptr parserFactory 
)

create a Policy file that points a file with given path. These constructors allow you to force interpretation as a particular format by passing in the PolicyParserFactory to use.

Parameters
filepaththe path to the file, either as a string or a boost::filesystem::path instance
parserFactorya PolicyParserFactory implementation to be used in parsing the file, assuming a particular format.
lsst::pex.policy::PolicyFile::PolicyFile ( const std::string &  filepath,
const boost::filesystem::path &  reposDir,
const SupportedFormats::Ptr fmts = defaultFormats 
)

create a Policy file that points a file with given path in a policy file repository. Typically, one need only provide a file path; this class will determine the type automatically using the default set of supported formats. If you want to control what formats (and the particular parsers) to allow, you can provide your own SupportedFormats instance. To force interpretation as a particular format, you can a PolicyParserFactory instance in lieu of a SupportedFormats (see PolicyFile(const std::string&, const SupportedFormats::Ptr&) ).

Parameters
filepaththe path to the file, either as a string or a boost::filesystem::path instance
reposDirthe policy repository directory to assume. If filepath is a relative path, then the full path to the file will be relative to this repository directory.
fmtsa SupportedFormats object to use. An instance encapsulates a configured set of known formats.
lsst::pex.policy::PolicyFile::PolicyFile ( const boost::filesystem::path &  filepath,
const boost::filesystem::path &  reposDir,
const SupportedFormats::Ptr fmts = defaultFormats 
)

create a Policy file that points a file with given path in a policy file repository. Typically, one need only provide a file path; this class will determine the type automatically using the default set of supported formats. If you want to control what formats (and the particular parsers) to allow, you can provide your own SupportedFormats instance. To force interpretation as a particular format, you can a PolicyParserFactory instance in lieu of a SupportedFormats (see PolicyFile(const std::string&, const SupportedFormats::Ptr&) ).

Parameters
filepaththe path to the file, either as a string or a boost::filesystem::path instance
reposDirthe policy repository directory to assume. If filepath is a relative path, then the full path to the file will be relative to this repository directory.
fmtsa SupportedFormats object to use. An instance encapsulates a configured set of known formats.
lsst::pex.policy::PolicyFile::PolicyFile ( const std::string &  filepath,
const boost::filesystem::path &  reposDir,
const PolicyParserFactory::Ptr parserFactory 
)

create a Policy file that points a file with given path in a policy file repository. These constructors allow you to force interpretation as a particular format by passing in the PolicyParserFactory to use.

Parameters
filepaththe path to the file, either as a string or a boost::filesystem::path instance
reposDirthe policy repository directory to assume. If filepath is a relative path, then the full path to the file will be relative to this repository directory.
parserFactorya PolicyParserFactory implementation to be used in parsing the file, assuming a particular format.
lsst::pex.policy::PolicyFile::PolicyFile ( const boost::filesystem::path &  filepath,
const boost::filesystem::path &  reposDir,
const PolicyParserFactory::Ptr parserFactory 
)

create a Policy file that points a file with given path in a policy file repository. These constructors allow you to force interpretation as a particular format by passing in the PolicyParserFactory to use.

Parameters
filepaththe path to the file, either as a string or a boost::filesystem::path instance
reposDirthe policy repository directory to assume. If filepath is a relative path, then the full path to the file will be relative to this repository directory.
parserFactorya PolicyParserFactory implementation to be used in parsing the file, assuming a particular format.
lsst::pex.policy::PolicyFile::PolicyFile ( const SupportedFormats::Ptr fmts = defaultFormats)

create a "null" Policy file that points to an unspecified file.

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

Member Function Documentation

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

Definition at line 229 of file PolicyFile.h.

229  {
230  _format = name;
231  return _format;
232  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
bool lsst::pex.policy::PolicyFile::exists ( ) const
inline

return true if the file exists.

Definition at line 181 of file PolicyFile.h.

181 { return boost::filesystem::exists(_file); }
def exists
Definition: cuda.py:53
boost::filesystem::path _file
Definition: PolicyFile.h:226
virtual const std::string& lsst::pex.policy::PolicyFile::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::PolicyFile::getFormatName ( ) const
inline

Definition at line 193 of file PolicyFile.h.

193  {
194  return const_cast<PolicyFile*>(this)->getFormatName();
195  }
virtual const std::string & getFormatName()
PolicyFile(const std::string &filepath, const SupportedFormats::Ptr &fmts=defaultFormats)
const std::string lsst::pex.policy::PolicyFile::getPath ( void  ) const
inline

return the file path as a string

Definition at line 176 of file PolicyFile.h.

176 { return _file.string(); }
boost::filesystem::path _file
Definition: PolicyFile.h:226
virtual void lsst::pex.policy::PolicyFile::load ( Policy policy) const
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.

Reimplemented in lsst::pex.policy::DefaultPolicyFile.

virtual void lsst::pex.policy::PolicyFile::load ( Policy policy)
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 206 of file PolicyFile.h.

206  {
207  ((const PolicyFile*) this)->load(policy); // delegate to const version
208  }
PolicyFile(const std::string &filepath, const SupportedFormats::Ptr &fmts=defaultFormats)

Member Data Documentation

boost::filesystem::path lsst::pex.policy::PolicyFile::_file
protected

the path to the underlying policy file

Definition at line 226 of file PolicyFile.h.

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

Definition at line 234 of file PolicyFile.h.

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

Definition at line 235 of file PolicyFile.h.

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

reg-exp for an empty line

Definition at line 215 of file PolicyFile.h.

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

reg-exp for the start of a comment

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

Definition at line 220 of file PolicyFile.h.

const std::string lsst::pex.policy::PolicyFile::EXT_PAF
static

Definition at line 211 of file PolicyFile.h.

const std::string lsst::pex.policy::PolicyFile::EXT_XML
static

the PAF file extension, ".paf"

Definition at line 212 of file PolicyFile.h.

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

the XML file extension, ".xml"

Definition at line 214 of file PolicyFile.h.


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