|
degate 0.1.1
|
The net class represents an electrical potential that is shared between electrically adjacent objects. More...
#include <Net.h>

Public Types | |
| typedef std::set< object_id_t > ::iterator | connection_iterator |
| typedef std::set< object_id_t > ::iterator | iterator |
| typedef std::set< object_id_t > ::const_iterator | const_iterator |
Public Member Functions | |
| Net () | |
| Construct a new net. | |
| virtual | ~Net () |
| Destroy a net. | |
| virtual connection_iterator | begin () |
| Get an iterator to iterate over all objects that are electrically connected with this net. | |
| virtual connection_iterator | end () |
| Get an end marker. | |
| virtual unsigned int | size () const |
| Get the number of objects that are connected with this net. | |
| const std::string | get_descriptive_identifier () const |
| Get a human readable description for the object. | |
Protected Member Functions | |
| virtual void | add_object (ConnectedLogicModelObject_shptr o) |
| Add an object of type ConnectedLogicModelObject to the net. | |
| virtual void | add_object (object_id_t oid) |
| Add an object to the net. | |
| virtual void | remove_object (ConnectedLogicModelObject_shptr o) |
| Remove an object from a net. | |
| virtual void | remove_object (object_id_t o) |
| Remove object. | |
Private Attributes | |
| std::set< object_id_t > | connections |
Friends | |
| class | ConnectedLogicModelObject |
The net class represents an electrical potential that is shared between electrically adjacent objects.
Why do methods in class Net work with object ID instead of shared pointers? There is an automatism. A ConnectedLogicModelObject adds itself to a net, if you set the net for the ConnectedLogicModelObject. And it removes itself from a Net object, if it's destructor is called. The problem is, that the ConnectedLogicModelObject itself only has a this pointer. An object can't have a shared pointer to itself. One could work with normal pointers, but this would somehow circumvent shared pointer approach in libdegate. So we use loosely coupled object IDs.
| typedef std::set<object_id_t>::iterator degate::Net::connection_iterator |
| typedef std::set<object_id_t>::const_iterator degate::Net::const_iterator |
| typedef std::set<object_id_t>::iterator degate::Net::iterator |
| Net::~Net | ( | ) | [virtual] |
| void Net::add_object | ( | ConnectedLogicModelObject_shptr | o | ) | [protected, virtual] |
Add an object of type ConnectedLogicModelObject to the net.
It is silently ignored, if the object is already referenced from the net.
| InvalidObjectIDException | This exception is thrown if the object has an invalid object ID. |
Definition at line 74 of file Net.cc.
{
add_object(o->get_object_id());
}
| void Net::add_object | ( | object_id_t | oid | ) | [protected, virtual] |
Add an object to the net.
Definition at line 66 of file Net.cc.
References connections.
{
if(oid == 0)
throw InvalidObjectIDException("The object that has to be "
"added to the net has no object ID.");
else
connections.insert(oid);
}
| Net::connection_iterator Net::begin | ( | ) | [virtual] |
Get an iterator to iterate over all objects that are electrically connected with this net.
Be careful with iterator invalidation!
Definition at line 38 of file Net.cc.
References connections.
{
return connections.begin();
}
| Net::connection_iterator Net::end | ( | ) | [virtual] |
Get an end marker.
Definition at line 42 of file Net.cc.
References connections.
{
return connections.end();
}
| const std::string Net::get_descriptive_identifier | ( | ) | const [virtual] |
Get a human readable description for the object.
Reimplemented from degate::LogicModelObjectBase.
Definition at line 84 of file Net.cc.
References degate::LogicModelObjectBase::get_object_id().
{
boost::format fmter("Net %1%");
fmter % get_object_id();;
return fmter.str();
}

| void Net::remove_object | ( | object_id_t | o | ) | [protected, virtual] |
Remove object.
Definition at line 46 of file Net.cc.
References connections.
{
if(oid == 0)
throw InvalidObjectIDException("The object that has to be "
"removed from the net has no object ID.");
connection_iterator i = connections.find(oid);
if(i != connections.end()) {
connections.erase(i);
}
else
throw CollectionLookupException("Can't remove object from the the net, "
"because it is not in the net.");
}
| void Net::remove_object | ( | ConnectedLogicModelObject_shptr | o | ) | [protected, virtual] |
Remove an object from a net.
| CollectionLookupException | Indicates that the object is not referenced from the net. |
| InvalidObjectIDException | As in add_object(). |
Definition at line 61 of file Net.cc.
{
remove_object(o->get_object_id());
}
| unsigned int Net::size | ( | ) | const [virtual] |
Get the number of objects that are connected with this net.
Definition at line 80 of file Net.cc.
References connections.
{
return connections.size();
}
friend class ConnectedLogicModelObject [friend] |
std::set<object_id_t> degate::Net::connections [private] |
Definition at line 58 of file Net.h.
Referenced by add_object(), begin(), end(), remove_object(), and size().
1.7.4