Add pluggable resource writing to MuJoCo
Extend mjpResourceProvider with an optional write callback (write) so that mj_encode, mj_saveXML, and mj_saveModel can write to any registered provider. PiperOrigin-RevId: 945202741 Change-Id: I37903425260932e555f4a8c2392c4ff8c2e6cc06
This commit is contained in:
committed by
Copybara-Service
parent
bdeb7e7c4d
commit
dc7581acfa
@@ -58,6 +58,10 @@ typedef int (*mjfUnmountResource)(mjResource* resource);
|
||||
// returns < 0 if the resource is older than the given timestamp
|
||||
typedef int (*mjfResourceModified)(const mjResource* resource, const char* timestamp);
|
||||
|
||||
// callback for writing bytes to a resource
|
||||
// return number of bytes written, return -1 if error
|
||||
typedef mjtSize (*mjfWriteResource)(mjResource* resource, const void* buffer, mjtSize nbytes);
|
||||
|
||||
// struct describing a single resource provider
|
||||
typedef struct mjpResourceProvider {
|
||||
const char* prefix; // prefix for match against a resource name
|
||||
@@ -67,6 +71,7 @@ typedef struct mjpResourceProvider {
|
||||
mjfMountResource mount; // mounting callback (optional)
|
||||
mjfUnmountResource unmount; // unmounting callback (optional)
|
||||
mjfResourceModified modified; // resource modified callback (optional)
|
||||
mjfWriteResource write; // writing callback (optional)
|
||||
void* data; // opaque data pointer (resource invariant)
|
||||
} mjpResourceProvider;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user