CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/12/07 11:45:37
Modified files: . : ChangeLog server : Makefile.am Added files: server : VirtualClock.h SystemClock.cpp SystemClock.h Log message: New VirtualClock virtual class and system time based implementation. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5103&r2=1.5104 http://cvs.savannah.gnu.org/viewcvs/gnash/server/Makefile.am?cvsroot=gnash&r1=1.133&r2=1.134 http://cvs.savannah.gnu.org/viewcvs/gnash/server/VirtualClock.h?cvsroot=gnash&rev=1.1 http://cvs.savannah.gnu.org/viewcvs/gnash/server/SystemClock.cpp?cvsroot=gnash&rev=1.1 http://cvs.savannah.gnu.org/viewcvs/gnash/server/SystemClock.h?cvsroot=gnash&rev=1.1 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5103 retrieving revision 1.5104 diff -u -b -r1.5103 -r1.5104 --- ChangeLog 7 Dec 2007 08:34:42 -0000 1.5103 +++ ChangeLog 7 Dec 2007 11:45:36 -0000 1.5104 @@ -1,5 +1,10 @@ 2007-12-07 Sandro Santilli <[EMAIL PROTECTED]> + * server/: Makefile.am, SystemClock.{cpp,h}, VirtualClock.cpp: + New VirtualClock virtual class and system time based implementation. + +2007-12-07 Sandro Santilli <[EMAIL PROTECTED]> + * testsuite/misc-ming.all/intervalTest.as: more self-contained tests, to reduce relying on MovieTester concept of time; Index: server/Makefile.am =================================================================== RCS file: /sources/gnash/gnash/server/Makefile.am,v retrieving revision 1.133 retrieving revision 1.134 diff -u -b -r1.133 -r1.134 --- server/Makefile.am 1 Dec 2007 15:40:59 -0000 1.133 +++ server/Makefile.am 7 Dec 2007 11:45:37 -0000 1.134 @@ -18,7 +18,7 @@ # # -# $Id: Makefile.am,v 1.133 2007/12/01 15:40:59 strk Exp $ +# $Id: Makefile.am,v 1.134 2007/12/07 11:45:37 strk Exp $ AUTOMAKE_OPTIONS = @@ -60,6 +60,7 @@ Property.cpp \ PropertyList.cpp \ URLAccessManager.cpp \ + SystemClock.cpp \ as_environment.cpp \ as_function.cpp \ as_object.cpp \ @@ -121,6 +122,8 @@ StreamProvider.h \ StringPredicates.h \ URLAccessManager.h \ + VirtualClock.h \ + SystemClock.h \ array.h \ as_environment.h \ as_function.h \ Index: server/VirtualClock.h =================================================================== RCS file: server/VirtualClock.h diff -N server/VirtualClock.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ server/VirtualClock.h 7 Dec 2007 11:45:37 -0000 1.1 @@ -0,0 +1,59 @@ +// VirtualClock.h -- virtual clock for gnash core lib +// +// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef GNASH_VIRTUAL_CLOCK_H +#define GNASH_VIRTUAL_CLOCK_H + +// What's the policy for when to include config.h ? --strk Dec 7 2007; +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + + +namespace gnash +{ + +/// A class used to virtualize time flow +// +/// This class will be used to fetch current time +/// everytime it is needed by the core lib. +/// +class VirtualClock +{ +public: + + /// Return number of milliseconds elapsed since start. + // + /// Subclass this to provide time to the core lib. + // + /// NOTE: + /// 32bit unsigned int has an upper limit of 4294967295 + /// which means about 49 days before overlflow. + /// + virtual unsigned long int elapsed() const=0; + + /// Restart the clock + virtual void restart()=0; + + virtual ~VirtualClock() {} +}; + +} // namespace gnash + +#endif // GNASH_VIRTUAL_CLOCK_H + Index: server/SystemClock.cpp =================================================================== RCS file: server/SystemClock.cpp diff -N server/SystemClock.cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ server/SystemClock.cpp 7 Dec 2007 11:45:37 -0000 1.1 @@ -0,0 +1,57 @@ +// SystemClock.cpp -- system-time based VirtualClock for gnash core lib +// +// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "SystemClock.h" + +#include "tu_timer.h" // for fetchSystemTime + +#include <boost/cstdint.hpp> // for boost::uint64_t typedef + +namespace gnash +{ + +/* static private */ +boost::uint64_t +SystemClock::fetchSystemTime() +{ + // TODO: review tu_timer implementation to make sure it + // always return milliseconds + return tu_timer::get_ticks(); +} + +/* public */ +unsigned long int +SystemClock::elapsed() const +{ + return fetchSystemTime() - _startTime; +} + +/* public */ +void +SystemClock::restart() +{ + _startTime = fetchSystemTime(); +} + +} // namespace gnash + Index: server/SystemClock.h =================================================================== RCS file: server/SystemClock.h diff -N server/SystemClock.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ server/SystemClock.h 7 Dec 2007 11:45:37 -0000 1.1 @@ -0,0 +1,65 @@ +// SystemClock.h -- system-time based VirtualClock for gnash core lib +// +// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef GNASH_SYSTEM_CLOCK_H +#define GNASH_SYSTEM_CLOCK_H + +// What's the policy for when to include config.h ? --strk Dec 7 2007; +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "VirtualClock.h" // for inheritance + +#include <boost/cstdint.hpp> // for boost::uint64_t typedef + +namespace gnash +{ + +/// A system-clock based virtual clock +// +/// This class uses the system clock for computing elapsed time. +/// See http://en.wikipedia.org/wiki/System_time for capacity +/// +class SystemClock +{ +public: + + // + SystemClock(); + + // see VirtualClock.h for dox + unsigned long int elapsed() const; + + // see VirtualClock.h for dox + void restart(); + +private: + + /// Query system time and return it in milliseconds + static boost::uint64_t fetchSystemTime(); + + /// System time at time of start + boost::uint64_t _startTime; +}; + + +} // namespace gnash + +#endif // GNASH_SYSTEM_CLOCK_H + _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit