Soprano
2.9.3
|
Central Soprano server class. More...
#include <Soprano/Server/ServerCore>
Public Member Functions | |
ServerCore (QObject *parent=0) | |
virtual | ~ServerCore () |
void | setBackend (const Backend *backend) |
const Backend * | backend () const |
void | setBackendSettings (const QList< BackendSetting > &settings) |
QList< BackendSetting > | backendSettings () const |
void | setMaximumConnectionCount (int max) |
int | maximumConnectionCount () const |
virtual Model * | model (const QString &name) |
virtual void | removeModel (const QString &name) |
virtual QStringList | allModels () const |
bool | start (const QString &socketPath=QString()) |
bool | listen (quint16 port=DEFAULT_PORT) |
void | stop () |
quint16 | serverPort () const |
void | registerAsDBusObject (const QString &objectPath=QString()) |
![]() | |
QObject (QObject *parent=0) | |
blockSignals (bool block) | |
childEvent (QChildEvent *event) | |
children () | |
connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type=Qt::AutoCompatConnection) | |
connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type=Qt::AutoCompatConnection) | |
connectNotify (const char *signal) | |
customEvent (QEvent *event) | |
deleteLater () | |
destroyed (QObject *obj=0) | |
disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) | |
disconnect (const char *signal=0, const QObject *receiver=0, const char *method=0) | |
disconnect (const QObject *receiver, const char *method=0) | |
disconnectNotify (const char *signal) | |
dumpObjectInfo () | |
dumpObjectTree () | |
dynamicPropertyNames () | |
event (QEvent *e) | |
eventFilter (QObject *watched, QEvent *event) | |
findChild (const QString &name=QString() | |
findChildren (const QString &name=QString() | |
findChildren (const QRegExp ®Exp) | |
inherits (const char *className) | |
installEventFilter (QObject *filterObj) | |
isWidgetType () | |
killTimer (int id) | |
metaObject () | |
moveToThread (QThread *targetThread) | |
parent () | |
property (const char *name) | |
receivers (const char *signal) | |
removeEventFilter (QObject *obj) | |
sender () | |
setParent (QObject *parent) | |
setProperty (const char *name, const QVariant &value) | |
signalsBlocked () | |
startTimer (int interval) | |
thread () | |
timerEvent (QTimerEvent *event) | |
tr (const char *sourceText, const char *comment=0, int n=-1) | |
trUtf8 (const char *sourceText, const char *comment=0, int n=-1) | |
staticMetaObject | |
QObject (QObject *parent, const char *name) | |
checkConnectArgs (const char *signal, const QObject *object, const char *method) | |
child (const char *objName, const char *inheritsClass=0, bool recursiveSearch=true) | |
className () | |
insertChild (QObject *object) | |
isA (const char *className) | |
name () | |
name (const char *defaultName) | |
normalizeSignalSlot (const char *signalSlot) | |
removeChild (QObject *object) | |
setName (const char *name) | |
![]() | |
virtual | ~ErrorCache () |
virtual Error | lastError () const |
Static Public Attributes | |
static const quint16 | DEFAULT_PORT |
Protected Member Functions | |
virtual Model * | createModel (const QList< BackendSetting > &settings) |
![]() | |
ErrorCache () | |
void | clearError () const |
void | setError (const Error &) const |
void | setError (const QString &errorMessage, int code=ErrorUnknown) const |
Central Soprano server class.
The ServerCore provides a Soprano server which maintains a set of named Model instances that can be accessed by clients over a tcp connection through Server::BackendPlugin.
Creating a server is very simple: Either derive from ServerCore or create an instance and then call start() to make the server listen for incoming connections.
Optionally ServerCore can be configured using normal BackendSetting settings through setBackendSettings().
Be aware the ServerCode supports multiple ways of communication. start() opens a TCP socket to accept new connections, registerAsDBusObject() registers a DBus interface on the DBus session bus. Both ways of communication can be used simultaneously.
ServerCore will spawn a new thread for each incoming TCP or local socket connection. In addition the D-Bus interface is running in its own thread. The maximum number of threads that are spawned can be set via setMaximumConnectionCount(). By default there is no restriction on the maximum thread count to keep backwards compatibility.
Definition at line 74 of file servercore.h.
Soprano::Server::ServerCore::ServerCore | ( | QObject * | parent = 0 | ) |
|
virtual |
void Soprano::Server::ServerCore::setBackend | ( | const Backend * | backend | ) |
const Backend* Soprano::Server::ServerCore::backend | ( | ) | const |
void Soprano::Server::ServerCore::setBackendSettings | ( | const QList< BackendSetting > & | settings | ) |
Set the settings that are to be used by createModel() to create new Model instances. Be aware that Soprano::BackendOptionStorageDir will be changed to include a subdir which is the Model's name.
settings | The settings to use for new Models. |
QList<BackendSetting> Soprano::Server::ServerCore::backendSettings | ( | ) | const |
Retrieve the backend settings configured via setBackendSettings().
void Soprano::Server::ServerCore::setMaximumConnectionCount | ( | int | max | ) |
Set the maximum number of TCP and local socket connections. If the max is reached new incoming connections are refused.
This makes sense to restrict the number of threads the server spawns.
A typical usage would be to server a max number of clients via a local socket connection and let the rest share the one D-Bus interface.
max | The maximum number of connections. Using a value of 0 means no restriction. |
int Soprano::Server::ServerCore::maximumConnectionCount | ( | ) | const |
The maximum number of incoming connections that are served.
Get or create Model with the specific name. The default implementation will use createModel() to create a new Model if none with the specified name exists and protect it against deadlocks with a Util::AsyncModel.
name | The name of the requested Model. |
|
virtual |
Remove a model and delete all data in it. Use with care.
Be aware that the Model instance will also be deleted.
Should be reimplemented if model() is reimplemented.
name | The name of the requested Model. |
|
virtual |
Retrieve all models that have been loaded.
Start the core on a local socket. On Windows this is a named pipe and on Unix this this is a local domain socket.
Use Client::LocalSocketClient to connect.
true
if the local socket could be successfully opened. false
on error. See ErrorCache::lastError() for details. bool Soprano::Server::ServerCore::listen | ( | quint16 | port = DEFAULT_PORT | ) |
Start the Server. Calling this method will make the Server listen on the specified port for incoming client connections.
port | The port to listen on for client connections. |
Use Client::TcpClient to connect.
true
if the server was successfully started, false
otherwise. void Soprano::Server::ServerCore::stop | ( | ) |
Stops listening on all connections. This includes the local socket connection, the tcp connection and dbus, depending on which all are listening.
This does not destroy the internal model
quint16 Soprano::Server::ServerCore::serverPort | ( | ) | const |
Register the ServerCore as a DBus object. The process needs to be registered as a DBus service before (QDBusConnection::registerService()).
objectPath | The DBus object path to register the server as. If empty the default path will be used (/org/soprano/Server). |
Use Client::DBusClient to connect.
In case Soprano is compiled without D-Bus support this method does nothing.
D-Bus clients will be served in a separate thread.
|
protectedvirtual |
Create a new Model. The default implementation uses the configured Backend with the configured settings to create a new Model. This method can be reimplemented to create specialized Model, for example in combination with some FilterModel.
settings | The settings to use (a reimplementation may choose to ignore the settings.) |
|
static |
The default Soprano server port: 5000
Definition at line 85 of file servercore.h.