33 #include "boost/cstdint.hpp"
34 #include "boost/format.hpp"
43 namespace ex = lsst::pex::exceptions;
50 namespace formatters {
53 if (properties->
isArray(
"sliceId")) {
54 throw LSST_EXCEPT(ex::RuntimeError,
"\"sliceId\" property has multiple values");
56 int sliceId = properties->
getAsInt(
"sliceId");
58 throw LSST_EXCEPT(ex::RangeError,
"negative \"sliceId\"");
60 if (properties->
exists(
"universeSize") && !properties->
isArray(
"universeSize")) {
61 int universeSize = properties->
getAsInt(
"universeSize");
62 if (sliceId >= universeSize) {
63 throw LSST_EXCEPT(ex::RangeError,
"\"sliceId\" must be less than \"universeSize \"");
70 if (properties->
isArray(
"visitId")) {
71 throw LSST_EXCEPT(ex::RuntimeError,
"\"visitId\" property has multiple values");
73 int visitId = properties->
getAsInt(
"visitId");
75 throw LSST_EXCEPT(ex::RangeError,
"negative \"visitId\"");
81 if (properties->
isArray(
"fpaExposureId")) {
82 throw LSST_EXCEPT(ex::RuntimeError,
"\"fpaExposureId\" property has multiple values");
84 int64_t fpaExposureId = properties->
getAsInt64(
"fpaExposureId");
85 if (fpaExposureId < 0) {
86 throw LSST_EXCEPT(ex::RangeError,
"negative \"fpaExposureId\"");
88 if ((fpaExposureId & 0xfffffffe00000000LL) != 0
LL) {
89 throw LSST_EXCEPT(ex::RangeError,
"\"fpaExposureId\" is too large");
95 if (properties->
isArray(
"ccdId")) {
96 throw LSST_EXCEPT(ex::RuntimeError,
"\"ccdId\" property has multiple values");
98 int ccdId = properties->
getAsInt(
"ccdId");
100 throw LSST_EXCEPT(ex::RangeError,
"negative \"ccdId\"");
103 throw LSST_EXCEPT(ex::RangeError,
"\"ccdId\" is too large");
105 return static_cast<int>(ccdId);
109 if (properties->
isArray(
"ampId")) {
110 throw LSST_EXCEPT(ex::RuntimeError,
"\"ampId\" property has multiple values");
112 int ampId = properties->
getAsInt(
"ampId");
114 throw LSST_EXCEPT(ex::RangeError,
"negative \"ampId\"");
117 throw LSST_EXCEPT(ex::RangeError,
"\"ampId\" is too large");
123 if (properties->
isArray(
"ccdExposureId")) {
124 throw LSST_EXCEPT(ex::RuntimeError,
"\"ccdExposureId\" property has multiple values");
126 int64_t ccdExposureId = properties->
getAsInt64(
"ccdExposureId");
127 if (ccdExposureId < 0) {
128 throw LSST_EXCEPT(ex::RangeError,
"negative \"ccdExposureId\"");
130 return ccdExposureId;
134 if (properties->
isArray(
"ampExposureId")) {
135 throw LSST_EXCEPT(ex::RuntimeError,
"\"ampExposureId\" property has multiple values");
137 int64_t ampExposureId = properties->
getAsInt64(
"ampExposureId");
138 if (ampExposureId < 0) {
139 throw LSST_EXCEPT(ex::RangeError,
"negative \"ampExposureId\"");
141 return ampExposureId;
153 throw LSST_EXCEPT(ex::InvalidParameterError,
"Null PropertySet::Ptr");
155 if (properties->
isArray(
"itemName")) {
156 throw LSST_EXCEPT(ex::InvalidParameterError,
"\"itemName\" property has multiple values");
168 std::string
const &
name
170 if (properties && properties->
exists(name)) {
228 std::string pattern(policy->
getString(itemName +
".tableNamePattern"));
230 if (properties->
exists(itemName +
".numSlices")) {
231 numSlices = properties->
getAsInt(itemName +
".numSlices");
233 if (numSlices <= 0) {
235 itemName +
" \".numSlices\" property value must be positive");
237 std::vector<std::string> names;
238 names.reserve(numSlices);
240 for (
int i = 0; i < numSlices; ++i) {
241 props->set(
"sliceId", i);
264 std::string model(policy->
getString(itemName +
".templateTableName"));
268 db.createTableFromTemplate(name, model);
282 for (std::vector<std::string>::const_iterator i(names.begin()), end(names.end()); i != end; ++i) {
289 typedef std::vector<std::string> NameList;
292 NameList paramNames = prop->
paramNames(
false);
294 for (NameList::const_iterator i = paramNames.begin(), end = paramNames.end(); i != end; ++i) {
295 std::size_t lastPeriod = i->rfind(
char(
'.'));
296 std::string
name = (lastPeriod == std::string::npos) ? *i : i->substr(lastPeriod + 1);
297 std::type_info
const & type = prop->
typeOf(*i);
299 std::string out =
"";
300 if (name.size() > 8) {
301 out +=
"HIERARCH = " +
name;
306 if (type ==
typeid(
int)) {
308 }
else if (type ==
typeid(
double)) {
310 }
else if (type ==
typeid(std::string)) {
314 int const len = out.size();
316 out += std::string(80 - len,
' ');
318 out = out.substr(0, 80);
bool getAsBool(std::string const &name) const
std::vector< std::string > paramNames(bool topLevelOnly=true) const
table::Key< std::string > name
virtual void setPersistLocation(LogicalLocation const &location)
int64_t getAsInt64(std::string const &name) const
Include files required for standard LSST Exception handling.
Class for logical location of a persisted Persistable instance.
a container for holding hierarchical configuration data in memory.
const std::string getString(const std::string &name) const
bool isArray(std::string const &name) const
lsst::daf::base::PropertySet PropertySet
int getAsInt(std::string const &name) const
Interface for DbTsvStorage class.
T get(std::string const &name) const
Class for database storage with data loading from TSV files.
#define LSST_EXCEPT(type,...)
std::type_info const & typeOf(std::string const &name) const
Class for storing generic metadata.
virtual Ptr deepCopy(void) const
std::string getAsString(std::string const &name) const
Interface for PropertySet class.
Interface for LogicalLocation class.
bool exists(std::string const &name) const
virtual void dropTable(std::string const &tableName)