113 static Class staticType;
114 static void ClassInit(
Class* cls);
115 static inline Class* StaticType(){
return &staticType;}
119 virtual Class* getType()
const;
123 virtual std::string getRepresentation()
const;
126 virtual const std::string& getName()
const;
133 const std::string&
name()
const {
return this->getName();}
138 errc_t showEditDialog();
151 errc_t getAttrBool(
StringView path,
bool& value)
const;
157 errc_t getAttrInt(
StringView path,
int& value)
const;
163 errc_t getAttrDouble(
StringView path,
double& value)
const;
169 errc_t getAttrString(
StringView path, std::string& value)
const;
197 std::string getAttrString(
StringView path)
const;
209 errc_t setAttrBool(
StringView path,
bool value);
215 errc_t setAttrInt(
StringView path,
int value);
221 errc_t setAttrDouble(
StringView path,
double value);
241 const std::string& typeName()
const;
251 ObjectId getID()
const;
256 errc_t setParentScope(
Object* parentScope);
260 Object* getParentScope()
const;
265 bool isOfType(
const Class* type)
const;
275 bool isOfType()
const;
298 printf(
"object ref count is not 0, can not destruct");
301 assert(refcnt_ == 0);
309 return aObject_IncWeakRef(
this);
316 return aObject_DecWeakRef(
this);
323 return aObject_IncRef(
this);
330 return aObject_DecRef(
this);
353 template<
typename Func>
354 inline void addDelayedLink(Func &&link);
361 template<
typename Func>
362 inline void addDelayedLinkIfFailed(Func &&link);
371 friend class ObjectManager;
373 Object(
const Object& obj)
376 Object& operator=(
const Object&)
382 friend uint32_t aObject_IncRef(Object* obj)
384 return ++(obj->refcnt_);
387 friend uint32_t aObject_DecRef(Object* obj)
389 if (obj->refcnt_ == 1) {
393 return --(obj->refcnt_);
396 friend uint32_t aObject_IncWeakRef(Object* obj)
398 return ++(obj->weakrefcnt_);
401 friend uint32_t aObject_DecWeakRef(Object* obj)
403 if (obj->weakrefcnt_ == 1) {
404 operator delete(obj);
408 return --(obj->weakrefcnt_);
412 friend bool aObject_IsDestructed(
const Object *obj)
414 return obj->refcnt_ ==
static_cast<uint32_t
>(-1);
419 std::atomic<uint32_t> refcnt_{0};
420 std::atomic<uint32_t> weakrefcnt_{1};
421 uint32_t index_{
static_cast<uint32_t
>(
INVALID_ID)};