OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Functions
kwl.cpp File Reference
#include <iostream>
#include "base/common/ossimCommon.h"
#include "base/data_types/ossimFilename.h"
#include "base/data_types/ossimKeywordlist.h"
#include "base/factory/ossimObjectFactoryRegistry.h"
#include "init/ossimInit.h"

Go to the source code of this file.

Functions

ossimObjectcreateObject (const ossimString &objectType)
 
void demo1 ()
 
void demo2 ()
 
void demo3 ()
 
int main (int argc, char *argv[])
 

Function Documentation

◆ createObject()

ossimObject * createObject ( const ossimString objectType)

Definition at line 64 of file kwl.cpp.

References ossimObjectFactoryRegistry::createObject(), and ossimObjectFactoryRegistry::instance().

Referenced by demo1(), demo2(), demo3(), and ossimObjectFactoryRegistry::getTypeNameList().

65 {
67 }
static ossimObjectFactoryRegistry * instance()
virtual ossimObject * createObject(const ossimString &name) const

◆ demo1()

void demo1 ( )

Demo1 will just instantiate and object of the passed in type and then execute a save state and print that keywordlist out.

Definition at line 73 of file kwl.cpp.

References ossimKeywordlist::clear(), createObject(), ossimObject::getClassName(), and ossimObject::saveState().

Referenced by main().

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 }
Represents serializable keyword/value map.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimObject.cpp:95
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
ossimObject * createObject(const ossimString &objectType)
Definition: kwl.cpp:64

◆ demo2()

void demo2 ( )

Save 2 objects to a keywordlist without conflict in values. This will force us to use a prefix in order to save 2 objects to the same list

Definition at line 101 of file kwl.cpp.

References createObject(), ossimObject::getClassName(), and ossimObject::saveState().

Referenced by main().

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 }
Represents serializable keyword/value map.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimObject.cpp:95
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
ossimObject * createObject(const ossimString &objectType)
Definition: kwl.cpp:64

◆ demo3()

void demo3 ( )

Save object to keywordlist and then pass keyword list to factory and instantitate an object from keywordlist. We will do it twice, the first time without a prefix and then the second time with a prefix.

We will use 2 object types: the first one will be a filter and the second one will be a projection.

Note: you should get identical outputs for both outputs.

Definition at line 136 of file kwl.cpp.

References ossimKeywordlist::clear(), ossimObjectFactoryRegistry::createObject(), createObject(), ossimObject::getClassName(), ossimObjectFactoryRegistry::instance(), and ossimObject::saveState().

Referenced by main().

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 }
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
ossimObject * createObject(const ossimString &objectType)
Definition: kwl.cpp:64
virtual ossimObject * createObject(const ossimString &name) const

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 45 of file kwl.cpp.

References demo1(), demo2(), demo3(), ossimInit::finalize(), ossimInit::initialize(), and ossimInit::instance().

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 }
void initialize(int &argc, char **argv)
Definition: ossimInit.cpp:119
void finalize()
Definition: ossimInit.cpp:261
void demo3()
Definition: kwl.cpp:136
void demo1()
Definition: kwl.cpp:73
void demo2()
Definition: kwl.cpp:101
static ossimInit * instance()
Definition: ossimInit.cpp:89