I want to add a statistic to ResourceInstance. I'm having some trouble binding it to the my class.
/* Lines (A) and (B) are causing errors If I keep (A) and don't bind it, there is an error. If I bind (A) as a variable (i.e., bind() { bindNodePtr(customStat); } ), no problems. If I bind (A) as a statistic (see (B)), there is an error. */ class CustomResourceInstance : public ::ProcessFlow::ResourceInstance { public: treenode customStat = nullptr; // (A) virtual void bindStatistics() override; } ... void CustomResourceInstance::bindStatistics() { ResourceInstance::bindStatistics(); bindStatistic(customStat, STAT_TIME_WEIGHTED); // (B) }
I think the instance is created within Resource::instanceFactory(), so I am copying that into CustomResourceInstance and returning that instead. I have verified that the created instance found in the tree is, in fact, the custom instance I've created:
ProcessBlockInstance* CustomResource::instanceFactory() { // memory leak? CustomResourceInstance* processBlockInstance = new CustomResourceInstance(*(CustomResourceInstance*) Resource::instanceFactory()); return processBlockInstance; }
Any thoughts as to why I am unable to bind the statistic?
Thanks.