X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Ftime.h;h=ef82b90a3b9f4ebd08627151319c922c85bfb669;hb=334e15ce6c4d9b1f30a168a55e7ef4d31320d568;hp=ca29908f7f88182234a71d497c2eed1e75345736;hpb=e3acc0b267b14fda5db3c7bbb2f218b993ef84b3;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/time.h b/synfig-core/trunk/src/synfig/time.h index ca29908..ef82b90 100644 --- a/synfig-core/trunk/src/synfig/time.h +++ b/synfig-core/trunk/src/synfig/time.h @@ -1,28 +1,30 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \file time.h ** \brief Template Header ** -** $Id: time.h,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package 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 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package 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. ** \endlegal */ /* ========================================================================= */ /* === S T A R T =========================================================== */ -#ifndef __SINFG_TIME_H -#define __SINFG_TIME_H +#ifndef __SYNFIG_TIME_H +#define __SYNFIG_TIME_H /* === H E A D E R S ======================================================= */ @@ -34,7 +36,7 @@ /* === C L A S S E S & S T R U C T S ======================================= */ -namespace sinfg { +namespace synfig { /*! \class Time ** \todo writeme @@ -54,14 +56,14 @@ public: FORMAT_NOSPACES=(1<<0), //!< Remove any whitespace FORMAT_FULL=(1<<1), //!< Do not remove units that have "zero" value FORMAT_VIDEO=(1<<2), //!< Use the HH:MM:SS.ff format - + FORMAT_END=(1<<4) //!< \internal Not used }; // END of enum Format private: value_type value_; - static const value_type epsilon_() { return static_cast(0.0005); } + static value_type epsilon_() { return static_cast(0.0005); } public: Time() { } @@ -74,7 +76,7 @@ public: //! Constructs Time from the given string. /*! \note If the string references frames, then the - ** frame rate (\afps) should be provided from the + ** frame rate (\a fps) should be provided from the ** correct source. (Which is most likely the RendDesc ** of the current Canvas) ** The frame count will be ignored if the @@ -82,31 +84,35 @@ public: Time(const String &string, float fps=0); //! Marks the exclusive negative boundary of time - static const Time begin() { return static_cast(-32767.0f*512.0f); } - + static const Time begin() { return static_cast(-32767.0f*512.0f); } + //! Marks the exclusive positive boundary of time - static const Time end() { return static_cast(32767.0f*512.0f); } + static const Time end() { return static_cast(32767.0f*512.0f); } //! Marks zero time - static const Time zero() { return static_cast(0); } - + static const Time zero() { return static_cast(0); } + //! The amount of allowable error in calculations - static const Time epsilon() { return static_cast(epsilon_()); } - + static const Time epsilon() { return static_cast(epsilon_()); } + //! Returns a string describing the current time value /*! \see Format */ String get_string(float fps=0, Time::Format format=FORMAT_NORMAL)const; - + +#ifdef _DEBUG + const char *c_str()const; +#endif + //! \writeme bool is_valid()const; - + //! Rounds time to the nearest frame for the given frame rate, \a fps Time round(float fps)const; bool is_equal(const Time& rhs)const { return (value_>rhs.value_)?value_-rhs.value_<=epsilon_():rhs.value_-value_<=epsilon_(); } bool is_less_than(const Time& rhs)const { return rhs.value_-value_ > epsilon_(); } bool is_more_than(const Time& rhs)const { return value_-rhs.value_ > epsilon_(); } - + operator double()const { return value_; } template bool operator<(const U& rhs)const { return value_ const Time& operator+=(const U &rhs) { value_+=static_cast(rhs); return *this; } template const Time& operator-=(const U &rhs) { value_-=static_cast(rhs); return *this; } template const Time& operator*=(const U &rhs) { value_*=static_cast(rhs); return *this; } @@ -141,7 +147,7 @@ public: template Time operator-(const U &rhs)const { return value_-static_cast(rhs); } template Time operator*(const U &rhs)const { return value_*static_cast(rhs); } template Time operator/(const U &rhs)const { return value_/static_cast(rhs); } - + Time operator-()const { return -value_; } }; // END of class Time @@ -157,8 +163,8 @@ inline Time::Format operator|(Time::Format lhs, Time::Format rhs) inline bool operator<=(Time::Format lhs, Time::Format rhs) { return (static_cast(lhs) & static_cast(rhs))==static_cast(rhs); } -}; // END of namespace sinfg - +}; // END of namespace synfig + /* === E N D =============================================================== */ #endif