Tulip  4.6.0
Better Visualization Through Research
library/tulip-core/include/tulip/cxx/Graph.cxx
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 #include <tulip/PluginProgress.h>
00020 #include <tulip/PropertyInterface.h>
00021 
00022 //================================================================================
00023 template<typename ATTRIBUTETYPE>
00024 bool tlp::Graph::getAttribute(const std::string &name, ATTRIBUTETYPE& value) const {
00025   return getAttributes().get(name, value);
00026 }
00027 //================================================================================
00028 template<typename ATTRIBUTETYPE>
00029 void tlp::Graph::setAttribute(const std::string &name,const ATTRIBUTETYPE&value) {
00030   tlp::DataSet &data=getNonConstAttributes();
00031   notifyBeforeSetAttribute(name);
00032   data.set(name,value);
00033   notifyAfterSetAttribute(name);
00034 }
00035 //================================================================================
00036 template<typename PropertyType>
00037 PropertyType* tlp::Graph::getLocalProperty(const std::string &name) {
00038   if (existLocalProperty(name)) {
00039     PropertyInterface* prop = getProperty(name);
00040     assert (dynamic_cast<PropertyType *>(prop)!=NULL);
00041     return dynamic_cast<PropertyType *>(prop);
00042   }
00043   else {
00044     PropertyType* prop = new PropertyType(this, name);
00045     this->addLocalProperty(name, prop);
00046     return prop;
00047   }
00048 }
00049 //====================================================================================
00050 template<typename PropertyType>
00051 PropertyType* tlp::Graph::getProperty(const std::string &name) {
00052   if (existProperty(name)) {
00053     tlp::PropertyInterface* prop = getProperty(name);
00054     assert (dynamic_cast<PropertyType *>(prop)!=NULL);
00055     return dynamic_cast<PropertyType *>(prop);
00056   }
00057   else {
00058     return getLocalProperty<PropertyType>(name);
00059   }
00060 }
 All Classes Files Functions Variables Enumerations Enumerator Properties