Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkAbstractClassifier.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <mitkAbstractClassifier.h>
14 
15 
16 void mitk::AbstractClassifier::SetNthItems(const char * val, unsigned int idx)
17 {
18  std::stringstream ss;
19  ss << "itemlist." << idx;
20  this->GetPropertyList()->SetStringProperty(ss.str().c_str(),val);
21 }
22 
23 std::string mitk::AbstractClassifier::GetNthItems(unsigned int idx) const
24 {
25  std::stringstream ss;
26  ss << "itemlist." << idx;
27  std::string val;
28  this->GetPropertyList()->GetStringProperty(ss.str().c_str(),val);
29  return val;
30 }
31 
32 void mitk::AbstractClassifier::SetItemList(std::vector<std::string> list)
33 {
34  for(unsigned int i = 0 ; i < list.size(); ++i)
35  this->SetNthItems(list[i].c_str(),i);
36 }
37 
38 std::vector<std::string> mitk::AbstractClassifier::GetItemList() const
39 {
40  std::vector<std::string> result;
41  for(unsigned int idx = 0 ;; idx++)
42  {
43  std::stringstream ss;
44  ss << "itemlist." << idx;
45  if(this->GetPropertyList()->GetProperty(ss.str().c_str()))
46  {
47  std::string s;
48  this->GetPropertyList()->GetStringProperty(ss.str().c_str(),s);
49  result.push_back(s);
50  }else
51  break;
52  }
53  return result;
54 }
std::vector< std::string > GetItemList() const
void SetItemList(std::vector< std::string >)
std::string GetNthItems(unsigned int idx) const
void SetNthItems(const char *val, unsigned int idx)
mitk::PropertyList::Pointer GetPropertyList() const
Get the data&#39;s property list.
mitk::BaseProperty::Pointer GetProperty(const char *propertyKey) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList, and set it to this, respectively;.