#ifndef MODULAR_DATAMANAGER_HPP #define MODULAR_DATAMANAGER_HPP #include #include #include #include #include /** * @brief Manages in-memory data records with optional caching and lifecycle control. * * Each record is identified by a unique string key and stores a std::any value. * The manager supports loading data, storing data, and clearing cached entries. */ class DataManager { public: /// @brief Default constructor. DataManager() = default; /** * @brief Load a record by its key. * @param key Unique identifier for the data. * @return A shared_ptr to the data (std::any), or nullptr if not found. */ std::shared_ptr load(const std::string& key) const; /** * @brief Store a data record. * @param key Unique identifier. * @param value Data value to store. */ void store(const std::string& key, const std::any& value); /** * @brief Check if a key exists in the manager. * @param key Unique identifier. * @return true if the key exists. */ bool exists(const std::string& key) const; /** * @brief Remove a record by key. * @param key Unique identifier to remove. * @return true if the record was removed, false if not found. */ bool remove(const std::string& key); /** * @brief Get the number of stored records. * @return Record count. */ size_t size() const; /** * @brief Clear all stored data. */ void clear(); private: std::unordered_map data_; }; #endif // MODULAR_DATAMANAGER_HPP