Polaris: Monotonicity.cc Source File

Monotonicity.cc

Go to the documentation of this file.
00001 ///
00002 /// \file Monotonicity.cc
00003 ///
00004 #ifdef POLARIS_GNU_PRAGMAS
00005 #pragma implementation
00006 #endif
00007 ///
00008 #include "Monotonicity.h"
00009 
00010 Monotonicity::Monotonicity( ) 
00011 {
00012     #ifdef CLASS_INSTANCE_REGISTRY
00013     register_instance(MONOTONICITY, sizeof(Monotonicity), this);
00014     #endif
00015 
00016     _direction = MONO_DIR_UNKNOWN;
00017     _movement  = MONO_MOV_UNKNOWN;
00018 }
00019 
00020 Monotonicity::Monotonicity( MONO_DIR direction, MONO_MOV movement) 
00021 {
00022     #ifdef CLASS_INSTANCE_REGISTRY
00023     register_instance(MONOTONICITY, sizeof(Monotonicity), this);
00024     #endif
00025 
00026     _direction = direction;
00027     _movement = movement;
00028 }
00029 
00030 Monotonicity::Monotonicity( const Monotonicity & other ) 
00031 {
00032     #ifdef CLASS_INSTANCE_REGISTRY
00033     register_instance(MONOTONICITY, sizeof(Monotonicity), this);
00034     #endif
00035 
00036     _direction = other._direction;
00037     _movement  = other._movement;
00038 }
00039 
00040 Monotonicity::~Monotonicity( ) 
00041 {
00042     #ifdef CLASS_INSTANCE_REGISTRY
00043     unregister_instance(MONOTONICITY, this);
00044     #endif
00045 }
00046 
00047 Listable *
00048 Monotonicity::listable_clone() const
00049 {
00050     return (Listable *) clone();
00051 }
00052 
00053 Monotonicity * 
00054 Monotonicity::clone( ) const 
00055 {
00056     return new Monotonicity( *this );
00057 }
00058 
00059 void
00060 Monotonicity::monotonicity( Monotonicity mon )
00061 {
00062     _direction = mon._direction;
00063     _movement = mon._movement;
00064 }
00065 
00066 MONO_DIR 
00067 Monotonicity::mono_dir( ) const 
00068 {
00069     return _direction;
00070 }
00071 
00072 MONO_MOV
00073 Monotonicity::mono_mov( ) const 
00074 {
00075     return _movement;
00076 }
00077 
00078 bool
00079 Monotonicity::unknown_dir ( ) const
00080 {
00081     return (_direction == MONO_DIR_UNKNOWN);
00082 }
00083 
00084 bool
00085 Monotonicity::positive ( ) const
00086 {
00087     return (_direction == MONO_POSITIVE);
00088 }
00089 
00090 bool
00091 Monotonicity::negative ( ) const
00092 {
00093     return (_direction == MONO_NEGATIVE);
00094 }
00095 
00096 bool
00097 Monotonicity::unknown_mov ( ) const
00098 {
00099     return (_movement == MONO_MOV_UNKNOWN);
00100 }
00101 
00102 bool
00103 Monotonicity::varying ( ) const
00104 {
00105     return (_movement == MONO_VARYING);
00106 }
00107 
00108 bool
00109 Monotonicity::constant ( ) const
00110 {
00111     return (_movement == MONO_CONSTANT);
00112 }
00113 
00114 void
00115 Monotonicity::set_unknown_dir ( )
00116 {
00117     _direction = MONO_DIR_UNKNOWN;
00118 }
00119 
00120 void
00121 Monotonicity::set_positive ( ) 
00122 {
00123     _direction = MONO_POSITIVE;
00124 }
00125 
00126 void
00127 Monotonicity::set_negative ( ) 
00128 {
00129     _direction = MONO_NEGATIVE;
00130 }
00131 
00132 void
00133 Monotonicity::set_unknown_mov ( ) 
00134 {
00135     _movement = MONO_MOV_UNKNOWN;
00136 }
00137 
00138 void
00139 Monotonicity::set_varying ( ) 
00140 {
00141     _movement = MONO_VARYING;
00142 }
00143 
00144 void
00145 Monotonicity::set_constant ( )
00146 {
00147     _movement = MONO_CONSTANT;
00148 }
00149 
00150 void
00151 Monotonicity::print( ostream & o ) const 
00152 {
00153     o << "{";
00154     switch (_direction)
00155     {
00156     case MONO_POSITIVE:
00157         o << "POSITIVE";
00158         break;
00159     case MONO_NEGATIVE:
00160         o << "NEGATIVE";
00161         break;
00162     case MONO_DIR_UNKNOWN:
00163         o << "UNKNOWN";
00164         break;
00165     default:
00166         o << "BAD VALUE";
00167         break;
00168     }
00169 
00170     o << ";";
00171 
00172     switch (_movement)
00173     {
00174     case MONO_VARYING:
00175         o << "VARYING";
00176         break;
00177     case MONO_CONSTANT:
00178         o << "CONSTANT";
00179         break;
00180     case MONO_MOV_UNKNOWN:
00181         o << "UNKNOWN";
00182         break;
00183     default:
00184         o << "BAD VALUE";
00185         break;
00186     }
00187 
00188     o << "}";
00189 }
00190 
00191 ostream & 
00192 operator << (ostream & o, const Monotonicity & mon) 
00193 {
00194     mon.print(o);
00195     return o;
00196 }
00197 
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:05:59 2005