degate  0.1.2
Public Member Functions | Private Attributes
degate::DOTAttributes Class Reference

Helper class to handle attributes for the dot language. More...

#include <DOTAttributes.h>

List of all members.

Public Member Functions

 DOTAttributes ()
 The constructor.
 ~DOTAttributes ()
 The destructor, that destroys a DOTAttributes object.
void add (std::string const &attribute_name, std::string const &value)
 Add a key/value attribute.
template<typename T >
void add_number (std::string const &attribute_name, T value)
 Add a key/value attribute.
void add_position (long center_x, long center_y, bool preserve_position=true)
 Add a position attertribute.
std::string get_string () const
 Get the attributes as a string.

Private Attributes

std::map< std::string,
std::string > 
attributes

Detailed Description

Helper class to handle attributes for the dot language.

Definition at line 40 of file DOTAttributes.h.


Constructor & Destructor Documentation

The constructor.

Definition at line 50 of file DOTAttributes.h.

{};

The destructor, that destroys a DOTAttributes object.

Definition at line 55 of file DOTAttributes.h.

{};

Member Function Documentation

void DOTAttributes::add ( std::string const &  attribute_name,
std::string const &  value 
)

Add a key/value attribute.

If this method is called multiple times with the same attribute name, the last value is accepted.

The value string should not contain quotation marks. If it has one, you should handle the escaping by yourself.

Parameters:
attribute_nameThe attribute name as a string.
valueThe string value. You don't have to add opening and closing quotation marks.

Definition at line 26 of file DOTAttributes.cc.

References attributes.

Referenced by degate::LogicModelDOTExporter::add_connection(), degate::LogicModelDOTExporter::add_gate(), degate::LogicModelDOTExporter::add_implicit_net(), degate::LogicModelDOTExporter::add_net(), and degate::LogicModelDOTExporter::add_via().

                                                {
  std::ostringstream stm;
  stm << attribute_name << "=\"" << value << "\"";
  attributes[attribute_name] = stm.str();
}

Here is the caller graph for this function:

template<typename T >
void degate::DOTAttributes::add_number ( std::string const &  attribute_name,
value 
) [inline]

Add a key/value attribute.

If this method is called multiple times with the same attribute name, the last value is accepted.

Parameters:
attribute_nameThe attribute name as a string.
valueThe parameter value.

Definition at line 83 of file DOTAttributes.h.

References attributes.

Referenced by degate::LogicModelDOTExporter::add_via().

                                                              {
      std::ostringstream stm;
      stm << attribute_name << "=\"" << value << "\"";
      attributes[attribute_name] = stm.str();
    }

Here is the caller graph for this function:

void DOTAttributes::add_position ( long  center_x,
long  center_y,
bool  preserve_position = true 
)

Add a position attertribute.

If this method is called multiple times with the same attribute name, the last value is accepted.

Parameters:
center_xThe x-coordinate for the center. Value and unit are the one from the dot coordinate system.
center_yThe y-coordinate for the center. Value and unit are the one from the dot coordinate system.
preserve_positionA boolean value that indicates if positions should be preserved. In the dot language this is expressed with a '!' flag.
See also:
http://www.graphviz.org/doc/info/attrs.html#d:pos

Definition at line 35 of file DOTAttributes.cc.

References attributes.

                                                         {
  std::ostringstream stm;
  stm << "pos" << "=\"" << center_x << "," << center_y;
  if(preserve_position) stm << "!";
  stm << "\"";
  attributes["pos"] = stm.str();
}
std::string DOTAttributes::get_string ( ) const

Get the attributes as a string.

Returns:
Returns the dot attributes as a string, you can directly write into the dot file. The string is of format [color="red",label="N3018",shape="box"], including the squared brackets.

Definition at line 45 of file DOTAttributes.cc.

References attributes.

Referenced by degate::LogicModelDOTExporter::add_connection(), degate::LogicModelDOTExporter::add_implicit_net(), degate::LogicModelDOTExporter::add_net(), and degate::LogicModelDOTExporter::add_via().

                                          {
  std::string result;

  for(std::map<std::string, std::string>::const_iterator iter = attributes.begin();
      iter != attributes.end(); ++iter) {

    if(result.size() > 0) result += ",";
    result += (*iter).second;
  }

  return std::string("[") + result + std::string("];");
}

Here is the caller graph for this function:


Member Data Documentation

std::map<std::string, std::string> degate::DOTAttributes::attributes [private]

Definition at line 43 of file DOTAttributes.h.

Referenced by add(), add_number(), add_position(), and get_string().


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