OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
kwl.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
31 
32 #include "base/common/ossimCommon.h"
33 #include "base/data_types/ossimFilename.h"
34 #include "base/data_types/ossimKeywordlist.h"
35 #include "base/factory/ossimObjectFactoryRegistry.h"
36 #include "init/ossimInit.h"
37 
38 using namespace std;
39 
40 ossimObject* createObject(const ossimString& objectType);
41 void demo1();
42 void demo2();
43 void demo3();
44 
45 int main(int argc, char* argv[])
46 {
47  ossimInit::instance()->initialize(argc, argv);
48 
49  cout << "_______________________________DEMO 1__________________________\n";
50  demo1();
51 
52  cout << "_______________________________DEMO 2__________________________\n";
53  demo2();
54 
55  cout << "_______________________________DEMO 3__________________________\n";
56  demo3();
57 
59 
60  return 0;
61 }
62 
63 
65 {
67 }
68 
73 void demo1()
74 {
75  ossimObject* obj1 = createObject("ossimRgbToGreyFilter");
76  if(obj1)
77  {
78  ossimKeywordlist kwl;
79 
80  obj1->saveState(kwl);
81 
82  cout << "------------------ object 1 = " << obj1->getClassName() << " keyword list is -----------------" << endl;
83  cout << kwl << endl;
84 
85  kwl.clear();
86  cout << "------------------ object 1 = " << obj1->getClassName() << " keyword list with prefix -----------------" << endl;
87  obj1->saveState(kwl, "object1.");
88  cout << kwl << endl;
89 
90  }
91  else
92  {
93  cout << "This shouldn't happen" << endl;
94  }
95 }
96 
101 void demo2()
102 {
103  ossimObject* obj1 = createObject("ossimRgbToGreyFilter");
104  ossimObject* obj2 = createObject("ossimBrightnessContrastSource");
105  if(obj1&&obj2)
106  {
107  ossimKeywordlist kwl;
108 
109  obj1->saveState(kwl, "object1.");
110  obj2->saveState(kwl, "object2.");
111 
112  cout << "Objects " << obj1->getClassName() << " and "
113  << obj2->getClassName() << " saved to the same keywordlist."
114  << endl;
115 
116  cout << kwl << endl;
117  }
118  else
119  {
120  cout << "This shouldn't happen" << endl;
121  }
122 
123 }
124 
136 void demo3()
137 {
138  ossimObject* obj = createObject("ossimRgbToGreyFilter");
139  ossimObject* proj = createObject("ossimUtmProjection");
140 
141  if(obj&&proj)
142  {
143  ossimKeywordlist kwl;
144  obj->saveState(kwl);
146 
147  if(objNew)
148  {
149  ossimKeywordlist kwl2;
150  objNew->saveState(kwl2);
151 
152  cout << "____________________ The Original object " << obj->getClassName() << " ___________________" << endl;
153  cout << kwl << endl;
154  cout << "____________________ The New object " << objNew->getClassName() << " ___________________" << endl;
155  cout << kwl2 << endl;
156 
157  delete objNew;
158  }
159  else
160  {
161  cout << "ERROR: This shouldn't happen" << endl;
162  }
163  kwl.clear();
164 
165  proj->saveState(kwl);
167 
168  if(objNew)
169  {
170  ossimKeywordlist kwl2;
171  objNew->saveState(kwl2);
172 
173  cout << "____________________ The Original object " << proj->getClassName() << " ___________________" << endl;
174  cout << kwl << endl;
175  cout << "____________________ The New object " << objNew->getClassName() << " ___________________" << endl;
176  cout << kwl2 << endl;
177 
178  delete objNew;
179  }
180  else
181  {
182  cout << "ERROR: This shouldn't happen" << endl;
183  }
184 
185  delete obj;
186  delete proj;
187  }
188  else
189  {
190  cout << "This shouldn't happen" << endl;
191  }
192 
193 }
void initialize(int &argc, char **argv)
Definition: ossimInit.cpp:119
Represents serializable keyword/value map.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimObject.cpp:95
static ossimObjectFactoryRegistry * instance()
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
void finalize()
Definition: ossimInit.cpp:261
void demo3()
Definition: kwl.cpp:136
void demo1()
Definition: kwl.cpp:73
ossimObject * createObject(const ossimString &objectType)
Definition: kwl.cpp:64
int main(int argc, char *argv[])
Definition: kwl.cpp:45
virtual ossimObject * createObject(const ossimString &name) const
void demo2()
Definition: kwl.cpp:101
static ossimInit * instance()
Definition: ossimInit.cpp:89