Skip to content

Commit

Permalink
Add a skeleten of grnxx::PeriodicClock.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yata committed Mar 14, 2013
1 parent c6a0eb9 commit d400972
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/time/Makefile.am
Expand Up @@ -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
Expand All @@ -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
37 changes: 37 additions & 0 deletions 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
41 changes: 41 additions & 0 deletions 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

0 comments on commit d400972

Please sign in to comment.