All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AbstractTreeItemFactory.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/layer/explorer/AbstractTreeItemFactory.cpp
22 
23  \brief A class for building layer items.
24 */
25 
26 // TerraLib
27 #include "../../../../maptools/AbstractLayer.h"
28 #include "../../../../maptools/DataSetLayer.h"
29 #include "../../../../maptools/DataSetAdapterLayer.h"
30 #include "../../../../maptools/FolderLayer.h"
31 #include "../../../../maptools/QueryLayer.h"
32 #include "../../../../maptools/RasterLayer.h"
34 #include "DataSetLayerItem.h"
36 #include "FolderLayerItem.h"
37 #include "QueryLayerItem.h"
38 #include "RasterLayerItem.h"
39 
40 // Boost
41 #include <boost/functional/factory.hpp>
42 #include <boost/bind.hpp>
43 
44 std::map<std::string, te::qt::widgets::AbstractTreeItemFactory::FactoryFnctType> te::qt::widgets::AbstractTreeItemFactory::sm_factories;
45 
46 void te::qt::widgets::AbstractTreeItemFactory::reg(const std::string& key, const FactoryFnctType& f)
47 {
48  sm_factories[key] = f;
49 }
50 
52 {
53  if(!sm_factories.empty())
54  return;
55 
56  sm_factories["DATASETLAYER"] = boost::bind(boost::factory<DataSetLayerItem*>(),_1, _2);
57  sm_factories["DATASETADAPTERLAYER"] = boost::bind(boost::factory<DataSetAdapterLayerItem*>(),_1, _2);
58  sm_factories["QUERYLAYER"] = boost::bind(boost::factory<QueryLayerItem*>(),_1, _2);
59  sm_factories["FOLDERLAYER"] = boost::bind(boost::factory<FolderLayerItem*>(),_1, _2);
60  sm_factories["RASTERLAYER"] = boost::bind(boost::factory<RasterLayerItem*>(),_1, _2);
61 }
62 
64 {
65  sm_factories.clear();
66 }
67 
boost::function< AbstractTreeItem *(const te::map::AbstractLayerPtr &, QObject *)> FactoryFnctType
The class that represents a dataset adapter layer item in a LayerTreeModel.
The class that represents a folder layer item in a LayerTreeModel.
The class that represents a dataset layer item in a LayerTreeModel.
static void reg(const std::string &key, const FactoryFnctType &f)
A class for building layer items.
The class that represents a raster layer item in a LayerTreeModel.
The class that represents a query layer item in a LayerTreeModel.
static std::map< std::string, FactoryFnctType > sm_factories