LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | List of all members
lsst::pex::policy::SupportedFormats Class Reference

a list of supported Policy formats. It can be used to determine the format type for a Policy data stream. More...

#include <SupportedFormats.h>

Public Types

typedef boost::shared_ptr
< SupportedFormats
Ptr
 

Public Member Functions

 SupportedFormats ()
 
void registerFormat (const PolicyParserFactory::Ptr &factory)
 
const std::string & recognizeType (const std::string &leaders) const
 
bool supports (const std::string &name) const
 
PolicyParserFactory::Ptr getFactory (const std::string &name) const
 
int size ()
 

Static Public Member Functions

static void initDefaultFormats (SupportedFormats &sf)
 

Private Types

typedef std::map< std::string,
PolicyParserFactory::Ptr
Lookup
 

Private Attributes

Lookup _formats
 

Detailed Description

a list of supported Policy formats. It can be used to determine the format type for a Policy data stream.

Definition at line 52 of file SupportedFormats.h.

Member Typedef Documentation

Definition at line 99 of file SupportedFormats.h.

Definition at line 55 of file SupportedFormats.h.

Constructor & Destructor Documentation

lsst::pex::policy::SupportedFormats::SupportedFormats ( )
inline

Definition at line 59 of file SupportedFormats.h.

Member Function Documentation

PolicyParserFactory::Ptr lsst::pex::policy::SupportedFormats::getFactory ( const std::string &  name) const

get a pointer to a factory with a given name. A null pointer is returned if the name is not recognized.

Definition at line 80 of file SupportedFormats.cc.

80  {
81 
82  SupportedFormats *me = const_cast<SupportedFormats*>(this);
83 
84  Lookup::iterator found = me->_formats.find(name);
85  return ((found != me->_formats.end()) ? found->second
87 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PolicyParserFactory > Ptr
void lsst::pex::policy::SupportedFormats::initDefaultFormats ( SupportedFormats sf)
static

initialize a given SupportFormats instance with the formats known by default.

Definition at line 40 of file SupportedFormats.cc.

40  {
41  sf.registerFormat(PolicyParserFactory::Ptr(new PAFParserFactory()));
42 }
boost::shared_ptr< PolicyParserFactory > Ptr
const std::string & lsst::pex::policy::SupportedFormats::recognizeType ( const std::string &  leaders) const

analyze the given string assuming contains the leading characters from the data stream and return true if it is recognized as being in the format supported by this parser. If it is, return the name of the this format;

analyze the given string assuming contains the leading characters from the data stream and determine if it is recognized as being in the format supported by this parser. If it is, return the name of the this format; if not return an empty string.

Definition at line 64 of file SupportedFormats.cc.

64  {
65 
66  Lookup::const_iterator f;
67  for(f=_formats.begin(); f != _formats.end(); ++f) {
68  if (f->second->isRecognized(leaders))
69  return f->second->getFormatName();
70  }
71 
73 }
void lsst::pex::policy::SupportedFormats::registerFormat ( const PolicyParserFactory::Ptr factory)

register a factory method for policy format parsers

Definition at line 47 of file SupportedFormats.cc.

48 {
49  if (factory.get() == 0)
50  throw LSST_EXCEPT(pexExcept::RuntimeError,
51  std::string("attempt to register null ") +
52  "PolicyParserFactory pointer");
53 
54  _formats[factory->getFormatName()] = factory;
55 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int lsst::pex::policy::SupportedFormats::size ( )
inline

return the number formats currently registered

Definition at line 96 of file SupportedFormats.h.

96 { return _formats.size(); }
bool lsst::pex::policy::SupportedFormats::supports ( const std::string &  name) const
inline

return true if the name resolves to a registered format

Definition at line 77 of file SupportedFormats.h.

77  {
78  return (_formats.find(name) != _formats.end());
79  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71

Member Data Documentation

Lookup lsst::pex::policy::SupportedFormats::_formats
private

Definition at line 100 of file SupportedFormats.h.


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