ConfigObject::ConfigObject(void)
{ }
-ConfigType::Ptr ConfigObject::GetType(void) const
-{
- return ConfigType::GetByName(GetReflectionType()->GetName());
-}
-
bool ConfigObject::IsActive(void) const
{
return GetActive();
public:
virtual bool ValidateName(const String& type, const String& name) const override
{
- ConfigType::Ptr dtype = ConfigType::GetByName(type);
+ Type::Ptr ptype = Type::GetByName(type);
+ ConfigType *dtype = dynamic_cast<ConfigType *>(ptype.get());
if (!dtype)
return false;
{
ASSERT(!OwnsLock());
- ConfigType::Ptr dtype = GetType();
- dtype->RegisterObject(this);
+ TypeImpl<ConfigObject>::Ptr type = static_pointer_cast<TypeImpl<ConfigObject> >(GetReflectionType());
+ type->RegisterObject(this);
}
void ConfigObject::Unregister(void)
{
ASSERT(!OwnsLock());
- ConfigType::Ptr dtype = GetType();
- dtype->UnregisterObject(this);
+ TypeImpl<ConfigObject>::Ptr type = static_pointer_cast<TypeImpl<ConfigObject> >(GetReflectionType());
+ type->UnregisterObject(this);
}
void ConfigObject::Start(bool runtimeCreated)
void ConfigObject::OnAllConfigLoaded(void)
{
- m_Zone = GetObject("Zone", GetZoneName());
+ static ConfigType *ctype;
+
+ if (!ctype) {
+ Type::Ptr type = Type::GetByName("Zone");
+ ctype = dynamic_cast<ConfigType *>(type.get());
+ }
+
+ String zoneName = GetZoneName();
+
+ if (!zoneName.IsEmpty())
+ m_Zone = ctype->GetObject(zoneName);
}
void ConfigObject::CreateChildObjects(const Type::Ptr& childType)
StdioStream::Ptr sfp = new StdioStream(&fp, false);
- BOOST_FOREACH(const ConfigType::Ptr& type, ConfigType::GetTypes()) {
- BOOST_FOREACH(const ConfigObject::Ptr& object, type->GetObjects()) {
+ BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) {
+ ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+
+ if (!dtype)
+ continue;
+
+ BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
Dictionary::Ptr persistentObject = new Dictionary();
persistentObject->Set("type", type->GetName());
Dictionary::Ptr persistentObject = JsonDecode(message);
String type = persistentObject->Get("type");
-
- ConfigType::Ptr dt = ConfigType::GetByName(type);
-
- if (!dt)
- return;
-
String name = persistentObject->Get("name");
- ConfigObject::Ptr object = dt->GetObject(name);
+ ConfigObject::Ptr object = GetObject(type, name);
if (!object)
return;
unsigned long no_state = 0;
- BOOST_FOREACH(const ConfigType::Ptr& type, ConfigType::GetTypes()) {
- BOOST_FOREACH(const ConfigObject::Ptr& object, type->GetObjects()) {
+ BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) {
+ ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+
+ if (!dtype)
+ continue;
+
+ BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
if (!object->GetStateLoaded()) {
object->OnStateLoaded();
object->SetStateLoaded(true);
void ConfigObject::StopObjects(void)
{
- BOOST_FOREACH(const ConfigType::Ptr& dt, ConfigType::GetTypes()) {
- BOOST_FOREACH(const ConfigObject::Ptr& object, dt->GetObjects()) {
+ BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) {
+ ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+
+ if (!dtype)
+ continue;
+
+ BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
object->Deactivate();
}
}
void ConfigObject::DumpModifiedAttributes(const boost::function<void(const ConfigObject::Ptr&, const String&, const Value&)>& callback)
{
- BOOST_FOREACH(const ConfigType::Ptr& dt, ConfigType::GetTypes()) {
- BOOST_FOREACH(const ConfigObject::Ptr& object, dt->GetObjects()) {
+ BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) {
+ ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+
+ if (!dtype)
+ continue;
+
+ BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
Dictionary::Ptr originalAttributes = object->GetOriginalAttributes();
if (!originalAttributes)
ConfigObject::Ptr ConfigObject::GetObject(const String& type, const String& name)
{
- ConfigType::Ptr dtype = ConfigType::GetByName(type);
- if (!dtype)
+ Type::Ptr ptype = Type::GetByName(type);
+ ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
+
+ if (!ctype)
return ConfigObject::Ptr();
- return dtype->GetObject(name);
+
+ return ctype->GetObject(name);
}
ConfigObject::Ptr ConfigObject::GetZone(void) const
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#ifndef DYNAMICOBJECT_H
-#define DYNAMICOBJECT_H
+#ifndef CONFIGOBJECT_H
+#define CONFIGOBJECT_H
#include "base/i2-base.hpp"
#include "base/configobject.thpp"
static boost::signals2::signal<void (const ConfigObject::Ptr&)> OnStateChanged;
- intrusive_ptr<ConfigType> GetType(void) const;
-
bool IsActive(void) const;
bool IsPaused(void) const;
template<typename T>
static intrusive_ptr<T> GetObject(const String& name)
{
- ConfigObject::Ptr object = GetObject(T::GetTypeName(), name);
-
- return static_pointer_cast<T>(object);
+ typedef TypeImpl<T> ObjType;
+ ObjType *ptype = static_cast<ObjType *>(T::TypeInstance.get());
+ return static_pointer_cast<T>(ptype->GetObject(name));
}
static ConfigObject::Ptr GetObject(const String& type, const String& name);
}
-#endif /* DYNAMICOBJECT_H */
+#endif /* CONFIGOBJECT_H */
******************************************************************************/
#include "base/debuginfo.hpp"
+#include "base/configtype.hpp"
library base;
private:
DebugInfo m_DebugInfo;
};
+
}}}
-abstract class ConfigObject : ConfigObjectBase
+abstract class ConfigObject : ConfigObjectBase < ConfigType
{
[config, no_user_modify] String __name (Name);
[config, no_user_modify] String "name" (ShortName) {
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#include "base/configtype.hpp"
-#include "base/serializer.hpp"
-#include "base/debug.hpp"
-#include "base/objectlock.hpp"
+#include "base/configobject.hpp"
#include "base/convert.hpp"
#include "base/exception.hpp"
using namespace icinga;
-ConfigType::ConfigType(const String& name)
- : m_Name(name)
+ConfigType::~ConfigType(void)
{ }
-ConfigType::Ptr ConfigType::GetByName(const String& name)
-{
- boost::mutex::scoped_lock lock(GetStaticMutex());
-
- ConfigType::TypeMap::const_iterator tt = InternalGetTypeMap().find(name);
-
- if (tt == InternalGetTypeMap().end()) {
- Type::Ptr type = Type::GetByName(name);
-
- if (!type || !ConfigObject::TypeInstance->IsAssignableFrom(type)
- || type->IsAbstract())
- return ConfigType::Ptr();
-
- ConfigType::Ptr dtype = new ConfigType(name);
-
- InternalGetTypeMap()[type->GetName()] = dtype;
- InternalGetTypeVector().push_back(dtype);
-
- return dtype;
- }
-
- return tt->second;
-}
-
-/**
- * Note: Caller must hold ConfigType::GetStaticMutex() while using the map.
- */
-ConfigType::TypeMap& ConfigType::InternalGetTypeMap(void)
-{
- static ConfigType::TypeMap typemap;
- return typemap;
-}
-
-ConfigType::TypeVector& ConfigType::InternalGetTypeVector(void)
+ConfigObject::Ptr ConfigType::GetObject(const String& name) const
{
- static ConfigType::TypeVector typevector;
- return typevector;
-}
+ boost::mutex::scoped_lock lock(m_Mutex);
-ConfigType::TypeVector ConfigType::GetTypes(void)
-{
- boost::mutex::scoped_lock lock(GetStaticMutex());
- return InternalGetTypeVector(); /* Making a copy of the vector here. */
-}
+ ConfigType::ObjectMap::const_iterator nt = m_ObjectMap.find(name);
-std::pair<ConfigTypeIterator<ConfigObject>, ConfigTypeIterator<ConfigObject> > ConfigType::GetObjects(void)
-{
- return std::make_pair(
- ConfigTypeIterator<ConfigObject>(this, 0),
- ConfigTypeIterator<ConfigObject>(this, -1)
- );
-}
+ if (nt == m_ObjectMap.end())
+ return ConfigObject::Ptr();
-String ConfigType::GetName(void) const
-{
- return m_Name;
+ return nt->second;
}
void ConfigType::RegisterObject(const ConfigObject::Ptr& object)
String name = object->GetName();
{
- ObjectLock olock(this);
+ boost::mutex::scoped_lock lock(m_Mutex);
ObjectMap::iterator it = m_ObjectMap.find(name);
if (it->second == object)
return;
- BOOST_THROW_EXCEPTION(ScriptError("An object with type '" + m_Name + "' and name '" + name + "' already exists (" +
+ Type *type = dynamic_cast<Type *>(this);
+
+ BOOST_THROW_EXCEPTION(ScriptError("An object with type '" + type->GetName() + "' and name '" + name + "' already exists (" +
Convert::ToString(it->second->GetDebugInfo()) + "), new declaration: " + Convert::ToString(object->GetDebugInfo()),
object->GetDebugInfo()));
}
String name = object->GetName();
{
- ObjectLock olock(this);
+ boost::mutex::scoped_lock lock(m_Mutex);
m_ObjectMap.erase(name);
m_ObjectVector.erase(std::remove(m_ObjectVector.begin(), m_ObjectVector.end(), object), m_ObjectVector.end());
}
}
-ConfigObject::Ptr ConfigType::GetObject(const String& name) const
+std::pair<ConfigTypeIterator<ConfigObject>, ConfigTypeIterator<ConfigObject> > ConfigType::GetObjects(void)
{
- ObjectLock olock(this);
-
- ConfigType::ObjectMap::const_iterator nt = m_ObjectMap.find(name);
+ Type::Ptr type = dynamic_cast<Type *>(this);
- if (nt == m_ObjectMap.end())
- return ConfigObject::Ptr();
-
- return nt->second;
-}
-
-boost::mutex& ConfigType::GetStaticMutex(void)
-{
- static boost::mutex mutex;
- return mutex;
+ return std::make_pair(
+ ConfigTypeIterator<ConfigObject>(type, 0),
+ ConfigTypeIterator<ConfigObject>(type, UINT_MAX)
+ );
}
-
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#ifndef DYNAMICTYPE_H
-#define DYNAMICTYPE_H
+#ifndef CONFIGTYPE_H
+#define CONFIGTYPE_H
#include "base/i2-base.hpp"
-#include "base/configobject.hpp"
-#include "base/objectlock.hpp"
-#include <map>
-# include <boost/iterator/iterator_facade.hpp>
+#include "base/object.hpp"
+#include "base/type.hpp"
+#include "base/dictionary.hpp"
namespace icinga
{
+class ConfigObject;
+
template<typename T>
class ConfigTypeIterator;
-class I2_BASE_API ConfigType : public Object
+class I2_BASE_API ConfigType
{
public:
- DECLARE_PTR_TYPEDEFS(ConfigType);
-
- ConfigType(const String& name);
-
- String GetName(void) const;
+ virtual ~ConfigType(void);
- static ConfigType::Ptr GetByName(const String& name);
+ intrusive_ptr<ConfigObject> GetObject(const String& name) const;
- ConfigObject::Ptr GetObject(const String& name) const;
+ void RegisterObject(const intrusive_ptr<ConfigObject>& object);
+ void UnregisterObject(const intrusive_ptr<ConfigObject>& object);
- void RegisterObject(const ConfigObject::Ptr& object);
- void UnregisterObject(const ConfigObject::Ptr& object);
-
- static std::vector<ConfigType::Ptr> GetTypes(void);
std::pair<ConfigTypeIterator<ConfigObject>, ConfigTypeIterator<ConfigObject> > GetObjects(void);
template<typename T>
static std::pair<ConfigTypeIterator<T>, ConfigTypeIterator<T> > GetObjectsByType(void)
{
- ConfigType::Ptr type = GetByName(T::GetTypeName());
+ Type::Ptr type = T::TypeInstance;
return std::make_pair(
ConfigTypeIterator<T>(type, 0),
ConfigTypeIterator<T>(type, UINT_MAX)
private:
template<typename T> friend class ConfigTypeIterator;
- String m_Name;
-
- typedef std::map<String, ConfigObject::Ptr> ObjectMap;
- typedef std::vector<ConfigObject::Ptr> ObjectVector;
+ typedef std::map<String, intrusive_ptr<ConfigObject> > ObjectMap;
+ typedef std::vector<intrusive_ptr<ConfigObject> > ObjectVector;
+ mutable boost::mutex m_Mutex;
ObjectMap m_ObjectMap;
ObjectVector m_ObjectVector;
-
- typedef std::map<String, ConfigType::Ptr> TypeMap;
- typedef std::vector<ConfigType::Ptr> TypeVector;
-
- static TypeMap& InternalGetTypeMap(void);
- static TypeVector& InternalGetTypeVector(void);
- static boost::mutex& GetStaticMutex(void);
};
template<typename T>
class ConfigTypeIterator : public boost::iterator_facade<ConfigTypeIterator<T>, const intrusive_ptr<T>, boost::forward_traversal_tag>
{
public:
- ConfigTypeIterator(const ConfigType::Ptr& type, int index)
- : m_Type(type), m_Index(index)
- { }
+ ConfigTypeIterator(const Type::Ptr& type, int index)
+ : m_Type(type), m_ConfigType(dynamic_cast<ConfigType *>(type.get())), m_Index(index)
+ {
+ ASSERT(m_ConfigType);
+ }
private:
friend class boost::iterator_core_access;
- ConfigType::Ptr m_Type;
+ Type::Ptr m_Type;
+ ConfigType *m_ConfigType;
ConfigType::ObjectVector::size_type m_Index;
mutable intrusive_ptr<T> m_Current;
ASSERT(other.m_Type == m_Type);
{
- ObjectLock olock(m_Type);
+ boost::mutex::scoped_lock lock(m_ConfigType->m_Mutex);
- if ((other.m_Index == UINT_MAX || other.m_Index >= other.m_Type->m_ObjectVector.size()) &&
- (m_Index == UINT_MAX || m_Index >= m_Type->m_ObjectVector.size()))
+ if ((other.m_Index == UINT_MAX || other.m_Index >= other.m_ConfigType->m_ObjectVector.size()) &&
+ (m_Index == UINT_MAX || m_Index >= m_ConfigType->m_ObjectVector.size()))
return true;
}
const intrusive_ptr<T>& dereference(void) const
{
- ObjectLock olock(m_Type);
- m_Current = static_pointer_cast<T>(*(m_Type->m_ObjectVector.begin() + m_Index));
+ boost::mutex::scoped_lock lock(m_ConfigType->m_Mutex);
+ m_Current = static_pointer_cast<T>(*(m_ConfigType->m_ObjectVector.begin() + m_Index));
return m_Current;
}
};
-
}
-#endif /* DYNAMICTYPE_H */
+#endif /* CONFIGTYPE_H */
ConfigObject::Ptr ScriptUtils::GetObject(const Value& vtype, const String& name)
{
- String typeName;
+ Type::Ptr ptype;
if (vtype.IsObjectType<Type>())
- typeName = static_cast<Type::Ptr>(vtype)->GetName();
+ ptype = vtype;
else
- typeName = vtype;
+ ptype = Type::GetByName(vtype);
- ConfigType::Ptr dtype = ConfigType::GetByName(typeName);
+ ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
- if (!dtype)
+ if (!ctype)
return ConfigObject::Ptr();
- return dtype->GetObject(name);
+ return ctype->GetObject(name);
}
Array::Ptr ScriptUtils::GetObjects(const Type::Ptr& type)
{
- ConfigType::Ptr dtype = ConfigType::GetByName(type->GetName());
+ if (!type)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type: Must not be null"));
- if (!dtype)
- BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type name"));
+ ConfigType *ctype = dynamic_cast<ConfigType *>(type.get());
+
+ if (!ctype)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type: Type must inherit from 'ConfigObject'"));
Array::Ptr result = new Array();
- BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects())
+ BOOST_FOREACH(const ConfigObject::Ptr& object, ctype->GetObjects())
result->Add(object);
return result;
#ifdef I2_DEBUG
Log(LogDebug, "ConfigItem")
- << "Activating object '" << object->GetName() << "' of type '" << object->GetType()->GetName() << "'";
+ << "Activating object '" << object->GetName() << "' of type '" << object->GetReflectionType()->GetName() << "'";
#endif /* I2_DEBUG */
upq.Enqueue(boost::bind(&ConfigObject::Activate, object, runtimeCreated));
}
BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo));
}
- if (!ConfigType::GetByName(m_Type)) {
+ Type::Ptr ptype = Type::GetByName(m_Type);
+ ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
+
+ if (!ctype) {
std::ostringstream msgbuf;
msgbuf << "The type '" + m_Type + "' is unknown";
BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo));
SetCategoryFilter(categories);
Log(LogWarning, "DbConnection")
<< "Specifying flags using '|' for 'categories' for object '" << GetName()
- << "' of type '" << GetType()->GetName() << "'"
+ << "' of type '" << GetReflectionType()->GetName() << "'"
<< " is deprecated. This functionality will be removed in 2.6.0. Please use an array.";
} else
SetCategoryFilter(FilterArrayToInt(categories, DbQuery::GetCategoryFilterMap(), DbCatEverything));
void DbConnection::UpdateAllObjects(void)
{
- ConfigType::Ptr type;
- BOOST_FOREACH(const ConfigType::Ptr& dt, ConfigType::GetTypes()) {
- BOOST_FOREACH(const ConfigObject::Ptr& object, dt->GetObjects()) {
+ BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) {
+ ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+
+ if (!dtype)
+ continue;
+
+ BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
UpdateObject(object);
}
}
fields1->Set("entry_type", comment->GetEntryType());
fields1->Set("object_id", checkable);
- if (checkable->GetType() == ConfigType::GetByName("Host")) {
+ if (checkable->GetReflectionType() == Host::TypeInstance) {
fields1->Set("comment_type", 2);
/* requires idoutils 1.10 schema fix */
fields1->Set("internal_comment_id", comment->GetLegacyId());
- } else if (checkable->GetType() == ConfigType::GetByName("Service")) {
+ } else if (checkable->GetReflectionType() == Service::TypeInstance) {
fields1->Set("comment_type", 1);
fields1->Set("internal_comment_id", comment->GetLegacyId());
} else {
fields1->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime()));
fields1->Set("object_id", checkable);
- if (checkable->GetType() == ConfigType::GetByName("Host")) {
+ if (checkable->GetReflectionType() == Host::TypeInstance) {
fields1->Set("downtime_type", 2);
/* requires idoutils 1.10 schema fix */
fields1->Set("internal_downtime_id", downtime->GetLegacyId());
- } else if (checkable->GetType() == ConfigType::GetByName("Service")) {
+ } else if (checkable->GetReflectionType() == Service::TypeInstance) {
fields1->Set("downtime_type", 1);
fields1->Set("internal_downtime_id", downtime->GetLegacyId());
} else {
return;
}
- ConfigType::Ptr dtype = ConfigType::GetByName(idoType);
+ ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
VERIFY(dtype);
DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));
#include "icinga/checkable.hpp"
#include "icinga/customvarobject.hpp"
+#impl_include "icinga/hostgroup.hpp"
library icinga;
#include "icinga/host.hpp"
#include "icinga/icingaapplication.hpp"
#include "icinga/customvarobject.hpp"
+#impl_include "icinga/servicegroup.hpp"
library icinga;
#include "icinga/customvarobject.hpp"
#include "base/array.hpp"
+#impl_include "icinga/usergroup.hpp"
library icinga;
/* update the object */
double objVersion = params->Get("version");
- ConfigType::Ptr dtype = ConfigType::GetByName(objType);
+ Type::Ptr ptype = Type::GetByName(objType);
+ ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
- if (!dtype) {
+ if (!ctype) {
Log(LogCritical, "ApiListener")
<< "Config type '" << objType << "' does not exist.";
return Empty;
}
- ConfigObject::Ptr object = dtype->GetObject(objName);
+ ConfigObject::Ptr object = ctype->GetObject(objName);
String config = params->Get("config");
/* object does not exist, create it through the API */
Array::Ptr errors = new Array();
- if (!ConfigObjectUtility::CreateObject(Type::GetByName(objType),
+ if (!ConfigObjectUtility::CreateObject(ptype,
objName, config, errors)) {
Log(LogCritical, "ApiListener")
<< "Could not create object '" << objName << "':";
return Empty;
}
- object = dtype->GetObject(objName);
+ object = ctype->GetObject(objName);
if (!object)
return Empty;
}
/* delete the object */
- ConfigType::Ptr dtype = ConfigType::GetByName(params->Get("type"));
+ Type::Ptr ptype = Type::GetByName(params->Get("type"));
+ ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
- if (!dtype) {
+ if (!ctype) {
Log(LogCritical, "ApiListener")
<< "Config type '" << params->Get("type") << "' does not exist.";
return Empty;
}
- ConfigObject::Ptr object = dtype->GetObject(params->Get("name"));
+ ConfigObject::Ptr object = ctype->GetObject(params->Get("name"));
if (!object) {
Log(LogNotice, "ApiListener")
Log(LogInformation, "ApiListener")
<< "Syncing runtime objects to endpoint '" << endpoint->GetName() << "'.";
- BOOST_FOREACH(const ConfigType::Ptr& dt, ConfigType::GetTypes()) {
- BOOST_FOREACH(const ConfigObject::Ptr& object, dt->GetObjects()) {
+ BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) {
+ ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+
+ if (!dtype)
+ continue;
+
+ BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
/* don't sync objects with an older version time than the endpoint's log position */
if (object->GetVersion() < endpoint->GetLocalLogPosition())
continue;
Dictionary::Ptr secname = pmessage->Get("secobj");
if (secname) {
- ConfigType::Ptr dtype = ConfigType::GetByName(secname->Get("type"));
-
- if (!dtype)
- continue;
-
- ConfigObject::Ptr secobj = dtype->GetObject(secname->Get("name"));
+ ConfigObject::Ptr secobj = ConfigObject::GetObject(secname->Get("type"), secname->Get("name"));
if (!secobj)
continue;
std::sort(endpoints.begin(), endpoints.end(), ObjectNameLessComparer);
}
- BOOST_FOREACH(const ConfigType::Ptr& type, ConfigType::GetTypes()) {
- BOOST_FOREACH(const ConfigObject::Ptr& object, type->GetObjects()) {
+ BOOST_FOREACH(const Type::Ptr& type, Type::GetAllTypes()) {
+ ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+
+ if (!dtype)
+ continue;
+
+ BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
if (object->GetHAMode() != HARunOnce)
continue;
return true;
}
- ConfigType::Ptr dtype = ConfigType::GetByName(type->GetName());
-
- ConfigObject::Ptr obj = dtype->GetObject(name);
+ ConfigType *ctype = dynamic_cast<ConfigType *>(type.get());
+ ConfigObject::Ptr obj = ctype->GetObject(name);
result1->Set("code", 200);
void ConfigObjectTargetProvider::FindTargets(const String& type, const boost::function<void (const Value&)>& addTarget) const
{
- ConfigType::Ptr dtype = ConfigType::GetByName(type);
+ Type::Ptr ptype = Type::GetByName(type);
+ ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
- if (dtype) {
- BOOST_FOREACH(const ConfigObject::Ptr& object, dtype->GetObjects()) {
+ if (ctype) {
+ BOOST_FOREACH(const ConfigObject::Ptr& object, ctype->GetObjects()) {
addTarget(object);
}
}
continue;
Dictionary::Ptr refInfo = new Dictionary();
- refInfo->Set("type", configObj->GetType()->GetName());
+ refInfo->Set("type", configObj->GetReflectionType()->GetName());
refInfo->Set("name", configObj->GetName());
used_by->Add(refInfo);
}
m_Header << "template<>" << std::endl
<< "class " << apiMacro << "TypeImpl<" << klass.Name << ">"
<< " : public Type";
+
+ if (!klass.Parent.empty())
+ m_Header << "Impl<" << klass.Parent << ">";
if (!klass.TypeBase.empty())
m_Header << ", public " + klass.TypeBase;
m_Header << std::endl
<< "{" << std::endl
- << "public:" << std::endl;
+ << "public:" << std::endl
+ << "\t" << "DECLARE_PTR_TYPEDEFS(TypeImpl<" << klass.Name << ">);" << std::endl << std::endl;
m_Impl << "template class TypeImpl<" << klass.Name << ">;" << std::endl << std::endl;
m_Impl << "\t" << "if (avalue.IsObjectType<Function>()) {" << std::endl
<< "\t\t" << "Function::Ptr func = avalue;" << std::endl
<< "\t\t" << "if (func->IsDeprecated())" << std::endl
- << "\t\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << "' for object '\" << dynamic_cast<ConfigObject *>(this)->GetName() << \"' of type '\" << dynamic_cast<ConfigObject *>(this)->GetType()->GetName() << \"' is set to a deprecated function: \" << func->GetName();" << std::endl
+ << "\t\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << "' for object '\" << dynamic_cast<ConfigObject *>(this)->GetName() << \"' of type '\" << dynamic_cast<ConfigObject *>(this)->GetReflectionType()->GetName() << \"' is set to a deprecated function: \" << func->GetName();" << std::endl
<< "\t" << "}" << std::endl << std::endl;
std::string ftype = FieldTypeToIcingaName(field, true);
if (!it->TrackAccessor.empty())
m_Impl << "\t" << it->TrackAccessor << std::endl;
- if (it->Type.ArrayRank > 0) {
- m_Impl << "\t" << "if (oldValue) {" << std::endl
- << "\t\t" << "ObjectLock olock(oldValue);" << std::endl
- << "\t\t" << "BOOST_FOREACH(const String& ref, oldValue) {" << std::endl
- << "\t\t\t" << "DependencyGraph::RemoveDependency(this, ConfigObject::GetObject(\"" << it->Type.TypeName << "\", ref).get());" << std::endl
- << "\t\t" << "}" << std::endl
- << "\t" << "}" << std::endl
- << "\t" << "if (newValue) {" << std::endl
- << "\t\t" << "ObjectLock olock(newValue);" << std::endl
- << "\t\t" << "BOOST_FOREACH(const String& ref, newValue) {" << std::endl
- << "\t\t\t" << "DependencyGraph::AddDependency(this, ConfigObject::GetObject(\"" << it->Type.TypeName << "\", ref).get());" << std::endl
- << "\t\t" << "}" << std::endl
- << "\t" << "}" << std::endl;
- } else {
- m_Impl << "\t" << "if (!oldValue.IsEmpty())" << std::endl
- << "\t\t" << "DependencyGraph::RemoveDependency(this, ConfigObject::GetObject(\"" << it->Type.TypeName << "\", oldValue).get());" << std::endl
- << "\t" << "if (!newValue.IsEmpty())" << std::endl
- << "\t\t" << "DependencyGraph::AddDependency(this, ConfigObject::GetObject(\"" << it->Type.TypeName << "\", newValue).get());" << std::endl;
+ if (it->Type.TypeName != "String") {
+ if (it->Type.ArrayRank > 0) {
+ m_Impl << "\t" << "if (oldValue) {" << std::endl
+ << "\t\t" << "ObjectLock olock(oldValue);" << std::endl
+ << "\t\t" << "BOOST_FOREACH(const String& ref, oldValue) {" << std::endl
+ << "\t\t\t" << "DependencyGraph::RemoveDependency(this, ConfigObject::GetObject";
+
+ /* Ew */
+ if (it->Type.TypeName == "Zone" && m_Library == "base")
+ m_Impl << "(\"Zone\", ";
+ else
+ m_Impl << "<" << it->Type.TypeName << ">(";
+
+ m_Impl << "ref).get());" << std::endl
+ << "\t\t" << "}" << std::endl
+ << "\t" << "}" << std::endl
+ << "\t" << "if (newValue) {" << std::endl
+ << "\t\t" << "ObjectLock olock(newValue);" << std::endl
+ << "\t\t" << "BOOST_FOREACH(const String& ref, newValue) {" << std::endl
+ << "\t\t\t" << "DependencyGraph::AddDependency(this, ConfigObject::GetObject";
+
+ /* Ew */
+ if (it->Type.TypeName == "Zone" && m_Library == "base")
+ m_Impl << "(\"Zone\", ";
+ else
+ m_Impl << "<" << it->Type.TypeName << ">(";
+
+ m_Impl << "ref).get());" << std::endl
+ << "\t\t" << "}" << std::endl
+ << "\t" << "}" << std::endl;
+ } else {
+ m_Impl << "\t" << "if (!oldValue.IsEmpty())" << std::endl
+ << "\t\t" << "DependencyGraph::RemoveDependency(this, ConfigObject::GetObject";
+
+ /* Ew */
+ if (it->Type.TypeName == "Zone" && m_Library == "base")
+ m_Impl << "(\"Zone\", ";
+ else
+ m_Impl << "<" << it->Type.TypeName << ">(";
+
+ m_Impl << "oldValue).get());" << std::endl
+ << "\t" << "if (!newValue.IsEmpty())" << std::endl
+ << "\t\t" << "DependencyGraph::AddDependency(this, ConfigObject::GetObject";
+
+ /* Ew */
+ if (it->Type.TypeName == "Zone" && m_Library == "base")
+ m_Impl << "(\"Zone\", ";
+ else
+ m_Impl << "<" << it->Type.TypeName << ">(";
+
+ m_Impl << "newValue).get());" << std::endl;
+ }
}
m_Impl << "}" << std::endl << std::endl;