mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-21 04:34:43 +02:00
parent
84b873fb4e
commit
b1ddc71925
@ -39,7 +39,7 @@ namespace icinga
|
|||||||
/**
|
/**
|
||||||
* @ingroup cluster
|
* @ingroup cluster
|
||||||
*/
|
*/
|
||||||
class ClusterListener : public ReflectionObjectImpl<ClusterListener>
|
class ClusterListener : public ObjectImpl<ClusterListener>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(ClusterListener);
|
DECLARE_PTR_TYPEDEFS(ClusterListener);
|
||||||
|
@ -35,7 +35,7 @@ class EndpointManager;
|
|||||||
*
|
*
|
||||||
* @ingroup cluster
|
* @ingroup cluster
|
||||||
*/
|
*/
|
||||||
class Endpoint : public ReflectionObjectImpl<Endpoint>
|
class Endpoint : public ObjectImpl<Endpoint>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Endpoint);
|
DECLARE_PTR_TYPEDEFS(Endpoint);
|
||||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup compat
|
* @ingroup compat
|
||||||
*/
|
*/
|
||||||
class CheckResultReader : public ReflectionObjectImpl<CheckResultReader>
|
class CheckResultReader : public ObjectImpl<CheckResultReader>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(CheckResultReader);
|
DECLARE_PTR_TYPEDEFS(CheckResultReader);
|
||||||
|
@ -33,7 +33,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup compat
|
* @ingroup compat
|
||||||
*/
|
*/
|
||||||
class CompatLogger : public ReflectionObjectImpl<CompatLogger>
|
class CompatLogger : public ObjectImpl<CompatLogger>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(CompatLogger);
|
DECLARE_PTR_TYPEDEFS(CompatLogger);
|
||||||
|
@ -33,7 +33,7 @@ namespace icinga
|
|||||||
/**
|
/**
|
||||||
* @ingroup compat
|
* @ingroup compat
|
||||||
*/
|
*/
|
||||||
class ExternalCommandListener : public ReflectionObjectImpl<ExternalCommandListener>
|
class ExternalCommandListener : public ObjectImpl<ExternalCommandListener>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(ExternalCommandListener);
|
DECLARE_PTR_TYPEDEFS(ExternalCommandListener);
|
||||||
|
@ -37,7 +37,7 @@ namespace icinga
|
|||||||
/**
|
/**
|
||||||
* @ingroup compat
|
* @ingroup compat
|
||||||
*/
|
*/
|
||||||
class StatusDataWriter : public ReflectionObjectImpl<StatusDataWriter>
|
class StatusDataWriter : public ObjectImpl<StatusDataWriter>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(StatusDataWriter);
|
DECLARE_PTR_TYPEDEFS(StatusDataWriter);
|
||||||
|
@ -34,7 +34,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup ido
|
* @ingroup ido
|
||||||
*/
|
*/
|
||||||
class IdoMysqlConnection : public ReflectionObjectImpl<IdoMysqlConnection>
|
class IdoMysqlConnection : public ObjectImpl<IdoMysqlConnection>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(IdoMysqlConnection);
|
DECLARE_PTR_TYPEDEFS(IdoMysqlConnection);
|
||||||
|
@ -34,7 +34,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup ido
|
* @ingroup ido
|
||||||
*/
|
*/
|
||||||
class IdoPgsqlConnection : public ReflectionObjectImpl<IdoPgsqlConnection>
|
class IdoPgsqlConnection : public ObjectImpl<IdoPgsqlConnection>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(IdoPgsqlConnection);
|
DECLARE_PTR_TYPEDEFS(IdoPgsqlConnection);
|
||||||
|
@ -29,7 +29,7 @@ namespace icinga
|
|||||||
/**
|
/**
|
||||||
* @ingroup demo
|
* @ingroup demo
|
||||||
*/
|
*/
|
||||||
class Demo : public ReflectionObjectImpl<Demo>
|
class Demo : public ObjectImpl<Demo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Demo);
|
DECLARE_PTR_TYPEDEFS(Demo);
|
||||||
|
@ -33,7 +33,7 @@ namespace livestatus
|
|||||||
/**
|
/**
|
||||||
* @ingroup livestatus
|
* @ingroup livestatus
|
||||||
*/
|
*/
|
||||||
class LivestatusListener : public ReflectionObjectImpl<LivestatusListener>
|
class LivestatusListener : public ObjectImpl<LivestatusListener>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(LivestatusListener);
|
DECLARE_PTR_TYPEDEFS(LivestatusListener);
|
||||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||||||
/**
|
/**
|
||||||
* @ingroup notification
|
* @ingroup notification
|
||||||
*/
|
*/
|
||||||
class NotificationComponent : public ReflectionObjectImpl<NotificationComponent>
|
class NotificationComponent : public ObjectImpl<NotificationComponent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(NotificationComponent);
|
DECLARE_PTR_TYPEDEFS(NotificationComponent);
|
||||||
|
@ -35,7 +35,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup perfdata
|
* @ingroup perfdata
|
||||||
*/
|
*/
|
||||||
class GraphiteWriter : public ReflectionObjectImpl<GraphiteWriter>
|
class GraphiteWriter : public ObjectImpl<GraphiteWriter>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(GraphiteWriter);
|
DECLARE_PTR_TYPEDEFS(GraphiteWriter);
|
||||||
|
@ -34,7 +34,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class PerfdataWriter : public ReflectionObjectImpl<PerfdataWriter>
|
class PerfdataWriter : public ObjectImpl<PerfdataWriter>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(PerfdataWriter);
|
DECLARE_PTR_TYPEDEFS(PerfdataWriter);
|
||||||
|
@ -30,12 +30,12 @@ add_library(base SHARED
|
|||||||
dynamicobject.th dynamictype.cpp exception.cpp fifo.cpp filelogger.cpp
|
dynamicobject.th dynamictype.cpp exception.cpp fifo.cpp filelogger.cpp
|
||||||
filelogger.th logger.cpp logger.th netstring.cpp networkstream.cpp object.cpp
|
filelogger.th logger.cpp logger.th netstring.cpp networkstream.cpp object.cpp
|
||||||
objectlock.cpp process.cpp process-unix.cpp process-windows.cpp qstring.cpp
|
objectlock.cpp process.cpp process-unix.cpp process-windows.cpp qstring.cpp
|
||||||
reflectionobject.cpp ringbuffer.cpp script.cpp script.th scriptfunction.cpp
|
ringbuffer.cpp script.cpp script.th scriptfunction.cpp scriptfunctionwrapper.cpp
|
||||||
scriptfunctionwrapper.cpp scriptinterpreter.cpp scriptlanguage.cpp
|
scriptinterpreter.cpp scriptlanguage.cpp scriptvariable.cpp serializer.cpp
|
||||||
scriptvariable.cpp socket.cpp stacktrace.cpp stdiostream.cpp stream_bio.cpp
|
socket.cpp stacktrace.cpp stdiostream.cpp stream_bio.cpp stream.cpp
|
||||||
stream.cpp streamlogger.cpp streamlogger.th sysloglogger.cpp sysloglogger.th
|
streamlogger.cpp streamlogger.th sysloglogger.cpp sysloglogger.th tcpsocket.cpp
|
||||||
tcpsocket.cpp threadpool.cpp timer.cpp tlsstream.cpp tlsutility.cpp
|
threadpool.cpp timer.cpp tlsstream.cpp tlsutility.cpp unixsocket.cpp
|
||||||
unixsocket.cpp utility.cpp value.cpp workqueue.cpp zlibstream.cpp
|
utility.cpp value.cpp workqueue.cpp zlibstream.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(base ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} cJSON mmatch)
|
target_link_libraries(base ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} cJSON mmatch)
|
||||||
|
@ -34,7 +34,7 @@ class Component;
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API Application : public ReflectionObjectImpl<Application> {
|
class I2_BASE_API Application : public ObjectImpl<Application> {
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Application);
|
DECLARE_PTR_TYPEDEFS(Application);
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API ConsoleLogger : public ReflectionObjectImpl<ConsoleLogger>
|
class I2_BASE_API ConsoleLogger : public ObjectImpl<ConsoleLogger>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(ConsoleLogger);
|
DECLARE_PTR_TYPEDEFS(ConsoleLogger);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "base/dynamicobject.h"
|
#include "base/dynamicobject.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
|
#include "base/serializer.h"
|
||||||
#include "base/netstring.h"
|
#include "base/netstring.h"
|
||||||
#include "base/registry.h"
|
#include "base/registry.h"
|
||||||
#include "base/stdiostream.h"
|
#include "base/stdiostream.h"
|
||||||
@ -220,7 +221,7 @@ void DynamicObject::DumpObjects(const String& filename, int attributeTypes)
|
|||||||
persistentObject->Set("type", type->GetName());
|
persistentObject->Set("type", type->GetName());
|
||||||
persistentObject->Set("name", object->GetName());
|
persistentObject->Set("name", object->GetName());
|
||||||
|
|
||||||
Dictionary::Ptr update = object->Serialize(attributeTypes);
|
Dictionary::Ptr update = Serializer::Serialize(object, attributeTypes);
|
||||||
|
|
||||||
if (!update)
|
if (!update)
|
||||||
continue;
|
continue;
|
||||||
@ -279,7 +280,7 @@ void DynamicObject::RestoreObjects(const String& filename, int attributeTypes)
|
|||||||
if (object) {
|
if (object) {
|
||||||
ASSERT(!object->IsActive());
|
ASSERT(!object->IsActive());
|
||||||
Log(LogDebug, "base", "Restoring object '" + name + "' of type '" + type + "'.");
|
Log(LogDebug, "base", "Restoring object '" + name + "' of type '" + type + "'.");
|
||||||
object->Deserialize(update, attributeTypes);
|
Serializer::Deserialize(object, update, attributeTypes);
|
||||||
object->OnStateLoaded();
|
object->OnStateLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,17 +34,6 @@ namespace icinga
|
|||||||
|
|
||||||
class DynamicType;
|
class DynamicType;
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of an attribute for a DynamicObject.
|
|
||||||
*
|
|
||||||
* @ingroup base
|
|
||||||
*/
|
|
||||||
enum AttributeType
|
|
||||||
{
|
|
||||||
Attribute_State = FAState,
|
|
||||||
Attribute_Config = FAConfig
|
|
||||||
};
|
|
||||||
|
|
||||||
enum DomainPriv
|
enum DomainPriv
|
||||||
{
|
{
|
||||||
DomainPrivRead = (1<<0),
|
DomainPrivRead = (1<<0),
|
||||||
@ -58,7 +47,7 @@ enum DomainPriv
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API DynamicObject : public ReflectionObjectImpl<DynamicObject>
|
class I2_BASE_API DynamicObject : public ObjectImpl<DynamicObject>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(DynamicObject);
|
DECLARE_PTR_TYPEDEFS(DynamicObject);
|
||||||
@ -105,8 +94,8 @@ public:
|
|||||||
return dynamic_pointer_cast<T>(object);
|
return dynamic_pointer_cast<T>(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DumpObjects(const String& filename, int attributeTypes = Attribute_State);
|
static void DumpObjects(const String& filename, int attributeTypes = FAState);
|
||||||
static void RestoreObjects(const String& filename, int attributeTypes = Attribute_State);
|
static void RestoreObjects(const String& filename, int attributeTypes = FAState);
|
||||||
static void StopObjects(void);
|
static void StopObjects(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
|
#include "base/serializer.h"
|
||||||
#include "base/debug.h"
|
#include "base/debug.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUp
|
|||||||
|
|
||||||
DynamicObject::Ptr object = factory();
|
DynamicObject::Ptr object = factory();
|
||||||
|
|
||||||
object->Deserialize(serializedUpdate, Attribute_Config);
|
Serializer::Deserialize(object, serializedUpdate, FAConfig);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API FileLogger : public ReflectionObjectImpl<FileLogger>
|
class I2_BASE_API FileLogger : public ObjectImpl<FileLogger>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(FileLogger);
|
DECLARE_PTR_TYPEDEFS(FileLogger);
|
||||||
|
@ -46,7 +46,7 @@ struct LogEntry {
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API Logger : public ReflectionObjectImpl<Logger>
|
class I2_BASE_API Logger : public ObjectImpl<Logger>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Logger);
|
DECLARE_PTR_TYPEDEFS(Logger);
|
||||||
|
@ -69,3 +69,18 @@ Object::SharedPtrHolder::operator Value(void) const
|
|||||||
{
|
{
|
||||||
return m_Object;
|
return m_Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Type *Object::GetReflectionType(void) const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetField(int id, const Value& value)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Invalid field ID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Value Object::GetField(int id) const
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Invalid field ID.");
|
||||||
|
}
|
||||||
|
@ -48,6 +48,8 @@ class Value;
|
|||||||
typedef shared_ptr<klass> Ptr; \
|
typedef shared_ptr<klass> Ptr; \
|
||||||
typedef weak_ptr<klass> WeakPtr
|
typedef weak_ptr<klass> WeakPtr
|
||||||
|
|
||||||
|
class Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all heap-allocated objects. At least one of its methods
|
* Base class for all heap-allocated objects. At least one of its methods
|
||||||
* has to be virtual for RTTI to work.
|
* has to be virtual for RTTI to work.
|
||||||
@ -62,6 +64,10 @@ public:
|
|||||||
Object(void);
|
Object(void);
|
||||||
virtual ~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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds a shared pointer and provides support for implicit upcasts.
|
* Holds a shared pointer and provides support for implicit upcasts.
|
||||||
*
|
*
|
||||||
@ -175,6 +181,16 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class TypeImpl
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class ObjectImpl
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* OBJECT_H */
|
#endif /* OBJECT_H */
|
||||||
|
@ -33,7 +33,7 @@ class ScriptInterpreter;
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API Script : public ReflectionObjectImpl<Script>
|
class I2_BASE_API Script : public ObjectImpl<Script>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Script);
|
DECLARE_PTR_TYPEDEFS(Script);
|
||||||
|
59
lib/base/serializer.cpp
Normal file
59
lib/base/serializer.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the Free Software Foundation *
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "base/serializer.h"
|
||||||
|
#include "base/type.h"
|
||||||
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
|
Dictionary::Ptr Serializer::Serialize(const Object::Ptr& object, int attributeTypes)
|
||||||
|
{
|
||||||
|
const Type *type = object->GetReflectionType();
|
||||||
|
|
||||||
|
Dictionary::Ptr update = boost::make_shared<Dictionary>();
|
||||||
|
|
||||||
|
for (int i = 0; i < type->GetFieldCount(); i++) {
|
||||||
|
Field field = type->GetFieldInfo(i);
|
||||||
|
|
||||||
|
if ((field.Attributes & attributeTypes) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
update->Set(field.Name, object->GetField(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serializer::Deserialize(const Object::Ptr& object, const Dictionary::Ptr& update, int attributeTypes)
|
||||||
|
{
|
||||||
|
const Type *type = object->GetReflectionType();
|
||||||
|
|
||||||
|
for (int i = 0; i < type->GetFieldCount(); i++) {
|
||||||
|
Field field = type->GetFieldInfo(i);
|
||||||
|
|
||||||
|
if ((field.Attributes & attributeTypes) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!update->Contains(field.Name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
object->SetField(i, update->Get(field.Name));
|
||||||
|
}
|
||||||
|
}
|
@ -17,42 +17,30 @@
|
|||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "base/reflectionobject.h"
|
#ifndef SERIALIZER_H
|
||||||
#include <boost/smart_ptr/make_shared.hpp>
|
#define SERIALIZER_H
|
||||||
|
|
||||||
using namespace icinga;
|
#include "base/i2-base.h"
|
||||||
|
#include "base/dictionary.h"
|
||||||
|
|
||||||
Dictionary::Ptr ReflectionObject::Serialize(int attributeTypes) const
|
namespace icinga
|
||||||
{
|
{
|
||||||
const ReflectionType *type = GetReflectionType();
|
|
||||||
|
|
||||||
Dictionary::Ptr update = boost::make_shared<Dictionary>();
|
/**
|
||||||
|
* Serializer utilities.
|
||||||
|
*
|
||||||
|
* @ingroup base
|
||||||
|
*/
|
||||||
|
class I2_BASE_API Serializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Dictionary::Ptr Serialize(const Object::Ptr& object, int attributeTypes);
|
||||||
|
static void Deserialize(const Object::Ptr& object, const Dictionary::Ptr& update, int attributeTypes);
|
||||||
|
|
||||||
for (int i = 0; i < type->GetFieldCount(); i++) {
|
private:
|
||||||
ReflectionField field = type->GetFieldInfo(i);
|
Serializer(void);
|
||||||
|
};
|
||||||
|
|
||||||
if ((field.Attributes & attributeTypes) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
update->Set(field.Name, GetField(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return update;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReflectionObject::Deserialize(const Dictionary::Ptr& update, int attributeTypes)
|
#endif /* SERIALIZER_H */
|
||||||
{
|
|
||||||
const ReflectionType *type = GetReflectionType();
|
|
||||||
|
|
||||||
for (int i = 0; i < type->GetFieldCount(); i++) {
|
|
||||||
ReflectionField field = type->GetFieldInfo(i);
|
|
||||||
|
|
||||||
if ((field.Attributes & attributeTypes) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!update->Contains(field.Name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
SetField(i, update->Get(field.Name));
|
|
||||||
}
|
|
||||||
}
|
|
@ -33,7 +33,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API StreamLogger : public ReflectionObjectImpl<StreamLogger>
|
class I2_BASE_API StreamLogger : public ObjectImpl<StreamLogger>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(StreamLogger);
|
DECLARE_PTR_TYPEDEFS(StreamLogger);
|
||||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API SyslogLogger : public ReflectionObjectImpl<SyslogLogger>
|
class I2_BASE_API SyslogLogger : public ObjectImpl<SyslogLogger>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(SyslogLogger);
|
DECLARE_PTR_TYPEDEFS(SyslogLogger);
|
||||||
|
@ -17,70 +17,40 @@
|
|||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef REFLECTIONOBJECT_H
|
#ifndef TYPE_H
|
||||||
#define REFLECTIONOBJECT_H
|
#define TYPE_H
|
||||||
|
|
||||||
#include "base/object.h"
|
#include "base/i2-base.h"
|
||||||
#include "base/dictionary.h"
|
#include "base/qstring.h"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
enum ReflectionFieldAttribute
|
enum FieldAttribute
|
||||||
{
|
{
|
||||||
FAConfig = 1,
|
FAConfig = 1,
|
||||||
FAState = 2
|
FAState = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ReflectionField
|
struct Field
|
||||||
{
|
{
|
||||||
int ID;
|
int ID;
|
||||||
String Name;
|
String Name;
|
||||||
int Attributes;
|
int Attributes;
|
||||||
|
|
||||||
ReflectionField(int id, const String& name, int attributes)
|
Field(int id, const String& name, int attributes)
|
||||||
: ID(id), Name(name), Attributes(attributes)
|
: ID(id), Name(name), Attributes(attributes)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum InvokationType
|
class I2_BASE_API Type
|
||||||
{
|
|
||||||
ITGet,
|
|
||||||
ITSet
|
|
||||||
};
|
|
||||||
|
|
||||||
class I2_BASE_API ReflectionType
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual int GetFieldId(const String& name) const = 0;
|
virtual int GetFieldId(const String& name) const = 0;
|
||||||
virtual ReflectionField GetFieldInfo(int id) const = 0;
|
virtual Field GetFieldInfo(int id) const = 0;
|
||||||
virtual int GetFieldCount(void) const = 0;
|
virtual int GetFieldCount(void) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class I2_BASE_API ReflectionObject : public Object
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DECLARE_PTR_TYPEDEFS(ReflectionObject);
|
|
||||||
|
|
||||||
virtual const ReflectionType *GetReflectionType(void) const = 0;
|
|
||||||
virtual void SetField(int id, const Value& value) = 0;
|
|
||||||
virtual Value GetField(int id) const = 0;
|
|
||||||
|
|
||||||
Dictionary::Ptr Serialize(int attributeTypes) const;
|
|
||||||
void Deserialize(const Dictionary::Ptr& update, int attributeTypes);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class ReflectionTypeImpl
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class ReflectionObjectImpl
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* REFLECTIONOBJECT_H */
|
#endif /* TYPE_H */
|
@ -34,7 +34,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup db_ido
|
* @ingroup db_ido
|
||||||
*/
|
*/
|
||||||
class I2_DB_IDO_API DbConnection : public ReflectionObjectImpl<DbConnection>
|
class I2_DB_IDO_API DbConnection : public ObjectImpl<DbConnection>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(DbConnection);
|
DECLARE_PTR_TYPEDEFS(DbConnection);
|
||||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API CheckCommand : public ReflectionObjectImpl<CheckCommand>
|
class I2_ICINGA_API CheckCommand : public ObjectImpl<CheckCommand>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(CheckCommand);
|
DECLARE_PTR_TYPEDEFS(CheckCommand);
|
||||||
|
@ -35,7 +35,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API Command : public ReflectionObjectImpl<Command>, public MacroResolver
|
class I2_ICINGA_API Command : public ObjectImpl<Command>, public MacroResolver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Command);
|
DECLARE_PTR_TYPEDEFS(Command);
|
||||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API Domain : public ReflectionObjectImpl<Domain>
|
class I2_ICINGA_API Domain : public ObjectImpl<Domain>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Domain);
|
DECLARE_PTR_TYPEDEFS(Domain);
|
||||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API EventCommand : public ReflectionObjectImpl<EventCommand>
|
class I2_ICINGA_API EventCommand : public ObjectImpl<EventCommand>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(EventCommand);
|
DECLARE_PTR_TYPEDEFS(EventCommand);
|
||||||
|
@ -48,7 +48,7 @@ enum HostState
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API Host : public ReflectionObjectImpl<Host>, public MacroResolver
|
class I2_ICINGA_API Host : public ObjectImpl<Host>, public MacroResolver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Host);
|
DECLARE_PTR_TYPEDEFS(Host);
|
||||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API HostGroup : public ReflectionObjectImpl<HostGroup>
|
class I2_ICINGA_API HostGroup : public ObjectImpl<HostGroup>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(HostGroup);
|
DECLARE_PTR_TYPEDEFS(HostGroup);
|
||||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API IcingaApplication : public ReflectionObjectImpl<IcingaApplication>, public MacroResolver
|
class I2_ICINGA_API IcingaApplication : public ObjectImpl<IcingaApplication>, public MacroResolver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(IcingaApplication);
|
DECLARE_PTR_TYPEDEFS(IcingaApplication);
|
||||||
|
@ -56,7 +56,7 @@ class NotificationCommand;
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API Notification : public ReflectionObjectImpl<Notification>, public MacroResolver
|
class I2_ICINGA_API Notification : public ObjectImpl<Notification>, public MacroResolver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Notification);
|
DECLARE_PTR_TYPEDEFS(Notification);
|
||||||
|
@ -33,7 +33,7 @@ class Notification;
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API NotificationCommand : public ReflectionObjectImpl<NotificationCommand>
|
class I2_ICINGA_API NotificationCommand : public ObjectImpl<NotificationCommand>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(NotificationCommand);
|
DECLARE_PTR_TYPEDEFS(NotificationCommand);
|
||||||
|
@ -118,7 +118,7 @@ class EventCommand;
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API Service : public ReflectionObjectImpl<Service>, public MacroResolver
|
class I2_ICINGA_API Service : public ObjectImpl<Service>, public MacroResolver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Service);
|
DECLARE_PTR_TYPEDEFS(Service);
|
||||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API ServiceGroup : public ReflectionObjectImpl<ServiceGroup>
|
class I2_ICINGA_API ServiceGroup : public ObjectImpl<ServiceGroup>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(ServiceGroup);
|
DECLARE_PTR_TYPEDEFS(ServiceGroup);
|
||||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API TimePeriod : public ReflectionObjectImpl<TimePeriod>
|
class I2_ICINGA_API TimePeriod : public ObjectImpl<TimePeriod>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(TimePeriod);
|
DECLARE_PTR_TYPEDEFS(TimePeriod);
|
||||||
|
@ -34,7 +34,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API User : public ReflectionObjectImpl<User>, public MacroResolver
|
class I2_ICINGA_API User : public ObjectImpl<User>, public MacroResolver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(User);
|
DECLARE_PTR_TYPEDEFS(User);
|
||||||
|
@ -32,7 +32,7 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API UserGroup : public ReflectionObjectImpl<UserGroup>
|
class I2_ICINGA_API UserGroup : public ObjectImpl<UserGroup>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(UserGroup);
|
DECLARE_PTR_TYPEDEFS(UserGroup);
|
||||||
|
@ -85,10 +85,10 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
|||||||
if (klass.Name.find_first_of(':') == std::string::npos)
|
if (klass.Name.find_first_of(':') == std::string::npos)
|
||||||
std::cout << "class " << klass.Name << ";" << std::endl << std::endl;
|
std::cout << "class " << klass.Name << ";" << std::endl << std::endl;
|
||||||
|
|
||||||
/* ReflectionTypeImpl */
|
/* TypeImpl */
|
||||||
std::cout << "template<>" << std::endl
|
std::cout << "template<>" << std::endl
|
||||||
<< "class ReflectionTypeImpl<" << klass.Name << ">"
|
<< "class TypeImpl<" << klass.Name << ">"
|
||||||
<< " : public ReflectionType, public Singleton<ReflectionTypeImpl<" << klass.Name << "> >" << std::endl
|
<< " : public Type, public Singleton<TypeImpl<" << klass.Name << "> >" << std::endl
|
||||||
<< "{" << std::endl
|
<< "{" << std::endl
|
||||||
<< "public:" << std::endl;
|
<< "public:" << std::endl;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
|||||||
<< "\t\t" << "int offset = ";
|
<< "\t\t" << "int offset = ";
|
||||||
|
|
||||||
if (!klass.Parent.empty())
|
if (!klass.Parent.empty())
|
||||||
std::cout << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
|
std::cout << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
|
||||||
else
|
else
|
||||||
std::cout << "0";
|
std::cout << "0";
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
|||||||
<< "\t\t" << "return ";
|
<< "\t\t" << "return ";
|
||||||
|
|
||||||
if (!klass.Parent.empty())
|
if (!klass.Parent.empty())
|
||||||
std::cout << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldId(name)";
|
std::cout << "TypeImpl<" << klass.Parent << ">::StaticGetFieldId(name)";
|
||||||
else
|
else
|
||||||
std::cout << "-1";
|
std::cout << "-1";
|
||||||
|
|
||||||
@ -129,18 +129,18 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
|||||||
<< "\t" << "}" << std::endl << std::endl;
|
<< "\t" << "}" << std::endl << std::endl;
|
||||||
|
|
||||||
/* GetFieldInfo */
|
/* GetFieldInfo */
|
||||||
std::cout << "\t" << "virtual ReflectionField GetFieldInfo(int id) const" << std::endl
|
std::cout << "\t" << "virtual Field GetFieldInfo(int id) const" << std::endl
|
||||||
<< "\t" << "{" << std::endl
|
<< "\t" << "{" << std::endl
|
||||||
<< "\t\t" << "return StaticGetFieldInfo(id);" << std::endl
|
<< "\t\t" << "return StaticGetFieldInfo(id);" << std::endl
|
||||||
<< "\t" << "}" << std::endl << std::endl;
|
<< "\t" << "}" << std::endl << std::endl;
|
||||||
|
|
||||||
/* StaticGetFieldInfo */
|
/* StaticGetFieldInfo */
|
||||||
std::cout << "\t" << "static ReflectionField StaticGetFieldInfo(int id)" << std::endl
|
std::cout << "\t" << "static Field StaticGetFieldInfo(int id)" << std::endl
|
||||||
<< "\t" << "{" << std::endl;
|
<< "\t" << "{" << std::endl;
|
||||||
|
|
||||||
if (!klass.Parent.empty())
|
if (!klass.Parent.empty())
|
||||||
std::cout << "\t\t" << "int real_id = id - " << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount();" << std::endl
|
std::cout << "\t\t" << "int real_id = id - " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount();" << std::endl
|
||||||
<< "\t\t" << "if (real_id < 0) { return " << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldInfo(id); }" << std::endl;
|
<< "\t\t" << "if (real_id < 0) { return " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldInfo(id); }" << std::endl;
|
||||||
|
|
||||||
std::cout << "\t\t" << "switch (";
|
std::cout << "\t\t" << "switch (";
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
|||||||
num = 0;
|
num = 0;
|
||||||
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
||||||
std::cout << "\t\t\t" << "case " << num << ":" << std::endl
|
std::cout << "\t\t\t" << "case " << num << ":" << std::endl
|
||||||
<< "\t\t\t\t" << "return ReflectionField(" << num << ", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
|
<< "\t\t\t\t" << "return Field(" << num << ", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,31 +176,31 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
|||||||
<< "\t\t" << "return " << klass.Fields.size();
|
<< "\t\t" << "return " << klass.Fields.size();
|
||||||
|
|
||||||
if (!klass.Parent.empty())
|
if (!klass.Parent.empty())
|
||||||
std::cout << " + " << "ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
|
std::cout << " + " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
|
||||||
|
|
||||||
std::cout << ";" << std::endl
|
std::cout << ";" << std::endl
|
||||||
<< "\t" << "}" << std::endl << std::endl;
|
<< "\t" << "}" << std::endl << std::endl;
|
||||||
|
|
||||||
std::cout << "};" << std::endl << std::endl;
|
std::cout << "};" << std::endl << std::endl;
|
||||||
|
|
||||||
/* ReflectionObjectImpl */
|
/* ObjectImpl */
|
||||||
std::cout << "template<>" << std::endl
|
std::cout << "template<>" << std::endl
|
||||||
<< "class ReflectionObjectImpl<" << klass.Name << ">"
|
<< "class ObjectImpl<" << klass.Name << ">"
|
||||||
<< " : public " << (klass.Parent.empty() ? "ReflectionObject" : klass.Parent) << std::endl
|
<< " : public " << (klass.Parent.empty() ? "Object" : klass.Parent) << std::endl
|
||||||
<< "{" << std::endl
|
<< "{" << std::endl
|
||||||
<< "public:" << std::endl
|
<< "public:" << std::endl
|
||||||
<< "\t" << "DECLARE_PTR_TYPEDEFS(ReflectionObjectImpl<" << klass.Name << ">);" << std::endl << std::endl;
|
<< "\t" << "DECLARE_PTR_TYPEDEFS(ObjectImpl<" << klass.Name << ">);" << std::endl << std::endl;
|
||||||
|
|
||||||
/* GetType */
|
/* GetReflectionType */
|
||||||
std::cout << "\t" << "virtual const ReflectionType *GetReflectionType(void) const" << std::endl
|
std::cout << "\t" << "virtual const Type *GetReflectionType(void) const" << std::endl
|
||||||
<< "\t" << "{" << std::endl
|
<< "\t" << "{" << std::endl
|
||||||
<< "\t\t" << "return ReflectionTypeImpl<" << klass.Name << ">::GetInstance();" << std::endl
|
<< "\t\t" << "return TypeImpl<" << klass.Name << ">::GetInstance();" << std::endl
|
||||||
<< "\t" << "}" << std::endl << std::endl;
|
<< "\t" << "}" << std::endl << std::endl;
|
||||||
|
|
||||||
if (!klass.Fields.empty()) {
|
if (!klass.Fields.empty()) {
|
||||||
/* constructor */
|
/* constructor */
|
||||||
std::cout << "public:" << std::endl
|
std::cout << "public:" << std::endl
|
||||||
<< "\t" << "ReflectionObjectImpl<" << klass.Name << ">(void)" << std::endl
|
<< "\t" << "ObjectImpl<" << klass.Name << ">(void)" << std::endl
|
||||||
<< "\t" << "{" << std::endl;
|
<< "\t" << "{" << std::endl;
|
||||||
|
|
||||||
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
||||||
@ -215,7 +215,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
|||||||
<< "\t" << "{" << std::endl;
|
<< "\t" << "{" << std::endl;
|
||||||
|
|
||||||
if (!klass.Parent.empty())
|
if (!klass.Parent.empty())
|
||||||
std::cout << "\t\t" << "int real_id = id - ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
|
std::cout << "\t\t" << "int real_id = id - TypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
|
||||||
<< "\t\t" << "if (real_id < 0) { " << klass.Parent << "::SetField(id, value); return; }" << std::endl;
|
<< "\t\t" << "if (real_id < 0) { " << klass.Parent << "::SetField(id, value); return; }" << std::endl;
|
||||||
|
|
||||||
std::cout << "\t\t" << "switch (";
|
std::cout << "\t\t" << "switch (";
|
||||||
@ -257,7 +257,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
|||||||
<< "\t" << "{" << std::endl;
|
<< "\t" << "{" << std::endl;
|
||||||
|
|
||||||
if (!klass.Parent.empty())
|
if (!klass.Parent.empty())
|
||||||
std::cout << "\t\t" << "int real_id = id - ReflectionTypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
|
std::cout << "\t\t" << "int real_id = id - TypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
|
||||||
<< "\t\t" << "if (real_id < 0) { return " << klass.Parent << "::GetField(id); }" << std::endl;
|
<< "\t\t" << "if (real_id < 0) { return " << klass.Parent << "::GetField(id); }" << std::endl;
|
||||||
|
|
||||||
std::cout << "\t\t" << "switch (";
|
std::cout << "\t\t" << "switch (";
|
||||||
@ -368,7 +368,8 @@ void ClassCompiler::CompileStream(const std::string& path, std::istream *stream)
|
|||||||
{
|
{
|
||||||
stream->exceptions(std::istream::badbit);
|
stream->exceptions(std::istream::badbit);
|
||||||
|
|
||||||
std::cout << "#include \"base/reflectionobject.h\"" << std::endl
|
std::cout << "#include \"base/object.h\"" << std::endl
|
||||||
|
<< "#include \"base/type.h\"" << std::endl
|
||||||
<< "#include \"base/singleton.h\"" << std::endl
|
<< "#include \"base/singleton.h\"" << std::endl
|
||||||
<< "#include \"base/debug.h\"" << std::endl
|
<< "#include \"base/debug.h\"" << std::endl
|
||||||
<< "#include \"base/value.h\"" << std::endl
|
<< "#include \"base/value.h\"" << std::endl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user