revlib_processor Class Reference

Base class for actions on the revlib_parser. More...

Inheritance diagram for revlib_processor:
circuit_processor specification_processor

List of all members.

Public Member Functions

 revlib_processor ()
 Default constructor.
virtual ~revlib_processor ()
 Default deconstructor.

Protected Member Functions

virtual void on_comment (const std::string &comment) const
 Called when parsing comments.
virtual void on_version (const std::string &version) const
 Called when parsing .version command.
virtual void on_numvars (unsigned numvars) const
 Called when parsing .numvars command.
virtual void on_variables (std::vector< std::string >::const_iterator first, std::vector< std::string >::const_iterator last) const
 Called when parsing .variables command.
virtual void on_inputs (std::vector< std::string >::const_iterator first, std::vector< std::string >::const_iterator last) const
 Called when parsing .inputs command.
virtual void on_outputs (std::vector< std::string >::const_iterator first, std::vector< std::string >::const_iterator last) const
 Called when parsing .outputs command.
virtual void on_constants (std::vector< constant >::const_iterator first, std::vector< constant >::const_iterator last) const
 Called when parsing the .constants command.
virtual void on_garbage (std::vector< bool >::const_iterator first, std::vector< bool >::const_iterator last) const
 Called when parsing .garbage command.
virtual void on_begin () const
 Called when parsing .begin command.
virtual void on_end () const
 Called when parsing .begin command.
virtual void on_gate (const boost::any &target_type, const std::vector< unsigned > &line_indices) const
 Called when a gate is parsed.
virtual void on_truth_table_line (unsigned line_index, const std::vector< boost::optional< bool > >::const_iterator first, const std::vector< boost::optional< bool > >::const_iterator last) const
 Called when a truth table line is parsed.
const std::string & variable (std::vector< std::string >::size_type index) const
 Returns the variable name to a given line index.

Friends

bool revlib_parser (std::istream &in, revlib_processor &reader, std::string *error)
 A parser for the RevLib file format.

Detailed Description

Base class for actions on the revlib_parser.

The RevLib file parser revlib_parser(std::istream&, revlib_processor&, std::string*) gets an instance of a revlib_processor object as parameter.

For creating a circuit a circuit_processor already exists. Other processors can be implemented by inhereting from this class.

The base class provides virtual functions for each command in a RevLib file with corresponding parameters.

Only the methods which data is needed must be overriden.

Author:
RevKit
Since:
1.0

Constructor & Destructor Documentation

Default constructor.

Initializes private data

Author:
RevKit
Since:
1.0
virtual ~revlib_processor (  )  [virtual]

Default deconstructor.

Clears private data

Author:
RevKit
Since:
1.0

Member Function Documentation

virtual void on_begin (  )  const [protected, virtual]

Called when parsing .begin command.

This method is called when a .begin command is parsed.

Author:
RevKit
Since:
1.0
virtual void on_comment ( const std::string &  comment  )  const [protected, virtual]

Called when parsing comments.

This method is called when a comment (starting with a #) is parsed. The comment (text after the #) is stored in the parameter comment.

Parameters:
comment Comment (single line)
Author:
RevKit
Since:
1.0
virtual void on_constants ( std::vector< constant >::const_iterator  first,
std::vector< constant >::const_iterator  last 
) const [protected, virtual]

Called when parsing the .constants command.

This method is called when a .constants command is parsed. The constant in a std::vector can be accessed via their first and last iterator. A optional boolean value indicates whether the line is constant or not and in case it is constant, which constant line is represented.

Parameters:
first Begin iterator of constants vector
last End iterator of constants vector
Author:
RevKit
Since:
1.0

Reimplemented in circuit_processor, and specification_processor.

virtual void on_end (  )  const [protected, virtual]

Called when parsing .begin command.

This method is called when a .begin command is parsed.

Author:
RevKit
Since:
1.0
virtual void on_garbage ( std::vector< bool >::const_iterator  first,
std::vector< bool >::const_iterator  last 
) const [protected, virtual]

Called when parsing .garbage command.

This method is called when a .garbage command is parsed. The garbage in a std::vector can be accessed via their first and last iterator. A boolean value indicates whether the line has a garbage output or not.

Parameters:
first Begin iterator of garbage vector
last End iterator of garbage vector
Author:
RevKit
Since:
1.0

Reimplemented in circuit_processor, and specification_processor.

virtual void on_gate ( const boost::any &  target_type,
const std::vector< unsigned > &  line_indices 
) const [protected, virtual]

Called when a gate is parsed.

This method is called when a gate is parsed providing the gate type in parameter target_type and all connected line via their zero-index indices.

The last indices in the list line_indices are the target lines. The number of target lines depends on the corresponding gate type.

Parameters:
target_type Target type of the target line(s).
line_indices All connected lines, both control and target lines.
Author:
RevKit
Since:
1.0

Reimplemented in circuit_processor.

virtual void on_inputs ( std::vector< std::string >::const_iterator  first,
std::vector< std::string >::const_iterator  last 
) const [protected, virtual]

Called when parsing .inputs command.

This method is called when a .inputs command is parsed. The inputs in a std::vector can be accessed via their first and last iterator.

Parameters:
first Begin iterator of inputs vector
last End iterator of inputs vector
Author:
RevKit
Since:
1.0

Reimplemented in circuit_processor, and specification_processor.

virtual void on_numvars ( unsigned  numvars  )  const [protected, virtual]

Called when parsing .numvars command.

This method is called when a .numvars command is parsed. The number of variables is stored in the parameter numvars.

Parameters:
numvars Number of variables
Author:
RevKit
Since:
1.0

Reimplemented in circuit_processor.

virtual void on_outputs ( std::vector< std::string >::const_iterator  first,
std::vector< std::string >::const_iterator  last 
) const [protected, virtual]

Called when parsing .outputs command.

This method is called when a .outputs command is parsed. The outputs in a std::vector can be accessed via their first and last iterator.

Parameters:
first Begin iterator of outputs vector
last End iterator of outputs vector
Author:
RevKit
Since:
1.0

Reimplemented in circuit_processor, and specification_processor.

virtual void on_truth_table_line ( unsigned  line_index,
const std::vector< boost::optional< bool > >::const_iterator  first,
const std::vector< boost::optional< bool > >::const_iterator  last 
) const [protected, virtual]

Called when a truth table line is parsed.

This method is called when a truth table line is parsed. A truth table line is parsed in a specification file.

The truth table line is given as first and last iterator over boost::optional<bool> values and as additional parameter the corresponding truth table line is given.

Parameters:
line_index The corresponding truth table line
first Begin iterator over truth table output value
last End iterator over truth table output value
Author:
RevKit
Since:
1.0

Reimplemented in specification_processor.

virtual void on_variables ( std::vector< std::string >::const_iterator  first,
std::vector< std::string >::const_iterator  last 
) const [protected, virtual]

Called when parsing .variables command.

This method is called when a .variables command is parsed. The variables in a std::vector can be accessed via their first and last iterator.

Note:
When overriding this function, make sure to call the base method first, because private data is filled with the variable names already in this class to access variable names with the method variable(std::vector<std::string>::size_type).
Parameters:
first Begin iterator of variables vector
last End iterator of variables vector
Author:
RevKit
Since:
1.0
virtual void on_version ( const std::string &  version  )  const [protected, virtual]

Called when parsing .version command.

This method is called when a .version command is parsed. The version (as a std::string) is stored in the parameter version.

Parameters:
version Version
Author:
RevKit
Since:
1.0
const std::string& variable ( std::vector< std::string >::size_type  index  )  const [protected]

Returns the variable name to a given line index.

The RevLib realization file format uses variable names for line indices, introduced via the .variables command.

This method can be useful when overriding the on_gate method, to translate line indices to their variable names.

Parameters:
index Line index
Returns:
Variable name to the given line index index
Author:
RevKit
Since:
1.0

Friends And Related Function Documentation

bool revlib_parser ( std::istream &  in,
revlib_processor reader,
std::string *  error 
) [friend]

A parser for the RevLib file format.

This function can read a circuit realization and truth table specifications in a format as proposed on RevLib. The function itself just realizes the parser and uses a revlib_processor instance which provides methods for implementation details.

For example, when reading the realization into a circuit structure, the read_realization_circuit_processor class can be used as instance.

Parameters:
in Input stream containing the file
reader An instance of the revlib_processor
error A pointer to a string. In case the parsing fails, and error is not null, a error message is stored
Returns:
true on success, false otherwise
Author:
RevKit
Since:
1.0

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

Generated on Fri Jul 2 07:50:42 2010 for by doxygen 1.6.3