7 #ifndef FORBCC_ENTITY_H 8 #define FORBCC_ENTITY_H 23 std::shared_ptr<entity> _parent;
32 entity() : _parent(nullptr), _name(
"") {};
63 std::shared_ptr<entity>
parent()
const {
82 std::string parent_name = (_parent !=
nullptr) ? _parent->codename() :
"";
84 return (parent_name.length()) ? parent_name +
"::" + _name : _name;
90 #endif //FORBCC_ENTITY_H virtual void print_declaration(code_ostream &out) const =0
Prints the declaration of the given entity, if required.
entity & operator=(entity &&)=default
This class supports moving.
entity(const std::shared_ptr< entity > &parent, const std::string &name)
Constructs an entity within a given parent.
Definition: entity.hpp:35
virtual std::string codename() const
Returns the codename of the given entity, which is the name of the entity as seen from the global sco...
Definition: entity.hpp:81
virtual void print_definition(code_ostream &out) const =0
Prints the definition of the given entity, if required.
entity()
Constructs an empty entity, used to preallocate entity variables (like in arrays) and to later use th...
Definition: entity.hpp:32
virtual ~entity()=default
Does nothing because the destructor of the shared_ptr handles all the stuff It's necessary for the de...
std::shared_ptr< entity > parent() const
Returns the parent of the given entity.
Definition: entity.hpp:63
std::string name() const
Returns the name of the given entity.
Definition: entity.hpp:68
This output stream supports indentation of code lines, which are formatted at each std::endl...
Definition: code_ostream.hpp:14
Definition: code_ostream.hpp:11
Any code entity that should be generated by the compiler: namespaces, classes, structures, methods, variables.
Definition: entity.hpp:18