1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
#include "base/primitivetype.hpp"
#include "base/dictionary.hpp"
using namespace icinga;
PrimitiveType::PrimitiveType(String name, String base, const ObjectFactory& factory)
: m_Name(std::move(name)), m_Base(std::move(base)), m_Factory(factory)
{ }
String PrimitiveType::GetName() const
{
return m_Name;
}
Type::Ptr PrimitiveType::GetBaseType() const
{
if (m_Base == "None")
return nullptr;
else
return Type::GetByName(m_Base);
}
int PrimitiveType::GetAttributes() const
{
return 0;
}
int PrimitiveType::GetFieldId(const String& name) const
{
Type::Ptr base = GetBaseType();
if (base)
return base->GetFieldId(name);
else
return -1;
}
Field PrimitiveType::GetFieldInfo(int id) const
{
Type::Ptr base = GetBaseType();
if (base)
return base->GetFieldInfo(id);
else
throw std::runtime_error("Invalid field ID.");
}
int PrimitiveType::GetFieldCount() const
{
Type::Ptr base = GetBaseType();
if (base)
return Object::TypeInstance->GetFieldCount();
else
return 0;
}
ObjectFactory PrimitiveType::GetFactory() const
{
return m_Factory;
}
|