souffle  2.0.2-371-g6315b36
Public Member Functions | Protected Member Functions | Protected Attributes
souffle::ast::Relation Class Reference

Defines a relation with a name, attributes, qualifiers, and internal representation. More...

#include <Relation.h>

Inheritance diagram for souffle::ast::Relation:
Inheritance graph
Collaboration diagram for souffle::ast::Relation:
Collaboration graph

Public Member Functions

void addAttribute (Own< Attribute > attr)
 Add a new used type to this relation. More...
 
void addQualifier (RelationQualifier q)
 Add qualifier to this relation. More...
 
void apply (const NodeMapper &map) override
 Apply the mapper to all child nodes. More...
 
Relationclone () const override
 Create a clone (i.e. More...
 
size_t getArity () const
 Return the arity of this relation. More...
 
std::vector< Attribute * > getAttributes () const
 Get relation attributes. More...
 
std::vector< const Node * > getChildNodes () const override
 Obtain a list of all embedded AST child nodes. More...
 
const QualifiedNamegetQualifiedName () const
 Get qualified relation name. More...
 
const std::set< RelationQualifier > & getQualifiers () const
 Get relation qualifiers. More...
 
RelationRepresentation getRepresentation () const
 Get relation representation. More...
 
bool hasQualifier (RelationQualifier q) const
 Check for a relation qualifier. More...
 
 Relation ()=default
 
 Relation (QualifiedName name, SrcLocation loc={})
 
void removeQualifier (RelationQualifier q)
 Remove qualifier from this relation. More...
 
void setAttributes (VecOwn< Attribute > attrs)
 Set relation attributes. More...
 
void setQualifiedName (QualifiedName n)
 Set name for this relation. More...
 
void setRepresentation (RelationRepresentation representation)
 Set relation representation. More...
 
- Public Member Functions inherited from souffle::ast::Node
std::string extloc () const
 Return source location of the syntactic element. More...
 
const SrcLocationgetSrcLoc () const
 Return source location of the Node. More...
 
 Node (SrcLocation loc={})
 
bool operator!= (const Node &other) const
 Inequality check for two AST nodes. More...
 
bool operator== (const Node &other) const
 Equivalence check for two AST nodes. More...
 
void setSrcLoc (SrcLocation l)
 Set source location for the Node. More...
 
virtual ~Node ()=default
 

Protected Member Functions

bool equal (const Node &node) const override
 Abstract equality check for two AST nodes. More...
 
void print (std::ostream &os) const override
 Output to a given output stream. More...
 

Protected Attributes

VecOwn< Attributeattributes
 Attributes of the relation. More...
 
QualifiedName name
 Name of relation. More...
 
std::set< RelationQualifierqualifiers
 Qualifiers of relation. More...
 
RelationRepresentation representation {RelationRepresentation::DEFAULT}
 Datastructure to use for this relation. More...
 

Detailed Description

Defines a relation with a name, attributes, qualifiers, and internal representation.

Definition at line 49 of file Relation.h.

Constructor & Destructor Documentation

◆ Relation() [1/2]

souffle::ast::Relation::Relation ( )
default

◆ Relation() [2/2]

souffle::ast::Relation::Relation ( QualifiedName  name,
SrcLocation  loc = {} 
)
inline

Definition at line 52 of file Relation.h.

56  {

Member Function Documentation

◆ addAttribute()

void souffle::ast::Relation::addAttribute ( Own< Attribute attr)
inline

Add a new used type to this relation.

Definition at line 67 of file Relation.h.

67  {
68  return attributes.size();
69  }
70 

References attributes.

◆ addQualifier()

void souffle::ast::Relation::addQualifier ( RelationQualifier  q)
inline

Add qualifier to this relation.

Definition at line 93 of file Relation.h.

97  {

◆ apply()

void souffle::ast::Relation::apply ( const NodeMapper )
inlineoverridevirtual

Apply the mapper to all child nodes.

Reimplemented from souffle::ast::Node.

Definition at line 125 of file Relation.h.

125  {
126  std::vector<const Node*> res;
127  for (const auto& cur : attributes) {
128  res.push_back(cur.get());
129  }

References attributes.

◆ clone()

Relation* souffle::ast::Relation::clone ( ) const
inlineoverridevirtual

Create a clone (i.e.

deep copy) of this node

Implements souffle::ast::Node.

Definition at line 117 of file Relation.h.

119  {
120  for (auto& cur : attributes) {
121  cur = map(std::move(cur));
122  }
123  }

◆ equal()

bool souffle::ast::Relation::equal ( const Node ) const
inlineoverrideprotectedvirtual

Abstract equality check for two AST nodes.

Reimplemented from souffle::ast::Node.

Definition at line 145 of file Relation.h.

◆ getArity()

size_t souffle::ast::Relation::getArity ( ) const
inline

Return the arity of this relation.

Definition at line 73 of file Relation.h.

◆ getAttributes()

std::vector<Attribute*> souffle::ast::Relation::getAttributes ( ) const
inline

Get relation attributes.

Definition at line 83 of file Relation.h.

87  {

◆ getChildNodes()

std::vector<const Node*> souffle::ast::Relation::getChildNodes ( ) const
inlineoverridevirtual

Obtain a list of all embedded AST child nodes.

Reimplemented from souffle::ast::Node.

Definition at line 131 of file Relation.h.

133  :
134  void print(std::ostream& os) const override {
135  os << ".decl " << getQualifiedName() << "(" << join(attributes, ", ") << ")" << join(qualifiers, " ")
136  << " " << representation;
137  }

◆ getQualifiedName()

const QualifiedName& souffle::ast::Relation::getQualifiedName ( ) const
inline

Get qualified relation name.

Definition at line 57 of file Relation.h.

61  {

◆ getQualifiers()

const std::set<RelationQualifier>& souffle::ast::Relation::getQualifiers ( ) const
inline

Get relation qualifiers.

Definition at line 88 of file Relation.h.

92  {

◆ getRepresentation()

RelationRepresentation souffle::ast::Relation::getRepresentation ( ) const
inline

Get relation representation.

Definition at line 103 of file Relation.h.

107  {

◆ hasQualifier()

bool souffle::ast::Relation::hasQualifier ( RelationQualifier  q) const
inline

Check for a relation qualifier.

Definition at line 113 of file Relation.h.

119  {

◆ print()

void souffle::ast::Relation::print ( std::ostream &  os) const
inlineoverrideprotectedvirtual

Output to a given output stream.

Implements souffle::ast::Node.

Definition at line 140 of file Relation.h.

◆ removeQualifier()

void souffle::ast::Relation::removeQualifier ( RelationQualifier  q)
inline

Remove qualifier from this relation.

Definition at line 98 of file Relation.h.

102  {

◆ setAttributes()

void souffle::ast::Relation::setAttributes ( VecOwn< Attribute attrs)
inline

Set relation attributes.

Definition at line 78 of file Relation.h.

◆ setQualifiedName()

void souffle::ast::Relation::setQualifiedName ( QualifiedName  n)
inline

Set name for this relation.

Definition at line 62 of file Relation.h.

67  {

◆ setRepresentation()

void souffle::ast::Relation::setRepresentation ( RelationRepresentation  representation)
inline

Set relation representation.

Definition at line 108 of file Relation.h.

111  {

Field Documentation

◆ attributes

VecOwn<Attribute> souffle::ast::Relation::attributes
protected

Attributes of the relation.

Definition at line 154 of file Relation.h.

Referenced by addAttribute(), and apply().

◆ name

QualifiedName souffle::ast::Relation::name
protected

Name of relation.

Definition at line 151 of file Relation.h.

◆ qualifiers

std::set<RelationQualifier> souffle::ast::Relation::qualifiers
protected

Qualifiers of relation.

Definition at line 157 of file Relation.h.

◆ representation

RelationRepresentation souffle::ast::Relation::representation {RelationRepresentation::DEFAULT}
protected

Datastructure to use for this relation.

Definition at line 160 of file Relation.h.


The documentation for this class was generated from the following file:
souffle::ast::Relation::attributes
VecOwn< Attribute > attributes
Attributes of the relation.
Definition: Relation.h:154
souffle::ast::Relation::print
void print(std::ostream &os) const override
Output to a given output stream.
Definition: Relation.h:140
souffle::map
auto map(const std::vector< A > &xs, F &&f)
Applies a function to each element of a vector and returns the results.
Definition: ContainerUtil.h:158
souffle::join
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...
Definition: StreamUtil.h:175
souffle::ast::Relation::representation
RelationRepresentation representation
Datastructure to use for this relation.
Definition: Relation.h:160
souffle::ast::Relation::getQualifiedName
const QualifiedName & getQualifiedName() const
Get qualified relation name.
Definition: Relation.h:57
souffle::ast::Relation::qualifiers
std::set< RelationQualifier > qualifiers
Qualifiers of relation.
Definition: Relation.h:157