Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ find_package(ers REQUIRED)

set(CMDLIB_DEPENDENCIES ${CETLIB} ${CETLIB_EXCEPT} TBB::tbb logging::logging ers::ers nlohmann_json::nlohmann_json)

daq_codegen(*.jsonnet TEMPLATES Structs.hpp.j2 Nljs.hpp.j2 )

##############################################################################
# Main library

Expand Down
50 changes: 50 additions & 0 deletions include/cmdlib/cmd/Nljs.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This file is 100% generated. Any manual edits will likely be lost.
*
* This contains functions struct and other type definitions for shema in
* namespace dunedaq::cmdlib::cmd to be serialized via nlohmann::json.
*/
#ifndef DUNEDAQ_CMDLIB_CMD_NLJS_HPP
#define DUNEDAQ_CMDLIB_CMD_NLJS_HPP

// My structs
#include "cmdlib/cmd/Structs.hpp"


#include <nlohmann/json.hpp>

namespace dunedaq::cmdlib::cmd {

using data_t = nlohmann::json;

inline void to_json(data_t& j, const Command& obj) {
j["id"] = obj.id;
j["data"] = obj.data;
}

inline void from_json(const data_t& j, Command& obj) {
if (j.contains("id"))
j.at("id").get_to(obj.id);
obj.data = j.at("data");
}

inline void to_json(data_t& j, const CommandReply& obj) {
j["success"] = obj.success;
j["result"] = obj.result;
j["appname"] = obj.appname;
j["data"] = obj.data;
}

inline void from_json(const data_t& j, CommandReply& obj) {
if (j.contains("success"))
j.at("success").get_to(obj.success);
if (j.contains("result"))
j.at("result").get_to(obj.result);
if (j.contains("appname"))
j.at("appname").get_to(obj.appname);
obj.data = j.at("data");
}

} // namespace dunedaq::cmdlib::cmd

#endif // DUNEDAQ_CMDLIB_CMD_NLJS_HPP
62 changes: 62 additions & 0 deletions include/cmdlib/cmd/Structs.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This file is 100% generated. Any manual edits will likely be lost.
*
* This contains struct and other type definitions for shema in
* namespace dunedaq::cmdlib::cmd.
*/
#ifndef DUNEDAQ_CMDLIB_CMD_STRUCTS_HPP
#define DUNEDAQ_CMDLIB_CMD_STRUCTS_HPP

#include <cstdint>

#include <nlohmann/json.hpp>
#include <string>

namespace dunedaq::cmdlib::cmd {

// @brief The aplication name.
using AppId = std::string;

// @brief The command name. FIXME: this should be an enum!
using CmdId = std::string;

// @brief An opaque object holding lower layer substructure
using Data = nlohmann::json;

// @brief Top-level command object structure
struct Command
{

// @brief Identify the type of command
CmdId id = "";

// @brief Command data object with type-specific structure
Data data = {};
};

// @brief Outcome of the command: OK=true, NotOK=false
using IsOk = bool;

// @brief The command name.
using Result = std::string;

// @brief Top-level command reply object structure
struct CommandReply
{

// @brief Outcome of the command: OK=true, NotOK=false
IsOk success = true;

// @brief Textual result of the command
Result result = "";

// @brief Application name
AppId appname = "";

// @brief Command reply data object with type-specific structure
Data data = {};
};

} // namespace dunedaq::cmdlib::cmd

#endif // DUNEDAQ_CMDLIB_CMD_STRUCTS_HPP
46 changes: 0 additions & 46 deletions schema/cmdlib/cmd.jsonnet

This file was deleted.