RegisterAttribute("__name", Attribute_Config, &m_Name);
RegisterAttribute("__type", Attribute_Config, &m_Type);
RegisterAttribute("__local", Attribute_Config, &m_Local);
- RegisterAttribute("__abstract", Attribute_Config, &m_Abstract);
RegisterAttribute("__source", Attribute_Local, &m_Source);
RegisterAttribute("methods", Attribute_Config, &m_Methods);
return m_Local;
}
-/**
- * @threadsafety Always.
- */
-bool DynamicObject::IsAbstract(void) const
-{
- return m_Abstract;
-}
-
/**
* @threadsafety Always.
*/
String GetName(void) const;
bool IsLocal(void) const;
- bool IsAbstract(void) const;
bool IsRegistered(void) const;
void SetSource(const String& value);
Attribute<String> m_Name;
Attribute<String> m_Type;
Attribute<bool> m_Local;
- Attribute<bool> m_Abstract;
Attribute<String> m_Source;
Attribute<Dictionary::Ptr> m_Methods;
*
* @param type The object type.
* @param name The name of the item.
+ * @param unit The unit of the item.
+ * @param abstract Whether the item is a template.
* @param exprl Expression list for the item.
* @param parents Parent objects for the item.
* @param debuginfo Debug information.
*/
ConfigItem::ConfigItem(const String& type, const String& name,
- const String& unit, const ExpressionList::Ptr& exprl,
+ const String& unit, bool abstract, const ExpressionList::Ptr& exprl,
const vector<String>& parents, const DebugInfo& debuginfo)
- : m_Type(type), m_Name(name), m_Unit(unit), m_ExpressionList(exprl),
- m_Parents(parents), m_DebugInfo(debuginfo)
+ : m_Type(type), m_Name(name), m_Unit(unit), m_Abstract(abstract),
+ m_ExpressionList(exprl), m_Parents(parents), m_DebugInfo(debuginfo)
{
}
return m_Unit;
}
+/**
+ * Checks whether the item is abstract.
+ *
+ * @returns true if the item is abstract, false otherwise.
+ */
+bool ConfigItem::IsAbstract(void) const
+{
+ return m_Abstract;
+}
+
/**
* Retrieves the debug information for the configuration item.
*
/* Update or create the object and apply the configuration settings. */
bool was_null = false;
- if (!dobj) {
+ if (!dobj && !IsAbstract()) {
dobj = dtype->CreateObject(update);
was_null = true;
}
m_DynamicObject = dobj;
}
- if (dobj->IsAbstract())
- dobj->Unregister();
- else
- dobj->Register();
+ if (dobj) {
+ if (IsAbstract())
+ dobj->Unregister();
+ else
+ dobj->Register();
+ }
/* notify our children of the update */
BOOST_FOREACH(const ConfigItem::WeakPtr wchild, children) {
typedef weak_ptr<ConfigItem> WeakPtr;
ConfigItem(const String& type, const String& name, const String& unit,
- const ExpressionList::Ptr& exprl, const vector<String>& parents,
+ bool abstract, const ExpressionList::Ptr& exprl, const vector<String>& parents,
const DebugInfo& debuginfo);
String GetType(void) const;
String GetName(void) const;
String GetUnit(void) const;
+ bool IsAbstract(void) const;
vector<String> GetParents(void) const;
String m_Type; /**< The object type. */
String m_Name; /**< The name. */
String m_Unit; /**< The compilation unit. */
+ bool m_Abstract; /**< Whether this is a template. */
ExpressionList::Ptr m_ExpressionList;
vector<String> m_Parents; /**< The names of parent configuration
Expression localExpr("__local", OperatorSet, m_Local, m_DebugInfo);
exprl->AddExpression(localExpr);
- Expression abstractExpr("__abstract", OperatorSet, m_Abstract, m_DebugInfo);
- exprl->AddExpression(abstractExpr);
-
- return boost::make_shared<ConfigItem>(m_Type, m_Name, m_Unit, exprl, m_Parents,
+ return boost::make_shared<ConfigItem>(m_Type, m_Name, m_Unit, m_Abstract, exprl, m_Parents,
m_DebugInfo);
}
ConfigItem::Ptr item = ConfigItem::GetObject("Host", GetName());
- /* Don't create slave services unless we own this object
- * and it's not a template. */
- if (!item || IsAbstract())
+ /* Don't create slave services unless we own this object */
+ if (!item)
return;
Dictionary::Ptr oldServices = m_SlaveServices;
item = ConfigItem::GetObject("Service", GetName());
- /* Don't create slave notifications unless we own this object
- * and it's not a template. */
- if (!item || IsAbstract())
+ /* Don't create slave notifications unless we own this object */
+ if (!item)
return;
{
ConfigItem::Ptr item = ConfigItem::GetObject("Service", GetName());
/* update the next check timestamp if we're the owner of this service */
- if (item && !IsAbstract())
+ if (item)
UpdateNextCheck();
}
}