소스 검색

cleaned up namespace in timing

master
Pete McNeil 3 년 전
부모
커밋
bb411702d8
2개의 변경된 파일10개의 추가작업 그리고 13개의 파일을 삭제
  1. 6
    6
      timing.cpp
  2. 4
    7
      timing.hpp

+ 6
- 6
timing.cpp 파일 보기



#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 파일 보기

// 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…
취소
저장