Page principale Liste des namespaces Hiérarchie des classes Liste par ordre alphabétique Liste des composants Liste des fichiers Membres des namespaces Composants Déclarations

# ExCTime.cpp

Aller à la documentation de ce fichier.

    00001 /*
    00002  * ExNihilo 3D Engine
    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 Library 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, write to the Free Software
    00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00017  *
    00018  * Please read AUTHORS file !!!
    00019  *
    00020  * $Id: ExCTime.cpp,v 1.4 2002/07/05 12:50:39 binny Exp $
    00021  *
    00022  */
    00023
    00024 #include "ExCTime.h"
    00025
    00026 ExCTime::ExCTime () {
    00027         _long_t = -1;
    00028 }
    00029
    00030 bool ExCTime::start (float long_t) {
    00031         if (long_t <= 0) return false;
    00032         else {
    00033                 _long_t = long_t;
    00034 #ifdef UNIX_SRC
    00035                 _start = clock ();
    00036 #endif
    00037                 _real_t0 = time (NULL);
    00038                 return true;
    00039         }
    00040 }
    00041
    00042 bool ExCTime::startBlock (float long_t) {
    00043         if (long_t < 0) return false;
    00044         else if (long_t == 0) return true;
    00045         else {
    00046                 _long_t = long_t;
    00047 #ifdef UNIX_SRC
    00048                 _start = clock ();
    00049 #endif
    00050                 _real_t0 = time (NULL);
    00051                 time_t t1;
    00052                 do {
    00053                         t1 = time (NULL);
    00054                 } while (difftime (t1, _real_t0) < _long_t);
    00055                 return true;
    00056         }
    00057 }
    00058
    00059 bool ExCTime::stop (void) {
    00060 #ifdef UNIX_SRC
    00061         _finish = clock ();
    00062 #endif
    00063         _real_t1 = time (NULL);
    00064         return true;
    00065 }
    00066
    00067 bool ExCTime::isTimePassed (float long_t) {
    00068         time_t t1 = time (NULL);
    00069         if (difftime (t1, _real_t0) >= _long_t) return true;
    00070         else return false;
    00071 }
    00072
    00073 bool ExCTime::isFinished (void) {
    00074         time_t t1 = time (NULL);
    00075         if (difftime (t1, _real_t0) >= _long_t) return true;
    00076         else return false;
    00077 }
    00078
    00079 #ifdef UNIX_SRC
    00080 bool ExCTime::isClockTimePassed (float long_t) {
    00081         clock_t f = clock ();
    00082         if (((double) (f - _start) / CLOCKS_PER_SEC) >= long_t) return true;
    00083         else return false;
    00084 }
    00085
    00086 bool ExCTime::isClockFinished (void) {
    00087         clock_t f = clock ();
    00088         if (((double) (f - _start) / CLOCKS_PER_SEC) >= _long_t) return true;
    00089         else return false;
    00090 }
    00091 #endif