#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 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_SUPPORT_COLLECTIONS_OBSERVABLEINDEXEDCOLLECTION_H #define NUCLEX_SUPPORT_COLLECTIONS_OBSERVABLEINDEXEDCOLLECTION_H #include "Nuclex/Support/Config.h" #include "Nuclex/Support/Events/Event.h" #include // for std::size_t namespace Nuclex { namespace Support { namespace Collections { // ------------------------------------------------------------------------------------------- // /// Provides notifications for when an indexed collection changes /// /// /// This does not monitor the state of items stored in the collection, it just reports /// when the items are added, removed or replaced in the collection. /// /// template class ObservableIndexedCollection { /// Fired when an item has been added to the collection /// Index at which the item has been added /// Item that has been added to the collection public: mutable Events::Event< void(std::size_t index, const TValue &value) > ItemAdded; /// Fired when an item has been removed from the collection /// Index at which the item has been removed /// Item that has been removed from the collection public: mutable Events::Event< void(std::size_t index, const TValue &value) > ItemRemoved; /// Fired when an item in the collection has been replaced /// Index at which the item has been replaced /// Item that is no longer part of the collection /// Item that has taken the place of the old item public: mutable Events::Event< void(std::size_t index, const TValue &oldValue, const TValue &newValue) > ItemReplaced; // public: mutable Event Clearing(); // public: mutable Event Cleared(); /// Initializes a new observable indexed collection protected: ObservableIndexedCollection() = default; /// Frees all memory used by the observable collection public: virtual ~ObservableIndexedCollection() = default; //private: ObservableIndexedCollection(const ObservableIndexedCollection &) = delete; //private: ObservableIndexedCollection &operator =( // const ObservableIndexedCollection & //) = delete; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Collections #endif // NUCLEX_SUPPORT_COLLECTIONS_OBSERVABLEINDEXEDCOLLECTION_H