#include "base/object.hpp"
#include "base/value.hpp"
#include "base/primitivetype.hpp"
+#include "base/utility.hpp"
using namespace icinga;
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
/**
* Checks if the calling thread owns the lock on this object.
class Value;
class Object;
class Type;
+class String;
#define DECLARE_PTR_TYPEDEFS(klass) \
typedef intrusive_ptr<klass> Ptr
Object(void);
virtual ~Object(void);
+ virtual String ToString(void) const;
+
virtual void SetField(int id, const Value& value);
virtual Value GetField(int id) const;
using namespace icinga;
+String Type::ToString(void) const
+{
+ return "type '" + GetName() + "'";
+}
+
void Type::Register(const Type::Ptr& type)
{
VERIFY(GetByName(type->GetName()) == NULL);
public:
DECLARE_PTR_TYPEDEFS(Type);
+ virtual String ToString(void) const;
+
virtual String GetName(void) const = 0;
virtual Type::Ptr GetBaseType(void) const = 0;
virtual int GetAttributes(void) const = 0;
return boost::get<String>(m_Value);
case ValueObject:
object = boost::get<Object::Ptr>(m_Value).get();
- return "Object of type '" + Utility::GetTypeName(typeid(*object)) + "'";
+ return object->ToString();
default:
BOOST_THROW_EXCEPTION(std::runtime_error("Unknown value type."));
}