Browse Source

cleaned up namespace in timing

master
Pete McNeil 4 years ago
parent
commit
bb411702d8
2 changed files with 10 additions and 13 deletions
  1. 6
    6
      timing.cpp
  2. 4
    7
      timing.hpp

+ 6
- 6
timing.cpp View File



#include "timing.hpp" #include "timing.hpp"


// Introduce the standard namespace ////////////////////////////////////////////

using namespace std;
namespace codedweller {


/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// class Sleeper - An object that remembers how long it is supposed to sleep. // class Sleeper - An object that remembers how long it is supposed to sleep.
if(x < MinimumSleeperTime || if(x < MinimumSleeperTime ||
x > MaximumSleeperTime) // If it's not a good time value x > MaximumSleeperTime) // If it's not a good time value
throw BadSleeperValue(); // then throw the exception. throw BadSleeperValue(); // then throw the exception.
MillisecondsToSleep = x; // If it is good - set it.
MillisecondsToSleep = x; // If it is good - set it.
return MillisecondsToSleep; // Return the set value. return MillisecondsToSleep; // Return the set value.
} }


// a natural spiral. // a natural spiral.
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////


PollTimer::PollTimer(int Nom, int Max) :
NominalPollTime(MinimumSleeperTime),
PollTimer::PollTimer(int Nom, int Max) :
NominalPollTime(MinimumSleeperTime),
MaximumPollTime(MinimumSleeperTime) { // Construction requires a MaximumPollTime(MinimumSleeperTime) { // Construction requires a
setNominalPollTime(Nom); // nominal delay to use and setNominalPollTime(Nom); // nominal delay to use and
setMaximumPollTime(Max); // a maximum delay to allow. setMaximumPollTime(Max); // a maximum delay to allow.
bool Timeout::isExpired() { // Return true if time is up. bool Timeout::isExpired() { // Return true if time is up.
return (!(myTimer.getElapsedTime() < myDuration)); // Check the elapsed time against myDuration. return (!(myTimer.getElapsedTime() < myDuration)); // Check the elapsed time against myDuration.
} }

} // End namespace codedweller

+ 4
- 7
timing.hpp View File

// bits and pieces. This module will provide classes that abstract // bits and pieces. This module will provide classes that abstract
// timing functions for use in GNU projects on *nix and win32 systems. // timing functions for use in GNU projects on *nix and win32 systems.


#ifndef MNR_timing
#define MNR_timing
#pragma once


// Introduce the standard namespace ///////////////////////////////////////////

using namespace std;
namespace codedweller {


/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// class Sleeper - An object that remembers how long it is supposed to sleep. // class Sleeper - An object that remembers how long it is supposed to sleep.


private: private:


bool RunningFlag; // True if clock is running.
bool RunningFlag; // True if clock is running.
msclock StartTime; // TimeOfDay at start. msclock StartTime; // TimeOfDay at start.
msclock StopTime; // TimeOfDay at stop or check. msclock StopTime; // TimeOfDay at stop or check.


** Returns true if time is up. ** Returns true if time is up.
*/ */


#endif // End MNR_timing once-only switch.
} // End namespace codedweller

Loading…
Cancel
Save