Config validator: Make sure that objects are not abstract.

Fixes #6148
This commit is contained in:
Gunnar Beutner 2014-05-09 19:40:56 +02:00
parent 042e4270bf
commit 0c31bae792
3 changed files with 10 additions and 16 deletions

View File

@ -245,20 +245,6 @@ ConfigItem::Ptr ConfigItem::GetObject(const String& type, const String& name)
return ConfigItem::Ptr();
}
bool ConfigItem::HasObject(const String& type, const String& name)
{
std::pair<String, String> key = std::make_pair(type, name);
ConfigItem::ItemMap::iterator it;
{
boost::mutex::scoped_lock lock(m_Mutex);
it = m_Items.find(key);
}
return (it != m_Items.end());
}
void ConfigItem::ValidateItem(void)
{
if (m_Validated)

View File

@ -61,7 +61,6 @@ public:
static ConfigItem::Ptr GetObject(const String& type,
const String& name);
static bool HasObject(const String& type, const String& name);
void ValidateItem(void);

View File

@ -45,6 +45,8 @@ bool TypeRule::MatchName(const String& name) const
bool TypeRule::MatchValue(const Value& value, String *hint) const
{
ConfigItem::Ptr item;
if (value.IsEmpty())
return true;
@ -76,11 +78,18 @@ bool TypeRule::MatchValue(const Value& value, String *hint) const
if (!value.IsScalar())
return false;
if (!ConfigItem::HasObject(m_NameType, value)) {
item = ConfigItem::GetObject(m_NameType, value);
if (!item) {
*hint = "Object '" + value + "' of type '" + m_NameType + "' does not exist.";
return false;
}
if (item->IsAbstract()) {
*hint = "Object '" + value + "' of type '" + m_NameType + "' must not be a template.";
return false;
}
return true;
default: