Choreonoid  1.8
BodyOverwriteAddon.h
Go to the documentation of this file.
1 #ifndef CNOID_BODY_PLUGIN_BODY_OVERWRITE_ADDON_H
2 #define CNOID_BODY_PLUGIN_BODY_OVERWRITE_ADDON_H
3 
4 #include "DeviceOverwriteItem.h"
5 #include <cnoid/ItemAddon>
6 #include <cnoid/ItemList>
7 #include "exportdecl.h"
8 
9 namespace cnoid {
10 
11 class LinkShapeOverwriteItem;
12 class DeviceOverwriteItem;
13 class Link;
14 class Device;
15 
16 class CNOID_EXPORT BodyOverwriteAddon : public ItemAddon
17 {
18 public:
19  static void initializeClass(ExtensionManager* ext);
20 
22 
23  virtual bool setOwnerItem(Item* item) override;
24 
25  // Functions on link shape overwriting
26  bool checkIfSingleShapeBody();
27  LinkShapeOverwriteItem* findLinkShapeOverwriteItem(Link* link);
28  LinkShapeOverwriteItem* getOrCreateLinkShapeOverwriteItem(Link* link);
29  bool registerLinkShapeOverwriteItem(Link* link, LinkShapeOverwriteItem* item);
30  void unregisterLinkShapeOverwriteItem(LinkShapeOverwriteItem* item);
31 
32  // Functions on device overwriting
33 
34  // Note that the getter ids of newly extracted items are not specified by this function and
35  // the ids should be specified by a caller after calling this function.
36  ItemList<DeviceOverwriteItem> extractDevicesAsOverwriteItems(std::function<bool(Device* device)> predicate);
37 
38  template<class DeviceType>
40  return ownerItem()->descendantItems<DeviceOverwriteItem>(
41  [](DeviceOverwriteItem* item) -> bool {
42  return dynamic_cast<DeviceType*>(item->device());
43  });
44  }
45 
46  DeviceOverwriteItem* findDeviceOverwriteItem(Device* device);
47  bool addDeviceOverwriteItem(DeviceOverwriteItem* item);
48  void removeDeviceOverwriteItem(DeviceOverwriteItem* item);
49 
50  void clearOverwriteItems();
51 
52  virtual bool store(Archive& archive) override;
53  virtual bool restore(const Archive& archive) override;
54 
55 private:
56  class Impl;
57  Impl* impl;
58 };
59 
60 }
61 
62 #endif
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::Archive
Definition: Archive.h:22
cnoid::LinkShapeOverwriteItem
Definition: LinkShapeOverwriteItem.h:14
cnoid::ItemAddon
Definition: ItemAddon.h:13
cnoid::DeviceOverwriteItem
Definition: DeviceOverwriteItem.h:60
cnoid::BodyOverwriteAddon::deviceOverwriteItems
ItemList< DeviceOverwriteItem > deviceOverwriteItems()
Definition: BodyOverwriteAddon.h:39
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Item
Definition: Item.h:29
cnoid::ItemList
Definition: Item.h:20
cnoid::Device
Definition: Device.h:53
DeviceOverwriteItem.h
cnoid::BodyOverwriteAddon
Definition: BodyOverwriteAddon.h:16