Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces 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/PluginProgress.h>
20 #include <tulip/PropertyInterface.h>
21 
22 //================================================================================
23 template<typename ATTRIBUTETYPE>
24 bool tlp::Graph::getAttribute(const std::string &name, ATTRIBUTETYPE& value) const {
25  return getAttributes().get(name, value);
26 }
27 //================================================================================
28 template<typename ATTRIBUTETYPE>
29 void tlp::Graph::setAttribute(const std::string &name,const ATTRIBUTETYPE&value) {
30  tlp::DataSet &data=getNonConstAttributes();
31  notifyBeforeSetAttribute(name);
32  data.set(name,value);
33  notifyAfterSetAttribute(name);
34 }
35 //================================================================================
36 template<typename PropertyType>
37 PropertyType* tlp::Graph::getLocalProperty(const std::string &name) {
38  if (existLocalProperty(name)) {
39  PropertyInterface* prop = getProperty(name);
40  assert (dynamic_cast<PropertyType *>(prop)!=NULL);
41  return dynamic_cast<PropertyType *>(prop);
42  }
43  else {
44  PropertyType* prop = new PropertyType(this, name);
45  this->addLocalProperty(name, prop);
46  return prop;
47  }
48 }
49 //====================================================================================
50 template<typename PropertyType>
51 PropertyType* tlp::Graph::getProperty(const std::string &name) {
52  if (existProperty(name)) {
53  tlp::PropertyInterface* prop = getProperty(name);
54  assert (dynamic_cast<PropertyType *>(prop)!=NULL);
55  return dynamic_cast<PropertyType *>(prop);
56  }
57  else {
58  return getLocalProperty<PropertyType>(name);
59  }
60 }
61 //====================================================================================
62 template<typename PropertyType>
63 bool tlp::Graph::computeProperty(const std::string &algorithm,
64  PropertyType* prop,
65  std::string &msg,
66  tlp::PluginProgress *progress,
67  tlp::DataSet *data) {
68  return applyPropertyAlgorithm(algorithm, prop, msg, progress, data);
69 }