OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfFileHeader.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: MIT
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: Garrett Potts
8 //
9 // Description: Nitf support class
10 //
11 //********************************************************************
12 // $Id$
13 
16 #include <iostream>
17 
18 static const char* TAGS_KW = "tags";
19 
21 
23 {
24  return out << "theImageHeaderOffset: "
25  << theImageHeaderOffset << std::endl
26  << "theImageDataOffset: "
28 }
29 
31 {
32 }
33 
35 {
36 }
37 
38 
40  const ossimString& tagName)const
41 {
42  if(theTagList.size())
43  {
44  for(ossim_uint32 i = 0; i < theTagList.size(); ++i)
45  {
46  if(theTagList[i].getTagName() == tagName)
47  {
48  tagInfo = theTagList[i];
49  return true;
50  }
51  }
52  }
53 
54  return false;
55 }
56 
58 {
59  return (getNumberOfImages() > 0);
60 }
61 
63 {
64  return (getNumberOfSymbols() > 0);
65 }
66 
68 {
69  return (getNumberOfGraphics() > 0);
70 }
71 
73 {
74  return (getNumberOfTextSegments() > 0);
75 }
76 
78 {
79  return (getNumberOfLabels() > 0);
80 }
82 {
83  return (getNumberOfDataExtSegments() > 0);
84 }
85 
87 {
88  ossim_uint32 idx = 0;
89  for(idx = 0; idx < theTagList.size(); ++idx)
90  {
91  if(theTagList[idx].getTagName() == tagName)
92  {
93  theTagList.erase(theTagList.begin() + idx);
94  return;
95  }
96  }
97 }
99 {
100  if(unique)
101  {
102  removeTag(tag.getTagName());
103  }
104  theTagList.push_back(tag);
105 }
106 
108  int idx) const
109 {
110  bool result = false;
111 
112  if(static_cast<ossim_uint32>(idx) < theTagList.size())
113  {
114  tag = theTagList[idx];
115  result = true;
116  }
117 
118  return result;
119 }
120 
122 {
123  return (int)theTagList.size();
124 }
125 
127 {
128  ossim_uint32 tagLength = 0;
129 
130  for(ossim_uint32 i = 0; i < theTagList.size(); ++i)
131  {
132  tagLength += theTagList[i].getTotalTagLength();
133  }
134 
135  return tagLength;
136 }
137 
138 
140 {
141 }
142 
144 {
145  ossimRefPtr<ossimProperty> result = 0;
146 
147  if(name == TAGS_KW)
148  {
149  ossim_uint32 idxMax = (ossim_uint32)theTagList.size();
150  if(idxMax > 0)
151  {
152  ossimContainerProperty* containerProperty = new ossimContainerProperty;
153  containerProperty->setName(name);
154  ossim_uint32 idx = 0;
155 
156  result = containerProperty;
157  for(idx = 0; idx < idxMax; ++idx)
158  {
159  ossimNitfTagInformation tagInfo;
160  getTagInformation(tagInfo, idx);
161 
162  const ossimRefPtr<ossimNitfRegisteredTag> tagData = tagInfo.getTagData();
163  if(tagData.valid())
164  {
165  ossimContainerProperty* containerPropertyTag = new ossimContainerProperty;
166  containerPropertyTag->setName(tagInfo.getTagName());
167  std::vector<ossimRefPtr<ossimProperty> > propertyList;
168  tagData->getPropertyList(propertyList);
169 
170  containerPropertyTag->addChildren(propertyList);
171  containerProperty->addChild(containerPropertyTag);
172  }
173  else
174  {
175  containerProperty->addStringProperty(tagInfo.getTagName(), "", true);
176  }
177  }
178  }
179  }
180 
181  return result;
182 }
183 
184 void ossimNitfFileHeader::getPropertyNames(std::vector<ossimString>& propertyNames)const
185 {
186  propertyNames.push_back(TAGS_KW);
187 }
188 
190 {
191  ossimObject::saveState(kwl, prefix);
192 
193  bool result = true;
194  ossimString tagsPrefix = prefix;
195  for(ossim_uint32 i = 0; i < theTagList.size(); ++i)
196  {
197  ossimRefPtr<ossimNitfRegisteredTag> tag = theTagList[i].getTagData();
198  if (tag.valid())
199  {
200  // we eventually need to do our own prefix for this object and not let the calling object do any prefix definitions
201 // ossimString newPrefix = tagsPrefix + tag->getRegisterTagName() + ".";
202 
203  tag->saveState(kwl, tagsPrefix);
204  }
205  }
206 
207  return result;
208 }
209 
211  const std::string& prefix ) const
212 {
213  return printTags(out, prefix);
214 }
215 
217  const std::string& prefix) const
218 {
219  for(ossim_uint32 i = 0; i < theTagList.size(); ++i)
220  {
221  ossimRefPtr<ossimNitfRegisteredTag> tag = theTagList[i].getTagData();
222  if (tag.valid())
223  {
224  tag->print(out, prefix);
225  }
226  }
227 
228  return out;
229 }
virtual std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
Print method that outputs a key/value type format adding prefix to keys.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
void getPropertyList(std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
virtual std::ostream & print(std::ostream &out) const
Generic print method.
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimObject.cpp:95
virtual bool saveState(ossimKeywordlist &kwl, const ossimString &prefix="") const
virtual ossim_int32 getNumberOfLabels() const =0
virtual std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
Pure virtual print method that outputs a key/value type format adding prefix to keys.
RTTI_DEF2(ossimNitfFileHeader, "ossimNitfFileHeader", ossimObject, ossimPropertyInterface)
virtual void addStringProperty(const ossimString &name, const ossimString &value, bool readOnlyFlag=false)
virtual std::ostream & printTags(std::ostream &out, const std::string &prefix=std::string()) const
print tags method that outputs a key/value type format adding prefix to keys.
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
std::vector< ossimNitfTagInformation > theTagList
virtual bool getTagInformation(ossimNitfTagInformation &tag, int idx) const
virtual ossim_int32 getNumberOfSymbols() const =0
virtual bool getTag(ossimNitfTagInformation &tagInfo, const ossimString &tagName) const
virtual ossim_uint32 getTotalTagLength() const
ossimRefPtr< ossimNitfRegisteredTag > getTagData()
virtual ossim_int32 getNumberOfTextSegments() const =0
virtual void removeTag(const ossimString &tagName)
unsigned int ossim_uint32
virtual ossim_int32 getNumberOfDataExtSegments() const =0
virtual ossim_int32 getNumberOfGraphics() const =0
virtual void addChildren(std::vector< ossimRefPtr< ossimProperty > > &propertyList)
void setName(const ossimString &name)
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual void addChild(ossimProperty *propery)
virtual bool saveState(ossimKeywordlist &kwl, const ossimString &prefix) const
virtual int getNumberOfTags() const
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
void addTag(const ossimNitfTagInformation &tag, bool unique=true)
virtual ossim_int32 getNumberOfImages() const =0