| 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/TeTable.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  __TERRALIB_INTERNAL_TABLE_H
    00028 #define  __TERRALIB_INTERNAL_TABLE_H
    00029
    00030 #if defined(_MSC_VER) /* MSVC Compiler */
    00031 #pragma warning(disable: 4786)
    00032 #endif
    00033
    00034 #include <string>
    00035 #include <vector>
    00036 #include "TeComposite.h"
    00037 using namespace std;
    00038
    00039 #include "TeAttribute.h"
    00040
    00041 class TeTableImpl;
    00042
    00044 typedef vector<string> TeTableRow;
    00045
    00047
    00050 class TL_DLL TeTableImpl: public TeComposite<TeTableRow>
    00051 {
    00052
    00053 friend class TeTable;
    00054
    00055            int refCount_;
    00056
    00058            TeTableImpl(): refCount_(0){}
    00059
    00061            string operator () ( int row, int col )
    00062            {
    00063                       return components_[row].operator[] ( col );
    00064            }
    00065
    00066            void setValue (int row, int col, string& val)
    00067            {
    00068                       TeTableRow tRow = components_[row];
    00069                       if (col >= (int)(tRow.size()))
    00070                                  tRow.resize(col+1);
    00071                       tRow[col] = val;
    00072                       components_[row] = tRow;
    00073            }
    00074
    00075 };
    00076
    00078
    00089 class TL_DLL TeTable
    00090 {
    00091 public:
    00093
    00110            TeTable();
    00111
    00113
    00130            TeTable(const string& name);
    00131
    00133
    00150            TeTable(const string& name, const TeAttributeList& attList, const string& uniqueName,
    00151                                  const string& linkName="", TeAttrTableType tableType=TeAttrStatic);
    00152
    00154            ~TeTable();
    00155
    00157
    00158            TeTable(const TeTable&);
    00159
    00161
    00166            TeTable& operator=(const TeTable&);
    00167
    00168 // -- Methods
    00169
    00171            const string& name() const
    00172            { return name_; }
    00173
    00175            string name()
    00176            { return name_; }
    00177
    00179            void name(const string& n)
    00180            { name_ = n; }
    00181
    00183            int id() { return id_; }
    00184
    00186            void setId(int n) { id_ = n; }
    00187
    00189            void setOrder(int n) { order_ = n; }
    00190
    00192            int getOrder() { return order_;}
    00193
    00195            void setAttributeList ( const TeAttributeList& attList)
    00196            { attList_ = attList; }
    00197
    00199            TeAttributeList& attributeList()
    00200            { return attList_; }
    00201
    00203   const TeAttributeList& attributeList() const
    00204            { return attList_; }
    00205
    00207            bool attributeNames(vector<string>& attrs);
    00208
    00210            TeAttrTableType tableType()
    00211            { return type_; }
    00212
    00214            void setSeparator ( const char& c )
    00215            { separator_ = c ; }
    00216
    00218            char separator ()
    00219            { return separator_; }
    00220
    00222
    00228            bool setTableType( TeAttrTableType attType, int relatedTableId=-1, const string& relatedAttribute="");
    00229
    00231
    00236            void setLinkName ( const string& linkName ) { attLink_ = linkName;}
    00237
    00239            string linkName()
    00240            {          return attLink_; }
    00241
    00243            void setUniqueName ( const string& uniqueName ) { attUnique_ = uniqueName; }
    00244
    00246            string uniqueName()
    00247            {          return attUnique_;    }
    00248
    00250
    00254            bool attrLink(TeAttribute& att);
    00255
    00257
    00261            bool attrUnique(TeAttribute& attr);
    00262
    00264            int attrLinkPosition();
    00265
    00267            int attrUniquePosition();
    00268
    00275
    00276            void relatedTableId(int id)
    00277            {   relatedTableId_ = id; }
    00278
    00280            int relatedTableId()
    00281            {   return relatedTableId_; }
    00282
    00284            void relatedTableName(string tableName)
    00285            {   relatedTableName_ = tableName; }
    00286
    00288            string relatedTableName()
    00289            {   return relatedTableName_; }
    00290
    00292            void relatedAttribute(const string& columnName)
    00293            {          relatedAttribute_ = columnName; }
    00294
    00296            string relatedAttribute()
    00297            { return relatedAttribute_; }
    00298
    00300
    00308
    00310            void attInitialTime(const string& t)
    00311            {          attInitialTime_ = t; }
    00312
    00314            string attInitialTime()
    00315            {          return attInitialTime_; }
    00316
    00318            void attFinalTime(const string& t)
    00319            {          attFinalTime_ = t; }
    00320
    00322            string attFinalTime()
    00323            {          return attFinalTime_; }
    00324
    00326            void attTimeUnit(TeChronon t)
    00327            {          attTimeUnit_ = t; }
    00328
    00330            TeChronon attTimeUnit()
    00331            {          return attTimeUnit_; }
    00333
    00338
    00339            void add ( const TeTableRow& row );
    00340
    00342            TeTableRow operator [] ( int row ) const;
    00343
    00345            string operator () ( int row, int col );
    00346
    00348            void setValue (int row, int col, string& val);
    00349
    00351            unsigned int size () const;
    00352
    00354            void clear ();
    00356
    00358            void primaryKeys(vector<string>& keys);
    00359
    00360 private:
    00361
    00362            int                                                    id_;       // unique id from a database where this table may be stored
    00363            string                                      name_;     // name
    00364            TeAttrTableType                  type_;     // type of table
    00365            int                                                    order_; // the table position relative to others in a join
    00366
    00367            TeAttributeList                  attList_;             // list of attributes
    00368            string                                      attLink_;             // attribute that links objects to their spatial representation
    00369                                                                                                               // in case of external table it is used to link to the related table
    00370            string                                      attUnique_;                      // primary key
    00371            char                separator_;             // in case of CSV table
    00372
    00373 // --- The following attributes are relative to tables with temporal information
    00374
    00375            string                attInitialTime_;      // initial time attribute
    00376            string                attFinalTime_;                   // final time attribute
    00377            TeChronon  attTimeUnit_;                    // time granularity
    00378
    00379 // --- The following attributes are relative to external tables
    00380            int                   relatedTableId_;      // id of a table to which this is related
    00381            string     relatedTableName_;    // name of a table to which this is related
    00382            string  relatedAttribute_;       // column name of table which this is related
    00383
    00384 // -- Table Implementation
    00385            TeTableImpl* pImpl_;             // the rows of a table
    00386
    00387 };
    00388
    00390 typedef vector<TeTable> TeAttrTableVector;
    00391
    00393 TL_DLL string tableJoin(TeAttrTableVector& vecTable, string firstTable="", string attrLink="");
    00394
    00399 #endif
    00400
    00401

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines