Go to the documentation of this file. 1 #ifndef CNOID_UTIL_CLONE_MAP_H
2 #define CNOID_UTIL_CLONE_MAP_H
7 #include "exportdecl.h"
11 class ClonableReferenced;
27 template<
class ObjectType>
29 return static_cast<ObjectType*
>(findClone_(org));
32 template<
class ObjectType>
34 return findClone<ObjectType>(org.
get());
37 template<
class ObjectType>
39 return static_cast<ObjectType*
>(findOrCreateClone_(org));
42 template<
class ObjectType>
44 return getClone<ObjectType>(org.
get());
54 template<
class ObjectType>
55 ObjectType*
getClone(
const ObjectType* org, std::function<ObjectType*(
const ObjectType* org)> cloneFunction){
56 return static_cast<ObjectType*
>(
60 return cloneFunction(
static_cast<const ObjectType*
>(org));
64 template<
class ObjectType>
66 return getClone(org.get(), cloneFunction);
76 template<
class ObjectType>
78 const ObjectType* org, std::function<
void(ObjectType* clone)> replaceFunction){
79 return static_cast<ObjectType*
>(
80 findCloneOrReplaceLater_(
83 replaceFunction(
static_cast<ObjectType*
>(clone)); }));
86 void replacePendingObjects();
88 void setOriginalAsClone(
const Referenced* org);
93 FlagId(
const char* name) : id_(getFlagId(name)) { }
94 operator int()
const {
return id_; }
97 bool flag(
int id)
const {
return flags[id]; }
98 void setFlag(
int id,
bool on) { flags[id] = on; }
103 std::vector<bool> flags;
112 static int getFlagId(
const char* name);
bool flag(int id) const
Definition: CloneMap.h:97
ObjectType * getClone(ref_ptr< ObjectType > org)
Definition: CloneMap.h:43
Definition: CloneMap.h:90
ObjectType * findClone(const ObjectType *org)
Definition: CloneMap.h:28
Definition: Referenced.h:103
FlagId(const char *name)
Definition: CloneMap.h:93
ObjectType * findCloneOrReplaceLater(const ObjectType *org, std::function< void(ObjectType *clone)> replaceFunction)
Definition: CloneMap.h:77
ObjectType * getClone(ref_ptr< ObjectType > org, std::function< ObjectType *(const ObjectType *org)> cloneFunction)
Definition: CloneMap.h:65
Definition: AbstractSceneLoader.h:11
Definition: ClonableReferenced.h:10
Definition: CloneMap.h:13
std::function< Referenced *(const Referenced *org)> CloneFunction
Definition: CloneMap.h:16
Definition: Referenced.h:54
ObjectType * getClone(const ObjectType *org, std::function< ObjectType *(const ObjectType *org)> cloneFunction)
Definition: CloneMap.h:55
ObjectType * findClone(ref_ptr< ObjectType > org)
Definition: CloneMap.h:33
void setFlag(int id, bool on)
Definition: CloneMap.h:98
ObjectType * getClone(const ObjectType *org)
Definition: CloneMap.h:38
T * get() const
Definition: Referenced.h:168