8 #include <rtti/objectptr.h>
47 void assign(
const std::string& targetPath,
rtti::Object* targetObject) { mPath = targetPath; mResource = rtti_cast<Entity>(targetObject); }
66 const Entity&
operator*()
const { assert(mResource !=
nullptr);
return *mResource; }
70 const Entity*
operator->()
const { assert(mResource !=
nullptr);
return mResource.get(); }
76 bool operator==(std::nullptr_t)
const {
return mResource ==
nullptr; }
80 bool operator!=(std::nullptr_t)
const {
return mResource !=
nullptr; }
100 template<
typename SourceComponentType>
112 template<
class SourceComponentType>
115 SourceComponentType* resource = sourceComponentInstance->
getComponent<SourceComponentType>();
116 EntityPtr& target_entity_resource = resource->*entityMemberPointer;
117 sourceComponentInstance->addToEntityLinkMap(target_entity_resource.get(), target_entity_resource.getInstancePath(), &mInstance);
123 template<
class SourceComponentType>
138 bool operator==(std::nullptr_t)
const {
return mInstance ==
nullptr; }
142 bool operator!=(std::nullptr_t)
const {
return mInstance !=
nullptr; }
157 template<
typename SourceComponentType_>
172 template<
typename SourceComponentType>
173 EntityInstancePtrInitProxy<SourceComponentType>
initEntityInstancePtr(ComponentInstance* sourceComponentInstance, EntityPtr(SourceComponentType::*entityMemberPointer));
183 template<
typename SourceComponentType>
184 std::vector<EntityInstancePtr>
initEntityInstancePtr(ComponentInstance* sourceComponentInstance, std::vector<EntityPtr>(SourceComponentType::*entityMemberPointer));
194 struct wrapper_mapper<
nap::EntityPtr>
198 inline static wrapped_type get(
const type& obj) {
return obj.
get(); }
199 inline static type create(
const wrapped_type& value) {
return nap::EntityPtr(value); }
209 template<
typename SourceComponentType>
213 return{ sourceComponentInstance, entityMemberPointer };
217 template<
typename SourceComponentType>
218 std::vector<nap::EntityInstancePtr>
221 SourceComponentType* resource = sourceComponentInstance->
getComponent<SourceComponentType>();
222 std::vector<EntityPtr>& target_entity_resource = resource->*entityMemberPointer;
224 std::vector<EntityInstancePtr> result;
225 result.resize(target_entity_resource.size());
227 for (
int i = 0; i != result.size(); ++i)
228 sourceComponentInstance->addToEntityLinkMap(target_entity_resource[i].get(), target_entity_resource[i].getInstancePath(), &result[i].mInstance);
Definition: entityptr.h:107
bool operator==(const EntityInstancePtr &other) const
Definition: entityptr.h:136
EntityInstancePtr(const EntityInstancePtrInitProxy< SourceComponentType > &proxy)
Definition: entityptr.h:124
EntityInstance & operator*()
Definition: entityptr.h:130
Definition: entityptr.h:15
EntityInstancePtr()=default
const std::string & getInstancePath() const
Definition: entityptr.h:26
bool operator==(const EntityPtr &other) const
Definition: entityptr.h:74
EntityInstance * get()
Definition: entityptr.h:154
Definition: objectptr.h:154
Entity * get() const
Definition: entityptr.h:52
bool operator>=(const EntityInstancePtr &other) const
Definition: entityptr.h:150
Entity * operator->()
Definition: entityptr.h:72
Entity & operator*()
Definition: entityptr.h:68
void assign(const std::string &targetPath, rtti::Object *targetObject)
Definition: entityptr.h:47
Definition: entityptr.h:101
EntityInstancePtr(ComponentInstance *sourceComponentInstance, EntityPtr(SourceComponentType::*entityMemberPointer))
Definition: entityptr.h:113
nap::Component * getComponent() const
Definition: component.h:74
bool operator!=(const EntityInstancePtr &other) const
Definition: entityptr.h:140
EntityPtr(Entity *entity)
Definition: entityptr.h:20
bool operator<(const EntityPtr &other) const
Definition: entityptr.h:82
const EntityInstance & operator*() const
Definition: entityptr.h:128
EntityInstance * operator->()
Definition: entityptr.h:134
bool operator<=(const EntityInstancePtr &other) const
Definition: entityptr.h:148
const Entity * operator->() const
Definition: entityptr.h:70
bool operator!=(const EntityPtr &other) const
Definition: entityptr.h:78
EntityInstance * operator->() const
Definition: entityptr.h:132
EntityPtr SourceComponentType::* mEntityMemberPointer
Member pointer to the EntityPtr located in the Component.
Definition: entityptr.h:104
bool operator>=(const EntityPtr &other) const
Definition: entityptr.h:88
const Entity & operator*() const
Definition: entityptr.h:66
Definition: component.h:43
bool operator==(std::nullptr_t) const
Definition: entityptr.h:138
bool operator>(const EntityInstancePtr &other) const
Definition: entityptr.h:146
EntityInstance * get() const
Definition: entityptr.h:152
Definition: templateapp.h:17
bool operator==(std::nullptr_t) const
Definition: entityptr.h:76
bool operator!=(std::nullptr_t) const
Definition: entityptr.h:142
bool operator<=(const EntityPtr &other) const
Definition: entityptr.h:86
Entity * toObject() const
Definition: entityptr.h:38
bool operator>(const EntityPtr &other) const
Definition: entityptr.h:84
static std::string translateTargetID(const std::string &targetID)
Entity * get()
Definition: entityptr.h:57
bool operator<(const EntityInstancePtr &other) const
Definition: entityptr.h:144
bool operator!=(std::nullptr_t) const
Definition: entityptr.h:80
EntityInstancePtrInitProxy< SourceComponentType > initEntityInstancePtr(ComponentInstance *sourceComponentInstance, EntityPtr(SourceComponentType::*entityMemberPointer))
Definition: entityptr.h:211
ComponentInstance * mSourceComponentInstance
The ComponentInstance that the EntityInstancePtr is located in.
Definition: entityptr.h:103
std::string toString() const
Definition: entityptr.h:32
friend std::vector< EntityInstancePtr > initEntityInstancePtr(ComponentInstance *sourceComponentInstance, std::vector< EntityPtr >(SourceComponentType_::*entityMemberPointer))