#ifndef __UT_LOG_BUFFER_HPP__ #define __UT_LOG_BUFFER_HPP__ #include namespace unitree { namespace common { class LogBuffer { public: LogBuffer(); bool Append(const std::string& s); const std::string& Get(); void Get(std::string& s); void Clear(); bool Empty(); private: std::string mData; }; typedef std::shared_ptr LogBufferPtr; class LogBlockBuffer { public: typedef std::shared_ptr LOG_BUFFER_PTR; LogBlockBuffer(); ~LogBlockBuffer(); bool Append(const std::string& s); /* * Get reference of data. [UNSAFE] */ const std::string& Get(); void Get(std::string& s); /* * Clear data. */ void Clear(bool lock = false); void Exchange(); private: volatile bool mR; std::vector mChain; Mutex mLock; }; typedef std::shared_ptr LogBlockBufferPtr; } } #endif//__UT_LOG_BUFFER_HPP__