2019-04-11 14:40:54 +08:00
|
|
|
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
2019-03-31 01:37:06 +08:00
|
|
|
|
//
|
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
|
//
|
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
|
//
|
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2019-10-11 21:55:29 +08:00
|
|
|
|
#include <kiwano/macros.h>
|
2019-12-23 18:05:08 +08:00
|
|
|
|
#include <kiwano/core/common.h>
|
2019-12-25 18:07:57 +08:00
|
|
|
|
#include <kiwano/core/RefCounter.h>
|
2019-11-13 14:33:15 +08:00
|
|
|
|
#include <kiwano/core/SmartPtr.hpp>
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-04-11 14:40:54 +08:00
|
|
|
|
namespace kiwano
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
2019-08-18 10:23:54 +08:00
|
|
|
|
KGE_DECLARE_SMART_PTR(ObjectBase);
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* \~chinese
|
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
*/
|
2019-08-18 10:23:54 +08:00
|
|
|
|
class KGE_API ObjectBase
|
2019-10-30 23:12:18 +08:00
|
|
|
|
: public virtual RefCounter
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
public:
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2019-08-18 10:23:54 +08:00
|
|
|
|
ObjectBase();
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-08-18 10:23:54 +08:00
|
|
|
|
virtual ~ObjectBase();
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void SetName(String const& name);
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
String GetName() const;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20>ж϶<D0B6><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ͬ
|
|
|
|
|
|
/// @param name <20><>Ҫ<EFBFBD>жϵ<D0B6><CFB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
bool IsName(String const& name) const;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
const Any& GetUserData() const;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void SetUserData(Any const& data);
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ID
|
|
|
|
|
|
uint32_t GetObjectID() const;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
String DumpObject();
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
|
|
|
|
|
public:
|
2019-12-25 23:37:36 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<C2A9><D7B7>
|
2019-08-03 23:28:45 +08:00
|
|
|
|
static bool IsTracingLeaks();
|
|
|
|
|
|
|
2019-12-25 23:37:36 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ʼ<CABC><D7B7><EFBFBD>ڴ<EFBFBD>й©
|
2019-03-31 01:37:06 +08:00
|
|
|
|
static void StartTracingLeaks();
|
|
|
|
|
|
|
2019-12-25 23:37:36 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief ֹͣ<D6B9><D7B7><EFBFBD>ڴ<EFBFBD>й©
|
2019-03-31 01:37:06 +08:00
|
|
|
|
static void StopTracingLeaks();
|
|
|
|
|
|
|
2019-12-25 23:37:36 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><D7B7><EFBFBD>еĶ<D0B5><C4B6><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2019-03-31 01:37:06 +08:00
|
|
|
|
static void DumpTracingObjects();
|
|
|
|
|
|
|
2019-12-25 23:37:36 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><D7B7><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>
|
2019-12-25 18:07:57 +08:00
|
|
|
|
static Vector<ObjectBase*>& GetTracingObjects();
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
private:
|
|
|
|
|
|
static void AddObjectToTracingList(ObjectBase*);
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-25 18:07:57 +08:00
|
|
|
|
static void RemoveObjectFromTracingList(ObjectBase*);
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
|
|
|
|
|
private:
|
2019-10-12 11:26:41 +08:00
|
|
|
|
bool tracing_leak_;
|
2019-10-13 17:45:58 +08:00
|
|
|
|
Any user_data_;
|
2019-10-12 11:26:41 +08:00
|
|
|
|
String* name_;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-10-12 11:26:41 +08:00
|
|
|
|
const uint32_t id_;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
};
|
2019-12-25 18:07:57 +08:00
|
|
|
|
|
|
|
|
|
|
inline String ObjectBase::GetName() const { if (name_) return *name_; return String(); }
|
|
|
|
|
|
|
|
|
|
|
|
inline bool ObjectBase::IsName(String const& name) const { return name_ ? (*name_ == name) : name.empty(); }
|
|
|
|
|
|
|
|
|
|
|
|
inline uint32_t ObjectBase::GetObjectID() const { return id_; }
|
2019-03-31 01:37:06 +08:00
|
|
|
|
}
|