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
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
pex_policy
11.0.rc2+6
src
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
29
#include "
lsst/pex/policy/SupportedFormats.h
"
30
#include "
lsst/pex/policy/paf/PAFParserFactory.h
"
31
#include "
lsst/pex/exceptions.h
"
32
33
namespace
lsst {
34
namespace
pex {
35
namespace
policy {
36
37
using
lsst::pex::policy::paf::PAFParserFactory
;
38
using
lsst::pex::policy::PolicyParserFactory
;
39
40
void
SupportedFormats::initDefaultFormats
(
SupportedFormats
& sf) {
41
sf.
registerFormat
(
PolicyParserFactory::Ptr
(
new
PAFParserFactory
()));
42
}
43
47
void
SupportedFormats::registerFormat
(
const
PolicyParserFactory::Ptr
& factory)
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
}
56
63
const
std::string&
64
SupportedFormats::recognizeType
(
const
std::string& leaders)
const
{
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
72
return
PolicyParserFactory::UNRECOGNIZED
;
73
}
74
79
PolicyParserFactory::Ptr
80
SupportedFormats::getFactory
(
const
std::string&
name
)
const
{
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
86
:
PolicyParserFactory::Ptr
());
87
}
88
89
}}}
// end namespace lsst::pex::policy
90
91
92
name
table::Key< std::string > name
Definition:
ApCorrMap.cc:71
lsst::pex.policy::paf::PAFParserFactory
Definition:
PAFParserFactory.h:53
lsst::pex.policy::SupportedFormats::initDefaultFormats
static void initDefaultFormats(SupportedFormats &sf)
Definition:
SupportedFormats.cc:40
lsst::pex.policy::SupportedFormats::getFactory
PolicyParserFactory::Ptr getFactory(const std::string &name) const
Definition:
SupportedFormats.cc:80
lsst::pex.policy::SupportedFormats::registerFormat
void registerFormat(const PolicyParserFactory::Ptr &factory)
Definition:
SupportedFormats.cc:47
lsst::pex.policy::SupportedFormats::_formats
Lookup _formats
Definition:
SupportedFormats.h:100
PAFParserFactory.h
definition of the PAFParserFactory class
lsst::pex.policy::PolicyParserFactory
an abstract factory class for creating PolicyParser instances. This class is used by the PolicySource...
Definition:
PolicyParserFactory.h:58
SupportedFormats.h
definition of the SupportedFormats class
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Definition:
Exception.h:46
lsst::pex.policy::PolicyParserFactory::UNRECOGNIZED
static const std::string UNRECOGNIZED
Definition:
PolicyParserFactory.h:104
lsst::pex.policy::SupportedFormats
a list of supported Policy formats. It can be used to determine the format type for a Policy data str...
Definition:
SupportedFormats.h:52
lsst::pex.policy::PolicyParserFactory::Ptr
boost::shared_ptr< PolicyParserFactory > Ptr
Definition:
PolicyParserFactory.h:61
lsst::pex.policy::SupportedFormats::recognizeType
const std::string & recognizeType(const std::string &leaders) const
Definition:
SupportedFormats.cc:64
exceptions.h
Include files required for standard LSST Exception handling.
Generated on Wed Sep 16 2015 13:35:34 for LSSTApplications by
1.8.5