7 #include "PlusConfigure.h" 31 LOG_TRACE(
"vtkPlusParameters::~vtkPlusParameters()");
50 Superclass::PrintSelf(os, indent);
54 if (it->second.Set ==
true)
56 os << indent << it->first <<
": " << it->second.Value
57 << (it->second.Pending ?
" (pending)" :
"") << std::endl;
65 vtkXMLDataElement* parameterList(NULL);
66 for (
int i = 0;
i < deviceConfig->GetNumberOfNestedElements(); ++
i)
68 vtkXMLDataElement* element = deviceConfig->GetNestedElement(
i);
71 parameterList = element;
76 if (parameterList == NULL)
78 LOG_ERROR(
"Unable to locate " << this->
GetXMLElementName() <<
" tag in device config.Unable to read imaging parameters.Device defaults will probably be used.");
82 for (
int i = 0;
i < parameterList->GetNumberOfNestedElements(); ++
i)
84 vtkXMLDataElement* element = parameterList->GetNestedElement(
i);
85 std::string name = element->GetAttribute(
NAME_TAG) ? element->GetAttribute(
NAME_TAG) :
"";
117 XML_FIND_NESTED_ELEMENT_CREATE_IF_MISSING(parameterList, deviceConfig, this->
GetXMLElementName());
120 parameterList->RemoveAllNestedElements();
124 if (it->second.Set ==
false)
130 vtkSmartPointer<vtkXMLDataElement> parameter = vtkSmartPointer<vtkXMLDataElement>::New();
132 parameter->SetAttribute(
NAME_TAG, it->first.c_str());
133 parameter->SetAttribute(
VALUE_TAG, it->second.Value.c_str());
135 parameterList->AddNestedElement(parameter);
147 return keyIt->second.Set;
150 LOG_ERROR(
"Invalid key request sent to vtkPlusParameters::IsSet -- " << paramName);
160 return keyIt->second.Pending;
163 LOG_ERROR(
"Invalid key request sent to vtkPlusParameters::IsPending -- " << paramName);
173 if (keyIt->second.Set)
175 keyIt->second.Pending = pending;
180 LOG_ERROR(
"Pending status cannot be set for unset parameter -- " << paramName);
185 LOG_ERROR(
"Invalid key request sent to vtkPlusParameters::SetPending -- " << paramName);
194 if (this->
Parameters[it->first].Value != it->second.Value)
199 this->
Parameters[it->first].Value = it->second.Value;
200 this->
Parameters[it->first].Set = it->second.Set;
ParameterMapConstIterator begin() const
ParameterMap::iterator ParameterMapIterator
virtual PlusStatus DeepCopy(const vtkPlusParameters &otherParameters)
bool IsSet(const std::string ¶mName) const
This class is used as the basis to store a configuration of generic parameters for any device....
static const char * NAME_TAG
static const char * XML_ELEMENT_TAG
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *deviceConfig)
ParameterMap::const_iterator ParameterMapConstIterator
bool IsPending(const std::string ¶mName) const
const char const char * value
ParameterMapConstIterator end() const
virtual ~vtkPlusParameters()
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *deviceConfig)
static const char * VALUE_TAG
static const char * PARAMETER_TAG
virtual const char * GetXMLElementName()
vtkStandardNewMacro(vtkPlusParameters)
PlusStatus SetPending(const std::string ¶mName, bool pending)