AccessedObjectsCallback Class Reference

#include <c4d_accessedobjects.h>

Detailed Description

An AccessedObjectsCallback is passed to BaseList2D::GetAccessedObjects so that an implementation of BaseList2D can tell which data it will access within methods like ModifyObject or GetVirtualObjects. This is used to parallelize the execution of those methods as much as possible.

Public Member Functions

MAXON_METHOD GET_ACCESSED_OBJECTS_FLAGS AddFlags (GET_ACCESSED_OBJECTS_FLAGS newFlags)
 
MAXON_METHOD void RestoreFlags (GET_ACCESSED_OBJECTS_FLAGS prevFlags)
 
MAXON_METHOD Bool TestFlags (GET_ACCESSED_OBJECTS_FLAGS mask) const
 
MAXON_METHOD maxon::Result< BoolMarkVisited (const BaseList2D *object)
 
MAXON_METHOD Bool IsReadable (const BaseList2D *object, ACCESSED_OBJECTS_MASK readMask)
 
MAXON_METHOD maxon::Result< void > EnsureReadable (const BaseList2D *object, ACCESSED_OBJECTS_MASK readMask)
 
MAXON_METHOD maxon::Result< BoolMayAccess (const BaseList2D *object, ACCESSED_OBJECTS_MASK readMask, ACCESSED_OBJECTS_MASK writeMask)
 
MAXON_METHOD maxon::Result< BoolMayAccessAnything ()
 
MAXON_METHOD const BaseDocumentGetDocument ()
 
MAXON_METHOD BUILDFLAGS GetBuildFlags ()
 

Private Member Functions

 MAXON_INTERFACE_SIMPLE_VIRTUAL (AccessedObjectsCallback, MAXON_REFERENCE_NONE)
 

Member Function Documentation

◆ MAXON_INTERFACE_SIMPLE_VIRTUAL()

MAXON_INTERFACE_SIMPLE_VIRTUAL ( AccessedObjectsCallback  ,
MAXON_REFERENCE_NONE   
)
private

◆ AddFlags()

◆ RestoreFlags()

MAXON_METHOD void RestoreFlags ( GET_ACCESSED_OBJECTS_FLAGS  prevFlags)

◆ TestFlags()

MAXON_METHOD Bool TestFlags ( GET_ACCESSED_OBJECTS_FLAGS  mask) const

◆ MarkVisited()

MAXON_METHOD maxon::Result<Bool> MarkVisited ( const BaseList2D object)

Marks object as visited to prevent endless recursion in implementations of BaseList2D::GetAccessedObjects.

Parameters
[in]objectAn object for which GetAccessedObjects is called.
Returns
true if the object hasn't been marked as visited before by a prior call to MarkVisited, false otherwise.

◆ IsReadable()

MAXON_METHOD Bool IsReadable ( const BaseList2D object,
ACCESSED_OBJECTS_MASK  readMask 
)

Checks if the data corresponding to readMask is already readable from object. That's the case unless there's a pending job which will write to that data.

Parameters
[in]objectAn object.
[in]readMaskThe data mask for which readability shall be checked.
Returns
True if the data is readable, false otherwise.

◆ EnsureReadable()

MAXON_METHOD maxon::Result<void> EnsureReadable ( const BaseList2D object,
ACCESSED_OBJECTS_MASK  readMask 
)

Waits if necessary until the data corresponding to readMask is readable from object. This method will wait as long as there are pending jobs which will write to that data.

Parameters
[in]objectAn object.
[in]readMaskThe data mask for which readability shall be checked.

◆ MayAccess()

MAXON_METHOD maxon::Result<Bool> MayAccess ( const BaseList2D object,
ACCESSED_OBJECTS_MASK  readMask,
ACCESSED_OBJECTS_MASK  writeMask 
)

Tells the callback that the current method may access object's data corresponding to readMask and writeMask. MayAccess is called in implementations of BaseList2D::GetAccessedObjects. A simple implementation for a generator could look like this:

class MyObject : public ObjectData
{
INSTANCE(MyObject, ObjectData)
public:
...
Result<Bool> GetAccessedObjects(const BaseList2D* node, METHOD_ID method, AccessedObjectsCallback& access) const override
{
switch (method)
{
{
}
}
return SUPER::GetAccessedObjects(node, method, access);
}
};
@ CACHE
The cache of the object will be accessed. Combination of CACHE_FLAG and BITS as CACHE_FLAG implies BI...
@ DATA
Data accessible via Get/SetParameter (including data stored in the BaseContainer and the DIRTYFLAGS::...
METHOD_ID
Definition: c4d_accessedobjects.h:90
@ GET_VIRTUAL_OBJECTS
BaseObject::GetVirtualObjects method of generators. For spline generators this includes the methods G...
Definition: c4d_accessedobjects.h:148
MAXON_METHOD maxon::Result< Bool > MayAccess(const BaseList2D *object, ACCESSED_OBJECTS_MASK readMask, ACCESSED_OBJECTS_MASK writeMask)
Definition: c4d_baselist.h:2377
Definition: c4d_objectdata.h:166
struct _Py_Identifier struct _Py_Identifier PyObject struct _Py_Identifier PyObject PyObject struct _Py_Identifier PyObject PyObject PyObject ** method
Definition: object.h:330
Definition: node.h:10

So when the object's GetVirtualObjects method is called, this may read from the BaseContainer and also from any tag, and it may write to the cache (namely, it writes the generated virtual object). If GetVirtualObjects reads from further objects (e.g., children or linked objects), this has to be matched by additional calls to MayAccess.

Parameters
[in]objectAn object which the current method will access during execution.
[in]readMaskThe data identified by readMask will be read from object.
[in]writeMaskThe data identified by writeMask will be written to object. This also allows to read the data.
Returns
If this returns false, the callback isn't interested in further calls to MayAccess and you can do an early exit.

◆ MayAccessAnything()

MAXON_METHOD maxon::Result<Bool> MayAccessAnything ( )

Tells the callback that the current method may access anything from the current document. You have to use this instead of MayAccess if it's unknown or too complex what the current method will actually do.

The default behaviour of BaseList2D::GetAccessedObjects is to call MayAccessAnything.

Returns
If this returns false, the callback isn't interested in further calls to MayAccess and you can do an early exit.

◆ GetDocument()

MAXON_METHOD const BaseDocument* GetDocument ( )

Returns the current document.

Returns
Current document.

◆ GetBuildFlags()

MAXON_METHOD BUILDFLAGS GetBuildFlags ( )

Returns the current build flags.

Returns
Current build flags. @MAXON_ANNOTATION{default=BUILDFLAGS(0)}