Implement typeof() function

This commit is contained in:
Gunnar Beutner 2014-11-03 00:44:04 +01:00
parent 0f4e3004b6
commit 170c5a59e4
157 changed files with 258 additions and 229 deletions

View File

@ -36,7 +36,7 @@ namespace icinga
*/
class I2_BASE_API Application : public ObjectImpl<Application> {
public:
DECLARE_PTR_TYPEDEFS(Application);
DECLARE_OBJECT(Application);
static boost::signals2::signal<void (void)> OnReopenLogs;

View File

@ -36,7 +36,7 @@ namespace icinga
class I2_BASE_API Array : public Object
{
public:
DECLARE_PTR_TYPEDEFS(Array);
DECLARE_OBJECT(Array);
/**
* An iterator that can be used to iterate over array elements.

View File

@ -37,7 +37,7 @@ namespace icinga
class I2_BASE_API Dictionary : public Object
{
public:
DECLARE_PTR_TYPEDEFS(Dictionary);
DECLARE_OBJECT(Dictionary);
/**
* An iterator that can be used to iterate over dictionary elements.

View File

@ -42,7 +42,7 @@ class DynamicType;
class I2_BASE_API DynamicObject : public ObjectImpl<DynamicObject>
{
public:
DECLARE_PTR_TYPEDEFS(DynamicObject);
DECLARE_OBJECT(DynamicObject);
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStarted;
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStopped;
@ -101,7 +101,7 @@ private:
DebugInfo m_DebugInfo;
};
#define DECLARE_TYPENAME(klass) \
#define DECLARE_OBJECTNAME(klass) \
inline static String GetTypeName(void) \
{ \
return #klass; \

View File

@ -37,7 +37,7 @@ DynamicType::Ptr DynamicType::GetByName(const String& name)
DynamicType::TypeMap::const_iterator tt = InternalGetTypeMap().find(name);
if (tt == InternalGetTypeMap().end()) {
const Type *type = Type::GetByName(name);
Type::Ptr type = Type::GetByName(name);
if (!type || !Type::GetByName("DynamicObject")->IsAssignableFrom(type)
|| type->IsAbstract())
@ -127,7 +127,7 @@ DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUp
{
ASSERT(!OwnsLock());
const Type *type = Type::GetByName(m_Name);
Type::Ptr type = Type::GetByName(m_Name);
Object::Ptr object = type->Instantiate();

View File

@ -36,7 +36,7 @@ class DynamicTypeIterator;
class I2_BASE_API DynamicType : public Object
{
public:
DECLARE_PTR_TYPEDEFS(DynamicType);
DECLARE_OBJECT(DynamicType);
DynamicType(const String& name);

View File

@ -34,7 +34,7 @@ namespace icinga
class I2_BASE_API FIFO : public Stream
{
public:
DECLARE_PTR_TYPEDEFS(FIFO);
DECLARE_OBJECT(FIFO);
static const size_t BlockSize = 16 * 1024;

View File

@ -34,8 +34,8 @@ namespace icinga
class I2_BASE_API FileLogger : public ObjectImpl<FileLogger>
{
public:
DECLARE_PTR_TYPEDEFS(FileLogger);
DECLARE_TYPENAME(FileLogger);
DECLARE_OBJECT(FileLogger);
DECLARE_OBJECTNAME(FileLogger);
static Value StatsFunc(Dictionary::Ptr& status, Array::Ptr& perfdata);

View File

@ -62,7 +62,7 @@ struct LogEntry {
class I2_BASE_API Logger : public ObjectImpl<Logger>
{
public:
DECLARE_PTR_TYPEDEFS(Logger);
DECLARE_OBJECT(Logger);
static String SeverityToString(LogSeverity severity);
static LogSeverity StringToSeverity(const String& severity);

View File

@ -35,7 +35,7 @@ namespace icinga
class I2_BASE_API NetworkStream : public Stream
{
public:
DECLARE_PTR_TYPEDEFS(NetworkStream);
DECLARE_OBJECT(NetworkStream);
NetworkStream(const Socket::Ptr& socket);

View File

@ -22,6 +22,8 @@
using namespace icinga;
REGISTER_PRIMITIVE_TYPE(Object);
#ifdef _DEBUG
boost::mutex Object::m_DebugMutex;
#endif /* _DEBUG */
@ -70,11 +72,6 @@ Object::SharedPtrHolder::operator Value(void) const
return m_Object;
}
const Type *Object::GetReflectionType(void) const
{
return NULL;
}
void Object::SetField(int, const Value&)
{
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
@ -85,3 +82,8 @@ Value Object::GetField(int) const
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
}
Type::Ptr icinga::LookupType(const char *name)
{
return Type::GetByName(name);
}

View File

@ -53,8 +53,20 @@ class Value;
typedef shared_ptr<klass> Ptr; \
typedef weak_ptr<klass> WeakPtr
#define IMPL_TYPE_LOOKUP(klass) \
inline virtual shared_ptr<Type> GetReflectionType(void) const \
{ \
return LookupType(#klass); \
}
#define DECLARE_OBJECT(klass) \
DECLARE_PTR_TYPEDEFS(klass); \
IMPL_TYPE_LOOKUP(klass);
class Type;
I2_BASE_API shared_ptr<Type> LookupType(const char *name);
/**
* Base class for all heap-allocated objects. At least one of its methods
* has to be virtual for RTTI to work.
@ -64,12 +76,11 @@ class Type;
class I2_BASE_API Object : public enable_shared_from_this<Object>
{
public:
DECLARE_PTR_TYPEDEFS(Object);
DECLARE_OBJECT(Object);
Object(void);
virtual ~Object(void);
virtual const Type *GetReflectionType(void) const;
virtual void SetField(int id, const Value& value);
virtual Value GetField(int id) const;

View File

@ -34,9 +34,9 @@ String PrimitiveType::GetName(void) const
return m_Name;
}
const Type *PrimitiveType::GetBaseType(void) const
Type::Ptr PrimitiveType::GetBaseType(void) const
{
return NULL;
return Type::Ptr();
}
int PrimitiveType::GetAttributes(void) const

View File

@ -33,7 +33,7 @@ public:
PrimitiveType(const String& name);
virtual String GetName(void) const;
virtual const Type *GetBaseType(void) const;
virtual Type::Ptr GetBaseType(void) const;
virtual int GetAttributes(void) const;
virtual int GetFieldId(const String& name) const;
virtual Field GetFieldInfo(int id) const;
@ -47,7 +47,7 @@ private:
namespace { namespace UNIQUE_NAME(prt) { \
void RegisterPrimitiveType ## type(void) \
{ \
icinga::Type *t = new PrimitiveType(#type); \
icinga::Type::Ptr t = make_shared<PrimitiveType>(#type); \
icinga::Type::Register(t); \
} \
\

View File

@ -53,7 +53,7 @@ struct ProcessResult
class I2_BASE_API Process : public Object
{
public:
DECLARE_PTR_TYPEDEFS(Process);
DECLARE_OBJECT(Process);
#ifdef _WIN32
typedef String Arguments;

View File

@ -35,7 +35,7 @@ namespace icinga
class I2_BASE_API RingBuffer : public Object
{
public:
DECLARE_PTR_TYPEDEFS(RingBuffer);
DECLARE_OBJECT(RingBuffer);
typedef std::vector<int>::size_type SizeType;

View File

@ -37,7 +37,7 @@ namespace icinga
class I2_BASE_API ScriptFunction : public Object
{
public:
DECLARE_PTR_TYPEDEFS(ScriptFunction);
DECLARE_OBJECT(ScriptFunction);
typedef boost::function<Value (const std::vector<Value>& arguments)> Callback;

View File

@ -40,6 +40,7 @@ REGISTER_SCRIPTFUNCTION(intersection, &ScriptUtils::Intersection);
REGISTER_SCRIPTFUNCTION(log, &ScriptUtils::Log);
REGISTER_SCRIPTFUNCTION(range, &ScriptUtils::Range);
REGISTER_SCRIPTFUNCTION(exit, &ScriptUtils::Exit);
REGISTER_SCRIPTFUNCTION(typeof, &ScriptUtils::TypeOf);
bool ScriptUtils::Regex(const String& pattern, const String& text)
{
@ -179,3 +180,19 @@ void ScriptUtils::Exit(int code)
{
exit(code);
}
Type::Ptr ScriptUtils::TypeOf(const Value& value)
{
switch (value.GetType()) {
case ValueEmpty:
return Type::GetByName("Object");
case ValueNumber:
return Type::GetByName("double");
case ValueString:
return Type::GetByName("String");
case ValueObject:
return static_cast<Object::Ptr>(value)->GetReflectionType();
default:
VERIFY(!"Invalid value type.");
}
}

View File

@ -40,6 +40,7 @@ public:
static void Log(const std::vector<Value>& arguments);
static Array::Ptr Range(const std::vector<Value>& arguments);
static void Exit(int code);
static Type::Ptr TypeOf(const Value& value);
private:
ScriptUtils(void);

View File

@ -43,7 +43,7 @@ public:
class I2_BASE_API ScriptVariable : public Object
{
public:
DECLARE_PTR_TYPEDEFS(ScriptVariable);
DECLARE_OBJECT(ScriptVariable);
ScriptVariable(const Value& data);

View File

@ -53,7 +53,7 @@ static Dictionary::Ptr SerializeDictionary(const Dictionary::Ptr& input, int att
static Object::Ptr SerializeObject(const Object::Ptr& input, int attributeTypes)
{
const Type *type = input->GetReflectionType();
Type::Ptr type = input->GetReflectionType();
VERIFY(type);
@ -101,11 +101,11 @@ static Dictionary::Ptr DeserializeDictionary(const Dictionary::Ptr& input, bool
static Object::Ptr DeserializeObject(const Object::Ptr& object, const Dictionary::Ptr& input, bool safe_mode, int attributeTypes)
{
const Type *type;
if (!object && safe_mode)
BOOST_THROW_EXCEPTION(std::runtime_error("Tried to instantiate object while safe mode is enabled."));
Type::Ptr type;
if (object)
type = object->GetReflectionType();
else

View File

@ -38,7 +38,7 @@ namespace icinga
class I2_BASE_API Socket : public Object
{
public:
DECLARE_PTR_TYPEDEFS(Socket);
DECLARE_OBJECT(Socket);
Socket(void);
Socket(SOCKET fd);

View File

@ -38,7 +38,7 @@ namespace icinga
class I2_BASE_API StatsFunction : public Object
{
public:
DECLARE_PTR_TYPEDEFS(StatsFunction);
DECLARE_OBJECT(StatsFunction);
typedef boost::function<Value (Dictionary::Ptr& status, Array::Ptr& perfdata)> Callback;

View File

@ -29,7 +29,7 @@ namespace icinga {
class I2_BASE_API StdioStream : public Stream
{
public:
DECLARE_PTR_TYPEDEFS(StdioStream);
DECLARE_OBJECT(StdioStream);
StdioStream(std::iostream *innerStream, bool ownsStream);
~StdioStream(void);

View File

@ -54,7 +54,7 @@ struct ReadLineContext
class I2_BASE_API Stream : public Object
{
public:
DECLARE_PTR_TYPEDEFS(Stream);
DECLARE_OBJECT(Stream);
/**
* Reads data from the stream.

View File

@ -36,7 +36,7 @@ namespace icinga
class I2_BASE_API StreamLogger : public ObjectImpl<StreamLogger>
{
public:
DECLARE_PTR_TYPEDEFS(StreamLogger);
DECLARE_OBJECT(StreamLogger);
virtual void Start(void);
virtual void Stop(void);

View File

@ -35,8 +35,8 @@ namespace icinga
class I2_BASE_API SyslogLogger : public ObjectImpl<SyslogLogger>
{
public:
DECLARE_PTR_TYPEDEFS(SyslogLogger);
DECLARE_TYPENAME(SyslogLogger);
DECLARE_OBJECT(SyslogLogger);
DECLARE_OBJECTNAME(SyslogLogger);
static Value StatsFunc(Dictionary::Ptr& status, Array::Ptr& perfdata);

View File

@ -34,7 +34,7 @@ namespace icinga
class I2_BASE_API TcpSocket : public Socket
{
public:
DECLARE_PTR_TYPEDEFS(TcpSocket);
DECLARE_OBJECT(TcpSocket);
void Bind(const String& service, int family);
void Bind(const String& node, const String& service, int family);

View File

@ -34,7 +34,7 @@ namespace icinga {
class I2_BASE_API Timer : public Object
{
public:
DECLARE_PTR_TYPEDEFS(Timer);
DECLARE_OBJECT(Timer);
Timer(void);
~Timer(void);

View File

@ -36,7 +36,7 @@ namespace icinga
class I2_BASE_API TlsStream : public Stream
{
public:
DECLARE_PTR_TYPEDEFS(TlsStream);
DECLARE_OBJECT(TlsStream);
TlsStream(const Socket::Ptr& socket, ConnectionRole role, const shared_ptr<SSL_CTX>& sslContext);

View File

@ -28,21 +28,21 @@ Type::TypeMap& Type::GetTypes(void)
return types;
}
void Type::Register(const Type *type)
void Type::Register(const Type::Ptr& type)
{
VERIFY(GetByName(type->GetName()) == NULL);
GetTypes()[type->GetName()] = type;
}
const Type *Type::GetByName(const String& name)
Type::Ptr Type::GetByName(const String& name)
{
std::map<String, const Type *>::const_iterator it;
std::map<String, Type::Ptr>::const_iterator it;
it = GetTypes().find(name);
if (it == GetTypes().end())
return NULL;
return Type::Ptr();
return it->second;
}
@ -57,10 +57,10 @@ bool Type::IsAbstract(void) const
return ((GetAttributes() & TAAbstract) != 0);
}
bool Type::IsAssignableFrom(const Type *other) const
bool Type::IsAssignableFrom(const Type::Ptr& other) const
{
for (const Type *t = other; t; t = t->GetBaseType()) {
if (t == this)
for (Type::Ptr t = other; t; t = t->GetBaseType()) {
if (t.get() == this)
return true;
}

View File

@ -42,11 +42,11 @@ class Type;
struct Field
{
int ID;
const Type *FType;
shared_ptr<Type> FType;
const char *Name;
int Attributes;
Field(int id, const Type *type, const char *name, int attributes)
Field(int id, const shared_ptr<Type>& type, const char *name, int attributes)
: ID(id), FType(type), Name(name), Attributes(attributes)
{ }
};
@ -56,13 +56,15 @@ enum TypeAttribute
TAAbstract = 1
};
class I2_BASE_API Type
class I2_BASE_API Type : public Object
{
public:
DECLARE_OBJECT(Type);
typedef boost::function<Object::Ptr (void)> Factory;
virtual String GetName(void) const = 0;
virtual const Type *GetBaseType(void) const = 0;
virtual Type::Ptr GetBaseType(void) const = 0;
virtual int GetAttributes(void) const = 0;
virtual int GetFieldId(const String& name) const = 0;
virtual Field GetFieldInfo(int id) const = 0;
@ -70,17 +72,17 @@ public:
Object::Ptr Instantiate(void) const;
bool IsAssignableFrom(const Type *other) const;
bool IsAssignableFrom(const Type::Ptr& other) const;
bool IsAbstract(void) const;
static void Register(const Type *type);
static const Type *GetByName(const String& name);
static void Register(const Type::Ptr& type);
static Type::Ptr GetByName(const String& name);
void SetFactory(const Factory& factory);
private:
typedef std::map<String, const Type *> TypeMap;
typedef std::map<String, Type::Ptr> TypeMap;
static TypeMap& GetTypes(void);
@ -111,7 +113,7 @@ struct FactoryHelper
namespace { namespace UNIQUE_NAME(rt) { \
void RegisterType ## type(void) \
{ \
icinga::Type *t = new TypeImpl<type>(); \
icinga::Type::Ptr t = make_shared<TypeImpl<type> >(); \
t->SetFactory(FactoryHelper<type>().GetFactory()); \
icinga::Type::Register(t); \
} \

View File

@ -29,7 +29,7 @@ namespace icinga
class I2_BASE_API UnixSocket : public Socket
{
public:
DECLARE_PTR_TYPEDEFS(UnixSocket);
DECLARE_OBJECT(UnixSocket);
UnixSocket(void);

View File

@ -148,7 +148,7 @@ ValueType Value::GetType(void) const
String Value::GetTypeName(void) const
{
const Type *t;
Type::Ptr t;
switch (GetType()) {
case ValueEmpty:

View File

@ -57,8 +57,8 @@ struct CheckableNextCheckExtractor
class CheckerComponent : public ObjectImpl<CheckerComponent>
{
public:
DECLARE_PTR_TYPEDEFS(CheckerComponent);
DECLARE_TYPENAME(CheckerComponent);
DECLARE_OBJECT(CheckerComponent);
DECLARE_OBJECTNAME(CheckerComponent);
typedef boost::multi_index_container<
Checkable::Ptr,

View File

@ -68,7 +68,7 @@ std::vector<String> icinga::GetBashCompletionSuggestions(const String& type, con
return result;
}
std::vector<String> icinga::GetFieldCompletionSuggestions(const Type *type, const String& word)
std::vector<String> icinga::GetFieldCompletionSuggestions(const Type::Ptr& type, const String& word)
{
std::vector<String> result;

View File

@ -23,6 +23,7 @@
#include "cli/i2-cli.hpp"
#include "base/value.hpp"
#include "base/utility.hpp"
#include "base/type.hpp"
#include <vector>
#include <boost/program_options.hpp>
@ -30,7 +31,7 @@ namespace icinga
{
std::vector<String> I2_CLI_API GetBashCompletionSuggestions(const String& type, const String& word);
std::vector<String> I2_CLI_API GetFieldCompletionSuggestions(const Type *type, const String& word);
std::vector<String> I2_CLI_API GetFieldCompletionSuggestions(const Type::Ptr& type, const String& word);
enum ImpersonationLevel
{
@ -47,7 +48,7 @@ enum ImpersonationLevel
class I2_CLI_API CLICommand : public Object
{
public:
DECLARE_PTR_TYPEDEFS(CLICommand);
DECLARE_OBJECT(CLICommand);
typedef std::vector<String>(*ArgumentCompletionCallback)(const String&, const String&);

View File

@ -33,7 +33,7 @@ namespace icinga
class DaemonCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(DaemonCommand);
DECLARE_OBJECT(DaemonCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class FeatureDisableCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(FeatureDisableCommand);
DECLARE_OBJECT(FeatureDisableCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class FeatureEnableCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(FeatureEnableCommand);
DECLARE_OBJECT(FeatureEnableCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class FeatureListCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(FeatureListCommand);
DECLARE_OBJECT(FeatureListCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class NodeAddCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(NodeAddCommand);
DECLARE_OBJECT(NodeAddCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -40,7 +40,7 @@ enum BlackAndWhitelistCommandType
class I2_CLI_API BlackAndWhitelistCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(BlackAndWhitelistCommand);
DECLARE_OBJECT(BlackAndWhitelistCommand);
BlackAndWhitelistCommand(const String& type, BlackAndWhitelistCommandType command);

View File

@ -33,7 +33,7 @@ namespace icinga
class NodeListCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(NodeListCommand);
DECLARE_OBJECT(NodeListCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class NodeRemoveCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(NodeRemoveCommand);
DECLARE_OBJECT(NodeRemoveCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class NodeSetCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(NodeSetCommand);
DECLARE_OBJECT(NodeSetCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class NodeSetupCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(NodeSetupCommand);
DECLARE_OBJECT(NodeSetupCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class NodeUpdateConfigCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(NodeUpdateConfigCommand);
DECLARE_OBJECT(NodeUpdateConfigCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class NodeWizardCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(NodeWizardCommand);
DECLARE_OBJECT(NodeWizardCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -36,7 +36,7 @@ namespace icinga
class ObjectListCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(ObjectListCommand);
DECLARE_OBJECT(ObjectListCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class PKINewCACommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(PKINewCACommand);
DECLARE_OBJECT(PKINewCACommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class PKINewCertCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(PKINewCertCommand);
DECLARE_OBJECT(PKINewCertCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class PKIRequestCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(PKIRequestCommand);
DECLARE_OBJECT(PKIRequestCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class PKISaveCertCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(PKISaveCertCommand);
DECLARE_OBJECT(PKISaveCertCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class PKISignCSRCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(PKISignCSRCommand);
DECLARE_OBJECT(PKISignCSRCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -33,7 +33,7 @@ namespace icinga
class PKITicketCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(PKITicketCommand);
DECLARE_OBJECT(PKITicketCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -36,7 +36,7 @@ namespace icinga
class RepositoryClearChangesCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(RepositoryClearChangesCommand);
DECLARE_OBJECT(RepositoryClearChangesCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -36,7 +36,7 @@ namespace icinga
class RepositoryCommitCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(RepositoryCommitCommand);
DECLARE_OBJECT(RepositoryCommitCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -129,7 +129,7 @@ std::vector<String> RepositoryObjectCommand::GetPositionalSuggestions(const Stri
{
if (m_Command == RepositoryCommandAdd) {
Utility::LoadExtensionLibrary("icinga");
const Type *ptype = Type::GetByName(m_Type);
Type::Ptr ptype = Type::GetByName(m_Type);
ASSERT(ptype);
return GetFieldCompletionSuggestions(ptype, word);
} else if (m_Command == RepositoryCommandRemove) {

View File

@ -41,7 +41,7 @@ enum RepositoryCommandType
class I2_CLI_API RepositoryObjectCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(RepositoryObjectCommand);
DECLARE_OBJECT(RepositoryObjectCommand);
RepositoryObjectCommand(const String& type, RepositoryCommandType command);

View File

@ -36,7 +36,7 @@ namespace icinga
class VariableGetCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(VariableGetCommand);
DECLARE_OBJECT(VariableGetCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -36,7 +36,7 @@ namespace icinga
class VariableListCommand : public CLICommand
{
public:
DECLARE_PTR_TYPEDEFS(VariableListCommand);
DECLARE_OBJECT(VariableListCommand);
virtual String GetDescription(void) const;
virtual String GetShortDescription(void) const;

View File

@ -35,8 +35,8 @@ namespace icinga
class CheckResultReader : public ObjectImpl<CheckResultReader>
{
public:
DECLARE_PTR_TYPEDEFS(CheckResultReader);
DECLARE_TYPENAME(CheckResultReader);
DECLARE_OBJECT(CheckResultReader);
DECLARE_OBJECTNAME(CheckResultReader);
static Value StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);

View File

@ -36,8 +36,8 @@ namespace icinga
class CompatLogger : public ObjectImpl<CompatLogger>
{
public:
DECLARE_PTR_TYPEDEFS(CompatLogger);
DECLARE_TYPENAME(CompatLogger);
DECLARE_OBJECT(CompatLogger);
DECLARE_OBJECTNAME(CompatLogger);
static Value StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);

View File

@ -36,8 +36,8 @@ namespace icinga
class ExternalCommandListener : public ObjectImpl<ExternalCommandListener>
{
public:
DECLARE_PTR_TYPEDEFS(ExternalCommandListener);
DECLARE_TYPENAME(ExternalCommandListener);
DECLARE_OBJECT(ExternalCommandListener);
DECLARE_OBJECTNAME(ExternalCommandListener);
static Value StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);

View File

@ -41,8 +41,8 @@ namespace icinga
class StatusDataWriter : public ObjectImpl<StatusDataWriter>
{
public:
DECLARE_PTR_TYPEDEFS(StatusDataWriter);
DECLARE_TYPENAME(StatusDataWriter);
DECLARE_OBJECT(StatusDataWriter);
DECLARE_OBJECTNAME(StatusDataWriter);
static Value StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);

View File

@ -143,7 +143,7 @@ Dictionary::Ptr ConfigItem::GetProperties(void)
String name = m_Name;
if (!m_Abstract) {
const NameComposer *nc = dynamic_cast<const NameComposer *>(Type::GetByName(m_Type));
shared_ptr<NameComposer> nc = dynamic_pointer_cast<NameComposer>(Type::GetByName(m_Type));
if (nc) {
name = nc->MakeName(m_Name, m_Properties);
@ -212,7 +212,7 @@ void ConfigItem::Register(void)
/* If this is a non-abstract object we need to figure out
* its real name now - or assign it a temporary name. */
if (!m_Abstract) {
const NameComposer *nc = dynamic_cast<const NameComposer *>(Type::GetByName(m_Type));
shared_ptr<NameComposer> nc = dynamic_pointer_cast<NameComposer>(Type::GetByName(m_Type));
if (nc) {
name = nc->MakeName(m_Name, Dictionary::Ptr());

View File

@ -35,7 +35,7 @@ namespace icinga
*/
class I2_CONFIG_API ConfigItem : public Object {
public:
DECLARE_PTR_TYPEDEFS(ConfigItem);
DECLARE_OBJECT(ConfigItem);
ConfigItem(const String& type, const String& name, bool abstract,
const Expression::Ptr& exprl, const DebugInfo& debuginfo,

View File

@ -37,7 +37,7 @@ namespace icinga
class I2_CONFIG_API ConfigItemBuilder : public Object
{
public:
DECLARE_PTR_TYPEDEFS(ConfigItemBuilder);
DECLARE_OBJECT(ConfigItemBuilder);
ConfigItemBuilder(void);
explicit ConfigItemBuilder(const DebugInfo& debugInfo);

View File

@ -37,7 +37,7 @@ namespace icinga
*/
class I2_CONFIG_API ConfigType : public Object {
public:
DECLARE_PTR_TYPEDEFS(ConfigType);
DECLARE_OBJECT(ConfigType);
ConfigType(const String& name, const DebugInfo& debuginfo);

View File

@ -480,7 +480,7 @@ Value Expression::OpIndexer(const Expression *expr, const Dictionary::Ptr& local
return arr->Get(index);
} else if (value.IsObjectType<Object>()) {
Object::Ptr object = value;
const Type *type = object->GetReflectionType();
Type::Ptr type = object->GetReflectionType();
if (!type)
BOOST_THROW_EXCEPTION(ConfigError("Dot operator applied to object which does not support reflection"));
@ -578,7 +578,7 @@ Value Expression::OpObject(const Expression* expr, const Dictionary::Ptr& locals
String checkName = name;
if (!abstract) {
const NameComposer *nc = dynamic_cast<const NameComposer *>(Type::GetByName(type));
shared_ptr<NameComposer> nc = dynamic_pointer_cast<NameComposer>(Type::GetByName(type));
if (nc)
checkName = nc->MakeName(name, Dictionary::Ptr());

View File

@ -52,7 +52,7 @@ struct DebugHint
class I2_CONFIG_API Expression : public Object
{
public:
DECLARE_PTR_TYPEDEFS(Expression);
DECLARE_OBJECT(Expression);
typedef Value (*OpCallback)(const Expression *, const Dictionary::Ptr&, DebugHint *dhint);

View File

@ -48,7 +48,7 @@ enum TypeValidationResult
class I2_CONFIG_API TypeRuleList : public Object
{
public:
DECLARE_PTR_TYPEDEFS(TypeRuleList);
DECLARE_OBJECT(TypeRuleList);
void SetValidator(const String& validator);
String GetValidator(void) const;

View File

@ -34,7 +34,7 @@ namespace icinga
class CommandDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(CommandDbObject);
DECLARE_OBJECT(CommandDbObject);
CommandDbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2);

View File

@ -37,7 +37,7 @@ namespace icinga
class I2_DB_IDO_API DbConnection : public ObjectImpl<DbConnection>
{
public:
DECLARE_PTR_TYPEDEFS(DbConnection);
DECLARE_OBJECT(DbConnection);
static void StaticInitialize(void);

View File

@ -61,7 +61,7 @@ enum DbObjectType
class I2_DB_IDO_API DbObject : public Object
{
public:
DECLARE_PTR_TYPEDEFS(DbObject);
DECLARE_OBJECT(DbObject);
static void StaticInitialize(void);

View File

@ -39,7 +39,7 @@ class DbObject;
class I2_DB_IDO_API DbType : public Object
{
public:
DECLARE_PTR_TYPEDEFS(DbType);
DECLARE_OBJECT(DbType);
typedef boost::function<shared_ptr<DbObject> (const shared_ptr<DbType>&, const String&, const String&)> ObjectFactory;
typedef std::map<String, DbType::Ptr> TypeMap;

View File

@ -42,7 +42,7 @@ enum DbValueType
struct I2_DB_IDO_API DbValue : public Object
{
public:
DECLARE_PTR_TYPEDEFS(DbValue);
DECLARE_OBJECT(DbValue);
DbValue(DbValueType type, const Value& value);

View File

@ -35,7 +35,7 @@ namespace icinga
class EndpointDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(EndpointDbObject);
DECLARE_OBJECT(EndpointDbObject);
EndpointDbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2);

View File

@ -34,7 +34,7 @@ namespace icinga
class HostDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(HostDbObject);
DECLARE_OBJECT(HostDbObject);
HostDbObject(const DbType::Ptr& type, const String& name1, const String& name2);

View File

@ -35,7 +35,7 @@ namespace icinga
class HostGroupDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(HostGroupDbObject);
DECLARE_OBJECT(HostGroupDbObject);
HostGroupDbObject(const DbType::Ptr& type, const String& name1, const String& name2);

View File

@ -35,7 +35,7 @@ namespace icinga
class ServiceDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(ServiceDbObject);
DECLARE_OBJECT(ServiceDbObject);
ServiceDbObject(const DbType::Ptr& type, const String& name1, const String& name2);

View File

@ -35,7 +35,7 @@ namespace icinga
class ServiceGroupDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(ServiceGroupDbObject);
DECLARE_OBJECT(ServiceGroupDbObject);
ServiceGroupDbObject(const DbType::Ptr& type, const String& name1, const String& name2);

View File

@ -34,7 +34,7 @@ namespace icinga
class TimePeriodDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(TimePeriodDbObject);
DECLARE_OBJECT(TimePeriodDbObject);
TimePeriodDbObject(const DbType::Ptr& type, const String& name1, const String& name2);

View File

@ -34,7 +34,7 @@ namespace icinga
class UserDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(UserDbObject);
DECLARE_OBJECT(UserDbObject);
UserDbObject(const DbType::Ptr& type, const String& name1, const String& name2);

View File

@ -35,7 +35,7 @@ namespace icinga
class UserGroupDbObject : public DbObject
{
public:
DECLARE_PTR_TYPEDEFS(UserGroupDbObject);
DECLARE_OBJECT(UserGroupDbObject);
UserGroupDbObject(const DbType::Ptr& type, const String& name1, const String& name2);

View File

@ -39,8 +39,8 @@ typedef shared_ptr<MYSQL_RES> IdoMysqlResult;
class IdoMysqlConnection : public ObjectImpl<IdoMysqlConnection>
{
public:
DECLARE_PTR_TYPEDEFS(IdoMysqlConnection);
DECLARE_TYPENAME(IdoMysqlConnection);
DECLARE_OBJECT(IdoMysqlConnection);
DECLARE_OBJECTNAME(IdoMysqlConnection);
static Value StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);

View File

@ -39,8 +39,8 @@ typedef shared_ptr<PGresult> IdoPgsqlResult;
class IdoPgsqlConnection : public ObjectImpl<IdoPgsqlConnection>
{
public:
DECLARE_PTR_TYPEDEFS(IdoPgsqlConnection);
DECLARE_TYPENAME(IdoPgsqlConnection);
DECLARE_OBJECT(IdoPgsqlConnection);
DECLARE_OBJECTNAME(IdoPgsqlConnection);
static Value StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);

View File

@ -33,8 +33,8 @@ namespace icinga
class Demo : public ObjectImpl<Demo>
{
public:
DECLARE_PTR_TYPEDEFS(Demo);
DECLARE_TYPENAME(Demo);
DECLARE_OBJECT(Demo);
DECLARE_OBJECTNAME(Demo);
virtual void Start(void);

View File

@ -33,8 +33,8 @@ namespace icinga
class Hello : public ObjectImpl<Hello>
{
public:
DECLARE_PTR_TYPEDEFS(Hello);
DECLARE_TYPENAME(Hello);
DECLARE_OBJECT(Hello);
DECLARE_OBJECTNAME(Hello);
int Main(void);
};

View File

@ -77,8 +77,8 @@ class Dependency;
class I2_ICINGA_API Checkable : public ObjectImpl<Checkable>
{
public:
DECLARE_PTR_TYPEDEFS(Checkable);
DECLARE_TYPENAME(Checkable);
DECLARE_OBJECT(Checkable);
DECLARE_OBJECTNAME(Checkable);
Checkable(void);

View File

@ -34,8 +34,8 @@ namespace icinga
class I2_ICINGA_API CheckCommand : public ObjectImpl<CheckCommand>
{
public:
DECLARE_PTR_TYPEDEFS(CheckCommand);
DECLARE_TYPENAME(CheckCommand);
DECLARE_OBJECT(CheckCommand);
DECLARE_OBJECTNAME(CheckCommand);
virtual void Execute(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
};

View File

@ -34,7 +34,7 @@ namespace icinga
class I2_ICINGA_API CheckResult : public ObjectImpl<CheckResult>
{
public:
DECLARE_PTR_TYPEDEFS(CheckResult);
DECLARE_OBJECT(CheckResult);
};
}

View File

@ -35,7 +35,7 @@ namespace icinga
class I2_ICINGA_API Command : public ObjectImpl<Command>
{
public:
DECLARE_PTR_TYPEDEFS(Command);
DECLARE_OBJECT(Command);
//virtual Dictionary::Ptr Execute(const Object::Ptr& context) = 0;

View File

@ -34,7 +34,7 @@ namespace icinga
class I2_ICINGA_API Comment : public ObjectImpl<Comment>
{
public:
DECLARE_PTR_TYPEDEFS(Comment);
DECLARE_OBJECT(Comment);
bool IsExpired(void) const;
};

View File

@ -57,7 +57,7 @@ enum ModifiedAttributeType
class I2_ICINGA_API CustomVarObject : public ObjectImpl<CustomVarObject>
{
public:
DECLARE_PTR_TYPEDEFS(CustomVarObject);
DECLARE_OBJECT(CustomVarObject);
static boost::signals2::signal<void (const CustomVarObject::Ptr&, const Dictionary::Ptr& vars, const MessageOrigin&)> OnVarsChanged;

View File

@ -37,8 +37,8 @@ class ApplyRule;
class I2_ICINGA_API Dependency : public ObjectImpl<Dependency>
{
public:
DECLARE_PTR_TYPEDEFS(Dependency);
DECLARE_TYPENAME(Dependency);
DECLARE_OBJECT(Dependency);
DECLARE_OBJECTNAME(Dependency);
shared_ptr<Checkable> GetParent(void) const;
shared_ptr<Checkable> GetChild(void) const;

View File

@ -34,7 +34,7 @@ namespace icinga
class I2_ICINGA_API Downtime : public ObjectImpl<Downtime>
{
public:
DECLARE_PTR_TYPEDEFS(Downtime);
DECLARE_OBJECT(Downtime);
bool IsActive(void) const;
bool IsTriggered(void) const;

View File

@ -34,8 +34,8 @@ namespace icinga
class I2_ICINGA_API EventCommand : public ObjectImpl<EventCommand>
{
public:
DECLARE_PTR_TYPEDEFS(EventCommand);
DECLARE_TYPENAME(EventCommand);
DECLARE_OBJECT(EventCommand);
DECLARE_OBJECTNAME(EventCommand);
virtual void Execute(const Checkable::Ptr& checkable);
};

View File

@ -38,8 +38,8 @@ class Service;
class I2_ICINGA_API Host : public ObjectImpl<Host>, public MacroResolver
{
public:
DECLARE_PTR_TYPEDEFS(Host);
DECLARE_TYPENAME(Host);
DECLARE_OBJECT(Host);
DECLARE_OBJECTNAME(Host);
shared_ptr<Service> GetServiceByShortName(const Value& name);

Some files were not shown because too many files have changed in this diff Show More