/** * @author Edouard DUPIN * * @copyright 2010, Edouard DUPIN, all right reserved * * @license GPL v3 (see license file) */ #ifndef __BUFFER_MANAGER_H__ #define __BUFFER_MANAGER_H__ #include #include #include #include #include namespace appl { class BufferManager : public ewol::Resource { protected: BufferManager(); public: virtual ~BufferManager(); private: std::list> m_list; // list of all buffer curently open public: /** * @brief Get a specific buffer with his name (can create a new buffer). * @param[in] _fileName Name of the file to open. * @param[in] _createIfNeeded Create the buffer if not existed. * @return a pointer on the buffer */ ewol::object::Shared get(const std::string& _fileName, bool _createIfNeeded=false); /** * @brief Load a specific file, event if it not existed: * @param[in] _fileName Name of the file to open or create. */ void open(const std::string& _fileName); /** * @brief Check if a buffer is already open. * @param[in] _fileName name of the file. * @return true if the buffer is already open. */ bool exist(const std::string& _fileName); /** * @brief Get count of all buffer availlable. * @return Number of buffer */ int32_t size() const { return m_list.size(); } /** * @brief Get a pointer on a buffer Id (never remember this ID!!!). * @param[in] _id Number of buffer * @return pointer on the buffer */ ewol::object::Shared get(int32_t _id); /** * @brief Create a new buffer empty. * @return Created buffer or NULL. */ ewol::object::Shared createNewBuffer(); private: ewol::object::Shared m_bufferSelected; public: /** * @brief Set the current buffer selected * @param[in] _bufferSelected Pointer on the buffer selected */ void setBufferSelected(ewol::object::Shared _bufferSelected); /** * @brief Get the current buffer selected * @return Pointer on the buffer selected */ ewol::object::Shared getBufferSelected() { return m_bufferSelected; }; public: // herited function void onReceiveMessage(const ewol::object::Message& _msg); void onObjectRemove(const ewol::object::Shared& _removeObject); public: // resource manager /** * @brief keep the resource pointer. * @note Never free this pointer by your own... * @param[in] _filename Name of the configuration file. * @return pointer on the resource or NULL if an error occured. */ static ewol::object::Shared keep(); }; }; #endif