Fawkes API Fawkes Development Version
fuse_client.h
1
2/***************************************************************************
3 * fuse_client.h - FUSE network transport client
4 *
5 * Created: Mon Jan 09 15:33:59 2006
6 * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _FIREVISION_FVUTILS_NET_FUSE_CLIENT_H_
25#define _FIREVISION_FVUTILS_NET_FUSE_CLIENT_H_
26
27#include <core/threading/thread.h>
28#include <fvutils/net/fuse.h>
29#include <sys/types.h>
30
31namespace fawkes {
32class StreamSocket;
33class WaitCondition;
34class Mutex;
35} // namespace fawkes
36namespace firevision {
37
38class FuseNetworkMessageQueue;
39class FuseNetworkMessage;
40class FuseClientHandler;
41
43{
44public:
45 FuseClient(const char *hostname, unsigned short int port, FuseClientHandler *handler);
46 virtual ~FuseClient();
47
48 void connect();
49 void disconnect();
50
52 void enqueue(FUSE_message_type_t type, void *payload, size_t payload_size);
53 void enqueue(FUSE_message_type_t type);
55 void enqueue_and_wait(FUSE_message_type_t type, void *payload, size_t payload_size);
56 void enqueue_and_wait(FUSE_message_type_t type);
57 void wait();
58 void wait_greeting();
59
60 virtual void loop();
61
62private:
63 void send();
64 void recv();
65 void sleep();
66
67 char * hostname_;
68 unsigned short int port_;
69
70 fawkes::StreamSocket *socket_;
71 unsigned int wait_timeout_;
72
73 fawkes::Mutex * mutex_;
74 fawkes::Mutex * recv_mutex_;
75 fawkes::WaitCondition *recv_waitcond_;
76
77 FuseNetworkMessageQueue *inbound_msgq_;
78 FuseNetworkMessageQueue *outbound_msgq_;
79
80 FuseClientHandler *handler_;
81
82 bool greeting_received_;
83 fawkes::Mutex * greeting_mutex_;
84 fawkes::WaitCondition *greeting_waitcond_;
85
86 bool alive_;
87};
88
89} // end namespace firevision
90
91#endif
Mutex mutual exclusion lock.
Definition: mutex.h:33
TCP stream socket over IP.
Definition: stream.h:32
Thread class encapsulation of pthreads.
Definition: thread.h:46
Wait until a given condition holds.
virtual void loop()
Thread loop.
FuseClient(const char *hostname, unsigned short int port, FuseClientHandler *handler)
Constructor.
Definition: fuse_client.cpp:59
void wait_greeting()
Wait for greeting message.
void enqueue_and_wait(FuseNetworkMessage *message)
Enqueue message and wait for reply.
void enqueue(FuseNetworkMessage *m)
Enqueue message.
void connect()
Connect.
void wait()
Wait for messages.
void disconnect()
Disconnect.
virtual ~FuseClient()
Destructor.
Definition: fuse_client.cpp:83
A LockQueue of FuseNetworkMessage to hold messages in inbound and outbound queues.
FUSE Network Message.
Definition: fuse_message.h:40
Fawkes library namespace.