Sources and registries

Collections of sources, units, schemas, functions, and node hierarchies.

enum class snt::dip::FunctionKind

Values:

enumerator Value
enumerator Nodes
struct Branch
#include <list_branching.h>

Branch containing the cases selected during DIPL evaluation.

Public Members

std::vector<size_t> cases
std::vector<CaseType> types
std::map<std::string, size_t> nodes
class BranchingList
#include <list_branching.h>

Collection of DIPL branches and their selected cases.

Public Functions

inline BranchingList()
int register_case()
bool false_case()
void solve_case(const BaseNode::PointerType &node)
void prepare_node(const BaseNode::PointerType &node)
std::string clean_name(const std::string &node)
struct Case
#include <list_branching.h>

One conditional case in a DIPL branching structure.

Public Members

std::string path
std::string code
std::string expr
bool value
size_t branch_id
size_t branch_part
size_t case_id
CaseType case_type
struct Collection
#include <list_hierarchy.h>

Information about a collection, keyed or indexed

Public Members

std::string path

Fully qualified path of a collection.

std::vector<std::string> items

List of collection items.

Path::Kind kind

Collection path kind.

std::vector<std::string> schemas

List of item schemas.

struct EnvFunction
#include <list_functions.h>

Traceable registered DIPL function.

Public Members

std::string id

Internal trace identifier, e.g. DIP0_FUNCTION0.

std::string name

Public function name used by DIPL.

FunctionKind kind
struct EnvSchema
#include <list_schema.h>

Reusable schema definition registered in a parsed DIPL environment.

Public Members

std::string name
BaseNode::ListType nodes
std::string id
ValueMetadata metadata

Metadata on the definition, not inherited by instances.

std::string source_name

Source containing the declaration or schema body.

size_t source_line

Declaration line, or first body line for host schemas.

struct EnvSource
#include <list_source.h>

Named DIPL source text together with its parsed nodes.

Public Members

std::string name
std::string path
std::string code
Source parent
NodeList<ValueNode> nodes
struct EnvUnit
#include <list_unit.h>

Custom unit data

Public Members

std::string name

unit key

std::string definition

unit definition

size_t stack

number of the current unit system stack

std::string id

Internal trace identifier, e.g. DIP0_UNIT0.

size_t registration_order

Environment-local registration order.

class FunctionList
#include <list_functions.h>

Registry of functions callable from DIPL expressions.

Public Types

using DataFunctionType = std::function<ValueNodeData(const Environment&)>
using NodesFunctionType = std::function<ValueNode::ListType(const Environment&)>

Public Functions

void append_value(const std::string &name, DataFunctionType func, const std::string &parent_id = {})

Register a value function under a public name and trace parent identifier.

void append_nodes(const std::string &name, NodesFunctionType func, const std::string &parent_id = {})

Register a node-producing function under a public name and trace parent identifier.

DataFunctionType get_value(const std::string &name) const

Return the registered value-producing function.

Parameters:

name – Function name to look up.

NodesFunctionType get_nodes(const std::string &name) const
const EnvFunction &get_value_info(const std::string &name) const

Return trace information for a registered value function.

const EnvFunction &get_nodes_info(const std::string &name) const

Return trace information for a registered node-producing function.

std::vector<EnvFunction> entries() const

Return trace information for all registered functions, ordered by name and kind.

class HierarchyList
#include <list_hierarchy.h>

The main class that manages node hierarchy

Public Functions

void record(const BaseNode::PointerType &node, const std::vector<NodeDtype> &excluded)

Register node into the node hierarchy

Parameters:
  • node – Node that should be registed

  • excluded – List of node types that will be ignored in a node hierarchy

void record_parent(const BaseNode::PointerType &node)

Update indentation context without creating nodes or collection items.

const Path get_current_path(size_t indent = 0, const std::string &path = "", bool show_item = true) const

Get path of the current hierarchy level

If indent and path is not provided, method returns the most recent path composed from parents in the stack. When provided, the method returns path relative to the given indent. E.g. if current path is ‘foo.bar.baz’ and group ‘bar’ has indent 2, than for input indent 2 and path crackle, the following path will be constructed: foo.crackle.

The paramer show_item strips the item from the end of the collection path: e.g. instead of foo[bar] only foo is returned

Parameters:
  • indent – Indent of a new node

  • path – Path name of a new node

  • show_item – Show collection item at the end of the path

Returns:

Path of the current hierarchy level

const std::unordered_map<std::string, Collection> &get_collections() const

Gets a reference on a ll collections

Returns:

Map of all collections

const Collection &get_collection(const std::string &path) const

Get reference to a specific collection

Parameters:

path – Collection fully qualified path

Returns:

Referenc on a collection

void set_collection(const std::string &path, Path::Kind kind, std::vector<std::string> schemas)

Set a new collection

Parameters:
  • path – Collection fully qualified path

  • kind – Collection kind (map/list)

  • schemas – List of schemas applied to collection items

void set_collection(const std::string &path, Path::Kind kind, std::vector<std::string> schemas, std::vector<std::string> items)

Restore a collection and its item order from persisted environment data.

void set_schemas(const std::string &path, std::vector<std::string> schemas)

Record schemas applied to an existing group or collection item.

const bool has_collection(const std::string &path) const

Test if collection whith the given path exists

Parameters:

path – Collection path that should be found

Returns:

Returns true if collection exists, otherwise returns false

const size_t num_collections() const

Get number of collections

Returns:

Number of collections

template<typename T>
class NodeList
#include <list_node.h>

Ordered, named collection of DIPL nodes.

Public Functions

NodeList() = default
inline NodeList(const typename T::ListType &nl)
inline size_t size() const
inline void push_front(const typename T::PointerType &node)
inline void push_back(const typename T::PointerType &node)
inline T::PointerType pop_front()
inline void erase(size_t index)
inline T::PointerType pop_back()
inline T::PointerType at(const size_t index)
inline T::PointerType at(const size_t index) const
inline const T::ListType &get_nodes() const
struct Parent
#include <list_hierarchy.h>

Holds information about a paraent node in the hierarchy

Public Members

size_t indent

Indent of a parent node.

std::string name

Fully qualified node path.

std::vector<Path::CollectionAccess> collections

List of collections in the node path.

class SchemaList
#include <list_schema.h>

Public Functions

SchemaList()
void append(const std::string &name, BaseNode::ListType &nodes, const std::string &parent_id = {}, const ValueMetadata &metadata = {}, size_t source_line = 0)

Append a schema definition to the registry.

Parameters:
  • name – Name used to identify the item.

  • nodes – Nodes defining the schema.

  • parent_id – Internal identifier of the registering source.

  • metadata – Metadata attached to the schema definition.

void append(const std::string &name, EnvSchema src, const std::string &parent_id = {})

Append a schema record, assigning an identifier when it has none.

EnvSchema &at(const std::string &name)
const EnvSchema &at(const std::string &name) const
const std::map<std::string, EnvSchema> &entries() const

Return all registered schema definitions and metadata keyed by name.

class SourceList
#include <list_source.h>

Collection of named DIPL sources.

Public Functions

SourceList()
void append(const std::string &name, const std::filesystem::path &path, const std::string &code, const Source &parent)

Append an item to the collection.

Parameters:
  • name – Name used to identify the item.

  • path – Path identifying the requested node or source.

  • code – Source code associated with the source entry.

  • parent – Parent source metadata used to preserve include provenance.

void append(const std::string &name, const EnvSource &src)
EnvSource &at(const std::string &name)
const EnvSource &at(const std::string &name) const
const std::map<std::string, EnvSource> &entries() const

Return all registered sources keyed by their DIPL source name.

class UnitList
#include <list_unit.h>

List of custom units

Public Functions

UnitList()

Unit list constructor

void append(const std::string &name, const std::string &definition, const std::string &parent_id = {})

Append new custom unit from a name and a definition expression

Parameters:
  • name – Name of a custom unit

  • definition – Expression that defines a new unit

  • parent_id – Internal identifier of the registering source.

void append(const std::string &name, EnvUnit data, const std::string &parent_id = {})

Append new custom unit from a name and a custom unit data

Parameters:
  • name – Name of a custom unit

  • data – Custom unit data object

  • parent_id – Internal identifier of the registering source.

EnvUnit &at(const std::string &name)

Select custom unit data

Parameters:

name – Name of a custom unit

Returns:

Custom unit data

const EnvUnit &at(const std::string &name) const

Select custom unit data for read-only

Parameters:

name – Name of a custom unit

Returns:

Custom unit data

const std::map<std::string, EnvUnit> &entries() const

Return all registered custom units keyed by unit name.