Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
berryEvaluationResult.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 "berryEvaluationResult.h"
14 
15 namespace berry {
16 
17 const int EvaluationResult::FALSE_VALUE = 0;
18 const int EvaluationResult::TRUE_VALUE = 1;
19 const int EvaluationResult::NOT_LOADED_VALUE = 2;
20 
21 const SmartPointer<const EvaluationResult> EvaluationResult::FALSE_EVAL(new EvaluationResult(EvaluationResult::FALSE_VALUE));
22 const SmartPointer<const EvaluationResult> EvaluationResult::TRUE_EVAL(new EvaluationResult(EvaluationResult::TRUE_VALUE));
23 const SmartPointer<const EvaluationResult> EvaluationResult::NOT_LOADED(new EvaluationResult(NOT_LOADED_VALUE));
24 
25 bool EvaluationResult::operator==(const Object* result) const
26 {
27  if(const EvaluationResult* o = dynamic_cast<const EvaluationResult*>(result))
28  {
29  return this->fValue == o->fValue;
30  }
31  return false;
32 }
33 
34 bool EvaluationResult::operator!=(const Object* result) const
35 {
36  return !(this == result);
37 }
38 
39 const SmartPointer<const EvaluationResult> EvaluationResult::AND[3][3] = {
40  // FALSE TRUE NOT_LOADED
41  /* FALSE */ { EvaluationResult::FALSE_EVAL, EvaluationResult::FALSE_EVAL, EvaluationResult::FALSE_EVAL },
43  /* PNL */ { EvaluationResult::FALSE_EVAL, EvaluationResult::NOT_LOADED, EvaluationResult::NOT_LOADED }
44 };
45 
46 const SmartPointer<const EvaluationResult> EvaluationResult::OR[3][3] = {
47  // FALSE TRUE NOT_LOADED
48  /* FALSE */ { EvaluationResult::FALSE_EVAL, EvaluationResult::TRUE_EVAL, EvaluationResult::NOT_LOADED },
49  /* TRUE */ { EvaluationResult::TRUE_EVAL, EvaluationResult::TRUE_EVAL, EvaluationResult::TRUE_EVAL },
50  /* PNL */ { EvaluationResult::NOT_LOADED, EvaluationResult::TRUE_EVAL, EvaluationResult::NOT_LOADED }
51 };
52 
53 const SmartPointer<const EvaluationResult> EvaluationResult::NOT[3] = {
54  // FALSE TRUE NOT_LOADED
55  EvaluationResult::TRUE_EVAL, EvaluationResult::FALSE_EVAL, EvaluationResult::NOT_LOADED
56 };
57 
58 
59 EvaluationResult::EvaluationResult(int value)
60 {
61  fValue= value;
62 }
63 
64 EvaluationResult::EvaluationResult(const EvaluationResult &o)
65  : Object()
66  , fValue(o.fValue)
67 {
68 }
69 
72 {
73  return AND[fValue][other->fValue];
74 }
75 
78 {
79  return OR[fValue][other->fValue];
80 }
81 
82 
85 {
86  return NOT[fValue];
87 }
88 
91 {
92  return (b ? TRUE_EVAL : FALSE_EVAL);
93 }
94 
95 
97 {
98  switch (fValue) {
99  case 0:
100  return "false";
101  case 1:
102  return "true";
103  case 2:
104  return "not_loaded";
105  default:
106  Q_ASSERT(false);
107  return "";
108  }
109 }
110 
111 } // namespace berry
static const SmartPointer< const EvaluationResult > FALSE_EVAL
EvaluationResult::ConstPointer Or(const EvaluationResult::ConstPointer &other) const
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:72
Implements transparent reference counting.
bool operator==(const Object *) const override
bool operator!=(const Object *) const
static EvaluationResult::ConstPointer ValueOf(bool b)
EvaluationResult::ConstPointer And(const EvaluationResult::ConstPointer &other) const
static const SmartPointer< const EvaluationResult > TRUE_EVAL
QString ToString() const override
EvaluationResult::ConstPointer Not() const
static const SmartPointer< const EvaluationResult > NOT_LOADED