gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/rtmp r9717: new files for caching class fo


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9717: new files for caching class for servers.
Date: Wed, 12 Nov 2008 18:13:57 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9717
committer: address@hidden
branch nick: rtmp
timestamp: Wed 2008-11-12 18:13:57 -0700
message:
  new files for caching class for servers.
added:
  libnet/cache.cpp
  libnet/cache.h
=== added file 'libnet/cache.cpp'
--- a/libnet/cache.cpp  1970-01-01 00:00:00 +0000
+++ b/libnet/cache.cpp  2008-11-13 01:13:57 +0000
@@ -0,0 +1,90 @@
+// cache.cpp:  HyperText Transport Protocol handler for Cygnal, for Gnash.
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program 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
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#include <boost/thread/mutex.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/shared_array.hpp>
+#include <boost/scoped_array.hpp>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string>
+#include <map>
+#include <iostream>
+#include <unistd.h>
+
+#include "cache.h"
+#include "log.h"
+#include "diskstream.h"
+
+using namespace std;
+
+//static boost::mutex cache_mutex;
+
+namespace gnash
+{
+
+Cache::Cache() 
+    : _max_size(0)
+{
+}
+
+Cache::~Cache()
+{
+}
+
+void
+Cache::dump(std::ostream& os) const
+{
+    
+//    GNASH_REPORT_FUNCTION;
+    
+//    boost::mutex::scoped_lock lock(cache_mutex);
+
+    // Dump all the pathnames
+    map<std::string, std::string>::const_iterator name;
+    for (name = _pathnames.begin(); name != _pathnames.end(); name++) {
+        os << "Full path for \"" << name->first << "\" is: " << name->second 
<< endl;
+    }
+
+    // Dump the responses
+    for (name = _responses.begin(); name != _responses.end(); name++) {
+        os << "Response for \"" << name->first << "\" is: " << name->second << 
endl;
+    }
+
+#if 0
+    map<std::string, DiskStream>::const_iterator data;
+    for (data = _files.begin(); data != _files.end(); data++) {
+        DiskStream filedata = data->second;
+        os << "File info for \"" << data->first << "\" is: ";
+//        filedata.dump(os) << endl;
+    }
+#endif
+}
+
+} // end of gnash namespace
+
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:

=== added file 'libnet/cache.h'
--- a/libnet/cache.h    1970-01-01 00:00:00 +0000
+++ b/libnet/cache.h    2008-11-13 01:13:57 +0000
@@ -0,0 +1,81 @@
+// 
+//   Copyright (C) 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program 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
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef __CACHE_H__
+#define __CACHE_H__
+
+#include <string>
+#include <map> 
+#include <iostream> // for output operator
+
+#include "statistics.h"
+#include "diskstream.h"
+
+/// \namespace gnash
+///    This is the main namespace for Gnash and it's libraries.
+namespace gnash {
+
+// forward instatiate
+//class DiskStream;
+
+/// \class Cache
+//
+class Cache {
+public:
+    Cache();
+    ~Cache();
+    
+    void addPath(const std::string &name, const std::string &fullpath) { 
_pathnames[name] = fullpath; };
+    void addResponse(const std::string &name, const std::string &response) { 
_responses[name] = response; };
+    void addFile(const std::string &name, DiskStream *file) { _files[name] = 
file; };
+
+    std::string &findPath(const std::string &name) { return _pathnames[name]; 
};
+    std::string &findResponse(const std::string &name) { return 
_responses[name]; };
+    DiskStream *findFile(const std::string &name) { return _files[name]; };
+
+    ///  \brief Dump the internal data of this class in a human readable form.
+    /// @remarks This should only be used for debugging purposes.
+    void dump() const { dump(std::cerr); }
+    /// \overload dump(std::ostream& os) const
+    void dump(std::ostream& os) const;    
+    
+private:
+    std::map<std::string, std::string> _pathnames;
+    std::map<std::string, std::string> _responses;
+    std::map<std::string, DiskStream *> _files;
+    size_t _max_size;
+    /// \var Cache::_pagesize
+    ///                The memory page size.
+    size_t     pagesize;        
+};
+
+/// \brief Dump to the specified output stream.
+inline std::ostream& operator << (std::ostream& os, const Cache& cache)
+{
+       cache.dump(os);
+       return os;
+}
+
+} // end of cygnal namespace
+
+#endif // __CACHE_H__
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:


reply via email to

[Prev in Thread] Current Thread [Next in Thread]