26 #ifndef DATATOOLS_DETAIL_OCD_UTILS_H 27 #define DATATOOLS_DETAIL_OCD_UTILS_H 37 #include <boost/scoped_ptr.hpp> 60 #include <boost/utility/enable_if.hpp> 61 #include <boost/mpl/has_xxx.hpp> 64 BOOST_MPL_HAS_XXX_TRAIT_DEF(
load)
68 template <
typename ConfigurableType>
76 template <
typename ConfigurableType>
88 #include <boost/shared_ptr.hpp> 128 bool has_id(
const std::string & class_id_)
const;
132 get(
const std::string & class_id_)
const;
143 void smart_dump(std::ostream & out_ = std::clog,
144 const std::string & title_ =
"",
145 const std::string & indent_ =
"")
const;
148 void compute_ids(std::vector<std::string> &)
const;
172 DT_LOG_TRACE(_logging_,
"Attempt to register class ID '" << class_id_ <<
"' !");
174 std::ostringstream message;
175 message <<
"datatools::detail::ocd::ocd_registration::registration: " 176 <<
"Class ID '" << class_id_ <<
"' is already registered !";
177 throw std::logic_error(message.str());
181 _dict_[class_id_] = dummy;
185 DT_LOG_TRACE(_logging_,
"Registration of class ID '" << class_id_ <<
"' was successful!");
191 DT_LOG_TRACE(_logging_,
"Attempt to unregister class ID '" << class_id_ <<
"' !");
192 ocd_dict_type::iterator found = _dict_.find(class_id_);
193 if (found == _dict_.end()) {
194 DT_LOG_ERROR(_logging_,
"Class ID '" << class_id_ <<
"' is not registered !");
198 if (! found->second.handle.unique()) {
200 "OCD registration entry for class ID '" << class_id_ <<
"' is not uniquely referenced !" 204 DT_LOG_TRACE(_logging_,
"Unregistration of class ID '" << class_id_ <<
"' was successful!");
222 char * docd_logging = getenv(
"DATATOOLS_OCD_DEVEL_LOGGING");
224 std::string ocd_logging_label = docd_logging;
230 DT_LOG_TRACE(_logging_,
"Creation of OCD system_factory_registrar for class '" << class_id_ <<
"'...");
231 DT_THROW_IF(class_id_.empty(), std::logic_error,
"Class ID is empty!");
236 bool support = load_ocd<T>(the_ocd);
238 ocd_reg.registration<T>(class_id_, h);
239 _class_id_ = class_id_;
243 DT_LOG_TRACE(_logging_,
"Destruction of OCD system_factory_registrar for registered class '" << _class_id_ <<
"'...");
245 if (! _class_id_.empty() && ocd_reg.
has_id(_class_id_)) {
252 std::string _class_id_;
256 template <
typename ClassType>
264 #endif // DATATOOLS_DETAIL_OCD_UTILS_H
void load(Archive &a_ar, geomtools::vector_3d &v_, const unsigned int a_version)
const object_configuration_description * link
Definition: ocd_utils.h:108
Internal entry to handle the OCD data associated to a class.
Definition: ocd_utils.h:106
#define DT_LOG_ERROR(Priority, Message)
Definition: logger_macros.h:82
#define DT_LOG_FATAL(Priority, Message)
Definition: logger_macros.h:46
#define DT_THROW_IF(Condition, ExceptionType, Message)
Definition: exception.h:76
#define DT_LOG_TRACE(Priority, Message)
Log Message if Priority is greater or equal to PRIO_TRACE.
Definition: logger_macros.h:227
ocd_handle_type handle
Definition: ocd_utils.h:107
Utilities for logging information.
const object_configuration_description & get() const