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

This class represents a library of template cells. More...

#include <GateLibrary.h>

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

List of all members.

Public Types

typedef std::map< object_id_t,
GateTemplate_shptr
gate_lib_collection_t
typedef
gate_lib_collection_t::iterator 
template_iterator
typedef
gate_lib_collection_t::const_iterator 
const_template_iterator

Public Member Functions

 GateLibrary ()
 Constructor for the gate library.
virtual ~GateLibrary ()
 The dtor.
void remove_template (GateTemplate_shptr gate_template)
 Remove a template from the gate library.
void add_template (GateTemplate_shptr gate_template)
 Add a template to the library.
GateTemplate_shptr get_template (object_id_t id)
 Get a gate template from the library.
bool exists_template (object_id_t id) const
 Check if a template for a given id exists.
bool is_name_in_use (std::string const &name) const
 Check for a name in the gate library.
bool exists_template_port (object_id_t port_id)
 Check if there is a template port in the gate library with the specified object ID.
GateTemplatePort_shptr get_template_port (object_id_t port_id)
 Lookup a template port in the gate library.
template_iterator begin ()
 Get an iterator in order to iterate over gate templates.
template_iterator end ()
 Get the end marker for the iteration.
const_template_iterator begin () const
 Get an iterator in order to iterate over gate templates.
const_template_iterator end () const
 Get the end marker for the iteration.
void print (std::ostream &os)
 print the gate library.
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

gate_lib_collection_t templates

Detailed Description

This class represents a library of template cells.

Todo:
There is no way to deal with gate libraries, which have different image sizes for the gate templates than the current project. There should be a way to scale the template images, but it is unknown how to derive the scaling factor without pain.

Definition at line 42 of file GateLibrary.h.


Member Typedef Documentation

typedef gate_lib_collection_t::const_iterator degate::GateLibrary::const_template_iterator

Definition at line 48 of file GateLibrary.h.

Definition at line 46 of file GateLibrary.h.

typedef gate_lib_collection_t::iterator degate::GateLibrary::template_iterator

Definition at line 47 of file GateLibrary.h.


Constructor & Destructor Documentation

Constructor for the gate library.

Definition at line 28 of file GateLibrary.cc.

                         {
}

The dtor.

Definition at line 31 of file GateLibrary.cc.

                          {
}

Member Function Documentation

Add a template to the library.

Exceptions:
InvalidObjectIDExceptionThis exception is thrown if the template has no object ID.
InvalidPointerException

Definition at line 49 of file GateLibrary.cc.

References templates.

                                                               {

  if(gate_template == NULL) throw InvalidPointerException();
  if(!gate_template->has_valid_object_id())
    throw InvalidObjectIDException("Can't add a gate template to the gate library, "
                                   "if the template has no valid object ID.");
  else
    templates[gate_template->get_object_id()] = gate_template;
}

Get an iterator in order to iterate over gate templates.

Definition at line 124 of file GateLibrary.cc.

References templates.

Referenced by exists_template_port(), get_template_port(), is_name_in_use(), and print().

                                                {
  return templates.begin();
}

Here is the caller graph for this function:

Get an iterator in order to iterate over gate templates.

Definition at line 133 of file GateLibrary.cc.

References templates.

                                                            {
  return templates.begin();
}
void GateLibrary::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.

Implements degate::DeepCopyableBase.

Definition at line 38 of file GateLibrary.cc.

References templates.

                                                                               {
  auto clone = std::dynamic_pointer_cast<GateLibrary>(dest);
  std::for_each(templates.begin(), templates.end(), [&](const gate_lib_collection_t::value_type &v) {
    clone->templates[v.first] = std::dynamic_pointer_cast<GateTemplate>(v.second->cloneDeep(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 34 of file GateLibrary.cc.

                                                   {
  return std::make_shared<GateLibrary>();
}

Get the end marker for the iteration.

Definition at line 129 of file GateLibrary.cc.

References templates.

Referenced by exists_template_port(), get_template_port(), is_name_in_use(), and print().

                                              {
  return templates.end();
}

Here is the caller graph for this function:

Get the end marker for the iteration.

Definition at line 138 of file GateLibrary.cc.

References templates.

                                                          {
  return templates.end();
}

Check if a template for a given id exists.

Definition at line 59 of file GateLibrary.cc.

References templates.

                                                      {
  return templates.find(id) != templates.end();
}

Check if there is a template port in the gate library with the specified object ID.

Definition at line 89 of file GateLibrary.cc.

References begin(), and end().

                                                          {

  for(template_iterator iter = begin(); iter != end(); ++iter) {

    GateTemplate_shptr tmpl((*iter).second);

    for(GateTemplate::port_iterator piter = tmpl->ports_begin();
        piter != tmpl->ports_end();
        piter++) {
      if((*piter)->get_object_id() == port_id) return true;
    }
  }

  return false;
}

Here is the call graph for this function:

Get a gate template from the library.

Exceptions:
CollectionLookupExceptionThis exception is thrown if there is no gate template that has ID id.
InvalidObjectIDExceptionThis exception is thrown if the object ID is invalid.
Returns:
Returns a shared pointer to the template. The pointer value is NULL, if a template with the id was not found.

Definition at line 64 of file GateLibrary.cc.

References templates.

                                                           {

  if(id == 0)
    throw InvalidObjectIDException("Error in get_template(): Can't lookup template with id == 0");

  template_iterator found = templates.find(id);
  if(found == templates.end()) {
    boost::format f("Error in get_template(): Can't lookup gate template with ID %1%");
    f % id;
    throw CollectionLookupException(f.str());
  }
  return found->second;
}

Lookup a template port in the gate library.

Exceptions:
CollectionLookupExceptionThrows this exception, if the port was nout found.

Definition at line 106 of file GateLibrary.cc.

References begin(), and end().

                                                                         {

  for(template_iterator iter = begin(); iter != end(); ++iter) {

    GateTemplate_shptr tmpl((*iter).second);

    for(GateTemplate::port_iterator piter = tmpl->ports_begin();
        piter != tmpl->ports_end();
        piter++) {
      if((*piter)->get_object_id() == port_id) return *piter;
    }
  }

  std::ostringstream stm;
  stm << "There is no template port with ID. " << port_id << " in the gate library.";
  throw CollectionLookupException(stm.str());
}

Here is the call graph for this function:

bool GateLibrary::is_name_in_use ( std::string const &  name) const

Check for a name in the gate library.

Returns:
Returns true, if a template name is already used for a template.

Definition at line 79 of file GateLibrary.cc.

References begin(), and end().

                                                             {

  for(const_template_iterator iter = begin(); iter != end(); ++iter) {
    if((*iter).second->has_name() && (*iter).second->get_name() == name)
      return true;
  }

  return false;
}

Here is the call graph for this function:

void GateLibrary::print ( std::ostream &  os)

print the gate library.

Definition at line 143 of file GateLibrary.cc.

References begin(), and end().

                                       {
  for(template_iterator iter = begin(); iter != end(); ++iter) {
    GateTemplate_shptr tmpl = (*iter).second;

    tmpl->print(os);
    os << std::endl;

  }
}

Here is the call graph for this function:

Remove a template from the gate library.

Definition at line 45 of file GateLibrary.cc.

References templates.

                                                                  {
  templates.erase(gate_template->get_object_id());
}

Member Data Documentation


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