Skip to content
Snippets Groups Projects
Commit d42c9082 authored by Fabian Reister's avatar Fabian Reister
Browse files

adding memory connector as base class for all memory accessors (read and write)

parent 9df3c2b8
No related branches found
No related tags found
No related merge requests found
#include "MemoryConnector.h"
#include <ArmarXCore/core/ManagedIceObject.h>
#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h>
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
namespace armarx {
MemoryConnector::MemoryConnector(ManagedIceObject &component) : component(component) {}
void MemoryConnector::registerPropertyDefinitions(PropertyDefinitionsPtr &def)
{
ARMARX_INFO << "Memory connector: registerPropertyDefinitions";
const std::string prefix = getPropertyPrefix();
def->component(memoryNameSystem, "ArMemMemoryNameSystem", prefix + "ArMemMemoryNameSystem");
}
armem::data::WaitForMemoryResult MemoryConnector::useMemory(const std::string &memoryName)
{
armem::data::WaitForMemoryInput input;
input.name = memoryName;
ARMARX_CHECK_NOT_NULL(memoryNameSystem);
ARMARX_INFO << "Waiting for memory ...";
armem::data::WaitForMemoryResult result = memoryNameSystem->waitForMemory(input);
if (result.success) {
// Add dependency.
component.usingProxy(result.proxy->ice_getIdentity().name);
}
else {
ARMARX_WARNING << "Use memory: Failure";
}
return result;
}
} // namespace armarx
/*
* 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/>.
*
* @package RobotAPI::ArmarXObjects::
* @author Fabian Reister ( fabian dot reister at kit dot edu )
* @date 2021
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h>
// TODO(fabian.reister): remove
#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h>
namespace armarx {
class ManagedIceObject;
// TODO(fabian.reister): add
// class PropertyDefinitionsPtr;
class MemoryConnector {
public:
MemoryConnector(ManagedIceObject &component);
protected:
armem::data::WaitForMemoryResult useMemory(const std::string &memoryName);
void registerPropertyDefinitions(PropertyDefinitionsPtr &def);
void waitForMemory();
virtual std::string getPropertyPrefix(){
return "mem.";
}
private:
ManagedIceObject &component;
armem::mns::MemoryNameSystemInterfacePrx memoryNameSystem;
};
} // namespace armarx
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment