if ((field.Attributes & attributeTypes) == 0)
continue;
- if (!input->Contains(field.Name))
+ Value value = input->Get(field.Name);
+
+ if (value.IsEmpty())
continue;
try {
- instance->SetField(i, Deserialize(input->Get(field.Name), attributeTypes));
+ instance->SetField(i, Deserialize(value, attributeTypes));
} catch (const std::exception&) {
instance->SetField(i, Empty);
}
{
ObjectLock olock(this);
+ if (m_LinkedExpressionList)
+ return;
+
m_LinkedExpressionList = make_shared<ExpressionList>();
BOOST_FOREACH(const String& name, m_ParentNames) {
} else {
parent->Link();
- ExpressionList::Ptr pexprl = parent->GetLinkedExpressionList();
+ ExpressionList::Ptr pexprl = parent->m_LinkedExpressionList;
m_LinkedExpressionList->AddExpression(Expression("", OperatorExecute, pexprl, m_DebugInfo));
}
}
m_LinkedExpressionList->AddExpression(Expression("", OperatorExecute, m_ExpressionList, m_DebugInfo));
}
-ExpressionList::Ptr ConfigItem::GetLinkedExpressionList(void) const
+ExpressionList::Ptr ConfigItem::GetLinkedExpressionList(void)
{
- ObjectLock olock(this);
+ if (!m_LinkedExpressionList)
+ Link();
return m_LinkedExpressionList;
}
+Dictionary::Ptr ConfigItem::GetProperties(void)
+{
+ if (!m_Properties) {
+ m_Properties = make_shared<Dictionary>();
+ GetLinkedExpressionList()->Execute(m_Properties);
+ }
+
+ return m_Properties;
+}
+
/**
- * Commits the configuration item by creating or updating a DynamicObject
+ * Commits the configuration item by creating a DynamicObject
* object.
*
* @returns The DynamicObject that was created/updated.
if (IsAbstract())
return DynamicObject::Ptr();
- /* Create a fake update in the format that
- * DynamicObject::Deserialize expects. */
- Dictionary::Ptr attrs = make_shared<Dictionary>();
-
- Link();
-
- Dictionary::Ptr properties = make_shared<Dictionary>();
- GetLinkedExpressionList()->Execute(properties);
+ Dictionary::Ptr properties = GetProperties();
- {
- ObjectLock olock(properties);
-
- BOOST_FOREACH(const Dictionary::Pair& kv, properties) {
- attrs->Set(kv.first, kv.second);
- }
- }
-
- DynamicObject::Ptr dobj = dtype->CreateObject(attrs);
+ DynamicObject::Ptr dobj = dtype->CreateObject(properties);
dobj->Register();
return dobj;
if (ConfigCompilerContext::GetInstance()->HasErrors())
return false;
- Log(LogInformation, "config", "Linking config items...");
-
- BOOST_FOREACH(const ItemMap::value_type& kv, m_Items) {
- kv.second->Link();
- }
-
if (ConfigCompilerContext::GetInstance()->HasErrors())
return false;
std::vector<ConfigItem::Ptr> GetParents(void) const;
void Link(void);
- ExpressionList::Ptr GetLinkedExpressionList(void) const;
-
- void GetProperties(void);
+ ExpressionList::Ptr GetLinkedExpressionList(void);
+ Dictionary::Ptr GetProperties(void);
DynamicObject::Ptr Commit(void);
void Register(void);
DebugInfo m_DebugInfo; /**< Debug information. */
ExpressionList::Ptr m_LinkedExpressionList;
+ Dictionary::Ptr m_Properties;
static boost::mutex m_Mutex;