Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
PropertiesCollection.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef PROPERTYCOLLECTION_H
22#define PROPERTYCOLLECTION_H
23
24#include <string>
25#include <vector>
26
27#include <tulip/tulipconf.h>
28
29namespace tlp {
30
31class Graph;
32
33/**
34 * This class represents the list of strings (identifying the graph properties) that can be used as
35 * plugin parameter to select some of the properties of a given graph.
36 */
37class TLP_SCOPE PropertiesCollection {
38 std::vector<std::string> _props;
39 std::vector<std::string> _selected;
40
41public:
42 /**
43 * Initializes an empty collection.
44 */
45 PropertiesCollection() {}
46
47 /**
48 * Initializes a collection with all properties of a graph selected
49 *
50 * @param graph the Graph for which the properties have to be selected
51 * @param selectViewProperties a flag indicating if the view properties have to be selected.
52 * Default is false
53 */
54 explicit PropertiesCollection(const Graph *graph, bool selectViewProperties = false);
55
56 /**
57 * Returns all the selectable string entries.
58 **/
59 const std::vector<std::string> &getProperties() const {
60 return _props;
61 }
62
63 /**
64 * Returns the currently selected string entries.
65 */
66 const std::vector<std::string> &getSelected() const {
67 return _selected;
68 }
69
70 /**
71 * Returns the currently unselected string entries.
72 */
73 std::vector<std::string> getUnselected() const;
74
75 /**
76 * Sets the current selected strings
77 * Returns true if the provided selected is a subset of the collection
78 *
79 * @param selected a valid subset
80 */
81 bool setSelected(const std::vector<std::string> &selected);
82
83 /**
84 * Adds a string value to the collection.
85 *
86 * @param element the string to add to the collection
87 */
88 void push_back(const std::string &element) {
89 _props.push_back(element);
90 }
91
92 /**
93 * Returns true if the collection is empty.
94 */
95 inline bool empty() const {
96 return _props.empty();
97 }
98
99 /**
100 * Returns true if the selected subset is empty.
101 */
102 inline bool emptySelected() const {
103 return _selected.empty();
104 }
105
106 /**
107 * @brief clear the content of the collection.
108 */
109 void clear() {
110 _props.clear();
111 _selected.clear();
112 }
113};
114} // namespace tlp
115#endif
116///@endcond