feisty meow concerns codebase  2.140
outcome.h
Go to the documentation of this file.
1 #ifndef OUTCOME_CLASS
2 #define OUTCOME_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : outcome *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 1990-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
18 #include "definitions.h"
19 
20 namespace basis {
21 
23 
30 class outcome
31 {
32 public:
33  outcome(int value = 0) : c_outcome_value(value) {}
35 
41  ~outcome() { c_outcome_value = 0; }
42 
43  bool equal_to(const outcome &to_compare) const
44  { return c_outcome_value == to_compare.c_outcome_value; }
46 
49  bool operator == (int to_compare) const
50  { return c_outcome_value == to_compare; }
52 
53  int value() const { return c_outcome_value; }
54  //<! returns the numerical value for the outcome.
55 
56  int packed_size() const { return 4; }
58 
61 private:
62  int c_outcome_value; //<! the numerical id for the outcome.
63 };
64 
66 
68 #define PROMOTE_OUTCOME(outc) \
69  if (outc != common::OKAY) return outc
70 
72 
74 
80 #define DEFINE_OUTCOME(NAME, CURRENT_VALUE, INFO_STRING) \
81  NAME = CURRENT_VALUE
82 
84 
90 #define DEFINE_API_OUTCOME(NAME, CURRENT_VALUE, INFO_STRING) \
91  NAME = CURRENT_VALUE
92 
94 
95 } //namespace.
96 
97 #endif
98 
Outcomes describe the state of completion for an operation.
Definition: outcome.h:31
bool equal_to(const outcome &to_compare) const
Returns true if this outcome is equal to "to_compare".
Definition: outcome.h:42
outcome(int value=0)
Represents the completion of an operation as a particular "value".
Definition: outcome.h:33
~outcome()
destructor resets outcome value.
Definition: outcome.h:40
int value() const
Definition: outcome.h:51
int packed_size() const
a convenience function for those packing outcomes.
Definition: outcome.h:54
bool operator==(int to_compare) const
Returns true if this outcome is equal to the integer "to_compare".
Definition: outcome.h:47
Constants and objects used throughout HOOPLE.
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30