Stellarium 0.15.2
Server.hpp
1 /*
2 The stellarium telescope library helps building
3 telescope server programs, that can communicate with stellarium
4 by means of the stellarium TCP telescope protocol.
5 It also contains smaple server classes (dummy, Meade LX200).
6 
7 Author and Copyright of this file and of the stellarium telescope library:
8 Johannes Gajdosik, 2006
9 
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14 
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this library; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
23 */
24 
25 #ifndef _SERVER_HPP_
26 #define _SERVER_HPP_
27 
28 #include <list>
29 using namespace std;
30 
31 class Socket;
32 
45 class Server
46 {
47 public:
48  Server(void) {}
49  Server(int port);
50  virtual ~Server(void) {}
51  virtual void step(long long int timeout_micros);
52 
53 protected:
54  void sendPosition(unsigned int ra_int, int dec_int, int status);
61  {
62  if (s)
63  socket_list.push_back(s);
64  }
65  void closeAcceptedConnections(void);
66  friend class Listener;
67 
68 private:
69  // called by Connection:
70  virtual void gotoReceived(unsigned int ra_int, int dec_int) = 0;
71  friend class Connection;
72 
73  class SocketList : public list<Socket*>
74  {
75  public:
76  ~SocketList(void) { clear(); }
77  void clear(void);
78  };
80  SocketList socket_list;
81 };
82 
83 #endif
Base class for telescope server classes.
Definition: Server.hpp:45
STL namespace.
void addConnection(Socket *s)
Adds this object to the list of connections maintained by this server.
Definition: Server.hpp:60
TCP/IP connection to a client.
Definition: Connection.hpp:31