Writer.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Fabian Reister ( fabian dot reister at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
24 #include <mutex>
25 #include <optional>
26 
28 
32 
33 #include "interfaces.h"
34 
36 {
37 
38  class Writer : virtual public WriterInterface
39  {
40  public:
41  Writer() = default;
42  ~Writer() override = default;
43 
45  void connect(armem::client::MemoryNameSystem& memoryNameSystem);
46 
47 
48  bool store(const ArticulatedObject& obj, bool isStatic) const override;
49 
50  bool storeInstance(const ArticulatedObject& obj, bool isStatic) const;
51  std::optional<armem::MemoryID> storeClass(const ArticulatedObject& obj) const;
52 
53  // const std::string& getPropertyPrefix() const override;
54 
55  std::string getProviderName() const;
56  void setProviderName(const std::string& providerName);
57 
58 
59  private:
60  std::optional<armem::MemoryID> storeOrGetClass(const ArticulatedObject& obj) const;
61 
62  // TODO duplicate
63  std::unordered_map<std::string, armem::MemoryID>
64  queryDescriptions(const armem::Time& timestamp) const;
65  std::optional<robot_state::description::RobotDescription>
66  getRobotDescription(const armarx::armem::wm::Memory& memory) const;
67  std::unordered_map<std::string, armem::MemoryID>
68  getRobotDescriptions(const armarx::armem::wm::Memory& memory) const;
69 
70  struct Properties
71  {
72  std::string memoryName = "Object";
73  std::string coreInstanceSegmentName = "Instance";
74  std::string coreClassSegmentName = "Class";
75  std::string providerName = "";
76 
77  bool allowClassCreation = false;
78  } properties;
79 
80  const std::string propertyPrefix = "mem.obj.articulated.";
81 
82  armem::client::Writer memoryWriter;
83  mutable std::mutex memoryWriterMutex;
84 
85  armem::client::Reader memoryReader;
86  mutable std::mutex memoryReaderMutex;
87  };
88 
89 
90 } // namespace armarx::armem::articulated_object
armarx::armem::client::Reader
Reads data from a memory server.
Definition: Reader.h:24
Reader.h
Writer.h
armarx::armem::robot_state::Robot
Definition: types.h:126
armarx::armem::articulated_object::Writer::setProviderName
void setProviderName(const std::string &providerName)
Definition: Writer.cpp:157
armarx::armem::articulated_object::Writer::getProviderName
std::string getProviderName() const
Definition: Writer.cpp:151
armarx::armem::articulated_object::Writer::connect
void connect(armem::client::MemoryNameSystem &memoryNameSystem)
Definition: Writer.cpp:50
armarx::memory
Brief description of class memory.
Definition: memory.h:38
armarx::armem::articulated_object::Writer::storeInstance
bool storeInstance(const ArticulatedObject &obj, bool isStatic) const
Definition: Writer.cpp:163
armarx::armem::articulated_object::Writer::store
bool store(const ArticulatedObject &obj, bool isStatic) const override
Definition: Writer.cpp:241
armarx::armem::wm::Memory
Client-side working memory.
Definition: memory_definitions.h:133
armarx::armem::articulated_object::Writer
Definition: Writer.h:38
armarx::armem::client::Writer
Helps a memory client sending data to a memory.
Definition: Writer.h:22
timestamp
std::string timestamp()
Definition: CartographerAdapter.cpp:85
armarx::armem::articulated_object::WriterInterface
Definition: interfaces.h:28
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::articulated_object::Writer::~Writer
~Writer() override=default
armarx::armem::laser_scans::constants::memoryName
const std::string memoryName
Definition: constants.h:28
IceUtil::Handle< class PropertyDefinitionContainer >
forward_declarations.h
armarx::armem::articulated_object
Definition: ArticulatedObjectReader.cpp:26
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:73
armarx::armem::articulated_object::Writer::registerPropertyDefinitions
void registerPropertyDefinitions(armarx::PropertyDefinitionsPtr &def)
Definition: Writer.cpp:29
armarx::armem::articulated_object::Writer::storeClass
std::optional< armem::MemoryID > storeClass(const ArticulatedObject &obj) const
Definition: Writer.cpp:105
MemoryNameSystem.h
armarx::armem::articulated_object::Writer::Writer
Writer()=default
interfaces.h