Skip to content

Commit

Permalink
added payload to the base structural element
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Staar <[email protected]>
  • Loading branch information
PeterStaar-IBM committed Dec 3, 2024
1 parent 5beeb00 commit 07df129
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/andromeda/tooling/structs/subjects/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace andromeda

const static inline std::string prov_lbl = "prov";

const static inline std::string payload_lbl = "payload"; // arbitrary data that needs to be carried through

const static inline std::string subj_hash_lbl = "subj_hash";
const static inline std::string text_hash_lbl = "text_hash"; // for text

Expand Down Expand Up @@ -141,6 +143,8 @@ namespace andromeda
std::vector<base_property> properties;
std::vector<base_instance> instances;
std::vector<base_relation> relations;

nlohmann::json payload;

//std::vector<base_entity> entities;
};
Expand All @@ -159,7 +163,9 @@ namespace andromeda

properties({}),
instances({}),
relations({})
relations({}),

payload(nlohmann::json::value_t::null)
{}

base_subject::base_subject(subject_name name):
Expand All @@ -176,7 +182,9 @@ namespace andromeda

properties({}),
instances({}),
relations({})
relations({}),

payload(nlohmann::json::value_t::null)
{}

base_subject::base_subject(uint64_t dhash,
Expand All @@ -195,7 +203,9 @@ namespace andromeda

properties({}),
instances({}),
relations({})
relations({}),

payload(nlohmann::json::value_t::null)
{
auto parts = utils::split(dloc, "#");
if(parts.size()==2)
Expand Down Expand Up @@ -321,6 +331,10 @@ namespace andromeda
{
nlohmann::json result = nlohmann::json::object({});

{
result[payload_lbl] = payload;
}

{
result[subj_hash_lbl] = hash;
result[dloc_lbl] = dloc;
Expand Down Expand Up @@ -379,6 +393,8 @@ namespace andromeda

bool base_subject::_from_json(const nlohmann::json& item)
{
payload = item.value(payload_lbl, payload);

hash = item.value(subj_hash_lbl, hash);

dloc = item.value(dloc_lbl, dloc);
Expand Down

0 comments on commit 07df129

Please sign in to comment.