22#include <kiwano/macros.h>
23#include <kiwano/core/Common.h>
24#include <kiwano/core/Exception.h>
25#include <kiwano/core/Serializable.h>
26#include <kiwano/base/RefObject.h>
27#include <kiwano/base/RefPtr.h>
55 return this->code == 0;
60 static const int fail = -1;
86 virtual char const* what()
const override;
97typedef Function<void(ObjectBase*,
const ObjectStatus&)> ObjectPolicyFunc;
161 void* GetUserData()
const;
166 void SetUserData(
void* data);
180 uint64_t GetObjectID()
const;
184 void DoSerialize(
Serializer* serializer)
const override;
188 void DoDeserialize(
Deserializer* deserializer)
override;
192 virtual bool IsValid()
const;
217 static bool IsTracingLeaks();
221 static void StartTracingLeaks();
225 static void StopTracingLeaks();
229 static void DumpTracingObjects();
233 static Vector<ObjectBase*>& GetTracingObjects();
236 static void AddObjectToTracingList(
ObjectBase*);
238 static void RemoveObjectFromTracingList(
ObjectBase*);
248 Set<RefPtr<ObjectBase>>* holdings_;
260 return name_ ? (*name_ == name) : name.empty();
Definition: Function.h:228
基础对象
Definition: ObjectBase.h:138
StringView GetName() const
获取对象名
Definition: ObjectBase.h:251
uint64_t GetObjectID() const
获取对象ID
Definition: ObjectBase.h:263
bool IsName(StringView name) const
判断对象的名称是否相同
Definition: ObjectBase.h:258
对象失败状态异常
Definition: ObjectBase.h:68
ObjectBase * GetObj() const
获取失败的对象指针
Definition: ObjectBase.h:74
ObjectStatus GetStatus() const
获取对象状态
Definition: ObjectBase.h:81
引用计数智能指针
Definition: RefBasePtr.hpp:35
引用计数器
Definition: RefObject.h:33
可序列化对象
Definition: Serializable.h:239
反序列化器
Definition: Serializable.h:147
对象处理策略
Definition: ObjectBase.h:104
static ObjectPolicyFunc WarnLog(int threshold=ObjectStatus::fail)
在对象状态变为失败时打印警告日志
Definition: ObjectBase.cpp:50
static ObjectPolicyFunc Ignore()
忽略对象失败状态
Definition: ObjectBase.h:107
static ObjectPolicyFunc Exception(int threshold=ObjectStatus::fail)
在对象状态变为失败时抛出 ObjectFailException
Definition: ObjectBase.cpp:72
static ObjectPolicyFunc ErrorLog(int threshold=ObjectStatus::fail)
在对象状态变为失败时打印错误日志(默认策略)
Definition: ObjectBase.cpp:61
对象状态
Definition: ObjectBase.h:39
String msg
状态信息
Definition: ObjectBase.h:41
static const int fail
对象失败状态
Definition: ObjectBase.h:60
bool Success() const
对象状态是否成功
Definition: ObjectBase.h:53
int code
状态码,等于 0 时为成功状态,否则为失败状态
Definition: ObjectBase.h:40
序列化器
Definition: Serializable.h:40