lsst.pex.policy  19.0.0-2-g3b2f90d+2
SupportedFormats.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008, 2009, 2010 LSST Corporation.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
31 #include "lsst/pex/exceptions.h"
32 
33 namespace lsst {
34 namespace pex {
35 namespace policy {
36 
39 
42 }
43 
48  if (factory.get() == 0)
50  std::string("attempt to register null ") + "PolicyParserFactory pointer");
51 
52  _formats[factory->getFormatName()] = factory;
53 }
54 
62  Lookup::const_iterator f;
63  for (f = _formats.begin(); f != _formats.end(); ++f) {
64  if (f->second->isRecognized(leaders)) return f->second->getFormatName();
65  }
66 
68 }
69 
75  SupportedFormats* me = const_cast<SupportedFormats*>(this);
76 
77  Lookup::iterator found = me->_formats.find(name);
78  return ((found != me->_formats.end()) ? found->second : PolicyParserFactory::Ptr());
79 }
80 
81 } // namespace policy
82 } // namespace pex
83 } // namespace lsst
std::string
STL class.
std::shared_ptr
STL class.
lsst::pex::policy::PolicyParserFactory::Ptr
std::shared_ptr< PolicyParserFactory > Ptr
Definition: PolicyParserFactory.h:59
SupportedFormats.h
definition of the SupportedFormats class
std::map::find
T find(T... args)
std::shared_ptr::get
T get(T... args)
lsst::pex::policy::PolicyParserFactory::UNRECOGNIZED
static const std::string UNRECOGNIZED
an empty string representing an unrecognized format
Definition: PolicyParserFactory.h:101
lsst::pex::policy::SupportedFormats::initDefaultFormats
static void initDefaultFormats(SupportedFormats &sf)
initialize a given SupportFormats instance with the formats known by default.
Definition: SupportedFormats.cc:40
PAFParserFactory.h
definition of the PAFParserFactory class
lsst::pex::policy::PolicyParserFactory
an abstract factory class for creating PolicyParser instances.
Definition: PolicyParserFactory.h:57
lsst::pex::policy::SupportedFormats::recognizeType
const std::string & recognizeType(const std::string &leaders) const
analyze the given string assuming contains the leading characters from the data stream and return tru...
Definition: SupportedFormats.cc:61
lsst::pex::policy::SupportedFormats::registerFormat
void registerFormat(const PolicyParserFactory::Ptr &factory)
register a factory method for policy format parsers
Definition: SupportedFormats.cc:47
lsst::pex::policy::SupportedFormats::getFactory
PolicyParserFactory::Ptr getFactory(const std::string &name) const
get a pointer to a factory with a given name.
Definition: SupportedFormats.cc:74
lsst
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
exceptions.h
std::map::begin
T begin(T... args)
lsst::pex::policy::SupportedFormats
a list of supported Policy formats.
Definition: SupportedFormats.h:52
lsst::pex::policy::paf::PAFParserFactory
a class for creating PAFParser objects
Definition: PAFParserFactory.h:53
std::map::end
T end(T... args)
lsst::pex::exceptions::RuntimeError