views:

161

answers:

1

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.

+1  A: 

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
};
Daniel Earwicker