2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright (C) 1995 Matthias Ettrich
8 * Copyright (C) 1995-1998 The LyX Team.
10 *======================================================*/
23 /* --- i/o pipes --------------------------------------------------------- */
25 /** This class managed the pipes used for communicating with clients.
26 Usage: Initialize with pipe-filename-base, client class to receive
27 messages, and callback-function that will be called with the messages.
28 When you want to send, use "send()".
29 This class encapsulates all the dirty communication and thus provides
30 a clean string interface.
35 /** When we receive a message, we send it to a client.
36 This is one of the small things that would have been a lot
37 cleaner with a Signal/Slot thing.
39 typedef void (*ClientCallbackfct)(LyXServer *, string const &);
41 /// Construct with pipe-basename and callback to receive messages
42 LyXComm(string const &pip, LyXServer * cli, ClientCallbackfct ccb = 0)
43 :pipename(pip), client(cli), clientcb(ccb)
55 void send(string const &);
58 void openConnection();
61 void closeConnection();
63 /// We receive messages via XForms through this callback
64 static void callback(int fd, void *v);
66 /// This is -1 if not open
69 /// This is -1 if not open
72 /// Are we up and running?
75 /// Base of pipename including path
81 /// The client callback function
82 ClientCallbackfct clientcb;
86 /* --- prototypes -------------------------------------------------------- */
91 // Hack! This should be changed in 0.13
93 /// The lyx server should not take an argument "LyXFunc" but this is
94 // how it will be done for 0.12. In 0.13 we must write a non-gui
96 // IMO lyxserver is atypical, and for the moment the only one, non-gui
97 // bufferview. We just have to find a way to handle situations like if
98 // lyxserver is using a buffer that is being edited with a bufferview.
99 // With a common buffer list this is not a problem, maybe. (Alejandro)
100 LyXServer(LyXFunc *f, string const &pip)
101 : numclients(0), func(f), pipes(pip, (this), callback)
106 void notifyClient(string const &);
109 static void callback(LyXServer *, string const & msg);
110 /// Names and number of current clients
111 enum { MAX_CLIENTS = 10 };
112 string clients[MAX_CLIENTS];
120 #endif /* _LYXSERVER_H_ */
122 /* === End of File: lyxserver.h ========================================== */