degate  0.1.2
Public Member Functions | Private Attributes
degate::GatePort Class Reference

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

#include <GatePort.h>

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

List of all members.

Public Member Functions

 GatePort ()
 GatePort (std::shared_ptr< Gate > _gate, std::shared_ptr< GateTemplatePort > _gate_template_port, unsigned int _diameter=5)
 Create a gate port and set a "reference" to the the template port.
 GatePort (std::shared_ptr< Gate > _gate, unsigned int _diameter=5)
 Create a gate port.
virtual ~GatePort ()
 The destructor.
virtual void set_template_port_type_id (object_id_t _template_port_id)
 Set the ID of the template port.
virtual object_id_t get_template_port_type_id () const
 Get the ID of the template port.
virtual GateTemplatePort_shptr get_template_port ()
 Get the template port.
virtual const
GateTemplatePort_shptr 
get_template_port () const
 Get the template port.
virtual void set_template_port (std::shared_ptr< GateTemplatePort > _gate_template_port)
 Set the template port.
virtual bool has_template_port () const
 Check if there is a template port defined.
virtual bool is_assigned_to_a_gate () const
 Check if a gate port already belongs to a gate.
std::shared_ptr< Gateget_gate ()
 Get the gate, this gate port belongs to.
virtual const std::string get_descriptive_identifier () const
 Get a human readable string that describes the whole logic model object.
virtual const std::string get_object_type_name () const
 Get a human readable string that names the object type.
void print (std::ostream &os=std::cout, int n_tabs=0) const
 Print gate port.
void set_x (int x)
 Set the absolute position of a port.
void set_y (int y)
 Set the absolute position of a port.
void shift_x (int delta_x)
 Shift the shape vertically.
void shift_y (int delta_y)
 Shift the shape horizontally.
void set_diameter (unsigned int diameter)
virtual bool in_bounding_box (BoundingBox const &bbox) const
 Check if this shape is in the bounding box.
virtual BoundingBox const & get_bounding_box () const
 Get the bounding box.
virtual bool in_shape (int x, int y, int max_distance=0) const
 Check in the Point with coordinates x and y is within the area of the shape.
DeepCopyable_shptr cloneShallow () const
 Return a copy of this object, but with all references to other DeepCopyables cleared (e.g.
void cloneDeepInto (DeepCopyable_shptr destination, oldnew_t *oldnew) const
 Deep-copy all members to destination.

Private Attributes

std::shared_ptr< Gategate
std::shared_ptr< GateTemplatePortgate_template_port
object_id_t template_port_id

Detailed Description

This class represents a port of a gate.

Todo:
Dispatch get_fill/frame_color() calls to GateTemplatePort::get_xxx_color(). Make sure, that colors are updated when changes are made in the PortColorManager.

Definition at line 44 of file GatePort.h.


Constructor & Destructor Documentation

degate::GatePort::GatePort ( ) [inline, explicit]

Definition at line 55 of file GatePort.h.

{};
GatePort::GatePort ( std::shared_ptr< Gate _gate,
std::shared_ptr< GateTemplatePort _gate_template_port,
unsigned int  _diameter = 5 
)

Create a gate port and set a "reference" to the the template port.

Parameters:
_gateA shared pointer to the gate, the port is created for.
_gate_template_portA shared pointer to a template port.
_diameterThe diameter of the port.

Definition at line 39 of file GatePort.cc.

                                           :
  Circle(_gate->get_min_x() +
         _gate->get_relative_x_position_within_gate(_gate_template_port->get_x()),
         _gate->get_min_y() +
         _gate->get_relative_y_position_within_gate(_gate_template_port->get_y()),
         _diameter),
  gate(_gate),
  gate_template_port(_gate_template_port),
  template_port_id(_gate_template_port->get_object_id()) {

}
GatePort::GatePort ( std::shared_ptr< Gate _gate,
unsigned int  _diameter = 5 
)

Create a gate port.

Parameters:
_gateA shared pointer to the gate, the port is created for.
diameterThe diameter of the port.

Definition at line 54 of file GatePort.cc.

                                                                    :
  Circle(0, 0, _diameter),
  gate(_gate),
  template_port_id(0) {
  //set_x(gate->get_min_x());
  //set_y(gate->get_min_y());
}
virtual degate::GatePort::~GatePort ( ) [inline, virtual]

The destructor.

Definition at line 81 of file GatePort.h.

{}

Member Function Documentation

void GatePort::cloneDeepInto ( DeepCopyable_shptr  destination,
oldnew_t oldnew 
) const [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::Circle.

Definition at line 68 of file GatePort.cc.

References gate, and gate_template_port.

                                                                            {
  auto clone = std::dynamic_pointer_cast<GatePort>(dest);
  
  clone->gate = std::dynamic_pointer_cast<Gate>(gate->cloneDeep(oldnew));
  clone->gate_template_port = std::dynamic_pointer_cast<GateTemplatePort>(gate_template_port->cloneDeep(oldnew));
  
  Circle::cloneDeepInto(dest, oldnew);
  ConnectedLogicModelObject::cloneDeepInto(dest, oldnew);
}

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 62 of file GatePort.cc.

References template_port_id.

                                                {
  auto clone = std::make_shared<GatePort>();
  clone->template_port_id = template_port_id;
  return clone;
}
virtual BoundingBox const& degate::GatePort::get_bounding_box ( ) const [inline, virtual]

Get the bounding box.

Reimplemented from degate::Circle.

Definition at line 192 of file GatePort.h.

Referenced by print().

                                                        {
      return Circle::get_bounding_box();
    }

Here is the caller graph for this function:

const std::string GatePort::get_descriptive_identifier ( ) const [virtual]

Get a human readable string that describes the whole logic model object.

The string should be unique in order to let the user identify the concrete object. But that is not a must.

Reimplemented from degate::LogicModelObjectBase.

Definition at line 123 of file GatePort.cc.

References gate, gate_template_port, degate::LogicModelObjectBase::get_object_id(), has_template_port(), and is_assigned_to_a_gate().

                                                           {

  if(has_template_port() && is_assigned_to_a_gate() &&
     gate->has_template()) {

    if(gate->has_name()) {
      boost::format fmter("%1%: %2% (%3%)");
      fmter
        % gate->get_name()
        % gate_template_port->get_name()
        % gate->get_gate_template()->get_name();
      return fmter.str();
    }
    else {
      boost::format fmter("%1% (%2%, gate=%3%)");
      fmter
        % gate_template_port->get_name()
        % gate->get_gate_template()->get_name()
        % gate->get_object_id();
      return fmter.str();
    }
  }
  else {
    boost::format fmter("Gate port %1%");
    fmter % get_object_id();
    return fmter.str();
  }

}

Here is the call graph for this function:

std::shared_ptr< Gate > GatePort::get_gate ( )

Get the gate, this gate port belongs to.

Returns:
Returns a shared pointer to a gate. A pointer value of NULL indicates, that the gate port is not assigned to a gate.
See also:
has_gate()

Definition at line 119 of file GatePort.cc.

References gate.

                                       {
  return gate;
}
const std::string GatePort::get_object_type_name ( ) const [virtual]

Get a human readable string that names the object type.

Here it is "Gate port".

Reimplemented from degate::LogicModelObjectBase.

Definition at line 154 of file GatePort.cc.

                                                     {
  return std::string("Gate port");
}

Get the template port.

Definition at line 87 of file GatePort.cc.

References gate_template_port.

Referenced by print().

                                                   {
  return gate_template_port;
}

Here is the caller graph for this function:

Get the template port.

Definition at line 91 of file GatePort.cc.

References gate_template_port.

                                                               {
  return gate_template_port;
}

Get the ID of the template port.

Definition at line 83 of file GatePort.cc.

References template_port_id.

                                                      {
  return template_port_id;
}
bool GatePort::has_template_port ( ) const [virtual]

Check if there is a template port defined.

Definition at line 110 of file GatePort.cc.

References gate_template_port.

Referenced by get_descriptive_identifier(), and print().

                                       {
  return gate_template_port != NULL;
}

Here is the caller graph for this function:

virtual bool degate::GatePort::in_bounding_box ( BoundingBox const &  bbox) const [inline, virtual]

Check if this shape is in the bounding box.

Note: it is somhow unclear if this 'in' means complete within or if an intersection is sufficient.

Reimplemented from degate::Circle.

Definition at line 188 of file GatePort.h.

                                                                {
      return Circle::in_bounding_box(bbox);
    }
virtual bool degate::GatePort::in_shape ( int  x,
int  y,
int  max_distance = 0 
) const [inline, virtual]

Check in the Point with coordinates x and y is within the area of the shape.

Reimplemented from degate::Circle.

Definition at line 196 of file GatePort.h.

                                                                    {
      return Circle::in_shape(x, y, max_distance);
    }
bool GatePort::is_assigned_to_a_gate ( ) const [virtual]

Check if a gate port already belongs to a gate.

Normally a gate port belongs to a gate.

Definition at line 114 of file GatePort.cc.

References gate.

Referenced by get_descriptive_identifier().

                                           {
  return gate != NULL;
}

Here is the caller graph for this function:

void GatePort::print ( std::ostream &  os = std::cout,
int  n_tabs = 0 
) const [virtual]

Print gate port.

Implements degate::PlacedLogicModelObject.

Definition at line 159 of file GatePort.cc.

References degate::gen_tabs(), get_bounding_box(), degate::Circle::get_diameter(), degate::LogicModelObjectBase::get_name(), degate::LogicModelObjectBase::get_object_id(), get_template_port(), degate::Circle::get_x(), degate::Circle::get_y(), has_template_port(), and degate::BoundingBox::to_string().

                                                      {

  const GateTemplatePort_shptr tmpl_port = get_template_port();

  os
    << gen_tabs(n_tabs) << "Gate port name    : " << get_name() << std::endl
    << gen_tabs(n_tabs) << "Object ID         : " << get_object_id() << std::endl
    << gen_tabs(n_tabs) << "Template Port ID  : " <<
    (has_template_port() ? tmpl_port->get_object_id() : 0)  << std::endl
    << gen_tabs(n_tabs) << "Diameter          : " << get_diameter() << std::endl
    << gen_tabs(n_tabs) << "Port position     : " << get_x() << " / " << get_y() << std::endl
    << gen_tabs(n_tabs) << "Bounding box      : " << get_bounding_box().to_string() << std::endl

    << std::endl;
    ;

}

Here is the call graph for this function:

void GatePort::set_diameter ( unsigned int  diameter) [virtual]

Reimplemented from degate::Circle.

Definition at line 199 of file GatePort.cc.

References degate::PlacedLogicModelObject::notify_shape_change().

Here is the call graph for this function:

void GatePort::set_template_port ( std::shared_ptr< GateTemplatePort _gate_template_port) [virtual]

Set the template port.

Definition at line 95 of file GatePort.cc.

References gate, gate_template_port, set_x(), and set_y().

                                                      {
  gate_template_port = _gate_template_port;
  /* If the gate port is added to a gate afterwards, this caluclation will
   be ignored. But if the port already belongs to a gate and a a template is
   set afterwards, this calculation is used.
  */
  assert(gate != NULL);
  set_x(gate->get_min_x() +
        gate->get_relative_x_position_within_gate(gate_template_port->get_x()));
  set_y(gate->get_min_y() +
        gate->get_relative_y_position_within_gate(gate_template_port->get_y()));
}

Here is the call graph for this function:

void GatePort::set_template_port_type_id ( object_id_t  _template_port_id) [virtual]

Set the ID of the template port.

Definition at line 78 of file GatePort.cc.

References template_port_id.

                                                                      {
  template_port_id = _template_port_id;
}
void GatePort::set_x ( int  x) [virtual]

Set the absolute position of a port.

Reimplemented from degate::Circle.

Definition at line 178 of file GatePort.cc.

References degate::PlacedLogicModelObject::notify_shape_change().

Referenced by set_template_port().

Here is the call graph for this function:

Here is the caller graph for this function:

void GatePort::set_y ( int  y) [virtual]

Set the absolute position of a port.

Reimplemented from degate::Circle.

Definition at line 184 of file GatePort.cc.

References degate::PlacedLogicModelObject::notify_shape_change().

Referenced by set_template_port().

Here is the call graph for this function:

Here is the caller graph for this function:

void GatePort::shift_x ( int  delta_x) [virtual]

Shift the shape vertically.

Note: If you store this shape in a QuadTree, you have to manage the changes in your QuadTree by yourself.

Reimplemented from degate::Circle.

Definition at line 189 of file GatePort.cc.

References degate::PlacedLogicModelObject::notify_shape_change().

Here is the call graph for this function:

void GatePort::shift_y ( int  delta_y) [virtual]

Shift the shape horizontally.

Note: If you store this shape in a QuadTree, you have to manage the changes in your QuadTree by yourself.

Reimplemented from degate::Circle.

Definition at line 194 of file GatePort.cc.

References degate::PlacedLogicModelObject::notify_shape_change().

Here is the call graph for this function:


Member Data Documentation

std::shared_ptr<Gate> degate::GatePort::gate [private]

Definition at line 50 of file GatePort.h.

Referenced by cloneShallow(), get_template_port_type_id(), and set_template_port_type_id().


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