2023-09-04 12:21:37 +02:00
|
|
|
/* Node list.
|
2021-06-21 16:12:47 -04:00
|
|
|
*
|
2022-03-15 09:18:01 -04:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2022-07-04 18:20:03 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2021-06-21 16:12:47 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <jansson.h>
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <uuid/uuid.h>
|
2021-06-21 16:12:47 -04:00
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
// Forward declarations
|
|
|
|
class Node;
|
|
|
|
|
|
|
|
class NodeList : public std::list<Node *> {
|
2021-06-21 16:12:47 -04:00
|
|
|
|
|
|
|
public:
|
2023-09-07 11:46:39 +02:00
|
|
|
// Lookup a node from the list based on its name
|
|
|
|
Node *lookup(const std::string &name);
|
2021-06-21 16:12:47 -04:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Lookup a node from the list based on its UUID
|
|
|
|
Node *lookup(const uuid_t &uuid);
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
/* Parse an array or single node and checks if they exist in the "nodes" section.
|
2021-08-10 10:12:48 -04:00
|
|
|
*
|
|
|
|
* Examples:
|
|
|
|
* out = [ "sintef", "scedu" ]
|
|
|
|
* out = "acs"
|
|
|
|
*
|
|
|
|
* @param json A JSON array or string. See examples above.
|
|
|
|
* @param nodes The nodes will be added to this list.
|
|
|
|
* @param all This list contains all valid nodes.
|
|
|
|
*/
|
2023-09-07 11:46:39 +02:00
|
|
|
int parse(json_t *json, NodeList &all);
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
json_t *toJson() const;
|
2021-06-21 16:12:47 -04:00
|
|
|
};
|
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|