NAP
object.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "rtti.h"
9 
10 // External Includes
11 #include <utility/errorstate.h>
12 #include <utility/dllexport.h>
13 
14 namespace nap
15 {
16  namespace rtti
17  {
18  constexpr const char* sIDPropertyName = "mID";
19 
30  class NAPAPI Object
31  {
32  RTTI_ENABLE()
33  public:
34  // Construction
35  Object();
36 
37  // Destruction
38  virtual ~Object();
39 
46  virtual bool init(utility::ErrorState& errorState) { return true; }
47 
55  virtual void onDestroy() { };
56 
60  static bool isIDProperty(rtti::Instance& object, const rtti::Property& property);
61 
65  Object(Object&) = delete;
66 
70  Object& operator=(const Object&) = delete;
71 
75  Object(Object&&) = delete;
76 
80  Object& operator=(Object&&) = delete;
81 
82  std::string mID;
83 
84  private:
85  friend class ObjectPtrBase;
86  template<class T> friend class ObjectPtr;
87 
88  inline void incrementObjectPtrRefCount() { mObjectPtrRefCount++; }
89  inline void decrementObjectPtrRefCount() { mObjectPtrRefCount--; };
90 
91  int mObjectPtrRefCount = 0;
92  };
93  }
94 }
nap::rtti::Object::mID
std::string mID
Property: 'mID' unique name of the object. Used as an identifier by the system.
Definition: object.h:82
nap::rtti::Object::init
virtual bool init(utility::ErrorState &errorState)
Definition: object.h:46
nap::rtti::sIDPropertyName
constexpr const char * sIDPropertyName
Definition: object.h:18
nap::rtti::ObjectPtr
Definition: objectptr.h:154
nap::rtti::Object
Definition: object.h:30
nap::utility::ErrorState
Definition: errorstate.h:19
nap::rtti::Property
rttr::property Property
Definition: typeinfo.h:142
nap::rtti::Object::onDestroy
virtual void onDestroy()
Definition: object.h:55
nap
Definition: templateapp.h:17
nap::rtti::Instance
rttr::instance Instance
Definition: typeinfo.h:144
nap::rtti::ObjectPtrBase
Definition: objectptr.h:27