Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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;
00123
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;
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
00280
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 }
00313
00314
00315 #endif
00316
00317
00318
00319
00320
00321