Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include <mitkAbstractClassifier.h>
18 
19 
20 void mitk::AbstractClassifier::SetNthItems(const char * val, unsigned int idx)
21 {
22  std::stringstream ss;
23  ss << "itemlist." << idx;
24  this->GetPropertyList()->SetStringProperty(ss.str().c_str(),val);
25 }
26 
27 std::string mitk::AbstractClassifier::GetNthItems(unsigned int idx) const
28 {
29  std::stringstream ss;
30  ss << "itemlist." << idx;
31  std::string val;
32  this->GetPropertyList()->GetStringProperty(ss.str().c_str(),val);
33  return val;
34 }
35 
36 void mitk::AbstractClassifier::SetItemList(std::vector<std::string> list)
37 {
38  for(unsigned int i = 0 ; i < list.size(); ++i)
39  this->SetNthItems(list[i].c_str(),i);
40 }
41 
42 std::vector<std::string> mitk::AbstractClassifier::GetItemList() const
43 {
44  std::vector<std::string> result;
45  for(unsigned int idx = 0 ;; idx++)
46  {
47  std::stringstream ss;
48  ss << "itemlist." << idx;
49  if(this->GetPropertyList()->GetProperty(ss.str().c_str()))
50  {
51  std::string s;
52  this->GetPropertyList()->GetStringProperty(ss.str().c_str(),s);
53  result.push_back(s);
54  }else
55  break;
56  }
57  return result;
58 }
void SetItemList(std::vector< std::string >)
std::string GetNthItems(unsigned int idx) const
void SetNthItems(const char *val, unsigned int idx)
std::vector< std::string > GetItemList() const
mitk::PropertyList::Pointer GetPropertyList() const
Get the data's property list.