• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

lcshm.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef __LCSHM_H__
00020 #define __LCSHM_H__
00021 
00022 #include <boost/cstdint.hpp>
00023 #include <boost/shared_ptr.hpp>
00024 #include <string>
00025 #include <vector>
00026 
00027 #include "amf.h"
00028 #include "element.h"
00029 #include "SharedMem.h"
00030 #include "dsodefs.h"
00031 
00035 namespace cygnal
00036 {
00037 
00043 class DSOEXPORT Listener {
00044 public:
00047     Listener();
00048     
00053     Listener(boost::uint8_t *baseaddr);
00054 
00056     ~Listener();
00057 
00063     bool addListener(const std::string &name);
00064     
00071     bool findListener(const std::string &name);
00072     
00079     bool removeListener(const std::string &name);
00080 
00086     std::auto_ptr< std::vector<std::string> > listListeners();
00087 
00093     void setBaseAddress(boost::uint8_t *addr) { _baseaddr = addr; };
00094 
00099     boost::uint8_t *getBaseAddress() { return _baseaddr; };
00100     
00101 protected:
00104     std::string _name;
00105 
00108     boost::uint8_t *_baseaddr;
00109     
00110 //    std::vector<std::string> _listeners;
00111 };
00112 
00115 class DSOEXPORT LcShm : public Listener, public gnash::SharedMem {
00116 public:
00119     typedef struct {
00120                 boost::uint32_t unknown1;
00121                 boost::uint32_t unknown2;
00122                 boost::uint32_t timestamp;      // number of milliseconds that have
00123                                 // elapsed since the system was started
00124                 boost::uint32_t length;
00125     } lc_header_t;
00128     typedef struct {
00129         std::string connection_name;
00130         std::string protocol;
00131         std::string method_name;
00132         std::vector<boost::shared_ptr<cygnal::Element> > data; // this can be any AMF data type
00133     } lc_message_t;
00136     typedef struct {
00137         std::string connection_name;
00138         std::string hostname;
00139         bool domain;
00140         double unknown_num1;
00141         double unknown_num2;
00142     } lc_object_t;
00143 
00145     LcShm();
00146     
00148     ~LcShm();
00149 
00153     LcShm(boost::uint8_t *baseaddr);
00154     
00158     LcShm(key_t key);
00159 
00166     bool connect(const std::string &name);
00167 
00174     bool connect(key_t key);
00175 
00181     void close(void);
00182 
00194     void send(const std::string& name, const std::string& dataname,
00195               std::vector< cygnal::Element* >& data);
00196 
00206     void recv(std::string &name, std::string &dataname, boost::shared_ptr<cygnal::Element> data);
00207 
00214     std::vector<boost::shared_ptr<cygnal::Element> > parseBody(boost::uint8_t *data);
00215 
00226     boost::uint8_t *parseHeader(boost::uint8_t *data, boost::uint8_t* tooFar);
00227 
00237     boost::uint8_t *formatHeader(const std::string &con, const std::string &host, bool domain);
00238 
00244     void addConnectionName(std::string &name);
00245 
00251     void addHostname(std::string &name);
00252 
00256     void addObject(boost::shared_ptr<cygnal::Element> el) { _amfobjs.push_back(el); };
00257 
00261     size_t size() { return _amfobjs.size(); };
00262 
00266     std::vector<boost::shared_ptr<cygnal::Element> > getElements() { return _amfobjs; };
00267 
00273     void setBaseAddr(boost::uint8_t *addr) { _baseaddr = addr; };
00274 
00277     void dump();
00278         
00279         //Si
00280         //Moved this from LocalConnection class to here
00281         void setconnected(bool trueorfalse) { _connected=trueorfalse; return;  };
00282         bool getconnected(){return _connected;};
00283     
00284 private:
00287     boost::uint8_t *_baseaddr;
00288 
00291     lc_header_t _header;
00292 
00295     lc_object_t _object;
00296 
00300     std::vector<boost::shared_ptr<cygnal::Element> > _amfobjs;
00301         
00304     boost::mutex        _localconnection_mutex;
00305 
00308     bool _connected;
00309 
00310 };
00311 
00312 } // end of gnash namespace
00313 
00314 // __LCSHM_H__
00315 #endif
00316 
00317 // local Variables:
00318 // mode: C++
00319 // indent-tabs-mode: t
00320 // End:
00321 

Generated on Fri Mar 16 2012 15:46:10 for Gnash by  doxygen 1.7.1