xref: /glogg/src/externalcom.h (revision e07da50a2e1900f7a64fbc97093e11798cdaefb4)
123abd45aSNicolas Bonnefon /*
2557fb9d8SNicolas Bonnefon  * Copyright (C) 2014 Nicolas Bonnefon and other contributors
323abd45aSNicolas Bonnefon  *
423abd45aSNicolas Bonnefon  * This file is part of glogg.
523abd45aSNicolas Bonnefon  *
623abd45aSNicolas Bonnefon  * glogg is free software: you can redistribute it and/or modify
723abd45aSNicolas Bonnefon  * it under the terms of the GNU General Public License as published by
823abd45aSNicolas Bonnefon  * the Free Software Foundation, either version 3 of the License, or
923abd45aSNicolas Bonnefon  * (at your option) any later version.
1023abd45aSNicolas Bonnefon  *
1123abd45aSNicolas Bonnefon  * glogg is distributed in the hope that it will be useful,
1223abd45aSNicolas Bonnefon  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1323abd45aSNicolas Bonnefon  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1423abd45aSNicolas Bonnefon  * GNU General Public License for more details.
1523abd45aSNicolas Bonnefon  *
1623abd45aSNicolas Bonnefon  * You should have received a copy of the GNU General Public License
1723abd45aSNicolas Bonnefon  * along with glogg.  If not, see <http://www.gnu.org/licenses/>.
1823abd45aSNicolas Bonnefon  */
1923abd45aSNicolas Bonnefon 
2023abd45aSNicolas Bonnefon #ifndef EXTERNALCOM_H
2123abd45aSNicolas Bonnefon #define EXTERNALCOM_H
2223abd45aSNicolas Bonnefon 
23557fb9d8SNicolas Bonnefon #include <string>
2423abd45aSNicolas Bonnefon 
25557fb9d8SNicolas Bonnefon #include <QObject>
26557fb9d8SNicolas Bonnefon 
27557fb9d8SNicolas Bonnefon class CantCreateExternalErr {};
28557fb9d8SNicolas Bonnefon 
29*e07da50aSNicolas Bonnefon /*
30*e07da50aSNicolas Bonnefon  * Virtual class representing another instance of glogg.
31*e07da50aSNicolas Bonnefon  * Sending messages to an object of this class will forward
32*e07da50aSNicolas Bonnefon  * them to the instance using the underlying IPC.
33*e07da50aSNicolas Bonnefon  */
34557fb9d8SNicolas Bonnefon class ExternalInstance
35557fb9d8SNicolas Bonnefon {
36557fb9d8SNicolas Bonnefon   public:
37557fb9d8SNicolas Bonnefon     ExternalInstance() {}
38557fb9d8SNicolas Bonnefon     virtual ~ExternalInstance() {}
39557fb9d8SNicolas Bonnefon 
40557fb9d8SNicolas Bonnefon     virtual void loadFile( const std::string& file_name ) const = 0;
41*e07da50aSNicolas Bonnefon     virtual uint32_t getVersion() const = 0;
4223abd45aSNicolas Bonnefon };
4323abd45aSNicolas Bonnefon 
44*e07da50aSNicolas Bonnefon /*
45*e07da50aSNicolas Bonnefon  * Class receiving messages from another instance of glogg.
46*e07da50aSNicolas Bonnefon  * Messages are forwarded to the application by signals.
47*e07da50aSNicolas Bonnefon  */
48557fb9d8SNicolas Bonnefon class ExternalCommunicator : public QObject
49557fb9d8SNicolas Bonnefon {
50557fb9d8SNicolas Bonnefon   Q_OBJECT
51557fb9d8SNicolas Bonnefon 
5223abd45aSNicolas Bonnefon   public:
53557fb9d8SNicolas Bonnefon     ExternalCommunicator() : QObject() {}
5423abd45aSNicolas Bonnefon 
55557fb9d8SNicolas Bonnefon     virtual ExternalInstance* otherInstance() const = 0;
5623abd45aSNicolas Bonnefon 
57*e07da50aSNicolas Bonnefon     /* Instruct the communicator to start listening for
58*e07da50aSNicolas Bonnefon      * remote initiated operations */
59*e07da50aSNicolas Bonnefon     virtual void startListening() = 0;
60*e07da50aSNicolas Bonnefon 
61557fb9d8SNicolas Bonnefon   signals:
62557fb9d8SNicolas Bonnefon     void loadFile( const std::string& file_name );
63*e07da50aSNicolas Bonnefon 
64*e07da50aSNicolas Bonnefon   public slots:
65*e07da50aSNicolas Bonnefon     virtual qint32 version() const = 0;
6623abd45aSNicolas Bonnefon };
6723abd45aSNicolas Bonnefon 
6823abd45aSNicolas Bonnefon #endif
69