This file is indexed.

/usr/include/terralib/kernel/TeExternalTheme.h is in libterralib-dev 4.3.0+dfsg.2-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/************************************************************************************
 TerraLib - a library for developing GIS applications.
Copyright © 2001-2006 INPE and Tecgraf/PUC-Rio.

This code is part of the TerraLib library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

You should have received a copy of the GNU Lesser General Public
License along with this library.

The authors reassure the license terms regarding the warranties.
They specifically disclaim any warranties, including, but not limited to,
the implied warranties of merchantability and fitness for a particular purpose.
The library provided hereunder is on an "as is" basis, and the authors have no
obligation to provide maintenance, support, updates, enhancements, or modifications.
In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
indirect, special, incidental, or consequential damages arising out of the use
of this library and its documentation.
*************************************************************************************/
/** \file TeExternalTheme.h
    \brief This file contains direct implementation of TeTheme in order to 
	support themes from another TerraLib databases (remote databases).
*/

#ifndef  __TERRALIB_INTERNAL_EXTERNALTHEME_H
#define  __TERRALIB_INTERNAL_EXTERNALTHEME_H

#include <map>
#include <string>

#include "TeTheme.h"

/** \fn bool TeLoadConnectionsInfo(TeDatabase* sourceDB)
    \brief Loads all connections information from source database and populates Remote theme database index.
	\param sourceDB A connection to a TerraLib database that stores information about others databases that can be used by remote themes. (Input)
 */
TL_DLL bool TeLoadConnectionsInfo(TeDatabase* sourceDB);


//! A class that implements the external theme concept  
/*!
	A external theme is a theme stored in a remote TerraLib database.
	Some information about the external theme is stored in the local database, but
	its geometries and attributes are stored in the remote database. 

	\sa TeTheme
  
 */
class TL_DLL TeExternalTheme : public TeTheme
{
	public:

		//! Constructor.
		TeExternalTheme(TeDatabase* sourceDb, TeTheme* remoteTheme, const int& viewId, 
                                 const string& name = "");

		//! Destructor.
		virtual ~TeExternalTheme();
	
		//! Operator =
		TeExternalTheme& operator=(TeExternalTheme& rhs);

		/** @name Remote Theme Accessor Methods
		  * Methods related to the remote theme reference.
		  */
		//@{

		virtual TeViewNode* clone();

        virtual TeTheme* getRemoteTheme() const;

		virtual void setRemoteTheme(TeTheme* theme);

        virtual TeDatabase* getSourceDatabase();

		virtual void setSourceDatabase(TeDatabase* srcDB);
		
		virtual string getRemoteThemeName(); 
		//@}


		/** @name Object status containers
		  * Methods to handle object status containers
		  */
		//@{
		virtual void loadObjectLegendMap();
		
		virtual int getGridStatus(const int uniqueId, const std::string objectId);

		virtual int getObjectStatus(const std::string objectId);

		virtual bool setObjectLegendStatusMap(const std::string objId, const int status);
		
		virtual bool setObjectGridStatusMap(const std::string objId, const int uniqueId, const int status);
		//@}

		/** @name Layer accessor methods
		  * Methods related to the layer that gives origin to this theme.
		  */
		//@{

		/** \brief Returns the identification of the source layer.
		    \note In a Remote Theme this will be always -1.
		  */
		virtual int layerId();

		/** \brief Sets the identification of the source layer.
		    \param i Layer identification value that will be used to set the source layer. (Input)
			\note In a Remote Theme this method does nothing.
		  */
		virtual void layerId(int i);

		/** \brief Sets the layer that is the source of objects of the theme.
		    \param layer A pointer to a TeLayer. (Input)
          */
		virtual void layer(TeLayer* layer);

		/** \brief Returns a pointer to the layer from which the theme get its objects.
		    \note In a Remote Theme this method returns a NULL pointer.
		  */
		virtual TeLayer* layer();

		//! Returns a pointer to the projection of the remote layer
		virtual TeProjection* getThemeProjection();

		//@}

		/** @name 
		  * Methods related to the restrictions over the theme used to generate this theme
          */
		//@{

		/** \brief Verifies if this theme has any kind of restrictions.
		    \note In a Remote Theme this method always returns FALSE.
		  */
		virtual bool hasRestriction();

		/** \brief Returns if there is an attribute restriction.
		    \note In a Remote Theme this method always returns FALSE.
		  */
		virtual bool hasAttrRest();

		/** \brief Returns TRUE if there is a temporal restriction defined in the theme.
		    \note In a Remote Theme this method always returns FALSE. 
		  */
		virtual bool hasTemporalRest();

		/** \brief Returns TRUE if this theme has a spatial restriction.
		    \note In a Remote Theme this method always returns FALSE.
		  */
		virtual bool hasSpatialRest();

		/** \brief Returns the clause WHERE derived from the combination of all restricitions (spatial, attribute and temporal).
		    \note In a Remote Theme this method always returns an empty string.
		  */
		virtual string sqlWhereRestrictions(TeRepresentation* rep = 0);

		//@}

		/** @name Collection
		  * Methods related to the materialization in the database of the theme as a collection of objects 
          */
		//@{

		/** \brief Fills the sqlGridJoin_ and sqlGridFrom_ statements according to the status of the database.
		    \note In a Remote Theme this method does nothing.
		  */
		virtual void loadTablesJoin(const string& geomTable = "");

		/** \brief Returns a SQL JOIN statement to get all the attributes of the theme objects, 
		           the attributes of the collection table, and the attributes of the extended 
                   collection table.
		    \note In a Remote Theme this method returns an empty string.
	      */
		virtual string sqlGridJoin();

		/** \brief Returns a FROM clause of a SQL statement to get attributes of the theme objects,
		           the attributes of the collection table, and the attributes of the
				   extended collection table .
		    \note In a Remote Theme this method returns an empty string.
	      */
		virtual string sqlGridFrom(const string& geomTable="");

        virtual bool save(const bool& copyExternalCollection = true);
		//! Save the the theme parameters in the database.
		virtual bool save(TeDatabase* db, const bool& copyExternalCollection = true); 
		
		/** \brief Create the auxiliar collection table used to represent objects with multiple versions in time.
		    \note In a Remote Theme this method creates a local auxiliary collection table.
		  */
		virtual bool createCollectionAuxTable();

		/** \brief Populate the auxiliar collection table used to represent objects with multiple versions in time.
		    \note In a Remote Theme this method populates the local auxiliary collection.
		  */
		virtual bool populateCollectionAux(std::string objectId = "");

		//@}

		//! Save the grouping parameters in memory when there is no chronon.
		virtual bool buildGrouping(const TeGrouping& g, TeSelectedObjects selectedObjects = TeAll,
			                       vector<double>* dValuesVec = 0);

		//! Save the grouping parameters in memory when there is chronon.
		virtual bool buildGrouping(const TeGrouping& g, TeChronon chr, vector<map<string, string> >& mapObjValVec);
						   
		//! Build the grouping and associate each object to its group in the collection table.
		virtual bool saveGrouping(TeSelectedObjects selectedObjects = TeAll);

		//! Save the theme grouping legends in the collection table.
		virtual bool saveLegendInCollection(TeSelectedObjects selectedObjects = TeAll, std::string objectId = "");

		//! Save the theme grouping legends in the collection table  
		virtual bool saveLegendInCollection(TeDatabase* db, TeSelectedObjects selectedObjects = TeAll, std::string objectId = "");

		///! Set the legend id for each object of the theme.
		virtual void setLegendsForObjects();

		//! Generates a optimized position (x,y) in the spatial extention of each object to position label or graphs.
		virtual bool generateLabelPositions(const std::string& objectId = "");  

		//! Delete grouping.
		virtual bool deleteGrouping(); 
		
		//! Creates an appropriate visual presentation to the raster of the theme.
		virtual void createRasterVisual(TeRaster* rst = 0);

		/** @name Attribute Tables
		  * A theme can use one or more attribute tables of the layer that gives its data.
		  * These methods are related to the manipulation of these tables.
          */
		//@{	

		//! Add a new attribute table to a theme.
		virtual bool addThemeTable(TeTable& table);

		//! Add a new attribute table to a theme.
		virtual void addThemeTable(string tableName);

		//! Verify if an attribute table is part of a theme.
		virtual bool isThemeTable(int tableId);

		//! Verify if an attribute table is part of a theme.
		virtual bool isThemeTable(string tableName);

		//! Returns the list of attribute tables used by this theme.
		virtual TeAttrTableVector& attrTables();

		//! Sets the entire list of attribute tables used by this theme.
		virtual bool setAttTables(TeAttrTableVector& attrs);  

		//! Returns a vector of attribute tables, of a specific type, used by this theme.
		virtual bool getAttTables(TeAttrTableVector& attrs, TeAttrTableType attType = TeAllAttrTypes); 

		//! Returns a representation of an attribute table  given name.
		virtual bool getTable(TeTable& table, const string tableName);

		//! Clears the list of attribute tables used by this theme.
		virtual void clearAttTableVector();

		/** \brief Returns the temporal attribute table of the theme (TeEvent or TeFixedGeomDynAttr).
		    \note A theme supports only one temporal attribute table.
		  */
		virtual bool getTemporalTable(TeTable& table);

		//! Removes an attribute table from the list of tables of a theme.
		virtual bool removeThemeTable(unsigned int index);

		//! Returns the the name of an attribute table that contains a given attribute.
		virtual string getTableName(const string& attrName);

		//! Returns the name of the index-th attribute resulting of the join of all attribute tables associated to the theme tables 
		virtual string getAttribute(unsigned int index);

		//! Loads the theme tables in the database
		virtual bool loadThemeTables();
		
		//! Returns the list of attributes of theme tables.
		virtual  TeAttributeList sqlAttList();
		
		//! Clears the list of attributes associated to the theme tables.
		virtual void clearAttList();

		//! Returns the list of numerical attributes of the theme tables.
		virtual TeAttributeList sqlNumAttList();

		//! Clears the list of numerical attributes associated to the theme tables.
		virtual void clearNumAttList();

		///! Returns a SQL JOIN statement to reach to all attribute tables used by this theme.
		virtual string sqlJoin();

		//! Returns a SQL FROM CLAUSE that gives access to all attribute tables used by this theme.
		virtual string sqlFrom();

		//! Returns the alias vector of the names of the theme tables.
		virtual vector<string>&	aliasVector();

		//! Fills aliasVector_.
		virtual void loadAliasVector();

		/** \brief Refresh list of attributes of all the theme tables.
		    \note All attributes are stored into sqlAttList_ and numeric attributes are stored into sqlNumAttList_.
          */
		virtual void loadAttrLists();
		//@}

		/** @name Locate geometries
		  * Returns the geometry(ies) of the theme given coordinate
          */
		//@{ 	

		virtual bool locatePolygon(TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0);
		virtual bool locatePolygonSet(TeCoord2D &pt, double tol, TePolygonSet &polygons);
		virtual bool locateLine(TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
		virtual bool locatePoint(TeCoord2D &pt, TePoint &point, const double& tol = 0.0);
		virtual bool locateCell(TeCoord2D &pt, TeCell &c, const double& tol = 0.0);

		//@}

		/** \brief Verifies if there are objects without geometries of a specific geometry representation.
		  */
		virtual bool hasObjectsWithoutGeometries(TeGeomRep geomRep);

		/** \brief Removes the objects without geometries of a specific geometry representation.
		  */
		virtual bool removeObjectsWithoutGeometries(TeGeomRep geomRep);

		/** \brief Creates a table to store information on how to connect to others databases and get remote theme.
		    \param sourceDB A connection to a TerraLib database that stores information about others databases that can be used by remote themes. (Input)
			\return Returns 1 if the table was created, -1 if it already exists and 0 on error.
		  */
		static int createExternalThemeTable(TeDatabase* sourceDB);

		//! Save the theme metadata in database. 
		virtual bool saveMetadata(TeDatabase* db); 

		/** \brief Retrieves remote theme information from the database.
		  */
		bool getRemoteThemeInfo(int& remoteThemeId, int& databaseId);

		/** \brief Sets the remote the id for this external theme
		  */
		void setRemoteDbId(const int& removeDbId);

	protected:

		/** \brief Fill the sqlJoin_ and sqlFrom_ .
		  */
		//virtual void loadThemeTablesJoin();
		
		/** \brief Populate the collection table based in the theme restrictions.
		  */
		virtual bool populateCollection(std::string objectId = "", const bool& sincronize = true);

		/** \brief Populate map with relationateds ids from local theme and remote theme.
		  */
		virtual void createLegendMapId(std::map<int, int>& mapIdLegend);

		/** \brief Copy the respective collection table from remoteTheme to localTheme.
		  */
		virtual bool copyRemoteCollection(std::map<int, int>& mapIdLegend);

		//! Load the external theme metadata from database. 
		virtual bool loadMetadata(TeDatabase* db);

		//! Erase the theme metadata in database. 
		virtual bool eraseMetadata(TeDatabase* db); 

	protected:
        //! A pointer to a theme in a remote database.
		TeTheme* remoteTheme_;
        TeDatabase* sourceDB_;
        int remoteDbId_;
};


//!  This class implements a factory to create external theme objects. 
class TL_DLL TeExternalThemeFactory : public TeViewNodeFactory
{
public:
	//! Constructor 
	TeExternalThemeFactory() : TeViewNodeFactory((int)TeEXTERNALTHEME)
	{}

	//! Created theme objects 
	TeViewNode* build(TeViewNodeParams* params)
	{	
		TeViewNodeParams auxParams = *params;
        return new TeExternalTheme(NULL, NULL, params->viewId_, params->name_);	
	}
	
	//! Created theme objects 
	TeViewNode* build()
	{	
		return new TeExternalTheme(NULL, NULL, -1);	
	}
};

namespace 
{
  static TeExternalThemeFactory externalThemeFactory;
}; 

#endif	// __TERRALIB_INTERNAL_REMOTETHEME_H