| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeProxMatrixImplementation.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00027 #ifndef TeProxMatrixImplementation_H
    00028 #define TeProxMatrixImplementation_H
    00029
    00030 #include "TeNeighbours.h"
    00031 #include "graph.h"
    00032
    00034 class TL_DLL TeProxMatrixImplementation
    00035 {
    00036 protected:
    00038            TeGPMImplementation type_;
    00039
    00041            TeProxMatrixImplementation(const TeGPMImplementation& type): type_(type)
    00042                       {}
    00043
    00044 public:
    00046            bool isConnected (const string& object_id1, const string& object_id2)
    00047            {
    00048                       TeProxMatrixAttributes attr;
    00049                       return getConnectionAttributes (object_id1, object_id2, attr);
    00050            }
    00051
    00053            virtual void connectObjects (const string& , const string& , const TeProxMatrixAttributes& ) = 0;
    00054
    00056            virtual bool disconnectObjects (const string& , const string& ) { return false; }
    00057
    00059            virtual bool removeObject (const string& ) { return false; }
    00060
    00062            virtual bool getConnectionAttributes (const string&, const string&, TeProxMatrixAttributes& )= 0;
    00063
    00065            virtual bool setConnectionAttributes (const string&, const string&, const TeProxMatrixAttributes&) =0;
    00066
    00068            virtual bool getNeighbours (const string& , TeNeighbours& )=0;
    00069
    00071            virtual bool getNeighbours (int, string& , TeNeighbours& )=0;
    00072
    00074            virtual bool getNeighboursNeighbours (const string&, TeNeighbours&, int /* max_order */ = 2)=0;
    00075
    00077            virtual int  numberOfObjects()=0;
    00078
    00080            TeGPMImplementation type() {return type_;}
    00081
    00083            virtual TeProxMatrixImplementation* createCopy ()=0;
    00084
    00086            virtual bool isEqual (TeProxMatrixImplementation& other)
    00087            {
    00088                       if (type_ == other.type_)
    00089                                  return true;
    00090                       return false;
    00091            }
    00092
    00094            virtual bool operator== (const TeProxMatrixImplementation& ) const { return false; }
    00095
    00097            virtual bool saveTextFile (const string&, map<string, string>*)=0;
    00098
    00100            virtual bool saveGALFile (const string&, map<string, string>*)=0;
    00101
    00103            virtual bool saveGWTFile (const string&, map<string, string>*)=0;
    00104
    00106            virtual bool saveTextFile (const string&, vector<string>*)=0;
    00107
    00109            virtual bool saveGALFile (const string&, vector<string>*)=0;
    00110
    00112            virtual bool saveGWTFile (const string&, vector<string>*)=0;
    00113
    00115            virtual ~TeProxMatrixImplementation(){}
    00116 };
    00117
    00118
    00120 class TL_DLL TeProxMatrixGraphBreymann : public  TeProxMatrixImplementation
    00121 {
    00122 private:
    00123            br_stl::Graph<string, TeProxMatrixAttributes> graph_;
    00124
    00125            typedef map<string, int> Object_id_map_type;
    00126            Object_id_map_type  map_;
    00127
    00128            typedef Object_id_map_type::iterator map_iterator;
    00129            typedef Object_id_map_type::const_iterator map_const_iterator;
    00130
    00131            bool getNeighboursNeighbours (const string& object_id, TeNeighbours& neigh, int max_order = 2, int current_order = 1);
    00132
    00133 public:
    00135            TeProxMatrixGraphBreymann ();
    00136
    00138            TeProxMatrixGraphBreymann(TeProxMatrixGraphBreymann& imp);
    00139
    00141            virtual void connectObjects (const string& object_id1, const string& object_id2, const TeProxMatrixAttributes& attr);
    00142
    00144            virtual bool getConnectionAttributes (const string& object_id1, const string& object_id2, TeProxMatrixAttributes& attr);
    00145
    00147            virtual bool setConnectionAttributes (const string& object_id1, const string& object_id2, const TeProxMatrixAttributes& attr);
    00148
    00150            virtual bool getNeighbours (const string& object_id, TeNeighbours& neigh);
    00151
    00153            virtual bool getNeighbours (int obj, string& object_id, TeNeighbours& neigh);
    00154
    00156            virtual bool getNeighboursNeighbours (const string& object_id, TeNeighbours& neigh, int max_order = 2);
    00157
    00159            virtual int  numberOfObjects () {return graph_.size();}
    00160
    00162            virtual TeProxMatrixImplementation* createCopy ();
    00163
    00165            virtual bool isEqual (TeProxMatrixImplementation& other)
    00166            {
    00167                       if (type_ == other.type())
    00168                                  return (*this == (TeProxMatrixGraphBreymann&)other);
    00169                       return false;
    00170            }
    00171
    00173            TeProxMatrixGraphBreymann& operator= (TeProxMatrixGraphBreymann& imp);
    00174
    00176            virtual ~TeProxMatrixGraphBreymann() {}
    00177
    00179            virtual bool saveTextFile (const string& name, map<string, string>* ids=0);
    00180
    00182            virtual bool saveGALFile (const string& name, map<string, string>* ids=0);
    00183
    00185            virtual bool saveGWTFile (const string& name, map<string, string>* ids=0);
    00186
    00188            virtual bool saveTextFile (const string& name, vector<string>* ids);
    00189
    00191            virtual bool saveGALFile (const string& name, vector<string>* ids);
    00192
    00194            virtual bool saveGWTFile (const string& name, vector<string>* ids);
    00195 };
    00196
    00197
    00199 class TL_DLL TeProxMatrixAbstractFactory
    00200 {
    00201 public:
    00202            static TeProxMatrixImplementation* MakeConcreteImplementation (const TeGPMImplementation& impl_type = TeGraphBreymann)
    00203            {
    00204                       if (impl_type == TeGraphBreymann)
    00205                                             return new TeProxMatrixGraphBreymann();
    00206
    00207                       return new TeProxMatrixGraphBreymann();
    00208            }
    00209
    00210 };
    00211
    00215 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines