diff --git a/lib/time/Makefile.am b/lib/time/Makefile.am index 88add27..2511296 100644 --- a/lib/time/Makefile.am +++ b/lib/time/Makefile.am @@ -6,6 +6,7 @@ libgrnxx_time_la_SOURCES = \ broken_down_time.cpp \ duration.cpp \ internal_clock.cpp \ + periodic_clock.cpp \ stopwatch.cpp \ system_clock.cpp \ time.cpp @@ -15,6 +16,7 @@ libgrnxx_time_include_HEADERS = \ broken_down_time.hpp \ duration.hpp \ internal_clock.hpp \ + periodic_clock.hpp \ stopwatch.hpp \ system_clock.hpp \ time.hpp diff --git a/lib/time/periodic_clock.cpp b/lib/time/periodic_clock.cpp new file mode 100644 index 0000000..af5e22c --- /dev/null +++ b/lib/time/periodic_clock.cpp @@ -0,0 +1,37 @@ +/* + Copyright (C) 2013 Brazil, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "time/periodic_clock.hpp" + +namespace grnxx { +namespace { + +// TODO + +} // namespace + +Time PeriodicClock::now_ = Time::min(); + +PeriodicClock::PeriodicClock() { + // TODO +} + +PeriodicClock::~PeriodicClock() { + // TODO +} + +} // namespace grnxx diff --git a/lib/time/periodic_clock.hpp b/lib/time/periodic_clock.hpp new file mode 100644 index 0000000..3823a7c --- /dev/null +++ b/lib/time/periodic_clock.hpp @@ -0,0 +1,41 @@ +/* + Copyright (C) 2013 Brazil, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef GRNXX_TIME_PERIODIC_CLOCK_HPP +#define GRNXX_TIME_PERIODIC_CLOCK_HPP + +#include "basic.hpp" +#include "time/system_clock.hpp" + +namespace grnxx { + +class PeriodicClock { + public: + PeriodicClock(); + ~PeriodicClock(); + + Time now() const { + return (now_ == Time::min()) ? SystemClock::now() : now_; + } + + private: + static Time now_; +}; + +} // namespace grnxx + +#endif // GRNXX_TIME_PERIODIC_CLOCK_HPP