1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| class IInteraction : public enable_shared_from_this<IInteraction>
{
protected:
IInteraction( boost::weak_ptr<CPointMechanicsEngine> iEngine ) :
_Engine( iEngine )
{
}
template<typename I>
boost::shared_ptr<I>
addToEngine(boost::weak_ptr<CPointMechanicsEngine> iEngine, I *nakedInter)
{
boost::shared_ptr<I> sharedInter(nakedInter);
boost::shared_ptr<CPointMechanicsEngine> Engine(iEngine);
Engine->AddInteraction(sharedInter);
return sharedInter;
}
public:
static boost::shared_ptr<IInteraction>
Create(boost::weak_ptr<CPointMechanicsEngine> iEngine)
{
return addToEngine(iEngine, new IInteraction(iEngine));
}
protected:
boost::weak_ptr<CPointMechanicsEngine> _Engine;
}; |
Partager