OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimVpfDatabase.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // License: See top level LICENSE.txt file.
3 //
4 // Author: Garrett Potts
5 //
6 // Description: This class extends the stl's string class.
7 //
8 //********************************************************************
9 // $Id: ossimVpfDatabase.cpp 19636 2011-05-24 16:48:45Z gpotts $
17 
19  :theDatabaseHeaderTable(""),
20  theLibraryAttributeTable(""),
21  theOpenedFlag(false)
22 {
23 }
24 
26 {
28 
29  closeDatabase();
30 }
31 
33 {
34  bool result = true;
35 
36  ossimFilename tempFilename = filename;
37 
38  // tempFilename.convertBackToForwardSlashes();
39 
40  // we should have two table to look at for the database.
41  // 1) database header (dht) 2) and the Library attribute (lat)
42  theDatabaseHeaderTable = ossimFilename(tempFilename.path()).dirCat("dht");
43  theLibraryAttributeTable = ossimFilename(tempFilename.path()).dirCat("lat");
44 
47  {
48  ossimVpfTable table;
49  // now lets see if they are valid tables
50  result = table.openTable(theDatabaseHeaderTable);
51  if(result&&
52  !ossimVpfDatabaseHeaderTableValidator().isValid(table))
53  {
54  result = false;
55  }
56 
57  result = table.openTable(theLibraryAttributeTable);
58  if((result) &&!ossimVpfLibraryAttributeTableValidator().isValid(table))
59  {
60  result = false;
61  }
62  }
63  else
64  {
65  result = false;
66  }
67 
68  if(result)
69  {
70  theOpenedFlag = true;
72  }
73 
74  return result;
75 }
76 
78 {
81  theOpenedFlag = false;
83 }
84 
85 
87 {
88  // we can use either table name since all we need is the path
90 }
91 
93 {
94  return (long)theVpfLibraryList.size();
95 }
96 
97 ossimVpfLibrary* ossimVpfDatabase::getLibrary(unsigned long libraryNumber)
98 {
99 
100  if(libraryNumber < theVpfLibraryList.size())
101  {
102  return theVpfLibraryList[libraryNumber];
103  }
104 
105  return NULL;
106 }
107 
109 {
110  for(long index = 0; index < (long)theVpfLibraryList.size(); ++index)
111  {
112  if(theVpfLibraryList[index]->getName() == name)
113  {
114  return theVpfLibraryList[index];
115  }
116  }
117 
118  return NULL;
119 }
120 
121 
123 {
124  return theOpenedFlag;
125 }
126 
127 vector<ossimString> ossimVpfDatabase::getLibraryNames()const
128 {
129 
130  ossimVpfTable table;
131 
133  {
134  return table.getColumnValues("LIBRARY_NAME");
135  }
136 
137  return vector<ossimString>();
138 }
139 
141 {
142  vector<ossimString> result;
143 
144  ossimVpfTable table;
145 
147  {
148  result = table.getColumnValues("LIBRARY_NAME");
149  }
150 
151  for(long index=0; index < (long)result.size();index++)
152  {
153  result[index] = ossimString(theLibraryAttributeTable.path()) +
154  ossimString("/") +
155  result[index];
156  }
157 
158  return result;
159 }
160 
162 {
164 }
165 
167 {
168  // make sure the library list is deleted
170  vector<ossimString> libraryNames = getLibraryNames();
171  for(long index = 0; index < (long)libraryNames.size(); index++)
172  {
173  ossimVpfLibrary *library = new ossimVpfLibrary;
174  library->openLibrary(this,
175  libraryNames[index],
176  getPath().dirCat(libraryNames[index]));
177  theVpfLibraryList.push_back(library);
178  }
179 }
180 
182 {
183  for(long idx = 0; idx <(long)theVpfLibraryList.size(); idx++)
184  {
185  delete theVpfLibraryList[idx];
186  theVpfLibraryList[idx] = 0;
187  }
188 
189  theVpfLibraryList.clear();
190 }
virtual ~ossimVpfDatabase()
virtual bool openDatabase(const ossimFilename &filename)
vector< ossimString > getLibraryNamesFullPath() const
ossimFilename theDatabaseHeaderTable
std::vector< ossimString > getColumnValues(const ossimString &columnName) const
virtual bool openTable(const ossimFilename &tableName)
bool openLibrary(ossimVpfDatabase *database, const ossimString &name, const ossimFilename &libraryPath)
bool exists() const
vector< ossimVpfLibrary * > theVpfLibraryList
vector< ossimString > getLibraryNames() const
ossimFilename getPath() const
ossimFilename getLibraryAttributeTable() const
ossimFilename theLibraryAttributeTable
long getNumberOfLibraries() const
ossimFilename path() const
ossimVpfLibrary * getLibrary(unsigned long libraryNumber)