NAP
entityobjectgraphitem.h
1 #pragma once
2 
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6 
7 // Local Includes
8 #include "componentresourcepath.h"
9 
10 // External Includes
11 #include <unordered_map>
12 #include <rtti/typeinfo.h>
13 
14 namespace nap
15 {
16  namespace rtti
17  {
18  class Object;
19  }
20 
27  {
28  public:
29  using Type = rtti::Object*;
30  using ClonedResourceMap = std::unordered_map<rtti::Object*, std::vector<rtti::Object*>>;
31  using ObjectsByTypeMap = std::unordered_map<rtti::TypeInfo, std::vector<rtti::Object*>>;
32 
33  enum class EType : uint8_t
34  {
35  Object,
36  File
37  };
38 
45  static const EntityObjectGraphItem create(rtti::Object* object, const ObjectsByTypeMap& objectsByType, const ClonedResourceMap& clonedResourceMap);
46 
50  const std::string getID() const;
51 
55  uint8_t getType() const { return (uint8_t)mType; }
56 
57 
64  bool getPointees(std::vector<EntityObjectGraphItem>& pointees, utility::ErrorState& errorState) const;
65 
66  EType mType; // Type: file or object
67  std::string mFilename; // If type is file, contains filename
68  rtti::Object* mObject = nullptr; // If type is object, contains object pointer
69  const ObjectsByTypeMap* mObjectsByType = nullptr; // All objects sorted by type
70  const ClonedResourceMap* mClonedResourceMap = nullptr; // All cloned resources
71  };
72 
73  template<typename ITEM> class ObjectGraph;
75 }
nap::EntityObjectGraphItem::mClonedResourceMap
const ClonedResourceMap * mClonedResourceMap
Definition: entityobjectgraphitem.h:70
nap::EntityObjectGraphItem::mType
EType mType
Definition: entityobjectgraphitem.h:66
nap::rtti::Object
Definition: object.h:30
nap::EntityObjectGraphItem::getPointees
bool getPointees(std::vector< EntityObjectGraphItem > &pointees, utility::ErrorState &errorState) const
nap::utility::ErrorState
Definition: errorstate.h:19
nap::ObjectGraph
Definition: objectgraph.h:20
nap::EntityObjectGraphItem::mObject
rtti::Object * mObject
Definition: entityobjectgraphitem.h:68
nap::EntityObjectGraphItem::getID
const std::string getID() const
nap::EntityObjectGraphItem::create
static const EntityObjectGraphItem create(rtti::Object *object, const ObjectsByTypeMap &objectsByType, const ClonedResourceMap &clonedResourceMap)
nap::EntityObjectGraphItem::getType
uint8_t getType() const
Definition: entityobjectgraphitem.h:55
nap::EntityObjectGraphItem::ClonedResourceMap
std::unordered_map< rtti::Object *, std::vector< rtti::Object * > > ClonedResourceMap
Definition: entityobjectgraphitem.h:30
nap::EntityObjectGraphItem::ObjectsByTypeMap
std::unordered_map< rtti::TypeInfo, std::vector< rtti::Object * > > ObjectsByTypeMap
Definition: entityobjectgraphitem.h:31
nap::EntityObjectGraphItem::mObjectsByType
const ObjectsByTypeMap * mObjectsByType
Definition: entityobjectgraphitem.h:69
nap
Definition: templateapp.h:17
nap::EntityObjectGraphItem::mFilename
std::string mFilename
Definition: entityobjectgraphitem.h:67
nap::EntityObjectGraphItem::EType::File
@ File
nap::EntityObjectGraphItem::EType::Object
@ Object
nap::EntityObjectGraphItem
Definition: entityobjectgraphitem.h:26
nap::EntityObjectGraphItem::EType
EType
Definition: entityobjectgraphitem.h:33