Program Listing for File snooze_pos.hpp

Return to documentation for file (/tmp/ws/src/ecl_core/ecl_time/include/ecl/time/snooze_pos.hpp)

/*****************************************************************************
** Ifdefs
*****************************************************************************/

#ifndef ECL_TIME_SNOOZE_POS_HPP_
#define ECL_TIME_SNOOZE_POS_HPP_

/*****************************************************************************
** Platform Check
*****************************************************************************/

#include <ecl/config.hpp>
#if defined(ECL_IS_POSIX)

/*****************************************************************************
** Includes
*****************************************************************************/

#include "duration.hpp"
#include <ecl/config/macros.hpp>
#include <ecl/time_lite/types.hpp>
#include "macros.hpp"

/*****************************************************************************
** Namespaces
*****************************************************************************/

namespace ecl {

/*****************************************************************************
** Classes [Snooze]
*****************************************************************************/

class ecl_time_PUBLIC Snooze {
public:
    /*********************
    ** C&D's
    **********************/
    Snooze();
    Snooze (const Duration &time, const bool& validate = false );
    virtual ~Snooze() {}

    /*********************
    ** Usage Methods
    **********************/
    void period(const Duration &time, const bool& validate = false);
    Duration period() { return Duration(time_period.tv_sec,time_period.tv_nsec); }
    void initialise();
    void operator()();

protected:
    /*********************
    ** Internal Methods
    **********************/
    void add_period();
    void validate();

    /*********************
    ** Internal Variables
    **********************/
    TimeStructure time_value;
    TimeStructure time_period;
    long wrap_value_ns;
    bool validate_times;

};

} // namespace ecl

#endif /* ECL_IS_POSIX */
#endif /* ECL_TIME_SNOOZE_POS_HPP_ */