Overture
Version 25
Main Page
Namespaces
Classes
Files
File List
File Members
Overture.v25.d
include
Bound.h
Go to the documentation of this file.
1
#ifndef BOUND_H
2
#define BOUND_H "bound.h"
3
4
#include "
OvertureTypes.h
"
5
#include "
Fraction.h
"
6
7
// Define a bound type as either a fraction or a real number
8
9
enum
boundType
{
realNumber
,
fraction
,
null
};
10
11
class
Bound
{
12
protected
:
13
boundType
bt
;
14
real
x
;
15
Fraction
f
;
16
public
:
17
Bound
( ){
bt
=
null
;
x
=0.;
f
=
Fraction
(0,1); }
// wdh 051018 -- add defaults to all variables to fix UMR's
18
Bound
(
const
real
x0 ){
bt
=
realNumber
;
x
=x0;
f
=
Fraction
(0,1); }
19
Bound
(
const
int
i ){
bt
=
fraction
;
f
=
Fraction
(i,1);
x
=0.; }
20
Bound
(
const
Fraction
f0 ){
bt
=
fraction
;
f
=f0; }
21
virtual
~Bound
(){};
//kkc 040414 added virtual to get rid of warnings
22
virtual
int
get
(
const
GenericDataBase
& dir,
const
aString
& name);
// get from a database file
23
virtual
int
put
(
GenericDataBase
& dir,
const
aString
& name)
const
;
// put to a database file
24
25
// ---here are the access routines to set/get values
26
inline
void
set
(
const
real
value );
27
inline
void
set
(
const
int
value );
28
inline
void
set
(
const
int
n,
const
int
d );
29
void
get
(
boundType
& bndType,
real
& rvalue,
Fraction
& fvalue )
const
;
30
31
bool
isFinite
();
32
operator
real
();
33
34
// ---here are routines to define arithmetic and relational operators
35
friend
Bound
operator +
(
const
Bound
b1,
const
Bound
b2 );
36
friend
Bound
operator -
(
const
Bound
b1,
const
Bound
b2 );
37
friend
Bound
operator *
(
const
Bound
b1,
const
Bound
b2 );
38
friend
Bound
operator /
(
const
Bound
b1,
const
Bound
b2 );
39
friend
int
operator <=
(
const
Bound
b1,
const
Bound
b2 );
40
friend
int
operator <
(
const
Bound
b1,
const
Bound
b2 );
41
friend
int
operator >=
(
const
Bound
b1,
const
Bound
b2 );
42
friend
int
operator >
(
const
Bound
b1,
const
Bound
b2 );
43
friend
int
operator ==
(
const
Bound
b1,
const
Bound
b2 );
44
friend
ostream&
operator<<
( ostream&,
const
Bound
& );
45
};
46
47
48
inline
void
Bound::set
(
const
real
value ){
bt
=
realNumber
;
x
=value;}
49
inline
void
Bound::set
(
const
int
value ){
bt
=
fraction
;
f
=
Fraction
( value ); }
50
inline
void
Bound::set
(
const
int
n,
const
int
d ){
bt
=
fraction
;
f
=
Fraction
(n,d); }
51
52
#endif // BOUND_H
53
Generated on Fri Jan 4 2013 10:17:48 for Overture by
1.8.3