THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/11/2010 at 15:35, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R9+
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
---------
Howdy,
I've got a tag that has a public function to set some data, which can be accesses from within the other parts of the plugin by first getting the tag's NodeData and then calling the function from there.
But I'd like to be able to access that function from a different plugin. So, I tried an experiment with a virtual function that seems to work, but I'd like to know if it's safe to do it this way.
Here's some simplified code:
In the tags header file, the class would be defined something like this:
class MyTag : public TagData
{
public:
virtual Bool Init(GeListNode *node);
/*..........
*/
virtual Bool Message(GeListNode *node, LONG type, void *data);
static NodeData *Alloc(void) { return gNew MyStorageTag; }
public:
void SetValues(Real *data, LONG count);
virtual void ExtSetValues(Real *data, LONG count);
};
The virtual function would then be defined in the plugin's cpp file like this:
void MyTag::ExtSetValues(Real *data, LONG count)
{
SetValues(Real *data, LONG count);
}
... so that the virtual function would simply call the public function SetValues() and pass the parameters to it.
Then from a different plugin, it would call the virtual function like this:
MyTag *mTag = static_cast<MyTag*>(tag->GetNodeData());
if(mTag) mTag->ExtSetValues(dataAddress, count);
It seems to work OK.
Adios,
Cactus Dan