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
std::string timestamp()
void connect(armem::client::MemoryNameSystem &memoryNameSystem)
Definition Writer.cpp:50
bool store(const ArticulatedObject &obj, bool isStatic) const override
Definition Writer.cpp:242
bool storeInstance(const ArticulatedObject &obj, bool isStatic) const
Definition Writer.cpp:163
void setProviderName(const std::string &providerName)
Definition Writer.cpp:157
std::optional< armem::MemoryID > storeClass(const ArticulatedObject &obj) const
Definition Writer.cpp:105
void registerPropertyDefinitions(armarx::PropertyDefinitionsPtr &def)
Definition Writer.cpp:29
The memory name system (MNS) client.
Reads data from a memory server.
Definition Reader.h:25
Helps a memory client sending data to a memory.
Definition Writer.h:23
Client-side working memory.
Brief description of class memory.
Definition memory.h:39
armarx::armem::robot_state::Robot ArticulatedObject
Definition types.h:140
armarx::core::time::DateTime Time
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.