List of all members | Public Types | Public Member Functions
bus_collection Class Reference

Collection for buses. More...

Public Types

typedef std::map< std::string,
std::vector< unsigned > > 
map
 

Public Member Functions

 bus_collection ()
 Standard constructor. More...
 
 ~bus_collection ()
 Deconstructor. More...
 
void add (const std::string &name, const std::vector< unsigned > &line_indices, const boost::optional< unsigned > &initial_value=boost::optional< unsigned >())
 Adds a new bus to the collection. More...
 
const std::vector< unsigned > & get (const std::string &name) const
 Gets the corresponding lines of a bus by the name. More...
 
const mapbuses () const
 Returns all buses of the collection. More...
 
std::string find_bus (unsigned line_index) const
 This method finds the bus for a line. More...
 
bool has_bus (unsigned line_index) const
 This method determines whether there exists a bus for a given line. More...
 
unsigned signal_index (unsigned line_index) const
 Returns the signal index relative to the bus. More...
 
void set_initial_value (const std::string &name, unsigned initial_value)
 Sets the initial value of a bus. More...
 
boost::optional< unsigned > initial_value (const std::string &name) const
 Retrieves the initial value of a bus. More...
 

Detailed Description

Collection for buses.

This class represents a collection of buses. Using respective methods it is possible to add new buses or find buses by name or line index.

Buses are usually accessed via the methods circuit::inputbuses() and circuit::outputbuses()

Author
RevKit
Since
1.1

Member Typedef Documentation

typedef std::map<std::string, std::vector<unsigned> > map
Author
RevKit
Since
1.1

Constructor & Destructor Documentation

Standard constructor.

Author
RevKit
Since
1.1

Deconstructor.

Author
RevKit
Since
1.1

Member Function Documentation

void add ( const std::string &  name,
const std::vector< unsigned > &  line_indices,
const boost::optional< unsigned > &  initial_value = boost::optional< unsigned >() 
)

Adds a new bus to the collection.

Parameters
nameName of the bus
line_indicesCorresponding lines of the bus
initial_valueThis value can optional be set to assign an initial value to this bus.
Author
RevKit
Since
1.1
const map& buses ( ) const

Returns all buses of the collection.

This method returns all the buses of the collection.

Returns
All buses of the collection
Author
RevKit
Since
1.1
std::string find_bus ( unsigned  line_index) const

This method finds the bus for a line.

If the line belongs to a bus, the name of the bus is returned, otherwise an empty string is returned.

If the name is not important, but just the check whether the line is contained in some bus, use this method rather than bus_collection::find_bus

Parameters
line_indexIndex of the line
Returns
Name of the bus, or empty string in case the line does not belong to any bus
Author
RevKit
Since
1.1
const std::vector<unsigned>& get ( const std::string &  name) const

Gets the corresponding lines of a bus by the name.

If there is no such bus with the name name in the collection, an assertion is thrown. This method is meant to be used in conjunction with find_bus.

Parameters
nameName of the bus
Returns
Corresponding lines of the bus
Author
RevKit
Since
1.1
bool has_bus ( unsigned  line_index) const

This method determines whether there exists a bus for a given line.

If the line at line_index is contained in a bus, this method returns true, otherwise false.

If the name is not important, but just the check whether the line is contained in some bus, use this method rather than bus_collection::find_bus

Parameters
line_indexIndex of the line
Returns
true, if line at line_index is contained in a bus
boost::optional<unsigned> initial_value ( const std::string &  name) const

Retrieves the initial value of a bus.

Given a name of the bus, this method tries to retrieve an initial value. If no bus with this name exists, or if a bus exist but does not have an initial value, an empty optional is returned. Thus, this method should be used as demonstrated in the following example:

boost::optional<unsigned> iv = bus.initial_value( "bus_name" );
if ( iv )
{
// bus has the initial value *iv
std::cout << "Initial value: " << iv << std::endl;
}

If there exists a default value for the initial value, the following shorter snippet can be used:

unsigned iv = bus.initial_value( "bus_name" ).get_value_or( 0u );
Parameters
nameName of the bus
Returns
Initial value
Author
RevKit
Since
1.1
void set_initial_value ( const std::string &  name,
unsigned  initial_value 
)

Sets the initial value of a bus.

This method is used primarily for state signals, which can be assigned an initial value. This method is called with the name of the bus. If no such bus exists, this method call has no effect.

Parameters
nameName of the bus
initial_valueInitial value
Author
RevKit
Since
1.1
unsigned signal_index ( unsigned  line_index) const

Returns the signal index relative to the bus.

If e.g. a bus A is defined by the line indices 3,4,6 then the signal index of 4 is 1, since it is the 2nd signal in the bus (considering counting from 0).

This method requires, that line_index belongs to a bus, otherwise an assertion is thrown.

Parameters
line_indexIndex of the line
Returns
Index of the signal relative to the bus
Author
RevKit
Since
1.1

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

Generated on Tue Apr 16 2013 08:12:02 for RevKit by doxygen 1.8.3.1