Essentia  2.1-beta6-dev
asciidagparser.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 Music Technology Group - Universitat Pompeu Fabra
3  *
4  * This file is part of Essentia
5  *
6  * Essentia is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License as published by the Free
8  * Software Foundation (FSF), either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the Affero GNU General Public License
17  * version 3 along with this program. If not, see http://www.gnu.org/licenses/
18  */
19 
20 #ifndef ESSENTIA_UTILS_ASCIIDAGPARSER_H
21 #define ESSENTIA_UTILS_ASCIIDAGPARSER_H
22 
23 #include "asciidag.h"
24 
25 namespace essentia {
26 
27 
29  public:
30  // NB: template is only used so that ARRAY_SIZE can work, we only want const char*[] here
31  template <typename NetworkType>
32  AsciiDAGParser(const NetworkType& network) : _network(network) {
33  _network.addBorder(); // spares us lots of checks afterwards
34  parseGraph();
35  }
36 
43  void parseGraph();
44 
48  const std::vector<std::string>& nodes() const { return _nodes; }
49 
50 
54  const std::vector<std::pair<std::string, std::string> >& namedEdges() const { return _namedEdges; }
59  const std::vector<std::pair<int, int> >& edges() const { return _edges; }
60 
61 
62  protected:
64  std::vector<std::string> _nodes;
65  std::vector<std::pair<int, int> > _edges; // node id -> node id
66  std::vector<std::pair<std::string, std::string> > _namedEdges; // node name -> node name
67 
68  void parseEdges(const std::vector<AsciiBox>& boxes);
69 };
70 
71 } // namespace essentia
72 
73 #endif // ESSENTIA_UTILS_ASCIIDAGPARSER_H
Definition: asciidag.h:76
Definition: asciidagparser.h:28
const std::vector< std::pair< int, int > > & edges() const
Definition: asciidagparser.h:59
const std::vector< std::string > & nodes() const
Definition: asciidagparser.h:48
std::vector< std::pair< int, int > > _edges
Definition: asciidagparser.h:65
AsciiDAGParser(const NetworkType &network)
Definition: asciidagparser.h:32
const std::vector< std::pair< std::string, std::string > > & namedEdges() const
Definition: asciidagparser.h:54
void parseEdges(const std::vector< AsciiBox > &boxes)
std::vector< std::pair< std::string, std::string > > _namedEdges
Definition: asciidagparser.h:66
AsciiCanvas _network
Definition: asciidagparser.h:63
std::vector< std::string > _nodes
Definition: asciidagparser.h:64
Definition: algorithm.h:28