diff options
Diffstat (limited to 'examples/APG/Naming/Thermometer.h')
-rw-r--r-- | examples/APG/Naming/Thermometer.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/APG/Naming/Thermometer.h b/examples/APG/Naming/Thermometer.h new file mode 100644 index 00000000000..609167874e7 --- /dev/null +++ b/examples/APG/Naming/Thermometer.h @@ -0,0 +1,47 @@ +/* -*- C++ -*- */ +// $Id$ + +#ifndef THERMOMETER_H +#define THERMOMETER_H + +#include "ace/Log_Msg.h" + +class Thermometer +{ +public: + Thermometer (const char *addr) + : addr_(addr), threshold_(5) + { } + + float temperature (void) + { + int success = ACE_OS::rand () % 10; + if (success < this->threshold_) + { + this->threshold_ = 7; + return -1.0; + } + + this->threshold_ = 3; + int itemp = 80 + ACE_OS::rand () % 10; // 80 <= t <= 90 + return (float)itemp; + } + + const char *address (void) + { + return this->addr_; + } + + void reset (void) + { + this->threshold_ = 4; + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Resetting thermometer %C\n"), + this->address ())); + } + +private: + const char *addr_; + int threshold_; +}; + +#endif /* THERMOMETER_H */ |