degate  0.1.2
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
degate::GateTemplatePort Class Reference

This class represents a port of a gate template. More...

#include <GateTemplatePort.h>

Inheritance diagram for degate::GateTemplatePort:
Inheritance graph
[legend]

List of all members.

Public Types

enum  PORT_TYPE {
  PORT_TYPE_UNDEFINED = 0,
  PORT_TYPE_IN = 1,
  PORT_TYPE_OUT = 2,
  PORT_TYPE_INOUT = 3
}
 Enum to define type of ports. More...

Public Member Functions

 GateTemplatePort (int _x, int _y, PORT_TYPE _port_type=PORT_TYPE_UNDEFINED)
 Create a template port.
 GateTemplatePort (PORT_TYPE _port_type=PORT_TYPE_UNDEFINED)
 Create a template port.
virtual ~GateTemplatePort ()
virtual bool is_position_defined () const
 Check if a position is defined for the port.
virtual void set_point (Point p)
 Set the port position within the gate template.
virtual bool is_inport () const
 Check if a port is of type input port or an in-out-port.
virtual bool is_outport () const
 Check if a port is of type output port or an in-out-port.
virtual bool is_inoutport () const
 Check if a port is of type tristate.
virtual bool has_undefined_port_type () const
 Check if a port is of type is undefined.
virtual void set_port_type (PORT_TYPE _port_type)
 Set the port type.
virtual PORT_TYPE get_port_type () const
 Get the port type.
virtual const std::string get_port_type_as_string () const
 Get a human readable string, that describes the port type.
virtual Point const & get_point () const
 Get the port position within the gate template.
virtual int get_x () const
 Get the x position for a port.
virtual int get_y () const
 Get the y position for a port.
DeepCopyable_shptr cloneShallow () const
 Return a copy of this object, but with all references to other DeepCopyables cleared (e.g.
void cloneDeepInto (DeepCopyable_shptr dest, oldnew_t *oldnew) const
 Deep-copy all members to destination.

Static Public Member Functions

static PORT_TYPE get_port_type_from_string (std::string const &port_type_str)
 Parse a port type type indicating string.

Private Attributes

Point point
PORT_TYPE port_type
bool position_defined

Detailed Description

This class represents a port of a gate template.

Definition at line 35 of file GateTemplatePort.h.


Member Enumeration Documentation

Enum to define type of ports.

Enumerator:
PORT_TYPE_UNDEFINED 
PORT_TYPE_IN 
PORT_TYPE_OUT 
PORT_TYPE_INOUT 

Definition at line 42 of file GateTemplatePort.h.


Constructor & Destructor Documentation

degate::GateTemplatePort::GateTemplatePort ( int  _x,
int  _y,
PORT_TYPE  _port_type = PORT_TYPE_UNDEFINED 
) [inline]

Create a template port.

Definition at line 63 of file GateTemplatePort.h.

                                                                                 :
      point(_x, _y), port_type(_port_type), position_defined( true) {
    }

Create a template port.

Definition at line 71 of file GateTemplatePort.h.

                                                                 :
      point(0, 0), port_type(_port_type), position_defined(false) {
    }
virtual degate::GateTemplatePort::~GateTemplatePort ( ) [inline, virtual]

Definition at line 76 of file GateTemplatePort.h.

{}

Member Function Documentation

void degate::GateTemplatePort::cloneDeepInto ( DeepCopyable_shptr  destination,
oldnew_t oldnew 
) const [inline, virtual]

Deep-copy all members to destination.

Todo:
Find out whether the default assignment operator can be used to simplify implementations of this method.

Reimplemented from degate::ColoredObject.

Definition at line 87 of file GateTemplatePort.h.

Return a copy of this object, but with all references to other DeepCopyables cleared (e.g.

set to 0-pointer).

Implements degate::DeepCopyable.

Definition at line 79 of file GateTemplatePort.h.

References is_position_defined(), point, and port_type.

                                            {
      auto clone = std::make_shared<GateTemplatePort>(port_type);
      if (is_position_defined()) {
        clone->set_point(point);
      }
      return clone;
    };

Here is the call graph for this function:

virtual Point const& degate::GateTemplatePort::get_point ( ) const [inline, virtual]

Get the port position within the gate template.

Returns:
Returns the position in relative coordinates related to the left upper corner of the gate template.

Definition at line 169 of file GateTemplatePort.h.

References point.

{ return point; }
virtual PORT_TYPE degate::GateTemplatePort::get_port_type ( ) const [inline, virtual]

Get the port type.

Definition at line 145 of file GateTemplatePort.h.

References port_type.

{ return port_type; }
virtual const std::string degate::GateTemplatePort::get_port_type_as_string ( ) const [inline, virtual]

Get a human readable string, that describes the port type.

That is "in", "out" or "tristate".

Definition at line 152 of file GateTemplatePort.h.

References port_type, PORT_TYPE_IN, PORT_TYPE_INOUT, PORT_TYPE_OUT, and PORT_TYPE_UNDEFINED.

                                                            {
      switch(port_type) {
      case PORT_TYPE_IN: return std::string("in");
      case PORT_TYPE_OUT: return std::string("out");
      case PORT_TYPE_INOUT: return std::string("inout");

      case PORT_TYPE_UNDEFINED:
      default: return std::string("undefined");
      }
    }
static PORT_TYPE degate::GateTemplatePort::get_port_type_from_string ( std::string const &  port_type_str) [inline, static]

Parse a port type type indicating string.

Exceptions:
DegateRuntimeExceptionThis exception is thrown if the string cannot be parsed.

Definition at line 194 of file GateTemplatePort.h.

References PORT_TYPE_IN, PORT_TYPE_INOUT, PORT_TYPE_OUT, and PORT_TYPE_UNDEFINED.

                                                                               {

      if(port_type_str == "undefined") return GateTemplatePort::PORT_TYPE_UNDEFINED;
      else if(port_type_str == "in") return  GateTemplatePort::PORT_TYPE_IN;
      else if(port_type_str == "out") return GateTemplatePort::PORT_TYPE_OUT;
      else if(port_type_str == "inout") return GateTemplatePort::PORT_TYPE_INOUT;
      else throw DegateRuntimeException("Can't parse port type.");
    }
virtual int degate::GateTemplatePort::get_x ( ) const [inline, virtual]

Get the x position for a port.

Returns:
Returns the postion relative to the left upper corner of the gate template.

Definition at line 177 of file GateTemplatePort.h.

References degate::Point::get_x(), and point.

{ return point.get_x(); }

Here is the call graph for this function:

virtual int degate::GateTemplatePort::get_y ( ) const [inline, virtual]

Get the y position for a port.

Returns:
Returns the postion relative to the left upper corner of the gate template.

Definition at line 185 of file GateTemplatePort.h.

References degate::Point::get_y(), and point.

{ return point.get_y(); }

Here is the call graph for this function:

virtual bool degate::GateTemplatePort::has_undefined_port_type ( ) const [inline, virtual]

Check if a port is of type is undefined.

Definition at line 133 of file GateTemplatePort.h.

References port_type, and PORT_TYPE_UNDEFINED.

virtual bool degate::GateTemplatePort::is_inoutport ( ) const [inline, virtual]

Check if a port is of type tristate.

Definition at line 127 of file GateTemplatePort.h.

References port_type, and PORT_TYPE_INOUT.

Referenced by is_inport(), and is_outport().

{ return port_type == PORT_TYPE_INOUT; }

Here is the caller graph for this function:

virtual bool degate::GateTemplatePort::is_inport ( ) const [inline, virtual]

Check if a port is of type input port or an in-out-port.

Definition at line 115 of file GateTemplatePort.h.

References is_inoutport(), port_type, and PORT_TYPE_IN.

{ return port_type == PORT_TYPE_IN || is_inoutport(); }

Here is the call graph for this function:

virtual bool degate::GateTemplatePort::is_outport ( ) const [inline, virtual]

Check if a port is of type output port or an in-out-port.

Definition at line 121 of file GateTemplatePort.h.

References is_inoutport(), port_type, and PORT_TYPE_OUT.

{ return port_type == PORT_TYPE_OUT || is_inoutport(); }

Here is the call graph for this function:

virtual bool degate::GateTemplatePort::is_position_defined ( ) const [inline, virtual]

Check if a position is defined for the port.

Definition at line 97 of file GateTemplatePort.h.

References position_defined.

Referenced by cloneShallow().

{ return position_defined; }

Here is the caller graph for this function:

virtual void degate::GateTemplatePort::set_point ( Point  p) [inline, virtual]

Set the port position within the gate template.

The position is in relative coordinates related to the left upper corner of the gate template.

Definition at line 106 of file GateTemplatePort.h.

References point, and position_defined.

                                    {
      position_defined = true;
      point = p;
    }
virtual void degate::GateTemplatePort::set_port_type ( PORT_TYPE  _port_type) [inline, virtual]

Set the port type.

Definition at line 139 of file GateTemplatePort.h.

References port_type.

{ port_type = _port_type; }

Member Data Documentation

Definition at line 51 of file GateTemplatePort.h.

Referenced by cloneShallow(), get_point(), get_x(), get_y(), and set_point().

Definition at line 54 of file GateTemplatePort.h.

Referenced by is_position_defined(), and set_point().


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