Essentia  2.1-beta5-dev
asciidagparser.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2010 Music Technology Group (MTG)
3  * Universitat Pompeu Fabra
4  *
5  */
6 
7 #ifndef ESSENTIA_UTILS_ASCIIDAGPARSER_H
8 #define ESSENTIA_UTILS_ASCIIDAGPARSER_H
9 
10 #include "asciidag.h"
11 
12 namespace essentia {
13 
14 
16  public:
17  // NB: template is only used so that ARRAY_SIZE can work, we only want const char*[] here
18  template <typename NetworkType>
19  AsciiDAGParser(const NetworkType& network) : _network(network) {
20  _network.addBorder(); // spares us lots of checks afterwards
21  parseGraph();
22  }
23 
30  void parseGraph();
31 
35  const std::vector<std::string>& nodes() const { return _nodes; }
36 
37 
41  const std::vector<std::pair<std::string, std::string> >& namedEdges() const { return _namedEdges; }
46  const std::vector<std::pair<int, int> >& edges() const { return _edges; }
47 
48 
49  protected:
51  std::vector<std::string> _nodes;
52  std::vector<std::pair<int, int> > _edges; // node id -> node id
53  std::vector<std::pair<std::string, std::string> > _namedEdges; // node name -> node name
54 
55  void parseEdges(const std::vector<AsciiBox>& boxes);
56 };
57 
58 } // namespace essentia
59 
60 #endif // ESSENTIA_UTILS_ASCIIDAGPARSER_H
const std::vector< std::pair< std::string, std::string > > & namedEdges() const
Definition: asciidagparser.h:41
void parseEdges(const std::vector< AsciiBox > &boxes)
Definition: asciidagparser.h:15
std::vector< std::pair< int, int > > _edges
Definition: asciidagparser.h:52
const std::vector< std::pair< int, int > > & edges() const
Definition: asciidagparser.h:46
std::vector< std::pair< std::string, std::string > > _namedEdges
Definition: asciidagparser.h:53
Definition: asciidag.h:76
AsciiDAGParser(const NetworkType &network)
Definition: asciidagparser.h:19
Definition: algorithm.h:28
std::vector< std::string > _nodes
Definition: asciidagparser.h:51
AsciiCanvas _network
Definition: asciidagparser.h:50
const std::vector< std::string > & nodes() const
Definition: asciidagparser.h:35