#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library 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 IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_GRAPHICS_RASTERIZATION_OPTIONS_H #define NUCLEX_GRAPHICS_RASTERIZATION_OPTIONS_H #include "../Config.h" #include "Resource.h" #include "../Helpers/ConcurrentObserverSet.h" namespace Nuclex { namespace Graphics { namespace Rasterization { // ------------------------------------------------------------------------------------------- // /// Options that can alter the behavior of a rasterizer class Options : Resource { #pragma region class Observer /// Observer that can be notified of changes to an options instance public: class Observer : public Resource::Observer { /// Frees all resources owned by the instance public: virtual ~Observer() {} /// Called right before the options are destroyed public: virtual void Destroying() = 0; /// Called when one of the options has changed public: virtual void Changed() = 0; }; #pragma endregion // class Observer /// Initializes a new options container protected: NUCLEX_GRAPHICS_API Options() {} /// Destroys the options container public: NUCLEX_GRAPHICS_API virtual ~Options() {} /// Retrieves the observer attached by the specified owner /// Owner whose observer will be looked up /// The observer registered by the specified owner or a nullptr public: NUCLEX_GRAPHICS_API Observer *GetObserver(const void *owner) const; /// Attaches an observer to the buffer /// The observer's owner, used as a unique key /// Observer that will be attached to the buffer public: NUCLEX_GRAPHICS_API void AttachObserver(const void *owner, Observer *observer); /// Detaches the specified owner's observer from the buffer /// Owner whose observer will be detached public: NUCLEX_GRAPHICS_API void DetachObserver(const void *owner); /// Notifies all observers that the options are about to be destroyed protected: NUCLEX_GRAPHICS_API void OnDestroying(); /// Notifies all observers that the options have been changed protected: NUCLEX_GRAPHICS_API void OnChanged(); private: Options(const Options &); private: Options &operator =(const Options &); /// Observed to changes in the options private: Helpers::ConcurrentObserverSet observers; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Graphics::Rasterization #endif // NUCLEX_GRAPHICS_RASTERIZATION_OPTIONS_H