Include program counter on action limit notification log
[gnash.git] / cygnal / cygnal.h
blobc5249cccbc2eca608c150fca789821f33fd31597
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
3 // Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef __CYGNAL_H__
20 #define __CYGNAL_H__
22 #include <boost/cstdint.hpp>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/thread.hpp>
25 #include <vector>
26 #include <string>
27 #include <map>
29 #include "dsodefs.h"
30 #include "extension.h"
31 #include "handler.h"
33 /// \namespace cygnal
34 ///
35 /// This namespace is for all the Cygnal specific classes not used by
36 /// anything else in Gnash.
37 namespace cygnal {
39 /// \class cygnal::Cygnal
41 class Cygnal
43 public:
44 typedef Handler::cygnal_init_t (*initentry_t)();
46 typedef struct {
47 std::string hostname;
48 short port;
49 bool connected;
50 int fd;
51 gnash::Network::protocols_supported_e protocol;
52 std::vector<std::string> supported;
53 } peer_t;
54 static Cygnal& getDefaultInstance();
55 ~Cygnal();
57 bool loadPeersFile();
58 bool loadPeersFile(const std::string &filespec);
60 void probePeers();
61 void probePeers(peer_t &peer);
62 void probePeers(boost::shared_ptr<peer_t> peer);
63 void probePeers(std::vector<boost::shared_ptr<peer_t> > &peers);
65 void addHandler(const std::string &path, boost::shared_ptr<Handler> x) {
66 _handlers[path] = x;
69 boost::shared_ptr<Handler> findHandler(const std::string &path);
70 void removeHandler(const std::string &path);
72 std::vector<boost::shared_ptr<peer_t> > & getActive() { return _active_peers; };
74 void dump();
76 private:
77 void addPeer(boost::shared_ptr<peer_t> x) {
78 _peers.push_back(x);
81 std::vector<boost::shared_ptr<peer_t> > _peers;
82 std::vector<boost::shared_ptr<peer_t> > _active_peers;
83 std::map<std::string, boost::shared_ptr<Handler> > _handlers;
84 boost::mutex _mutex;
87 /// \class cygnal::ThreadCounter of threads currently
88 /// active. This is primarily so the counter can be wrapped with a
89 /// mutex to be thread safe, as threads delete themseleves.
90 class ThreadCounter
92 public:
94 ThreadCounter() : _tids(0) {};
95 void increment() { boost::mutex::scoped_lock lk(_tid_mutex); ++_tids; };
96 void decrement() { boost::mutex::scoped_lock lk(_tid_mutex); --_tids; };
97 int num_of_tids() { return _tids; };
98 private:
99 boost::mutex _tid_mutex;
100 int _tids;
101 boost::thread _tid_handle;
104 // End of gnash namespace
107 // __CYGNAL_H__
108 #endif
111 // local Variables:
112 // mode: C++
113 // indent-tabs-mode: t
114 // End: