5 #ifndef CNOID_BODY_SCENE_DEVICE_H
6 #define CNOID_BODY_SCENE_DEVICE_H
8 #include <cnoid/SceneGraph>
10 #include "exportdecl.h"
23 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
27 template<
class DeviceType>
29 registerSceneDeviceFactory_(
typeid(DeviceType), factory);
32 template<
class DeviceType>
35 registerSceneDeviceFactory_(
typeid(DeviceType), factory);
44 std::function<
void()> functionOnStateChanged =
nullptr,
45 std::function<
void(
double time)> functionOnTimeChanged =
nullptr);
47 template <
class DeviceType> DeviceType*
device() {
48 return static_cast<DeviceType*
>(device_);
50 template <
class DeviceType>
const DeviceType*
device()
const {
51 return static_cast<DeviceType*
>(device_);
56 void setFunctionOnStateChanged(std::function<
void()>
function);
59 setFunctionOnStateChanged(
function); };
60 void setFunctionOnTimeChanged(std::function<
void(
double time)>
function);
63 if(functionOnStateChanged) functionOnStateChanged();
64 if(functionOnTimeChanged) functionOnTimeChanged(time);
67 void setSceneUpdateConnection(
bool on);
75 std::function<void()> functionOnStateChanged;
76 std::function<void(
double time)> functionOnTimeChanged;
80 static void registerSceneDeviceFactory_(
const std::type_info& type,
const SceneDeviceFactory& factory);