~ubuntu-branches/ubuntu/gutsy/soprano/gutsy

« back to all changes in this revision

Viewing changes to server/tcpclient.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-10-12 14:43:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071012144348-yajzi51v4k23ahxf
Tags: 1.95.0~beta2-1ubuntu1
* Sync with Debian
* Add versioned build-dep on raptor

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of Soprano Project.
 
3
 *
 
4
 * Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library 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 GNU
 
14
 * Library General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Library General Public License
 
17
 * along with this library; see the file COPYING.LIB.  If not, write to
 
18
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
19
 * Boston, MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
#ifndef _SOPRANO_SERVER_CLIENT_H_
 
23
#define _SOPRANO_SERVER_CLIENT_H_
 
24
 
 
25
#include <QtCore/QObject>
 
26
#include <QtCore/QList>
 
27
#include <QtNetwork/QHostAddress>
 
28
 
 
29
#include "error.h"
 
30
#include "backend.h"
 
31
#include "soprano_export.h"
 
32
 
 
33
// FIXME: add signals for conection and disconnection, maybe even make it async as Qt's network stuff itself
 
34
 
 
35
namespace Soprano {
 
36
 
 
37
    class Model;
 
38
 
 
39
    namespace Client {
 
40
        /**
 
41
         * \class TcpClient tcpclient.h Soprano/Client/TcpClient
 
42
         *
 
43
         * \brief Creates a connection to the %Soprano server.
 
44
         *
 
45
         * The %Soprano server can be accessed normally through PluginManager::discoverBackendByName()
 
46
         * with name "sopranoserver" or by simply creating an instance of TcpClient. The latter solution can have advantages
 
47
         * as it uses a new connection to the server.
 
48
         *
 
49
         * \author Sebastian Trueg <trueg@kde.org>
 
50
         */
 
51
        class SOPRANO_CLIENT_EXPORT TcpClient : public QObject, public Error::ErrorCache
 
52
        {
 
53
            Q_OBJECT
 
54
 
 
55
        public:
 
56
            /**
 
57
             * Create a new Client instance.
 
58
             */
 
59
            TcpClient( QObject* parent = 0 );
 
60
 
 
61
            /**
 
62
             * Destructor.
 
63
             */
 
64
            virtual ~TcpClient();
 
65
 
 
66
            /**
 
67
             * The default %Soprano server connection port.
 
68
             */
 
69
            static const quint16 DEFAULT_PORT;
 
70
 
 
71
            /**
 
72
             * Tries to connect to the %Soprano server.
 
73
             *
 
74
             * \return \p true on success, \p false if an error occured.
 
75
             * Check lastError() for details.
 
76
             */
 
77
            bool connect( const QHostAddress& address = QHostAddress::LocalHost, int port = DEFAULT_PORT );
 
78
 
 
79
            /**
 
80
             * Check if the client is connected to a server.
 
81
             *
 
82
             * \return \p true if this client is connected to a server, \p false
 
83
             * otherwise.
 
84
             */
 
85
            bool isConnected();
 
86
 
 
87
            /**
 
88
             * Disconnect from the server. The created model instances are not
 
89
             * deleted but remain useless; open iterators are closed.
 
90
             */
 
91
            void disconnect();
 
92
 
 
93
            /**
 
94
             * Creates a new Model instance that wraps a server model.
 
95
             * %Client models are very light wrappers and creating them is
 
96
             * very fast.
 
97
             *
 
98
             * \param name The name of the model to access.
 
99
             * \param settings The settings to send to the server for creating a new model.
 
100
             * These settings may be ignored by the server if a model with that name has
 
101
             * already been created.
 
102
             *
 
103
             * \return A new Model instance wrapping the requested server
 
104
             * model or 0 on error (check lastError() for details.)
 
105
             */
 
106
            Model* createModel( const QString& name, const QList<BackendSetting>& settings = QList<BackendSetting>() );
 
107
 
 
108
            /**
 
109
             * Get a list of all models that the server currently holds.
 
110
             * This method may return an empty list before any call to 
 
111
             * createModel().
 
112
             *
 
113
             * \return A list of the names of all models that are currently
 
114
             * opened by the server.
 
115
             */
 
116
//          QStringList models() const;
 
117
 
 
118
        private Q_SLOTS:
 
119
            void slotError( QAbstractSocket::SocketError error );
 
120
 
 
121
        private:
 
122
            class Private;
 
123
            Private* const d;
 
124
        };
 
125
    }
 
126
}
 
127
 
 
128
#endif