Cerata
A library to generate structural hardware designs
cerata::Graph Class Reference

A graph representing a hardware structure. More...

#include <graph.h>

+ Inheritance diagram for cerata::Graph:
+ Collaboration diagram for cerata::Graph:

Public Types

enum  ID { COMPONENT, INSTANCE }
 Graph type ID for convenient run-time type checking. More...
 

Public Member Functions

 Graph (std::string name, ID id)
 Construct a new graph.
 
ID id () const
 Return the graph type ID.
 
bool IsComponent () const
 Return true if this graph is a component, false otherwise.
 
bool IsInstance () const
 Return true if this graph is an instance, false otherwise.
 
virtual GraphAdd (const std::shared_ptr< Object > &object)
 Add an object to the component.
 
virtual GraphAdd (const std::vector< std::shared_ptr< Object >> &objects)
 Add a list of objects to the component.
 
virtual GraphRemove (Object *obj)
 Remove an object from the component.
 
template<typename T >
std::vector< T * > GetAll () const
 Get all objects of a specific type.
 
template<typename T >
T * Get (const std::string &name) const
 Get one object of a specific type.
 
std::optional< Node * > FindNode (const std::string &node_name) const
 Find a node with a specific name.
 
NodeGetNode (const std::string &node_name) const
 Get a Node of a specific type with a specific name.
 
Nodeoperator() (const std::string &node_name) const
 Obtain a node by name.
 
std::vector< Node * > GetNodesOfTypes (std::initializer_list< Node::NodeID > ids) const
 Obtain all nodes which ids are in a list of Node::IDs.
 
size_t CountNodes (Node::NodeID id) const
 Count nodes of a specific node type.
 
size_t CountArrays (Node::NodeID id) const
 Count nodes of a specific array type.
 
std::vector< Node * > GetNodes () const
 Get all nodes.
 
std::vector< Node * > GetNodesOfType (Node::NodeID id) const
 Get all nodes of a specific type.
 
std::vector< NodeArray * > GetArraysOfType (Node::NodeID id) const
 Get all arrays of a specific type.
 
std::vector< Node * > GetImplicitNodes () const
 Return all graph nodes that do not explicitly belong to the graph.
 
PortArrayprt_arr (const std::string &name) const
 Shorthand to Get<PortArray>(...)
 
SignalArraysig_arr (const std::string &name) const
 Shorthand to Get<SignalArray>(...)
 
Portprt (const std::string &name) const
 Shorthand to Get<Port>(...)
 
Signalsig (const std::string &name) const
 Shorthand to Get<Signal>(...)
 
Parameterpar (const std::string &name) const
 Shorthand to Get<Parameter>(...)
 
Parameterpar (const Parameter &param) const
 Get a parameter by supplying another parameter. Lookup is done according to the name of the supplied param.
 
Parameterpar (const std::shared_ptr< Parameter > &param) const
 Get a parameter by supplying another parameter. Lookup is done according to the name of the supplied param.
 
std::unordered_map< std::string, std::string > meta () const
 Return a copy of the metadata.
 
std::vector< Object * > objects () const
 Get all objects.
 
bool Has (const std::string &name)
 Return true if object with name already exists on graph.
 
GraphSetMeta (const std::string &key, std::string value)
 Set metadata.
 
std::string ToString () const
 Return a human-readable representation.
 
std::string ToStringAllOjects () const
 Return a comma separated list of object names.
 
- Public Member Functions inherited from cerata::Named
 Named (std::string name)
 Named constructor.
 
std::string name () const
 Return the name of the object.
 
void SetName (std::string name)
 Change the name of the object.
 
virtual ~Named ()=default
 Destructor.
 

Protected Attributes

ID id_
 Graph type id for convenience.
 
std::vector< std::shared_ptr< Object > > objects_
 Graph objects.
 
std::unordered_map< std::string, std::string > meta_
 KV storage for metadata of tools or specific backend implementations.
 

Detailed Description

A graph representing a hardware structure.

Definition at line 37 of file graph.h.

Member Enumeration Documentation

◆ ID

Graph type ID for convenient run-time type checking.

Enumerator
COMPONENT 

A component graph.

INSTANCE 

An instance graph.

Definition at line 40 of file graph.h.


The documentation for this class was generated from the following files: