10 const char *
bool2str(
bool value) {
return (value ?
"yes" :
"no"); }
13 const std::string& name,
type_t type,
const std::string&
range,
14 int_format_t int_format,
bool is_not_null,
bool is_multi_value,
15 const std::string& default_value,
const std::string& description
20 p_int_format (int_format),
21 p_is_not_null (is_not_null),
22 p_is_multi_value (is_multi_value),
23 p_default_value (default_value),
24 p_description (description)
31 case s8_type:
return "8-bits signed integer";
32 case u8_type:
return "8-bits unsigned integer";
33 case s16_type:
return "16-bits signed integer";
34 case u16_type:
return "16-bits unsigned integer";
35 case s32_type:
return "32-bits signed integer";
36 case u32_type:
return "32-bits unsigned integer";
37 case s64_type:
return "64-bits signed integer";
38 case u64_type:
return "64-bits unsigned integer";
46 default:
return "unknown";
69 default:
return "unknown";
79 default:
return "not applicable";
86 << prefix <<
"attribute \'" <<
p_name <<
"\'\n"
88 << prefix <<
" range: \'" <<
p_range <<
"\'\n";
109 const std::string& name,
const std::string& type,
bool can_be_null,
110 bool is_multi_value,
bool is_aggregation,
const std::string& description
120 p_is_aggregation (is_aggregation),
121 p_description (description)
126 switch(cardinality) {
131 default:
return "unknown";
138 << prefix <<
"relationship \'" <<
p_name <<
"\'\n"
139 << prefix <<
" class type: \'" <<
p_type <<
"\'\n"
152 const std::string& name,
153 const std::string& description,
154 const std::string& schema_path,
158 p_description (description),
159 p_schema_path (schema_path),
160 p_abstract (is_abstract)
166 << prefix <<
"class \'" <<
p_name <<
"\'\n"
172 out << prefix <<
" there are no superclasses\n";
177 out << prefix <<
" \'" << *i <<
"\'\n";
182 out << prefix <<
" there are no subclasses\n";
187 out << prefix <<
" \'" << *i <<
"\'\n";
191 std::string new_prefix(prefix);
195 out << prefix <<
" there are no attributes\n";
200 (*i).print(
out, new_prefix.c_str());
206 out << prefix <<
" there are no relationships\n";
211 (*i).print(
out, new_prefix.c_str());
225 p_number_of_cache_hits (0),
226 p_number_of_object_read (0),
240 "Configuration implementation profiler report:\n"
251 const std::string * class_name =
nullptr;
253 if(i != m_impl_objects.end()) {
256 if(j != i->second->end()) {
257 p_number_of_cache_hits++;
258 TLOG_DEBUG(4) <<
"\n * found the object with id = \'" <<
id <<
"\' in class \'" << name <<
'\'' ;
262 class_name = i->first;
268 TLOG_DEBUG(40) <<
" * there is no object with id = \'" <<
id <<
"\' found in the class \'" << name
269 <<
"\' that has " << i->second->size() <<
" objects in cache: ";
270 for(j=i->second->begin(); j != i->second->end();++j) {
277 class_name = &DalFactory::instance().get_known_class_name_ref(name);
278 TLOG_DEBUG(40) <<
" * there is no object with id = \'" <<
id <<
"\' found in the class \'" << name
279 <<
"\' that has no objects in cache";
287 if(subclasses != m_conf->subclasses().end()) {
288 for(conffwk::fset::const_iterator k = subclasses->second.begin(); k != subclasses->second.end(); ++k) {
289 i = m_impl_objects.find(*k);
290 if(i != m_impl_objects.end()) {
293 if(j != i->second->end()) {
294 p_number_of_cache_hits++;
295 TLOG_DEBUG(40) <<
" * found the object with id = \'" <<
id <<
"\' in class \'" << *k <<
'\'';
304 TLOG_DEBUG(40) <<
" * there is no object with id = \'" <<
id <<
"\' found in the class \'" << *k
305 <<
"\' that has " << i->second->size() <<
" objects in cache: ";
306 for(j=i->second->begin(); j != i->second->end();++j) {
314 TLOG_DEBUG(40) <<
" * there is no object with id = \'" <<
id <<
"\' found in the class \'" << *k
315 <<
"\' that has no objects in cache\n";
321 TLOG_DEBUG(40) <<
" * there is no object \'" <<
id <<
"\' in class \'" << name
322 <<
"\' and it's subclasses, returning NULL ...";
325 TLOG_DEBUG(40) <<
" * there is no object \'" <<
id <<
"\' in class \'" << name <<
"\', returning NULL ...";
335 p_number_of_object_read++;
339 if(i != m_impl_objects.end()) {
340 (*i->second)[
id] = obj;
341 obj->m_class_name = i->first;
345 obj->m_class_name = &DalFactory::instance().get_known_class_name_ref(name);
346 m_impl_objects[obj->m_class_name] = m;
356 if (i != m_impl_objects.end())
360 if (j != i->second->end())
367 m_tangled_objects.push_back(obj);
372 TLOG_DEBUG(2) <<
"rename implementation " << (
void *)j->second <<
" of object \'" << old_id <<
'@' << *class_name <<
"\' to \'" << new_id <<
'\'';
383 for (
auto& j : *i.second)
406 m_impl->m_conf->convert(value, obj, attr_name);
412 m_impl->m_conf->convert(value, obj, attr_name);
418 m_impl->m_conf->convert(value, obj, attr_name);
424 m_impl->m_conf->convert(value, obj, attr_name);
430 m_impl->m_conf->convert(value, obj, attr_name);
436 m_impl->m_conf->convert(value, obj, attr_name);
442 m_impl->m_conf->convert(value, obj, attr_name);
448 m_impl->m_conf->convert(value, obj, attr_name);
454 m_impl->m_conf->convert(value, obj, attr_name);
460 m_impl->m_conf->convert(value, obj, attr_name);
466 m_impl->m_conf->convert(value, obj, attr_name);
472 m_impl->m_conf->convert(value, obj, attr_name);
485 m_impl->m_conf->convert2(value, obj, attr_name);
491 m_impl->m_conf->convert2(value, obj, attr_name);
497 m_impl->m_conf->convert2(value, obj, attr_name);
503 m_impl->m_conf->convert2(value, obj, attr_name);
509 m_impl->m_conf->convert2(value, obj, attr_name);
515 m_impl->m_conf->convert2(value, obj, attr_name);
521 m_impl->m_conf->convert2(value, obj, attr_name);
527 m_impl->m_conf->convert2(value, obj, attr_name);
533 m_impl->m_conf->convert2(value, obj, attr_name);
539 m_impl->m_conf->convert2(value, obj, attr_name);
545 m_impl->m_conf->convert2(value, obj, attr_name);
Implements database objects.
void convert(bool &value, const ConfigObject &obj, const std::string &attr_name) noexcept
virtual void clear() noexcept
Virtual method to clean resources used by the implementation object.
Represents database objects.
void put_impl_object(const std::string &class_name, const std::string &id, ConfigObjectImpl *obj) noexcept
put object to cache
ConfigurationImpl() noexcept
The constructor.
void clean() noexcept
clean cache (e.g. to be used by destructor)
std::vector< ConfigObjectImpl * > m_tangled_objects
ConfigObjectImpl * get_impl_object(const std::string &class_name, const std::string &id) const noexcept
get object from cache
virtual ~ConfigurationImpl()
Virtual destructor.
void rename_impl_object(const std::string *class_name, const std::string &old_id, const std::string &new_id) noexcept
rename object in cache
unsigned long p_number_of_cache_hits
void print_cache_info() noexcept
Print profiling information about objects in cache.
Configuration * m_conf
Configuration pointer is needed for notification on changes, e.g. in case of subscription or an objec...
std::mutex & get_conf_impl_mutex() const
Is required by reload methods.
conffwk::pmap< conffwk::map< ConfigObjectImpl * > * > m_impl_objects
cache of implementation objects (class-name::->object_id->implementation)
unsigned long p_number_of_object_read
#define TLOG_DEBUG(lvl,...)
const char * bool2str(bool value)
std::ostream & operator<<(std::ostream &, const ConfigurationChange &)
DAC value out of range
Message.
FELIX Initialization std::string initerror FELIX queue timed out
int_format_t p_int_format
static const char * type(type_t type)
std::string p_description
void print(std::ostream &out, const std::string &prefix="") const
std::string p_default_value
static const char * type2str(type_t type)
static const char * format2str(int_format_t format)
const std::vector< attribute_t > p_attributes
const std::vector< relationship_t > p_relationships
void print(std::ostream &out, const std::string &prefix="") const
const std::vector< std::string > p_subclasses
std::string p_description
std::string p_schema_path
const std::vector< std::string > p_superclasses
cardinality_t p_cardinality
void print(std::ostream &out, const std::string &prefix="") const
static const char * card2str(cardinality_t cardinality)
std::string p_description