COIN-OR::LEMON - Graph Library

Changeset 1133:9fd485470fee in lemon-0.x for src/work/deba/graph_writer.h


Ignore:
Timestamp:
02/07/05 11:48:14 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1532
Message:

Documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/deba/graph_writer.h

    r1115 r1133  
    3434namespace lemon {
    3535
     36  /// \brief Standard WriterTraits for the GraphWriter class.
     37  ///
     38  /// Standard WriterTraits for the GraphWriter class.
     39  /// It defines standard writing method for all type of value.
    3640  struct DefaultWriterTraits {
    3741
     42    /// \brief Template class for writing an value.
     43    ///
     44    /// Template class for writing an value.
    3845    template <typename _Value>
    3946    struct Writer {
     47      /// The value type.
    4048      typedef _Value Value;
    4149
     50      /// \brief Writes a value from the given stream.
     51      ///
     52      /// Writes a value from the given stream.
    4253      void write(std::ostream& os, const Value& value) {
    4354        os << value << '\t';
     
    4859
    4960
     61  /// \brief Writer class for quoted strings.
     62  ///
     63  /// Writer class for quoted strings. It can process the escape
     64  /// sequences in the string.
    5065  class QuotedStringWriter {
    5166  public:
    5267    typedef std::string Value;
    5368
     69    /// \brief Constructor for the writer.
     70    ///
     71    /// Constructor for the writer. If the given parameter is true
     72    /// the writer creates escape sequences from special characters.
    5473    QuotedStringWriter(bool _escaped = true) : escaped(_escaped) {}
    5574
     75    /// \brief Writes a quoted string from the given stream.
     76    ///
     77    /// Writes a quoted string from the given stream.
    5678    void write(std::ostream& os, const std::string& value) {
    5779      os << "\"";
     
    118140  };
    119141
    120   // Graph writer
    121142 
     143  /// \brief The graph writer class.
     144  ///
     145  /// The writer class for the graph output.
     146  /// \see graph-io-page
    122147  template <typename _Graph, typename _WriterTraits = DefaultWriterTraits>
    123148  class GraphWriter {
     
    131156
    132157    typedef _WriterTraits WriterTraits;
    133 
     158 
     159    /// \brief Construct a new GraphWriter.
     160    ///
     161    /// Construct a new GraphWriter. It writes from the given map,
     162    /// it constructs the given map and it use the given writer as the
     163    /// default skipper.
    134164    GraphWriter(std::ostream& _os, Graph& _graph) : os(_os), graph(_graph) {}
    135165
    136166
     167    /// \brief Destruct the graph writer.
     168    ///
     169    /// Destruct the graph writer.
    137170    ~GraphWriter() {
    138171      for (typename NodeMapWriters::iterator it = node_map_writers.begin();
     
    150183    // Node map rules
    151184
     185    /// \brief Add a new node map writer command for the writer.
     186    ///
     187    /// Add a new node map writer command for the writer.
    152188    template <typename Map>
    153189    GraphWriter& addNodeMap(std::string name, const Map& map) {
     
    156192    }
    157193
     194    /// \brief Add a new node map writer command for the writer.
     195    ///
     196    /// Add a new node map writer command for the writer.
    158197    template <typename Writer, typename Map>
    159198    GraphWriter& addNodeMap(std::string name, const Map& map,
    160199                              const Writer& writer = Writer()) {
    161       //      if (node_map_writers.find(name) != node_map_writers.end()) {
    162       //        throw Exception() << "Multiple write rule for node map: "
    163       //        << name;
    164       //      }
    165200      node_map_writers.push_back(
    166201        make_pair(name, new MapWriter<Node, Map, Writer>(map, writer)));
     
    170205    // Edge map rules
    171206
     207    /// \brief Add a new edge map writer command for the writer.
     208    ///
     209    /// Add a new edge map writer command for the writer.
    172210    template <typename Map>
    173211    GraphWriter& addEdgeMap(std::string name, const Map& map) {
    174       return addEdgeMap<typename WriterTraits::template Writer<typename Map::Value>, Map>(name, map);
    175     }
    176 
    177 
     212      return addEdgeMap<typename WriterTraits::template Writer<
     213        typename Map::Value>, Map>(name, map);
     214    }
     215
     216
     217    /// \brief Add a new edge map writer command for the writer.
     218    ///
     219    /// Add a new edge map writer command for the writer.
    178220    template <typename Writer, typename Map>
    179     GraphWriter& addEdgeMap(std::string name, const Map& map, const Writer& writer = Writer()) {
    180       //      if (edge_map_writers.find(name) != edge_map_writers.end()) {
    181       //        throw Exception() << "Multiple write rule for edge map: " << name;
    182       //      }
    183       edge_map_writers.push_back(make_pair(name, new MapWriter<Edge, Map, Writer>(map, writer)));
     221    GraphWriter& addEdgeMap(std::string name,
     222                            const Map& map, const Writer& writer = Writer()) {
     223      edge_map_writers.push_back(make_pair(name,
     224        new MapWriter<Edge, Map, Writer>(map, writer)));
    184225      return *this;
    185226    }
    186227
    187     // Node rules
     228    /// \brief Add a new labeled node writer for the writer.
     229    ///
     230    /// Add a new labeled node writer for the writer.
    188231    GraphWriter& addNode(std::string name, const Node& node) {
    189       //      if (node_writers.find(name) != node_writers.end()) {
    190       //        throw Exception() << "Multiple write rule for node";
    191       //      }
    192232      node_writers.push_back(make_pair(name, node));
    193233      return *this;
    194234    }
    195235
    196     // Edge rules
    197 
     236    /// \brief Add a new labeled edge writer for the writer.
     237    ///
     238    /// Add a new labeled edge writer for the writer.
    198239    GraphWriter& addEdge(std::string name, const Edge& edge) {
    199       //      if (edge_writers.find(name) != edge_writers.end()) {
    200       //        throw Exception() << "Multiple write rule for edge";
    201       //      }
    202240      edge_writers.push_back(make_pair(name, edge));
    203241      return *this;
    204242    }
    205243
    206     void write() {   
     244    /// \brief Executes the writer commands.
     245    ///
     246    /// Executes the writer commands.
     247    void run() {   
    207248      writeNodeSet();
    208249      writeEdgeSet();
Note: See TracChangeset for help on using the changeset viewer.