Skip to content
Snippets Groups Projects
Commit 0b579ccd authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add JSON conversion for armarx::ObjectID

parent 55e93590
No related branches found
No related tags found
1 merge request!77Object pose JSON serialization
/*
* 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::ArmarXObjects
* @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
* @date 2020
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include "ArmarXObjects.h"
namespace armarx
{
}
......@@ -8,11 +8,11 @@ set(LIBS
)
set(LIB_FILES
ArmarXObjects.cpp
ObjectID.cpp
ObjectInfo.cpp
ObjectFinder.cpp
json_conversions.cpp
)
set(LIB_HEADERS
ArmarXObjects.h
......@@ -20,6 +20,8 @@ set(LIB_HEADERS
ObjectID.h
ObjectInfo.h
ObjectFinder.h
json_conversions.h
)
......
......@@ -30,6 +30,10 @@ namespace armarx
{
return _instanceName;
}
inline void setInstanceName(const std::string& instanceName)
{
this->_instanceName = instanceName;
}
/// Return "dataset/className" or "dataset/className/instanceName".
std::string str() const;
......
#include "json_conversions.h"
void armarx::to_json(nlohmann::json& j, const ObjectID& id)
{
j["dataset"] = id.dataset();
j["className"] = id.className();
j["instanceName"] = id.instanceName();
j["str"] = id.str();
}
void armarx::from_json(const nlohmann::json& j, ObjectID& id)
{
id =
{
j.at("dataset").get<std::string>(),
j.at("className").get<std::string>(),
j.at("instanceName").get<std::string>()
};
}
#pragma once
#include <SimoxUtility/json/json.hpp>
#include "ObjectID.h"
namespace armarx
{
void to_json(nlohmann::json& j, const ObjectID& value);
void from_json(const nlohmann::json& j, ObjectID& value);
}
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