Reputation: 1092
Micropather requires users implement their abstract class "Graph" in order to use the library. What's a good way to do this from C++/CLI so I can use Micropather in .NET?
There are only two methods to implement:
virtual float LeastCostEstimate( void* stateStart, void* stateEnd ) = 0;
virtual void AdjacentCost( void* state, std::vector< StateCost > *adjacent ) = 0;
So far I have been scheming with gcroot and delegates, but I don't have anything solid yet.
Upvotes: 3
Views: 491
Reputation: 116724
Just write an ordinary C++ class that inherits Graph
, and use the gcroot template to refer to CLR objects from within that class.
class MyGraph : public Graph
{
gcroot<SomethingImportant ^> _stuff;
// implement abstract memfuncs to call onto _stuff
};
Upvotes: 3