| 10 | using namespace gte; |
| 11 | |
| 12 | void ControlledObject::AttachController(std::shared_ptr<Controller> const& controller) |
| 13 | { |
| 14 | if (controller) |
| 15 | { |
| 16 | // Test whether the controller is already in the list. |
| 17 | for (auto const& element : mControllers) |
| 18 | { |
| 19 | if (element == controller) |
| 20 | { |
| 21 | // The controller is in the list, so nothing to do. |
| 22 | return; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | // Bind the controller to the object using a regular pointer to avoid |
| 27 | // a reference-count cycle. |
| 28 | controller->SetObject(this); |
| 29 | |
| 30 | // The controller is not in the current list, so add it. |
| 31 | mControllers.push_back(controller); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | void ControlledObject::DetachController(std::shared_ptr<Controller> const& controller) |
| 36 | { |
no test coverage detected