source: golgotha/src/max_plugin/sdk_inc/interval.h @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/**********************************************************************
2 *<
3        FILE: interval.h
4
5        DESCRIPTION:  Defines TimeValue and Interval Classes
6
7        CREATED BY: Rolf Berteig
8
9        HISTORY: created 13 September 1994
10             950818 - Added methods for setting start/end individually (gus)
11
12 *>     Copyright (c) 1994, All Rights Reserved.
13 **********************************************************************/
14
15
16#ifndef _INTERVAL_H_
17#define _INTERVAL_H_
18
19
20class Interval {
21        private:
22                TimeValue       start;
23                TimeValue       end;
24
25        public:         
26                /*
27                 Constructors:
28                 */             
29                CoreExport Interval( TimeValue s, TimeValue e );
30                Interval() { SetEmpty(); }
31
32                int operator==( const Interval& i ) { return( i.start==start && i.end==end ); }
33                CoreExport int InInterval(const TimeValue t);
34                int InInterval(const Interval interval) { return InInterval( interval.Start() ) && InInterval( interval.End() ); }
35                int Empty() { return (start == TIME_NegInfinity) && (end == TIME_NegInfinity); }
36
37                void Set       ( TimeValue s, TimeValue e ) { start = s; end = e; }
38                void SetStart  ( TimeValue s )              { start = s;          }
39                void SetEnd    ( TimeValue e )              { end = e;            }
40
41                void SetEmpty() { start = TIME_NegInfinity; end = TIME_NegInfinity; }
42                void SetInfinite() { start = TIME_NegInfinity; end = TIME_PosInfinity; }
43                void SetInstant(const TimeValue t) { start = end = t; }
44                TimeValue Start() const { return start; }
45                TimeValue End() const { return end; }
46                TimeValue Duration() const { return end-start+TimeValue(1); } // end points included
47
48                // intersection of intervals
49                CoreExport Interval operator&(const Interval i) const;
50                Interval& operator&=(const Interval i) { return (*this = (*this&i)); }
51                Interval& operator+=(const TimeValue t) { if (t<start) start=t; if (t>end) end=t; return *this; }
52};
53
54#define FOREVER Interval(TIME_NegInfinity, TIME_PosInfinity)
55#define NEVER Interval(TIME_NegInfinity, TIME_NegInfinity)
56
57#endif
58
59
Note: See TracBrowser for help on using the repository browser.