39 # define __attribute__(x)
50 #include <boost/serialization/nvp.hpp>
51 #include <boost/serialization/shared_ptr.hpp>
52 #include <boost/serialization/vector.hpp>
67 static void execTrace(std::string s,
int level =
EXEC_TRACE) {
71 namespace dafBase = lsst::daf::base;
72 namespace dafPersist = lsst::daf::persistence;
73 namespace pexPolicy = lsst::pex::policy;
75 using boost::serialization::make_nvp;
90 dafPersist::
Formatter(typeid(*this)), _policy(policy) {
102 execTrace(
"PropertySetFormatter write start");
106 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Persisting non-PropertySet");
109 execTrace(
"PropertySetFormatter write BoostStorage");
113 execTrace(
"PropertySetFormatter write end");
117 execTrace(
"PropertySetFormatter write XmlStorage");
121 execTrace(
"PropertySetFormatter write end");
125 execTrace(
"PropertySetFormatter write DbStorage");
129 std::string itemName = additionalData->getAsString(
"itemName");
130 std::string tableName = itemName;
132 if (_policy && _policy->exists(itemName)) {
133 itemPolicy = _policy->getPolicy(itemName);
134 if (itemPolicy->exists(
"TableName")) {
135 tableName = itemPolicy->getString(
"TableName");
140 std::vector<std::string> list;
141 if (itemPolicy && itemPolicy->exists(
"KeyList")) {
143 itemPolicy->getStringArray(
"KeyList"));
144 for (pexPolicy::Policy::StringArray::const_iterator it =
145 array.begin(); it != array.end(); ++it) {
153 for (std::vector<std::string>::const_iterator it = list.begin();
154 it != list.end(); ++it) {
155 std::string::size_type split = it->find(
'=');
158 if (split == std::string::npos) {
162 colName = it->substr(0, split);
163 key = it->substr(split + 1);
171 std::type_info
const& type(ps->
typeOf(key));
173 if (type ==
typeid(
bool)) {
176 else if (type ==
typeid(
char)) {
179 else if (type ==
typeid(
short)) {
182 else if (type ==
typeid(
int)) {
185 else if (type ==
typeid(
long)) {
188 else if (type ==
typeid(
long long)) {
189 db->
setColumn<
long long>(colName, ps->
get<
long long>(key));
191 else if (type ==
typeid(
float)) {
194 else if (type ==
typeid(
double)) {
197 else if (type ==
typeid(std::string)) {
198 db->
setColumn<std::string>(colName, ps->
get<std::string>(key));
205 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
206 std::string(
"Unknown type ") + type.name() +
207 " in PropertySetFormatter write");
211 execTrace(
"PropertySetFormatter write end");
215 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized Storage for PropertySet");
220 execTrace(
"PropertySetFormatter read start");
223 execTrace(
"PropertySetFormatter read BoostStorage");
227 execTrace(
"PropertySetFormatter read end");
231 execTrace(
"PropertySetFormatter read XmlStorage");
235 execTrace(
"PropertySetFormatter read end");
238 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized Storage for PropertySet");
244 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unexpected call to update for PropertySet");
std::vector< std::string > paramNames(bool topLevelOnly=true) const
Class for XML file storage.
Class for handling dates/times, including MJD, UTC, and TAI.
std::vector< std::string > StringArray
Interface for DbStorage class.
void setColumn(std::string const &columnName, T const &value)
virtual boost::archive::text_iarchive & getIArchive(void)
boost::shared_ptr< PropertySet > Ptr
definition of the Trace messaging facilities
boost::shared_ptr< Policy > Ptr
limited backward compatibility to the DC2 run-time trace facilities
virtual boost::archive::xml_iarchive & getIArchive(void)
Class for database storage.
lsst::daf::base::PropertySet PropertySet
Interface for XmlStorage class.
T get(std::string const &name) const
virtual void insertRow(void)
Interface for DateTime class.
#define LSST_EXCEPT(type,...)
virtual boost::archive::text_oarchive & getOArchive(void)
virtual boost::archive::xml_oarchive & getOArchive(void)
std::type_info const & typeOf(std::string const &name) const
boost::shared_ptr< Storage > Ptr
Class for storing generic metadata.
Class for boost::serialization storage.
Interface for PropertySet class.
Base class for all persistable classes.
Interface for LogicalLocation class.
virtual void setTableForInsert(std::string const &tableName)
bool exists(std::string const &name) const
virtual void setColumnToNull(std::string const &columnName)
Include files required for standard LSST Exception handling.
Interface for BoostStorage class.