|
degate 0.1.1
|
This class represents a library of template cells. More...
#include <GateLibrary.h>
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. | |
Private Attributes | |
| gate_lib_collection_t | templates |
This class represents a library of template cells.
Definition at line 40 of file GateLibrary.h.
| typedef gate_lib_collection_t::const_iterator degate::GateLibrary::const_template_iterator |
Definition at line 46 of file GateLibrary.h.
| typedef std::map<object_id_t, GateTemplate_shptr> degate::GateLibrary::gate_lib_collection_t |
Definition at line 44 of file GateLibrary.h.
| typedef gate_lib_collection_t::iterator degate::GateLibrary::template_iterator |
Definition at line 45 of file GateLibrary.h.
| GateLibrary::GateLibrary | ( | ) |
| GateLibrary::~GateLibrary | ( | ) | [virtual] |
| void GateLibrary::add_template | ( | GateTemplate_shptr | gate_template | ) |
Add a template to the library.
| InvalidObjectIDException | This exception is thrown if the template has no object ID. |
| InvalidPointerException |
Definition at line 38 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;
}
| GateLibrary::template_iterator GateLibrary::begin | ( | ) |
Get an iterator in order to iterate over gate templates.
Definition at line 113 of file GateLibrary.cc.
References templates.
Referenced by exists_template_port(), get_template_port(), is_name_in_use(), and print().
{
return templates.begin();
}

| GateLibrary::const_template_iterator GateLibrary::begin | ( | ) | const |
Get an iterator in order to iterate over gate templates.
Definition at line 122 of file GateLibrary.cc.
References templates.
{
return templates.begin();
}
| GateLibrary::template_iterator GateLibrary::end | ( | ) |
Get the end marker for the iteration.
Definition at line 118 of file GateLibrary.cc.
References templates.
Referenced by exists_template_port(), get_template_port(), is_name_in_use(), and print().
{
return templates.end();
}

| GateLibrary::const_template_iterator GateLibrary::end | ( | ) | const |
Get the end marker for the iteration.
Definition at line 127 of file GateLibrary.cc.
References templates.
{
return templates.end();
}
| bool GateLibrary::exists_template | ( | object_id_t | id | ) | const |
Check if a template for a given id exists.
Definition at line 48 of file GateLibrary.cc.
References templates.
| bool GateLibrary::exists_template_port | ( | object_id_t | port_id | ) |
Check if there is a template port in the gate library with the specified object ID.
Definition at line 78 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;
}

| GateTemplate_shptr GateLibrary::get_template | ( | object_id_t | id | ) |
Get a gate template from the library.
| CollectionLookupException | This exception is thrown if there is no gate template that has ID id. |
| InvalidObjectIDException | This exception is thrown if the object ID is invalid. |
id was not found. Definition at line 53 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;
}
| GateTemplatePort_shptr GateLibrary::get_template_port | ( | object_id_t | port_id | ) |
Lookup a template port in the gate library.
| CollectionLookupException | Throws this exception, if the port was nout found. |
Definition at line 95 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());
}

| bool GateLibrary::is_name_in_use | ( | std::string const & | name | ) | const |
Check for a name in the gate library.
Definition at line 68 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;
}

| void GateLibrary::print | ( | std::ostream & | os | ) |
print the gate library.
Definition at line 132 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;
}
}

| void GateLibrary::remove_template | ( | GateTemplate_shptr | gate_template | ) |
Remove a template from the gate library.
Definition at line 34 of file GateLibrary.cc.
References templates.
{
templates.erase(gate_template->get_object_id());
}
Definition at line 50 of file GateLibrary.h.
Referenced by add_template(), begin(), end(), exists_template(), get_template(), and remove_template().
1.7.4