// $Revision: 1.10 $ //------------------------------------------------------------------------------ // // Copyright (C) 1994 Taligent, Inc. All rights reserved. // // Project: ConcurrentActors // File: RefreshSubsystem.h // Build/Version: 1.0.0 // // Description: The Refresh subsystem maintains a thread that decides when // to refresh the screen. It enforces a maximum, regular frame // rate. (If the operating system slows with other processes, // the frame rate might fall below the maximum.) // //------------------------------------------------------------------------------ #ifndef TaligentSamples_REFRESHSUBSYSTEM #define TaligentSamples_REFRESHSUBSYSTEM class MRefreshable; class TRefreshThread; #ifndef Taligent_COLLECTIONS #include #endif #ifndef Taligent_SYNCHRONIZATION #include #endif #ifndef Taligent_NOTIFICATION #include #endif #ifndef Taligent_BASEGEOMETRY #include #endif #ifndef TaligentSamples_LOCALUTILITIES #include "LocalUtilities.h" #endif class TGrafPort; // The TGrafPort can be found in GrafPort.h. //============================================================================== // MRefreshable class MRefreshable { public: MRefreshable(); virtual ~MRefreshable(); virtual void PreRefresh(const TTime& interval); virtual void Draw(TGrafPort& port) const = 0; virtual void PostRefresh(const TTime& interval); }; //============================================================================== // TRefreshThread class TRefreshThread : public TPeriodicThread { public: static const TTime& kDefaultFrameRate; TRefreshThread(TGrafPort* port, const TTime& rate = kDefaultFrameRate); virtual ~TRefreshThread(); virtual void Add(MRefreshable* object); virtual MRefreshable* Remove(MRefreshable& object); virtual void RemoveAll(); virtual void SetBackground(MRefreshable* background); TInterest* CreateRefreshInterest(); protected: virtual void HandleIntervalPassed(const TTime& interval); virtual void GetDelayInterval(TTime& interval) const; private: static const TToken& kRefreshToken; TGrafPort* fPort; MRefreshable* fBackground; TDequeOf fObjects; TSeconds fRefreshRate; TNotifier fRefreshNotifier; TInterest fRefreshInterest; }; #endif