Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
Graph.cxx
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 #include <tulip/SimplePluginProgress.h>
20 
21 //================================================================================
22 template<typename ATTRIBUTETYPE>
23 bool tlp::Graph::getAttribute(const std::string &name, ATTRIBUTETYPE& value) const {
24  return getAttributes().get(name, value);
25 }
26 //================================================================================
27 template<typename ATTRIBUTETYPE>
28 void tlp::Graph::setAttribute(const std::string &name,const ATTRIBUTETYPE&value) {
29  tlp::DataSet &data=getNonConstAttributes();
30  notifyBeforeSetAttribute(name);
31  data.set(name,value);
32  notifyAfterSetAttribute(name);
33 }
34 //================================================================================
35 template<typename PropertyType>
36 PropertyType* tlp::Graph::getLocalProperty(const std::string &name) {
37  if (existLocalProperty(name)) {
38  PropertyInterface* prop = getProperty(name);
39  assert (dynamic_cast<PropertyType *>(prop)!=NULL);
40  return dynamic_cast<PropertyType *>(prop);
41  }
42  else {
43  PropertyType* prop = new PropertyType(this, name);
44  this->addLocalProperty(name, prop);
45  return prop;
46  }
47 }
48 //====================================================================================
49 template<typename PropertyType>
50 PropertyType* tlp::Graph::getProperty(const std::string &name) {
51  if (existProperty(name)) {
52  tlp::PropertyInterface* prop = getProperty(name);
53  assert (dynamic_cast<PropertyType *>(prop)!=NULL);
54  return dynamic_cast<PropertyType *>(prop);
55  }
56  else {
57  return getLocalProperty<PropertyType>(name);
58  }
59 }
60 //====================================================================================
61 template<typename PropertyType>
62 bool tlp::Graph::computeProperty(const std::string &algorithm,
63  PropertyType* prop,
64  std::string &msg,
65  tlp::PluginProgress *progress,
66  tlp::DataSet *data) {
67  return applyPropertyAlgorithm(algorithm, prop, msg, progress, data);
68 }