Using the application data manager to share information within your application is very easy and powerful. You only need to do the following:
Define your data structure and implement the writeObject and readObject functions for it.
Create and instance of your new data structure
Initialize the data structure by assigning it a GUID(Globally Unique Identifier) and assigning a host to be responsible for updating its value when needed.
Calculate the value of the data structure on the responsible host node.
Use the data structure's value in your application.
Once you have completed this simple tasks you will have a custom data type that is being synchronized across all cluster nodes behind the scenes. This can make the process of sharing the transformation matrix a simple task that can be implemented in 50 lines of code.
Example 6.1. Define Your Data Structure
1 #include <vpr/IO/SerializableObject.h> struct MyType{ int something; 5 float otherStuff; char stupid; bool drawBool; }; 10 template<class MyType> vpr::ReturnStatus vpr::SerializableObjectMixin<MyType>::writeObject(vpr::ObjectWriter* writer)
{ writer->writeUint16(something); 15 writer->writeBool(drawBool); } template<class MyType> vpr::ReturnStatus 20 vpr::SerializableObjectMixin<MyType>::readObject(vpr::ObjectReader* reader)
{ something = reader->readUint16(); drawBool = reader->readBool(); }
Example 6.3. Initialize the Data Structure
vpr::GUID new_guid("d6be4359-e8cf-41fc-a72b-a5b4f3f29aa2");
std::string hostname = "gfxn1";
mMyData.init(new_guid, hostname);