lsst.pex.policy  13.0-1-g47a359c+17
Public Member Functions | Static Public Member Functions | List of all members
lsst::pex::policy::UrnPolicyFile Class Reference

A Policy file in the installation directory of an LSST product, referred to using a URN. More...

#include <UrnPolicyFile.h>

Inheritance diagram for lsst::pex::policy::UrnPolicyFile:
lsst::pex::policy::DefaultPolicyFile lsst::pex::policy::PolicyFile lsst::pex::policy::PolicySource

Public Member Functions

 UrnPolicyFile (const std::string &urn, bool strictUrn=false, bool strictLoads=true)
 Construct a new policy file reference from a URN. More...
 
- Public Member Functions inherited from lsst::pex::policy::DefaultPolicyFile
 DefaultPolicyFile (const char *const productName, const std::string &filepath, const std::string &repos="", bool strict=true)
 define a default policy file More...
 
virtual boost::filesystem::path getInstallPath (const char *const productName)
 return the file path to the installation directory of a given named product. More...
 
const boost::filesystem::path & getRepositoryPath () const
 return the full file path to the repository directory where this file will found. More...
 
virtual void load (Policy &policy) const
 load the data from this Policy source into a Policy object. More...
 
- Public Member Functions inherited from lsst::pex::policy::PolicyFile
 PolicyFile (const SupportedFormats::Ptr &fmts=defaultFormats)
 create a "null" Policy file that points to an unspecified file. More...
 
const std::string getPath () const
 return the file path as a string More...
 
bool exists () const
 return true if the file exists. More...
 
virtual const std::string & getFormatName ()
 return the name of the format that the data is stored in. More...
 
const std::string & getFormatName () const
 
 PolicyFile (const std::string &filepath, const SupportedFormats::Ptr &fmts=defaultFormats)
 create a Policy file that points a file with given path. More...
 
 PolicyFile (const char *filepath, const SupportedFormats::Ptr &fmts=defaultFormats)
 create a Policy file that points a file with given path. More...
 
 PolicyFile (const boost::filesystem::path &filepath, const SupportedFormats::Ptr &fmts=defaultFormats)
 create a Policy file that points a file with given path. More...
 
 PolicyFile (const std::string &filepath, const PolicyParserFactory::Ptr &parserFactory)
 create a Policy file that points a file with given path. More...
 
 PolicyFile (const boost::filesystem::path &filepath, const PolicyParserFactory::Ptr &parserFactory)
 create a Policy file that points a file with given path. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
virtual void load (Policy &policy)
 load the data from this Policy source into a Policy object More...
 
- Public Member Functions inherited from lsst::pex::policy::PolicySource
 PolicySource (SupportedFormats::Ptr fmts=defaultFormats)
 create a Policy file that points a file with given path. More...
 
virtual ~PolicySource ()
 destroy the source More...
 

Static Public Member Functions

static std::string productNameFromUrn (const std::string &urn, bool strictUrn=false)
 Extract the product name from a URN. More...
 
static std::string filePathFromUrn (const std::string &urn, bool strictUrn=false)
 Extract the local file path from a URN. More...
 
static std::string reposFromUrn (const std::string &urn, bool strictUrn=false)
 Extract the repository name from a URN, or "" if none. More...
 
static bool looksLikeUrn (const std::string &s, bool strict=false)
 Does s look like a URN? That is, does it start with URN_PREFIX or URN_PREFIX_ABBREV? More...
 
- Static Public Member Functions inherited from lsst::pex::policy::DefaultPolicyFile
static boost::filesystem::path installPathFor (const char *const productName)
 return the file path to the installation directory of a given named product. More...
 

Static Public Attributes

static const std::string URN_PREFIX
 The prefix that a Policy URN starts with. More...
 
static const std::string URN_PREFIX_ABBREV
 The prefix that a Policy URN starts with. More...
 
- Static Public Attributes inherited from lsst::pex::policy::PolicyFile
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
 returns true if the given string containing a content identifier indicates that it contains dictionary data. More...
 

Additional Inherited Members

- Protected Attributes inherited from lsst::pex::policy::PolicyFile
boost::filesystem::path _file
 the path to the underlying policy file More...
 
- Protected Attributes inherited from lsst::pex::policy::PolicySource
SupportedFormats::Ptr _formats
 

Detailed Description

A Policy file in the installation directory of an LSST product, referred to using a URN.

For use of URN references in PAF-formatted policy files, see Policy Authoring Format.

The syntax is urn:eupspkg:[PRODUCT_NAME][:REPOSITORY]:PATH, although "urn:eupspkg:" may optionally be abbreviated with "@". PRODUCT_NAME is the name of an LSST product (see DefaultPolicyFile for more details on LSST product installation dirs), and REPOSITORY is a subdirectory, which other references within the Policy will be relative to (see Policy for more details on repositories).

For example:

Caveat: Only supports Dictionary's "DictionaryFile" directive if the value is prefixed like a normal URN reference with "@urn:eupspkg:" or "@@".

Definition at line 68 of file UrnPolicyFile.h.

Constructor & Destructor Documentation

◆ UrnPolicyFile()

lsst::pex::policy::UrnPolicyFile::UrnPolicyFile ( const std::string &  urn,
bool  strictUrn = false,
bool  strictLoads = true 
)
inlineexplicit

Construct a new policy file reference from a URN.

Basically, the only required element is a colon, separating the product directory from the local path.

Parameters
urnThe URN of the policy file. A prefix such as "urn:eupspkg:" or "@" is optional.
strictUrnif true, the URN must strictly begin with "@urn:eupspkg:" or "urn:eupspkg:".
strictLoadsif true (default), load() will throw an exception if it encounters recoverable parsing errors in the underlying file (or any of the files it references). Otherwise, the loaded Policy will be incomplete. This is identical to the strict argument to Policy's loadPolicyFiles().

Definition at line 85 of file UrnPolicyFile.h.

Member Function Documentation

◆ filePathFromUrn()

static std::string lsst::pex::policy::UrnPolicyFile::filePathFromUrn ( const std::string &  urn,
bool  strictUrn = false 
)
static

Extract the local file path from a URN.

For example,

  • "@urn:eupspkg:product:repos:PATH/TO/FILE.PAF"
  • "@@product:repos:PATH/TO/FILE.PAF"
  • "@product:PATH/TO/FILE.PAF"

◆ looksLikeUrn()

static bool lsst::pex::policy::UrnPolicyFile::looksLikeUrn ( const std::string &  s,
bool  strict = false 
)
static

Does s look like a URN? That is, does it start with URN_PREFIX or URN_PREFIX_ABBREV?

Parameters
sthe string to be tested
strictif false, "@" will be accepted as a substitute for "urn:eupspkg:"; if true, urn:eupspkg must be present.

◆ productNameFromUrn()

static std::string lsst::pex::policy::UrnPolicyFile::productNameFromUrn ( const std::string &  urn,
bool  strictUrn = false 
)
static

Extract the product name from a URN.

For example,

  • @urn:eupspkg:PRODUCT:repos:path/to/file.paf
  • @@PRODUCT:repos:path/to/file.paf
  • @PRODUCT:path/to/file.paf

◆ reposFromUrn()

static std::string lsst::pex::policy::UrnPolicyFile::reposFromUrn ( const std::string &  urn,
bool  strictUrn = false 
)
static

Extract the repository name from a URN, or "" if none.

For example,

  • "@urn:eupspkg:product:REPOS:path/to/file.paf"
  • "@@product:REPOS:path/to/file.paf"
  • "@product:path/to/file.paf" – no repository, returns ""

Member Data Documentation

◆ URN_PREFIX

const std::string lsst::pex::policy::UrnPolicyFile::URN_PREFIX
static

The prefix that a Policy URN starts with.

May be abbreviated as "@".

Definition at line 125 of file UrnPolicyFile.h.

◆ URN_PREFIX_ABBREV

const std::string lsst::pex::policy::UrnPolicyFile::URN_PREFIX_ABBREV
static

The prefix that a Policy URN starts with.

May be abbreviated as "@".

Definition at line 126 of file UrnPolicyFile.h.


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