内容表
关于
A
GeMarker
object contains an unique ID. It is used to identify
BaseList2D
based objects.
-
警告
-
These markers change when the source object is copied or when the document is re-loaded.
Access
// This example gets the name and the marker of the given BaseObject.
// The name is used to search for an object with the same name in the document.
// The marker is used to check if the found object is also the original object.
const
String
objectName =
object
->GetName();
const
GeMarker
& marker =
object
->
GetMarker
();
// search object with the same name
const
BaseObject
*
const
foundObject = doc->
SearchObject
(objectName);
if
(foundObject !=
nullptr
)
{
// check if it is the same object
const
GeMarker
& foundObjectMarker = foundObject->
GetMarker
();
// compare if the markers are equal
if
(foundObjectMarker.
比较
(marker) == 0)
ApplicationOutput
(
"The found object is the original object"
_s);
else
ApplicationOutput
(
"The found object is not the original object"
_s);
}
The marker of a copy is different than the marker of the original object:
// This example copies an object.
// The copy has a different marker than the original.
const
GeMarker
& originalMarker =
object
->GetMarker();
C4DAtom
*
const
atomClone =
object
->
GetClone
(
COPYFLAGS::NONE
,
nullptr
);
BaseObject
*
const
clone =
static_cast<
BaseObject
*
>
(atomClone);
if
(clone ==
nullptr
)
return
maxon::OutOfMemoryError(
MAXON_SOURCE_LOCATION
);
doc->
InsertObject
(clone,
nullptr
,
nullptr
);
const
GeMarker
& cloneMarker = clone->
GetMarker
();
// check if the markers are not equal
if
(cloneMarker.
IsEqual
(originalMarker) ==
false
)
ApplicationOutput
(
"The markers are not equal"
_s);
另请参阅
BaseList2D
Marker
.
Allocation/Deallocation
GeMarker
objects can be created with the usual tools:
// This example creates two markers and checks if they are not equal.
AutoAlloc<GeMarker>
markerA;
AutoAlloc<GeMarker>
markerB;
const
Bool
invalidMarkerA = markerA ==
nullptr
;
const
Bool
invalidMarkerB = markerB ==
nullptr
;
if
(invalidMarkerA || invalidMarkerB)
return
maxon::OutOfMemoryError(
MAXON_SOURCE_LOCATION
);
// compare
if
(markerA->
IsEqual
(*markerB) ==
false
)
ApplicationOutput
(
"Markers not identical"
_s);
Functionality
GeMarker
objects can be handled with:
// This example iterates through all BaseDocuments in the document list.
// The active BaseDocument is marked with a star.
const
BaseDocument
*
const
activeDocument =
GetActiveDocument
();
if
(activeDocument ==
nullptr
)
return
maxon::UnexpectedError(
MAXON_SOURCE_LOCATION
);
BaseDocument
* document =
GetFirstDocument
();
while
(document !=
nullptr
)
{
const
GeMarker
& docMarker = document->
GetMarker
();
const
GeMarker
& activeDocMarker = activeDocument->
GetMarker
();
// use GeMarker to compare identity of the BaseDocuments
if
(docMarker.
IsEqual
(activeDocMarker))
{
ApplicationOutput
(
"Document: "
+ document->
GetDocumentName
().
GetString
() +
" *"
);
}
else
{
ApplicationOutput
(
"Document: "
+ document->
GetDocumentName
().
GetString
());
}
document = document->
GetNext
();
}
Read and Write
GeMarker
objects can be stored in a
HyperFile
.
延伸阅读
BaseDocument * GetActiveDocument(void)
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
BaseObject * SearchObject(const maxon::String &str)
C4DAtom * GetClone(COPYFLAGS flags, AliasTrans *trn)
定义:
c4d_baselist.h:1417
const GeMarker & GetMarker() const
定义:
c4d_baselist.h:2365
Int32 Compare(const GeMarker &m) const
定义:
c4d_baselist.h:1294
#define MAXON_SOURCE_LOCATION
定义:
memoryallocationbase.h:66
BaseDocument * GetFirstDocument(void)
String GetString(void) const
Bool IsEqual(const GeMarker &m) const
定义:
c4d_baselist.h:1287
A unique marker that identifies an object.
定义:
c4d_baselist.h:1256
#define ApplicationOutput(formatString,...)
定义:
debugdiagnostics.h:207
maxon::Bool Bool
定义:
ge_sys_math.h:53
Filename GetDocumentName(void)
BaseDocument * GetNext(void)
定义:
c4d_basedocument.h:527
定义:
c4d_basedocument.h:490