Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
c4a92841
Commit
c4a92841
authored
2 years ago
by
Fabian Reister
Browse files
Options
Downloads
Patches
Plain Diff
Component plugin for memroy reader and writer
parent
f58b1b4a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!249
Component plugin for memory reader and writer
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h
+119
-0
119 additions, 0 deletions
...otAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h
with
119 additions
and
0 deletions
source/RobotAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h
0 → 100644
+
119
−
0
View file @
c4a92841
/**
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Fabian Reister ( fabian dot reister at kit dot edu )
* @date 2022
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include
<string>
#include
"ArmarXCore/core/exceptions/local/ExpressionException.h"
#include
<ArmarXCore/core/ComponentPlugin.h>
#include
"RobotAPI/libraries/armem/client/plugins/Plugin.h"
#include
<RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h>
#include
<RobotAPI/libraries/armem/client/MemoryNameSystem.h>
namespace
armarx
::
armem
::
client
::
plugins
{
/**
* @brief A component plugin offering client-side access to a reader or writer
* and manages the lifecycle, e.g. connecting to the memory.
* Access to the working memory system is provided by a Memory Name System (MNS) client.
*
* @see MemoryNameSystem
*/
template
<
typename
T
>
class
ReaderWriterPlugin
:
public
armarx
::
ComponentPlugin
{
public:
ReaderWriterPlugin
(
ManagedIceObject
&
parent
,
const
std
::
string
pre
)
:
ComponentPlugin
(
parent
,
pre
),
readerWriter
(
memoryNameSystem
())
{
addPlugin
(
armemPlugin
);
}
~
ReaderWriterPlugin
()
override
=
default
;
void
postCreatePropertyDefinitions
(
PropertyDefinitionsPtr
&
properties
)
override
{
readerWriter
.
registerPropertyDefinitions
(
properties
);
}
void
preOnConnectComponent
()
override
{
ARMARX_CHECK_NOT_NULL
(
armemPlugin
);
if
(
not
armemPlugin
->
isMemoryNameSystemEnabled
())
{
ARMARX_INFO
<<
"The memory name system is disabled by user choice via the property."
<<
"Reader and writer will not be able to connect to the memory."
;
return
;
}
readerWriter
.
connect
();
}
bool
isAvailable
()
const
noexcept
{
ARMARX_CHECK_NOT_NULL
(
armemPlugin
);
return
armemPlugin
->
isMemoryNameSystemEnabled
();
}
T
&
get
()
{
ARMARX_CHECK_NOT_NULL
(
armemPlugin
);
ARMARX_CHECK
(
armemPlugin
->
isMemoryNameSystemEnabled
());
return
readerWriter
;
}
const
T
&
get
()
const
{
ARMARX_CHECK_NOT_NULL
(
armemPlugin
);
ARMARX_CHECK
(
armemPlugin
->
isMemoryNameSystemEnabled
());
return
readerWriter
;
}
private
:
MemoryNameSystem
&
memoryNameSystem
()
{
// if (armemPlugin == nullptr)
{
addPlugin
(
armemPlugin
);
}
ARMARX_CHECK_NOT_NULL
(
armemPlugin
);
return
armemPlugin
->
getMemoryNameSystemClient
();
}
T
readerWriter
;
armarx
::
armem
::
client
::
plugins
::
Plugin
*
armemPlugin
=
nullptr
;
};
}
// namespace armarx::armem::client::plugins
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment