Drizzled Public API Documentation

times.h
00001 /* Drizzle
00002  * Copyright (C) 2011 Olaf van der Spek
00003  * 
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation, either version 2 of the License, or
00007  * (at your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #include <boost/date_time.hpp>
00019 #include <drizzled/common_fwd.h>
00020 
00021 namespace drizzled {
00022 namespace session {
00023 
00024 class DRIZZLED_API Times
00025 {
00026 public:
00027   Times() :
00028     _epoch(boost::gregorian::date(1970, 1 ,1))
00029   {
00030     _connect_time = boost::posix_time::microsec_clock::universal_time();
00031     utime_after_lock = 0;
00032   }
00033 
00034   uint64_t getConnectMicroseconds() const;
00035   uint64_t getConnectSeconds() const;
00036   void resetUserTime();
00037   void set_time();
00038   void set_time(time_t); // This is done by a sys_var, as long as user_time is set, we will use that for all references to time
00039   void set_time_after_lock();
00040   void set_end_timer(Session&);
00041   uint64_t getElapsedTime() const;
00042   type::epoch_t getCurrentTimestamp(bool actual= true) const;
00043   type::epoch_t getCurrentTimestampEpoch() const;
00044   type::epoch_t getCurrentTimestampEpoch(type::usec_t& fraction_arg) const;
00045   type::epoch_t query_start();
00046   boost::posix_time::ptime start_timer() const;
00047   boost::posix_time::ptime epoch() const;
00048 
00049   boost::posix_time::ptime _epoch;
00050   boost::posix_time::ptime _connect_time;
00051   boost::posix_time::ptime _end_timer;
00052   boost::posix_time::ptime _user_time;
00053   boost::posix_time::ptime _start_timer;
00054   uint64_t utime_after_lock;
00055 };
00056 
00057 }
00058 }