mirror of https://github.com/Icinga/icinga2.git
parent
57f84741b9
commit
cf2b6e7ccc
|
@ -20,6 +20,7 @@
|
||||||
#include "base/object.hpp"
|
#include "base/object.hpp"
|
||||||
#include "base/value.hpp"
|
#include "base/value.hpp"
|
||||||
#include "base/primitivetype.hpp"
|
#include "base/primitivetype.hpp"
|
||||||
|
#include "base/utility.hpp"
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -41,6 +42,14 @@ Object::Object(void)
|
||||||
Object::~Object(void)
|
Object::~Object(void)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation for the object.
|
||||||
|
*/
|
||||||
|
String Object::ToString(void) const
|
||||||
|
{
|
||||||
|
return "Object of type '" + Utility::GetTypeName(typeid(*this)) + "'";
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
/**
|
/**
|
||||||
* Checks if the calling thread owns the lock on this object.
|
* Checks if the calling thread owns the lock on this object.
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace icinga
|
||||||
class Value;
|
class Value;
|
||||||
class Object;
|
class Object;
|
||||||
class Type;
|
class Type;
|
||||||
|
class String;
|
||||||
|
|
||||||
#define DECLARE_PTR_TYPEDEFS(klass) \
|
#define DECLARE_PTR_TYPEDEFS(klass) \
|
||||||
typedef intrusive_ptr<klass> Ptr
|
typedef intrusive_ptr<klass> Ptr
|
||||||
|
@ -92,6 +93,8 @@ public:
|
||||||
Object(void);
|
Object(void);
|
||||||
virtual ~Object(void);
|
virtual ~Object(void);
|
||||||
|
|
||||||
|
virtual String ToString(void) const;
|
||||||
|
|
||||||
virtual void SetField(int id, const Value& value);
|
virtual void SetField(int id, const Value& value);
|
||||||
virtual Value GetField(int id) const;
|
virtual Value GetField(int id) const;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
String Type::ToString(void) const
|
||||||
|
{
|
||||||
|
return "type '" + GetName() + "'";
|
||||||
|
}
|
||||||
|
|
||||||
void Type::Register(const Type::Ptr& type)
|
void Type::Register(const Type::Ptr& type)
|
||||||
{
|
{
|
||||||
VERIFY(GetByName(type->GetName()) == NULL);
|
VERIFY(GetByName(type->GetName()) == NULL);
|
||||||
|
|
|
@ -60,6 +60,8 @@ class I2_BASE_API Type : public Object
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Type);
|
DECLARE_PTR_TYPEDEFS(Type);
|
||||||
|
|
||||||
|
virtual String ToString(void) const;
|
||||||
|
|
||||||
virtual String GetName(void) const = 0;
|
virtual String GetName(void) const = 0;
|
||||||
virtual Type::Ptr GetBaseType(void) const = 0;
|
virtual Type::Ptr GetBaseType(void) const = 0;
|
||||||
virtual int GetAttributes(void) const = 0;
|
virtual int GetAttributes(void) const = 0;
|
||||||
|
|
|
@ -59,7 +59,7 @@ Value::operator String(void) const
|
||||||
return boost::get<String>(m_Value);
|
return boost::get<String>(m_Value);
|
||||||
case ValueObject:
|
case ValueObject:
|
||||||
object = boost::get<Object::Ptr>(m_Value).get();
|
object = boost::get<Object::Ptr>(m_Value).get();
|
||||||
return "Object of type '" + Utility::GetTypeName(typeid(*object)) + "'";
|
return object->ToString();
|
||||||
default:
|
default:
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Unknown value type."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Unknown value type."));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue