OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimContainerProperty.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts
6 //
7 //*************************************************************************
8 // $Id: ossimContainerProperty.cpp 19920 2011-08-09 12:04:27Z gpotts $
12 
13 RTTI_DEF1(ossimContainerProperty, "ossimContainerProperty", ossimProperty);
14 
16  :ossimProperty(name)
17 {
18 }
19 
21  :ossimProperty(rhs)
22 {
23  copyList(rhs);
24 }
25 
27 {
29 }
30 
32 {
33  return new ossimContainerProperty(*this);
34 }
35 
37 {
38  const ossimContainerProperty* rhsContainer = dynamic_cast<const ossimContainerProperty*>(&rhs);
40 
41  if(rhsContainer)
42  {
43  copyList(*rhsContainer);
44  }
45 
46  return *this;
47 }
48 
50 {
52 
53  for(ossim_uint32 idx = 0; idx < rhs.theChildPropertyList.size();++idx)
54  {
55  if(rhs.theChildPropertyList[idx].valid())
56  {
57  theChildPropertyList.push_back((ossimProperty*)(rhs.theChildPropertyList[idx]->dup()));
58  }
59  else
60  {
61  theChildPropertyList.push_back((ossimProperty*)0);
62  }
63  }
64 }
65 
67 {
68  for(ossim_uint32 idx = 0; idx < propertyList.size(); ++idx)
69  {
70  if(propertyList[idx].valid())
71  {
72  theChildPropertyList.push_back(propertyList[idx]);
73  }
74  }
75 }
76 
78 {
79  theChildPropertyList.push_back(property);
80 }
81 
83  const ossimString& value,
84  bool readOnlyFlag)
85 {
86  ossimProperty* prop = new ossimStringProperty(name, value);
87 
88  prop->setReadOnlyFlag(readOnlyFlag);
89  addChild(prop);
90 }
91 
93 {
94  return this;
95 }
96 
98 {
99  return this;
100 }
101 
103  bool recurse)
104 {
105  ossim_uint32 idx = 0;
106  std::vector<ossimRefPtr<ossimContainerProperty> > containers;
107  if(name == getName())
108  {
109  return this;
110  }
111  for(idx = 0; idx < theChildPropertyList.size(); ++idx)
112  {
113  if(theChildPropertyList[idx].valid())
114  {
115  if(theChildPropertyList[idx]->getName() == name)
116  {
117  return theChildPropertyList[idx];
118  }
119  if(dynamic_cast<ossimContainerProperty*>(theChildPropertyList[idx].get())&&recurse)
120  {
121  containers.push_back(dynamic_cast<ossimContainerProperty*>(theChildPropertyList[idx].get()));
122  }
123  }
124  }
125 
126  if(containers.size())
127  {
128  for(idx = 0; idx < containers.size();++idx)
129  {
130  ossimRefPtr<ossimProperty> prop = containers[idx]->getProperty(name, recurse);
131  if(prop.valid())
132  {
133  return prop;
134  }
135  }
136  }
137 
138  return (ossimProperty*)0;
139 }
140 
142 {
143 // for(ossim_uint32 idx = 0; idx < theChildPropertyList.size(); ++idx)
144 // {
145 // if(theChildPropertyList[idx])
146 // {
147 // delete theChildPropertyList[idx];
148 // theChildPropertyList[idx] = (ossimProperty*)0;
149 // }
150 // }
151  theChildPropertyList.clear();
152 }
153 
154 
156 {
157  return false;
158 }
159 
161 {
162 }
163 
165 {
166  return (ossim_uint32)theChildPropertyList.size();
167 }
168 
170 {
171  if(idx < theChildPropertyList.size())
172  {
173  return theChildPropertyList[idx];
174  }
175 
176  return (ossimProperty*)0;
177 }
178 
180  std::vector<ossimRefPtr<ossimProperty> >& children) const
181 {
182  children = theChildPropertyList;
183 }
184 
186 {
187  ossimXmlNode* result = new ossimXmlNode;
188 
189  result->setTag(getName());
190 
191  ossim_uint32 idx = 0;
192  for(idx = 0; idx < theChildPropertyList.size(); ++idx)
193  {
194  ossimRefPtr<ossimXmlNode> child = theChildPropertyList[idx]->toXml();
195 
196  result->addChildNode(child.get());
197  }
198 
199  return result;
200 }
201 
203 {
205  ossim_uint32 idx = 0;
206  for(idx = 0; idx < theChildPropertyList.size(); ++idx)
207  {
208  theChildPropertyList[idx]->setReadOnlyFlag(flag);
209  }
210 }
211 
213 {
214  ossim_uint32 idx = 0;
215  if(!visitor.hasVisited(this))
216  {
217  ossimProperty::accept(visitor);
219  {
220  for(idx = 0; idx < theChildPropertyList.size(); ++idx)
221  {
222  theChildPropertyList[idx]->accept(visitor);
223  }
224  }
225  }
226 }
227 
void setTag(const ossimString &tag)
virtual void accept(ossimVisitor &visitor)
virtual void getPropertyList(std::vector< ossimRefPtr< ossimProperty > > &children) const
virtual ossim_uint32 getNumberOfProperties() const
virtual bool setValue(const ossimString &value)
bool valid() const
Definition: ossimRefPtr.h:75
ossimContainerProperty(const ossimString &name=ossimString(""))
virtual const ossimProperty & assign(const ossimProperty &rhs)
virtual void addStringProperty(const ossimString &name, const ossimString &value, bool readOnlyFlag=false)
virtual void setReadOnlyFlag(bool flag)
virtual const ossimProperty & assign(const ossimProperty &rhs)
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name, bool recurse=false)
std::vector< ossimRefPtr< ossimProperty > > theChildPropertyList
virtual ossimString valueToString() const
virtual void accept(ossimVisitor &visitor)
unsigned int ossim_uint32
RTTI_DEF1(ossimContainerProperty, "ossimContainerProperty", ossimProperty)
bool hasVisited(ossimObject *obj) const
virtual void copyList(const ossimContainerProperty &rhs)
virtual void addChildren(std::vector< ossimRefPtr< ossimProperty > > &propertyList)
virtual ossimObject * dup() const
virtual void setReadOnlyFlag(bool flag)
VisitorType getVisitorType() const
virtual void addChild(ossimProperty *propery)
virtual const ossimContainerProperty * asContainer() const
void addChildNode(ossimRefPtr< ossimXmlNode > node)
virtual ossimRefPtr< ossimXmlNode > toXml() const
const ossimString & getName() const