OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimStringProperty.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // LICENSE: LGPL see top level license.txt
5 //
6 // Author: Garrett Potts
7 //
8 //*************************************************************************
9 // $Id: ossimStringProperty.cpp 9094 2006-06-13 19:12:40Z dburken $
11 #include <algorithm>
12 RTTI_DEF1(ossimStringProperty, "ossimStringProperty", ossimProperty);
13 
15  const ossimString& value,
16  bool editableFlag,
17  const std::vector<ossimString>& constraintList)
18  :ossimProperty(name),
19  theValue(value),
20  theEditableFlag(editableFlag),
21  theConstraints(constraintList)
22 {
23 }
24 
26  :ossimProperty(rhs),
27  theValue(rhs.theValue),
28  theEditableFlag(rhs.theEditableFlag),
29  theConstraints(rhs.theConstraints)
30 {
31 }
32 
34 {
35  return new ossimStringProperty(*this);
36 }
37 
39 {
41 
42  const ossimStringProperty* rhsPtr = dynamic_cast<const ossimStringProperty*>(&rhs);
43 
44  theValue = rhs.valueToString();
45 
46  if(rhsPtr)
47  {
50  }
51 
52  return *this;
53 }
54 
55 
57 {
58  theEditableFlag = flag;
59 }
60 
62 {
63  return theEditableFlag;
64 }
65 
67 {
68  return (getEditableFlag() == true);
69 }
70 
71 
73 {
74  theConstraints.clear();
75 }
76 
77 void ossimStringProperty::setConstraints(const std::vector<ossimString>& constraintList)
78 {
79  theConstraints = constraintList;
80 }
81 
83 {
84  theConstraints.push_back(value);
85 }
86 
87 const std::vector<ossimString>& ossimStringProperty::getConstraints()const
88 {
89  return theConstraints;
90 }
91 
93 {
94  return (theConstraints.size() > 0);
95 }
96 
98 {
99  bool result = true;
100 
101  if(theConstraints.size() > 0)
102  {
103  if(std::find(theConstraints.begin(),
104  theConstraints.end(),
105  value)
106  != theConstraints.end())
107  {
108  theValue = value;
109  }
110  else
111  {
112  result = false;
113  }
114  }
115  else
116  {
117  theValue = value;
118  }
119 
120  return result;
121 }
122 
124 {
125  valueResult = theValue;
126 }
virtual void valueToString(ossimString &valueResult) const =0
ossimStringProperty(const ossimString &name=ossimString(""), const ossimString &value=ossimString(""), bool editableFlag=true, const std::vector< ossimString > &constraintList=std::vector< ossimString >())
virtual const ossimProperty & assign(const ossimProperty &rhs)
void addConstraint(const ossimString &value)
const std::vector< ossimString > & getConstraints() const
std::vector< ossimString > theConstraints
virtual ossimString valueToString() const
void setEditableFlag(bool flag)
RTTI_DEF1(ossimStringProperty, "ossimStringProperty", ossimProperty)
virtual const ossimProperty & assign(const ossimProperty &rhs)
virtual ossimObject * dup() const
virtual bool setValue(const ossimString &value)
void setConstraints(const std::vector< ossimString > &constraintList)