00001 /*************************************************************************** 00002 ulxr_cached_resource.h - resources accessed via ulxmlrpcpp 00003 ------------------- 00004 begin : Sun May 1 2005 00005 copyright : (C) 2002-2007 by Ewald Arnold 00006 email : ulxmlrpcpp@ewald-arnold.de 00007 00008 $Id: ulxr_cached_resource.h 940 2006-12-30 18:22:05Z ewald-arnold $ 00009 00010 ***************************************************************************/ 00011 00012 /************************************************************************** 00013 * 00014 * This program is free software; you can redistribute it and/or modify 00015 * it under the terms of the GNU Lesser General Public License as 00016 * published by the Free Software Foundation; either version 2 of the License, 00017 * or (at your option) any later version. 00018 * 00019 * This program is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this program; if not, write to the Free Software 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00027 * 00028 ***************************************************************************/ 00029 00030 #ifndef ULXR_CACHED_RESOURCE_H 00031 #define ULXR_CACHED_RESOURCE_H 00032 00033 #include <ulxmlrpcpp/ulxmlrpcpp.h> // always first header 00034 00035 00036 namespace ulxr { 00037 00038 00045 class ULXR_API_DECL0 CachedResource 00046 { 00047 public: 00048 00052 CachedResource(const CppString &name); 00053 00056 virtual ~CachedResource(); 00057 00060 CppString getResourceName() const; 00061 00064 virtual void open() = 0; 00065 00068 virtual void close() = 0; 00069 00074 virtual bool good() = 0; 00075 00079 std::string read(); 00080 00085 std::string read(unsigned len); 00086 00090 void write (const std::string &s); 00091 00096 void write (const char *str, unsigned len); 00097 00100 virtual void clear(); 00101 00104 virtual void reset(); 00105 00109 std::string data() const; 00110 00111 private: 00112 00113 CppString name; 00114 std::string cache; 00115 unsigned read_pointer; 00116 }; 00117 00118 00119 }; // namespace ulxr 00120 00121 00122 #endif // ULXR_CACHED_RESOURCE_H