Choreonoid  1.8
HolderDevice.h
Go to the documentation of this file.
1 #ifndef CNOID_BODY_HOLDER_DEVICE_H
2 #define CNOID_BODY_HOLDER_DEVICE_H
3 
4 #include "Device.h"
5 #include "exportdecl.h"
6 
7 namespace cnoid {
8 
9 class AttachmentDevice;
10 typedef ref_ptr<AttachmentDevice> AttachmentDevicePtr;
11 class Mapping;
12 
13 class CNOID_EXPORT HolderDevice : public Device
14 {
15 public:
16  HolderDevice();
17  virtual ~HolderDevice();
18 
19  virtual const char* typeName() const override;
20  void copyHolderDeviceStateFrom(const HolderDevice* other);
21  virtual void copyStateFrom(const DeviceState& other) override;
22  virtual DeviceState* cloneState() const override;
23  void copyHolderDeviceFrom(const HolderDevice* device);
24  virtual bool copyFrom(const Device* other) override;
25  virtual void forEachActualType(std::function<bool(const std::type_info& type)> func) override;
26  virtual int stateSize() const override;
27  virtual const double* readState(const double* buf) override;
28  virtual double* writeState(double* out_buf) const override;
29 
30  virtual bool on() const override;
31  virtual void on(bool on) override;
32 
33  std::string category() const;
34  void setCategory(const std::string& category);
35 
36  enum HoldCondition { Distance, Collision, Name };
37  int holdCondition() const;
38  void setHoldCondition(int condition);
39  double maxHoldDistance() const;
40  void setMaxHoldDistance(double distance);
41  const std::string& holdTargetName() const;
42  void setHoldTargetName(const std::string& name);
43 
44  int numAttachments() const;
45  AttachmentDevice* attachment(int index);
46  bool addAttachment(AttachmentDevice* attachment);
47  void removeAttachment(int index);
48  bool removeAttachment(AttachmentDevice* attachment);
49  void clearAttachments();
50 
51  bool readDescription(const Mapping* info);
52  bool writeDescription(Mapping* info) const;
53 
54 protected:
55  HolderDevice(const HolderDevice& org, bool copyStateOnly, CloneMap* cloneMap);
56  virtual Referenced* doClone(CloneMap* cloneMap) const override;
57 
58 private:
59  bool on_;
60  class NonState;
61  NonState* ns;
62 };
63 
65 
66 }
67 
68 #endif
cnoid::Mapping
Definition: ValueTree.h:253
Device.h
cnoid::ref_ptr
Definition: Referenced.h:103
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::HolderDevice
Definition: HolderDevice.h:13
cnoid::Collision
Definition: Collision.h:14
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::AttachmentDevicePtr
ref_ptr< AttachmentDevice > AttachmentDevicePtr
Definition: AttachmentDevice.h:56
cnoid::AttachmentDevice
Definition: AttachmentDevice.h:13
cnoid::DeviceState
Definition: Device.h:20
cnoid::HolderDevicePtr
ref_ptr< HolderDevice > HolderDevicePtr
Definition: HolderDevice.h:64
cnoid::Referenced
Definition: Referenced.h:54
cnoid::Device
Definition: Device.h:53
cnoid::HolderDevice::HoldCondition
HoldCondition
Definition: HolderDevice.h:36