xref: /glogg/src/externalcom.h (revision c633ced33b4f2c2cf77c0c80a15fa73a7f13ad9f)
1 /*
2  * Copyright (C) 2014 Nicolas Bonnefon and other contributors
3  *
4  * This file is part of glogg.
5  *
6  * glogg is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * glogg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with glogg.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef EXTERNALCOM_H
21 #define EXTERNALCOM_H
22 
23 #include <QObject>
24 
25 class CantCreateExternalErr {};
26 
27 /*
28  * Virtual class representing another instance of glogg.
29  * Sending messages to an object of this class will forward
30  * them to the instance using the underlying IPC.
31  */
32 class ExternalInstance
33 {
34   public:
35     ExternalInstance() {}
36     virtual ~ExternalInstance() {}
37 
38     virtual void loadFile( const QString& file_name ) const = 0;
39     virtual uint32_t getVersion() const = 0;
40 };
41 
42 /*
43  * Class receiving messages from another instance of glogg.
44  * Messages are forwarded to the application by signals.
45  */
46 class ExternalCommunicator : public QObject
47 {
48   Q_OBJECT
49 
50   public:
51     ExternalCommunicator() : QObject() {}
52 
53     virtual ExternalInstance* otherInstance() const = 0;
54 
55     /* Instruct the communicator to start listening for
56      * remote initiated operations */
57     virtual void startListening() = 0;
58 
59   signals:
60     void loadFile( const QString& file_name );
61 
62   public slots:
63     virtual qint32 version() const = 0;
64 };
65 
66 #endif
67