Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryEvaluationResult.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
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 "berryEvaluationResult.h"
18 
19 namespace berry {
20 
21 const int EvaluationResult::FALSE_VALUE = 0;
22 const int EvaluationResult::TRUE_VALUE = 1;
23 const int EvaluationResult::NOT_LOADED_VALUE = 2;
24 
25 const SmartPointer<const EvaluationResult> EvaluationResult::FALSE_EVAL(new EvaluationResult(EvaluationResult::FALSE_VALUE));
26 const SmartPointer<const EvaluationResult> EvaluationResult::TRUE_EVAL(new EvaluationResult(EvaluationResult::TRUE_VALUE));
27 const SmartPointer<const EvaluationResult> EvaluationResult::NOT_LOADED(new EvaluationResult(NOT_LOADED_VALUE));
28 
29 bool EvaluationResult::operator==(const Object* result) const
30 {
31  if(const EvaluationResult* o = dynamic_cast<const EvaluationResult*>(result))
32  {
33  return this->fValue == o->fValue;
34  }
35  return false;
36 }
37 
38 bool EvaluationResult::operator!=(const Object* result) const
39 {
40  return !(this == result);
41 }
42 
43 const SmartPointer<const EvaluationResult> EvaluationResult::AND[3][3] = {
44  // FALSE TRUE NOT_LOADED
45  /* FALSE */ { EvaluationResult::FALSE_EVAL, EvaluationResult::FALSE_EVAL, EvaluationResult::FALSE_EVAL },
47  /* PNL */ { EvaluationResult::FALSE_EVAL, EvaluationResult::NOT_LOADED, EvaluationResult::NOT_LOADED }
48 };
49 
50 const SmartPointer<const EvaluationResult> EvaluationResult::OR[3][3] = {
51  // FALSE TRUE NOT_LOADED
53  /* TRUE */ { EvaluationResult::TRUE_EVAL, EvaluationResult::TRUE_EVAL, EvaluationResult::TRUE_EVAL },
55 };
56 
57 const SmartPointer<const EvaluationResult> EvaluationResult::NOT[3] = {
58  // FALSE TRUE NOT_LOADED
60 };
61 
62 
63 EvaluationResult::EvaluationResult(int value)
64 {
65  fValue= value;
66 }
67 
68 EvaluationResult::EvaluationResult(const EvaluationResult &o)
69  : Object()
70  , fValue(o.fValue)
71 {
72 }
73 
76 {
77  return AND[fValue][other->fValue];
78 }
79 
82 {
83  return OR[fValue][other->fValue];
84 }
85 
86 
89 {
90  return NOT[fValue];
91 }
92 
95 {
96  return (b ? TRUE_EVAL : FALSE_EVAL);
97 }
98 
99 
101 {
102  switch (fValue) {
103  case 0:
104  return "false";
105  case 1:
106  return "true";
107  case 2:
108  return "not_loaded";
109  default:
110  Q_ASSERT(false);
111  return "";
112  }
113 }
114 
115 } // namespace berry
berry::SmartPointer< const Self > ConstPointer
Definition: berryObject.h:89
bool operator!=(const Object *) const
static const SmartPointer< const EvaluationResult > FALSE_EVAL
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:78
virtual bool operator==(const Object *) const
Implements transparent reference counting.
static EvaluationResult::ConstPointer ValueOf(bool b)
EvaluationResult::ConstPointer Not() const
EvaluationResult::ConstPointer And(const EvaluationResult::ConstPointer &other) const
EvaluationResult::ConstPointer Or(const EvaluationResult::ConstPointer &other) const
static const SmartPointer< const EvaluationResult > TRUE_EVAL
QString ToString() const override
static const SmartPointer< const EvaluationResult > NOT_LOADED