Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 57 files changed
  • 0 commit comments
  • 1 contributor
Showing with 647 additions and 731 deletions.
  1. +1 −1  .astylerc
  2. +1 −1  CMakeLists.txt
  3. +12 −12 INSTALL.md
  4. +14 −9 README
  5. +2 −0  lib/daemon/README.md
  6. +2 −1  lib/daemon/plugin.cpp
  7. +1 −0  lib/dbus/README.md
  8. +7 −6 lib/dbus/dispatcher.cpp
  9. +14 −11 lib/dbus/dispatcher.hpp
  10. +1 −1  lib/dbus/module.cpp
  11. +1 −0  lib/heartbeat/README.md
  12. +7 −5 lib/heartbeat/calls/greet.hpp
  13. +2 −3 lib/heartbeat/module.cpp
  14. +2 −2 lib/heartbeat/plugin.cpp
  15. +1 −0  lib/zeromq/README.md
  16. +12 −12 lib/zeromq/dispatcher.cpp
  17. +16 −13 lib/zeromq/dispatcher.hpp
  18. +19 −23 lib/zeromq/module.cpp
  19. +4 −0 lib/zeromq/module.hpp
  20. +1 −1  lib/zeromq/plugin.cpp
  21. +12 −12 lib/zeromq/receiver.cpp
  22. +17 −14 lib/zeromq/receiver.hpp
  23. +16 −19 src/Wintermute/Events/Filters/call.cpp
  24. +2 −2 src/Wintermute/Events/Filters/call.hpp
  25. +2 −4 src/Wintermute/Events/call.cpp
  26. +1 −1  src/Wintermute/Events/call.hpp
  27. +15 −19 src/Wintermute/Procedure/call.cpp
  28. +117 −117 src/Wintermute/Procedure/call.hpp
  29. +7 −7 src/Wintermute/Procedure/dispatcher.cpp
  30. +16 −16 src/Wintermute/Procedure/dispatcher.hpp
  31. +8 −9 src/Wintermute/Procedure/dummy_dispatcher.cpp
  32. +1 −1  src/Wintermute/Procedure/dummy_dispatcher.hpp
  33. +4 −5 src/Wintermute/Procedure/dummy_receiver.cpp
  34. +13 −10 src/Wintermute/Procedure/dummy_receiver.hpp
  35. +5 −5 src/Wintermute/Procedure/method_call.cpp
  36. +2 −2 src/Wintermute/Procedure/method_call.hpp
  37. +2 −3 src/Wintermute/Procedure/module.cpp
  38. +5 −5 src/Wintermute/Procedure/module.hpp
  39. +2 −2 src/Wintermute/Procedure/process_module.cpp
  40. +12 −15 src/Wintermute/Procedure/receiver.cpp
  41. +1 −1  src/Wintermute/Procedure/receiver.hpp
  42. +11 −17 src/Wintermute/application.cpp
  43. +136 −137 src/Wintermute/application.hpp
  44. +20 −34 src/Wintermute/factory.cpp
  45. +1 −1  src/Wintermute/factory.hpp
  46. +3 −5 src/Wintermute/logging.cpp
  47. +2 −4 src/Wintermute/private/Procedure/call.hpp
  48. +25 −39 src/Wintermute/private/Procedure/dispatcher.hpp
  49. +9 −15 src/Wintermute/private/Procedure/module.hpp
  50. +15 −24 src/Wintermute/private/Procedure/receiver.hpp
  51. +17 −33 src/Wintermute/private/application.hpp
  52. +17 −34 src/Wintermute/private/factory.hpp
  53. +3 −6 src/Wintermute/private/logging.hpp
  54. +4 −8 src/Wintermute/private/plugin.hpp
  55. +0 −1  src/main.cpp
  56. +2 −1  test/unit/CMakeLists.txt
  57. +2 −2 test/unit/command_line.cpp
View
2  .astylerc
@@ -1,4 +1,4 @@
-# vim: ft=conf
+# vim: ft=astylerc tw=78
--style=kr
View
2  CMakeLists.txt
@@ -1,5 +1,5 @@
#############################################################################
-### Copyright (C) 2013 Jacky Alciné <me@jalcine.me>
+### Copyright (C) 2011 - 2014 Jacky Alciné <me@jalcine.me>
###
### This file is part of Wintermute, the extensible AI platform.
###
View
24 INSTALL.md
@@ -16,27 +16,27 @@ provided by contributors of other platforms.
* Qt 4.7 or greater - http://qt-project.org
* QCommandLine - https://github.com/jalcine/qcommandline
* QLogger - https://gitorious.org/log4qt/log4qt
- * Qt bindings to [ZeroMQ](http://zeromq.org) - https://github.com/jalcine/QtZeroMQ
+ * Qt to [ZeroMQ](http://zeromq.org) - https://github.com/jalcine/QtZeroMQ
If you want to test Wintermute, you'll need the following:
-* gcov 4.6
-* lcov 1.9
-* valgrind 3.8.1
+ * gcov 4.6
+ * lcov 1.9
+ * valgrind 3.8.1
Once you've satisfied those dependencies, building is a breeze. Seriously.
## Procedure
```bash
-$ mkdir build && cd build # Create and enter build directory.
-$ cmake .. - DCMAKE_BUILD_TYPE = Debug # Configure Wintermute for debugging.
-$ make # Build Wintermute.
-$ make test # (optional) Test Wintermute.
-$ make coverage # (optional) Get coverage information.
-$ make memorycheck # (optional) Checks for memory leaks.
-$ make install # Install Wintermute if `CMAKE_INSTALL_PREFIX` is user writable.
-# make install # Install Wintermute system-wide.
+$ mkdir build && cd build # Create and enter build directory.
+$ cmake .. -DCMAKE_BUILD_TYPE=Debug # Configure Wintermute for debugging.
+$ make # Build Wintermute.
+$ make test # (optional) Test Wintermute.
+$ make coverage # (optional) Get coverage information.
+$ make memorycheck # (optional) Checks for memory leaks.
+$ make install # Install Wintermute if `CMAKE_INSTALL_PREFIX` is user writable.
+# make install # Install Wintermute system-wide.
```
Once you've satisfied those dependencies, building is a breeze. Seriously.
View
23 README
@@ -1,4 +1,5 @@
# Wintermute [![Stories in Ready](https://badge.waffle.io/wintermuteapp/wintermute.png)](http://waffle.io/wintermuteapp/wintermute) [![Coverage Status](https://coveralls.io/repos/wintermuteapp/wintermute/badge.png?branch=develop)](https://coveralls.io/r/wintermuteapp/wintermute?branch=develop) [![Build Status](https://travis-ci.org/wintermuteapp/wintermute.png)](https://travis-ci.org/wintermuteapp/wintermute) [![Gitter chat](https://badges.gitter.im/wintermuteapp/wintermute.png)](https://gitter.im/wintermuteapp/wintermute)
+
**Wintermute** is meant to be an application platform that aims to:
+ extend by means of plug-ins and RPC
+ embrace the mannerisms of parallel computing
@@ -8,8 +9,9 @@
This repository has been my tinkering to get the application as close to
ideally fit as possibly capable by [me](http://jalcine.me).
-Installing? **Easy**. We use [CMake](http://cmake.org); we gotcha. But read
-[INSTALL.md](./INSTALL.md) for more information.
+Building and/or installing? **Easy**. We use [CMake](http://cmake.org); we
+gotcha; read [INSTALL.md](./INSTALL.md) for more information. Feel free to
+[contribute](./CONTRIBUTING.md) to the project.
## Notes
**Wintermute** itself is built using [Qt][qt4].
@@ -18,19 +20,22 @@ build with either `clang >= 3.5-1~exp1` or `gcc >= 4.8.1`.
## Tested Operating Systems
So far, Wintermute has only been built and tested on a Linux operating system,
-more precisely, running [Kubuntu][] Raring Ringtail 13.04.
-Please build, test and upload your results for comparison!
+more precisely, running [Kubuntu][] Raring Ringtail 13.04. Please build, test
+and upload your results for comparison!
**Update**: Also builds fine on [Kubuntu][] Saucy Salamander 13.10.
+
## Contributing
- - Fork, make a topic branch and propose your changes! **Bonus points for using Waffle**
- - Build and test Wintermute on a foreign, untested system!
- - Spread the word and do your part to make Wintermute an awesome app!
+ - Fork, make a topic branch and propose your changes.
+ **Bonus points for using Waffle and/or topic branches!**
+ - Build and test Wintermute on a foreign, untested system.
+ - Spread the word and do your part to make Wintermute an awesome app
+ framework.
I *strongly* recommend using tools like `[git-flow][gitflows]` and
-`[git-hooks][githooks]` to
-accelerate your development process on the source control side.
+`[git-hooks][githooks]` to accelerate your development process on
+the source control side.
Also, if you're adding a new feature, try writing a test for it first!
Wintermute has a few wrappers over Qt's testing tools. If you get stuck,
View
2  lib/daemon/README.md
@@ -0,0 +1,2 @@
+# Daemon
+
View
3  lib/daemon/plugin.cpp
@@ -28,7 +28,7 @@ using Wintermute::Version;
Plugin::Plugin()
{
module = new Daemon::Module ( this );
- module->connect(this, SIGNAL(started()), SLOT(start()));
+ module->connect ( this, SIGNAL ( started() ), SLOT ( start() ) );
}
QString
@@ -45,6 +45,7 @@ Plugin::stop()
void
Plugin::start()
{
+ // TODO Ask for the loading of a messaging plug-in.
}
Version
View
1  lib/dbus/README.md
@@ -0,0 +1 @@
+# D-Bus Support in Wintermute.
View
13 lib/dbus/dispatcher.cpp
@@ -29,7 +29,8 @@ using Wintermute::DBus::Module;
using Wintermute::Procedure::Call;
Dispatcher::Dispatcher() :
- Wintermute::Procedure::Dispatcher::Dispatcher() {
+ Wintermute::Procedure::Dispatcher::Dispatcher()
+{
}
Dispatcher::~Dispatcher()
@@ -37,14 +38,14 @@ Dispatcher::~Dispatcher()
}
void
-Dispatcher::sendMessage(const Call* message)
+Dispatcher::sendMessage ( const Call* message )
{
const QByteArray data = message->toString().toUtf8();
QDBusConnection sessionBus = QDBusConnection::sessionBus();
- QDBusMessage methodCall = QDBusMessage::createMethodCall(WINTERMUTE_DOMAIN,
- "/Receiver", message->recipient(), "handleCall");
+ QDBusMessage methodCall = QDBusMessage::createMethodCall ( WINTERMUTE_DOMAIN,
+ "/Receiver", message->recipient(), "handleCall" );
methodCall << data;
- QDBusPendingReply<QString> methodCallState = sessionBus.asyncCall(methodCall);
+ QDBusPendingReply<QString> methodCallState = sessionBus.asyncCall ( methodCall );
methodCallState.waitForFinished();
- winfo(this, "Invoked call over D-Bus; though the pending call isn't being caught.");
+ winfo ( this, "Invoked call over D-Bus; though the pending call isn't being caught." );
}
View
25 lib/dbus/dispatcher.hpp
@@ -21,18 +21,21 @@
#include <Wintermute/Procedure/Dispatcher>
-namespace Wintermute {
- namespace DBus {
- class Dispatcher : public Wintermute::Procedure::Dispatcher {
- Q_OBJECT;
- Q_DISABLE_COPY(Dispatcher);
+namespace Wintermute
+{
+namespace DBus
+{
+class Dispatcher : public Wintermute::Procedure::Dispatcher
+{
+ Q_OBJECT;
+ Q_DISABLE_COPY ( Dispatcher );
- public:
- explicit Dispatcher();
- virtual ~Dispatcher();
- virtual void sendMessage(const Procedure::Call* call);
- };
- }
+public:
+ explicit Dispatcher();
+ virtual ~Dispatcher();
+ virtual void sendMessage ( const Procedure::Call* call );
+};
+}
}
#endif
View
2  lib/dbus/module.cpp
@@ -34,7 +34,7 @@ Module::Module ( DBus::Plugin* plugin ) : Wintermute::Procedure::Module ( plugin
setDomain ( WINTERMUTE_DOMAIN );
setPackage ( "dbus" );
Dispatcher* dispatcher = new Dispatcher;
- dispatcher->setParent(this);
+ dispatcher->setParent ( this );
}
void
View
1  lib/heartbeat/README.md
@@ -0,0 +1 @@
+# Heartbeat
View
12 lib/heartbeat/calls/greet.hpp
@@ -23,11 +23,13 @@
namespace Wintermute
{
- namespace Heartbeat {
- class GreetCall : public Wintermute::Procedure::Call {
- Q_OBJECT;
- };
- }
+namespace Heartbeat
+{
+class GreetCall : public Wintermute::Procedure::Call
+{
+ Q_OBJECT;
+};
+}
}
#endif /** WINTERMUTE_HEARTBEAT_CALLS_GREET */
View
5 lib/heartbeat/module.cpp
@@ -26,18 +26,17 @@
using Wintermute::Heartbeat::Module;
using Wintermute::Heartbeat::Plugin;
-Module::Module ( Heartbeat::Plugin* plugin ) :
+Module::Module ( Heartbeat::Plugin* plugin ) :
Wintermute::Procedure::Module ( plugin )
{
setDomain ( WINTERMUTE_DOMAIN );
setPackage ( "heartbeat" );
- winfo(this, "Heartbeat ready to pulse.");
+ winfo ( this, "Heartbeat ready to pulse." );
}
void
Module::start()
{
-
}
Module::~Module()
View
4 lib/heartbeat/plugin.cpp
@@ -27,7 +27,7 @@ using Wintermute::Version;
Plugin::Plugin() :
Wintermute::Plugin(),
- module(new Wintermute::Heartbeat::Module(this))
+ module ( new Wintermute::Heartbeat::Module ( this ) )
{
}
@@ -73,4 +73,4 @@ Plugin::type() const
return Support;
}
-Q_EXPORT_PLUGIN2 ( wintermute-heartbeat, Wintermute::Heartbeat::Plugin );
+Q_EXPORT_PLUGIN2 ( wintermute - heartbeat, Wintermute::Heartbeat::Plugin );
View
1  lib/zeromq/README.md
@@ -0,0 +1 @@
+# ZeroMQ Support in Wintermute
View
24 lib/zeromq/dispatcher.cpp
@@ -28,14 +28,14 @@ using Wintermute::ZeroMQ::Dispatcher;
using Wintermute::ZeroMQ::Module;
using Wintermute::Procedure::Call;
-Dispatcher::Dispatcher(Module* a_module) :
+Dispatcher::Dispatcher ( Module* a_module ) :
Wintermute::Procedure::Dispatcher::Dispatcher(),
- m_socket(0)
+ m_socket ( 0 )
{
- setParent(a_module);
- m_socket = dynamic_cast<QtZeroMQ::PollingSocket*>(
- a_module->m_context->createSocket(QtZeroMQ::Socket::TypePublish, this));
- m_socket->bindTo(WINTERMUTE_SOCKET_IPC);
+ setParent ( a_module );
+ m_socket = dynamic_cast<QtZeroMQ::PollingSocket*> (
+ a_module->m_context->createSocket ( QtZeroMQ::Socket::TypePublish, this ) );
+ m_socket->bindTo ( WINTERMUTE_SOCKET_IPC );
}
Dispatcher::~Dispatcher()
@@ -43,12 +43,12 @@ Dispatcher::~Dispatcher()
}
void
-Dispatcher::sendMessage(const Call* message) throw (zmq::error_t)
+Dispatcher::sendMessage ( const Call* message ) throw ( zmq::error_t )
{
const QByteArray data = message->toString().toUtf8();
- Module* module = qobject_cast<Module*>(parent());
- winfo(this, QString("Sending %1 ...").arg(QString(data)));
- Q_ASSERT(module != NULL);
- m_socket->sendMessage(data);
- winfo(this, "Message sent.");
+ Module* module = qobject_cast<Module*> ( parent() );
+ winfo ( this, QString ( "Sending %1 ..." ).arg ( QString ( data ) ) );
+ Q_ASSERT ( module != NULL );
+ m_socket->sendMessage ( data );
+ winfo ( this, "Message sent." );
}
View
29 lib/zeromq/dispatcher.hpp
@@ -22,20 +22,23 @@
#include <Wintermute/Procedure/Dispatcher>
#include <QtZeroMQ/PollingSocket>
-namespace Wintermute {
- namespace ZeroMQ {
- class Module;
- class Dispatcher : public Wintermute::Procedure::Dispatcher {
- Q_OBJECT;
- Q_DISABLE_COPY(Dispatcher);
- QtZeroMQ::PollingSocket* m_socket;
+namespace Wintermute
+{
+namespace ZeroMQ
+{
+class Module;
+class Dispatcher : public Wintermute::Procedure::Dispatcher
+{
+ Q_OBJECT;
+ Q_DISABLE_COPY ( Dispatcher );
+ QtZeroMQ::PollingSocket* m_socket;
- public:
- explicit Dispatcher(Wintermute::ZeroMQ::Module* module);
- virtual ~Dispatcher();
- virtual void sendMessage(const Procedure::Call* call) throw (zmq::error_t);
- };
- }
+public:
+ explicit Dispatcher ( Wintermute::ZeroMQ::Module* module );
+ virtual ~Dispatcher();
+ virtual void sendMessage ( const Procedure::Call* call ) throw ( zmq::error_t );
+};
+}
}
#endif
View
42 lib/zeromq/module.cpp
@@ -34,41 +34,37 @@ using Wintermute::ZeroMQ::Plugin;
using Wintermute::ZeroMQ::Dispatcher;
using Wintermute::ZeroMQ::Receiver;
-Module::Module ( ZeroMQ::Plugin* plugin ) : Wintermute::Procedure::Module ( plugin ),
- m_context(new QtZeroMQ::PollingContext(this)), m_dispatcher(0), m_receiver(0)
+Module::Module ( ZeroMQ::Plugin* plugin ) :
+ Wintermute::Procedure::Module ( plugin ),
+ m_context ( new QtZeroMQ::PollingContext ( this ) ),
+ m_dispatcher ( 0 ),
+ m_receiver ( 0 )
{
setDomain ( WINTERMUTE_DOMAIN );
setPackage ( "zeromq" );
- m_dispatcher = new Dispatcher(this);
- m_receiver = new Receiver(this);
+ m_receiver = new Receiver ( this );
+ m_dispatcher = new Dispatcher ( this );
+ connect ( m_context, SIGNAL ( polled() ), this, SLOT ( pollInvoked() ) );
+ connect ( m_context, SIGNAL ( pollError() ), this, SLOT ( pollError() ) );
}
void
-Module::start()
+Module::pollInvoked()
{
- m_context->start();
+ // TODO Query context for more messages.
}
void
-Module::bindIncomingSocket(){
- //m_incomingSocket = dynamic_cast<QtZeroMQ::PollingSocket*>(m_context->createSocket(QtZeroMQ::Socket::TypeSubscribe, this));
- //m_incomingSocket->setIdentity("wintermute:in");
- //m_incomingSocket->connectTo(WINTERMUTE_SOCKET_IPC);
- //m_incomingSocket->subscribeTo("wintermute:global");
+Module::pollError()
+{
+ // TODO Handle errors with polling.
}
-//void
-//Module::onMessageReceived(const QList<QByteArray>& message)
-//{
- //winfo(this, "Got some messages...");
- //QByteArray data;
- //foreach(const QByteArray& part, message){
- //data += part;
- //}
-
- //QtZeroMQ::Message msg(data);
- //winfo(this, QString(msg.toByteArray()));
-//}
+void
+Module::start()
+{
+ m_context->start();
+}
void
Module::stop()
View
4 lib/zeromq/module.hpp
@@ -36,13 +36,17 @@ class Module : public Wintermute::Procedure::Module
friend class Wintermute::ZeroMQ::Receiver;
friend class Wintermute::ZeroMQ::Dispatcher;
QtZeroMQ::PollingSocket* m_incomingSocket;
+
public:
explicit Module ( ZeroMQ::Plugin* plugin );
Q_SLOT virtual void start();
Q_SLOT virtual void stop();
virtual ~Module();
+
private:
void bindIncomingSocket();
+ Q_SLOT void pollInvoked();
+ Q_SLOT void pollError();
QtZeroMQ::PollingContext* m_context;
Dispatcher* m_dispatcher;
Receiver* m_receiver;
View
2  lib/zeromq/plugin.cpp
@@ -25,7 +25,7 @@ using Wintermute::ZeroMQ::Plugin;
using Wintermute::ZeroMQ::Module;
using Wintermute::Version;
-Plugin::Plugin() : module(new ZeroMQ::Module(this))
+Plugin::Plugin() : module ( new ZeroMQ::Module ( this ) )
{
}
View
24 lib/zeromq/receiver.cpp
@@ -29,15 +29,15 @@ using Wintermute::ZeroMQ::Receiver;
using Wintermute::ZeroMQ::Module;
using Wintermute::Procedure::Call;
-Receiver::Receiver(Module* a_module) :
- Wintermute::Procedure::Receiver(), m_socket(0)
+Receiver::Receiver ( Module* a_module ) :
+ Wintermute::Procedure::Receiver(), m_socket ( 0 )
{
- setParent(a_module);
- m_socket = dynamic_cast<QtZeroMQ::PollingSocket*>(
- a_module->m_context->createSocket(QtZeroMQ::Socket::TypeSubscribe, this));
- m_socket->subscribeTo(QString::null);
- m_socket->connectTo(WINTERMUTE_SOCKET_IPC);
- winfo(this, "Hey, listening on ZeroMQ.");
+ setParent ( a_module );
+ m_socket = dynamic_cast<QtZeroMQ::PollingSocket*> (
+ a_module->m_context->createSocket ( QtZeroMQ::Socket::TypeSubscribe, this ) );
+ m_socket->subscribeTo ( QString ( "" ) );
+ m_socket->connectTo ( WINTERMUTE_SOCKET_IPC );
+ winfo ( this, "Hey, listening on ZeroMQ." );
}
Receiver::~Receiver()
@@ -45,13 +45,13 @@ Receiver::~Receiver()
}
void
-Receiver::onMessageReceived(const QList<QByteArray>& data)
+Receiver::onMessageReceived ( const QList<QByteArray>& data )
{
QByteArray chunks;
- foreach (QByteArray chunk, data){
+ foreach ( QByteArray chunk, data ) {
chunks += chunk;
}
- winfo(this, QString("Obtained incoming call of %1 bytes.").arg(chunks.size()));
- Call* receivedCall = Call::fromString(chunks);
+ winfo ( this, QString ( "Obtained incoming call of %1 bytes." ).arg ( chunks.size() ) );
+ Call* receivedCall = Call::fromString ( chunks );
receivedCall->invoke();
}
View
31 lib/zeromq/receiver.hpp
@@ -21,22 +21,25 @@
#include <Wintermute/Procedure/Receiver>
-namespace Wintermute {
- namespace ZeroMQ {
- class Module;
- class Receiver : public Wintermute::Procedure::Receiver {
- Q_OBJECT;
- Q_DISABLE_COPY(Receiver);
- QtZeroMQ::PollingSocket* m_socket;
+namespace Wintermute
+{
+namespace ZeroMQ
+{
+class Module;
+class Receiver : public Wintermute::Procedure::Receiver
+{
+ Q_OBJECT;
+ Q_DISABLE_COPY ( Receiver );
+ QtZeroMQ::PollingSocket* m_socket;
- public:
- explicit Receiver(Wintermute::ZeroMQ::Module* module);
- virtual ~Receiver();
+public:
+ explicit Receiver ( Wintermute::ZeroMQ::Module* module );
+ virtual ~Receiver();
- private:
- Q_SLOT void onMessageReceived(const QList<QByteArray>& data);
- };
- }
+private:
+ Q_SLOT void onMessageReceived ( const QList<QByteArray>& data );
+};
+}
}
#endif
View
35 src/Wintermute/Events/Filters/call.cpp
@@ -29,38 +29,35 @@ using Wintermute::Events::Filters::CallFilter;
using Wintermute::Procedure::Call;
CallFilter::CallFilter() :
- QObject(wntrApp)
+ QObject ( wntrApp )
{
- winfo(this, "Call filter installled into process.");
+ winfo ( this, "Call filter installled into process." );
}
bool
-CallFilter::eventFilter(QObject* object, QEvent* event)
+CallFilter::eventFilter ( QObject* object, QEvent* event )
{
- if (event->type() == CallEvent::TypeDispatch)
- {
- winfo(this, "Handling a local call for dispatching aboard.");
- CallEvent* callEvent = static_cast<CallEvent*>(event);
+ if ( event->type() == CallEvent::TypeDispatch ) {
+ winfo ( this, "Handling a local call for dispatching aboard." );
+ CallEvent* callEvent = static_cast<CallEvent*> ( event );
const Procedure::Call* call = callEvent->call();
- winfo(this, QString("Call heading to %1.").arg(call->recipient()));
- Procedure::DispatcherPrivate::dispatch(call->toString());
- winfo(this, "Call dispatched.");
+ winfo ( this, QString ( "Call heading to %1." ).arg ( call->recipient() ) );
+ Procedure::DispatcherPrivate::dispatch ( call->toString() );
+ winfo ( this, "Call dispatched." );
return true;
- }
- else if (event->type() == CallEvent::TypeReceive)
- {
- winfo(this, "Handling a remote call for local invocation.");
- CallEvent* callEvent = static_cast<CallEvent*>(event);
+ } else if ( event->type() == CallEvent::TypeReceive ) {
+ winfo ( this, "Handling a remote call for local invocation." );
+ CallEvent* callEvent = static_cast<CallEvent*> ( event );
const Procedure::Call* call = callEvent->call();
- const bool invocated = Procedure::Call::attemptInvocation(call);
- invocated ? winfo(this, "Call invoked.") : wwarn(this, "Call failed to invoke.");
+ const bool invocated = Procedure::Call::attemptInvocation ( call );
+ invocated ? winfo ( this, "Call invoked." ) : wwarn ( this, "Call failed to invoke." );
return true;
}
// TODO: Filter out receive events.
- return QObject::eventFilter(object, event);
+ return QObject::eventFilter ( object, event );
}
CallFilter::~CallFilter()
{
- winfo(this, "Call filter removed from process.");
+ winfo ( this, "Call filter removed from process." );
}
View
4 src/Wintermute/Events/Filters/call.hpp
@@ -30,12 +30,12 @@ namespace Filters
class CallFilter : public QObject
{
Q_OBJECT;
- Q_DISABLE_COPY(CallFilter);
+ Q_DISABLE_COPY ( CallFilter );
public:
explicit CallFilter();
virtual ~CallFilter();
- virtual bool eventFilter(QObject* object, QEvent* event);
+ virtual bool eventFilter ( QObject* object, QEvent* event );
};
}
}
View
6 src/Wintermute/Events/call.cpp
@@ -25,10 +25,9 @@ using Wintermute::Procedure::Call;
const int CallEvent::TypeReceive = QEvent::registerEventType();
const int CallEvent::TypeDispatch = QEvent::registerEventType();
-CallEvent::CallEvent(int type, const Call* call) :
- QEvent((QEvent::Type) type) , m_call(call)
+CallEvent::CallEvent ( int type, const Call* call ) :
+ QEvent ( ( QEvent::Type ) type ) , m_call ( call )
{
-
}
const Call*
@@ -39,5 +38,4 @@ CallEvent::call() const
CallEvent::~CallEvent()
{
-
}
View
2  src/Wintermute/Events/call.hpp
@@ -37,7 +37,7 @@ class CallEvent : public QEvent
public:
static const int TypeReceive;
static const int TypeDispatch;
- explicit CallEvent(int type, const Procedure::Call* call);
+ explicit CallEvent ( int type, const Procedure::Call* call );
virtual ~CallEvent();
const Procedure::Call* call() const;
};
View
34 src/Wintermute/Procedure/call.cpp
@@ -27,12 +27,12 @@
using Wintermute::Procedure::Call;
using Wintermute::Procedure::Module;
-Call::Call ( QObject* parent ) :
+Call::Call ( QObject* parent ) :
QObject ( parent ), d_ptr ( new CallPrivate ( this ) )
{
}
-Call::Call ( CallPrivate* d ) :
+Call::Call ( CallPrivate* d ) :
QObject ( Wintermute::Application::instance() ), d_ptr ( d )
{
}
@@ -84,23 +84,21 @@ Call::toString() const
callMap["data"] = d->data;
QByteArray json = serializer.serialize ( callMap, &ok );
if ( !ok )
- return QString::null;
-
+ { return QString::null; }
return QString ( json );
}
Call*
-Call::fromString(const QString& data)
+Call::fromString ( const QString& data )
{
QJson::Parser parser;
bool ok;
- QVariant callData = parser.parse(data.toLocal8Bit(), &ok);
- if (!ok)
- return 0;
-
+ QVariant callData = parser.parse ( data.toLocal8Bit(), &ok );
+ if ( !ok )
+ { return 0; }
QVariantMap callMap = callData.toMap();
- Call* aCall = new Call(wntrApp);
- aCall->d_ptr->type = (Call::Type) callMap["type"].toInt();
+ Call* aCall = new Call ( wntrApp );
+ aCall->d_ptr->type = ( Call::Type ) callMap["type"].toInt();
aCall->d_ptr->recipient = callMap["recipient"].toString();
aCall->d_ptr->data = callMap["data"].toMap();
return aCall;
@@ -113,17 +111,15 @@ Call::operator() ( const QVariantList& data )
}
bool
-Call::attemptInvocation(const Call* call)
+Call::attemptInvocation ( const Call* call )
{
- Procedure::Module* module = wntrApp->findModule(call->recipient());
-
- if (!module){
- werr(staticMetaObject.className(), QString("Can't find module '%1' in this process.").arg(call->recipient()));
+ Procedure::Module* module = wntrApp->findModule ( call->recipient() );
+ if ( !module ) {
+ werr ( staticMetaObject.className(), QString ( "Can't find module '%1' in this process." ).arg ( call->recipient() ) );
return false;
}
-
- QVariant result = module->invoke(call->d_ptr->data["method"].toString(), call->d_ptr->data["arguments"].toList());
- winfo(staticMetaObject.className(), result.toString());
+ QVariant result = module->invoke ( call->d_ptr->data["method"].toString(), call->d_ptr->data["arguments"].toList() );
+ winfo ( staticMetaObject.className(), result.toString() );
return true;
}
View
234 src/Wintermute/Procedure/call.hpp
@@ -26,123 +26,123 @@
namespace Wintermute
{
- namespace Procedure
- {
- class CallPrivate;
- class Call : public QObject
- {
- Q_OBJECT;
-
- protected:
- Q_DISABLE_COPY ( Call );
- Q_DECLARE_PRIVATE ( Call );
- QSharedPointer<CallPrivate> d_ptr;
- Call ( CallPrivate* d );
- Q_ENUMS(Type);
-
- public:
- /**
- * @typedef Signature
- *
- * Provides the short-hand signature for Call methods.
- */
- typedef std::function<QVariant ( QVariantList ) > Signature;
-
- /**
- * @typedef Callback
- *
- * Provides the callback necessary for async calling.
- */
- typedef std::function<void ( QVariant ) > Callback;
-
- /**
- * @enum Type
- *
- * Defines the potential types a Call can take in the procedural system. In
- * order to keep things clean, you can add your own types only if it's over
- * 9000 (this was intentional)
- */
- enum Type {
- TypeUndefined = 0x0000, // Undefined call. Don't bother with.
-
- TypeResponse = 0x0001, // Represents a invoking call being responsed to.
- TypeDispatch = 0x0002, // Represents a invoked call being sent to.
- TypeSignal = 0x0003, // Represents a invoking signal being raised.
-
- TypeInvocation = 0x0010, // Represents a call to be invoked.
- TypeRemoteNoAuth = 0x0100, // This call deals with a remote network with no authentication.
- TypeRemoteAuth = 0x0200, // This call deals with a remote network with authentication.
-
- TypeUser = 0x1000 // Anything above this is available to the user space.
- };
- Q_FLAGS(Type Types);
-
- /**
- * @ctor
- * @fn Call
- */
- explicit Call ( QObject* parent );
-
- /**
- * @dtor
- * @fn ~Call
- */
- virtual ~Call ();
-
- /**
- * @fn name
- * @brief Obtains the name of the call.
- */
- QString name() const;
-
- /**
- * @fn type
- * @brief Obtains the type of call this is.
- *
- * Obtains the type of message that this exposes.
- */
- Type type() const;
-
- /**
- * @fn toString
- * @brief Generates a string representation of this call.
- */
- QString toString() const;
-
- static Call* fromString(const QString& data);
-
- /**
- * @fn recipient
- * @brief Obtains the name of the module to recieve this message.
- *
- * Obtains the qualified module name that this Call is sending a message
- * to.
- */
- QString recipient() const;
-
- /**
- * @fn setRecipient
- * @brief Changes the recipient of this Call.
- */
- void setRecipient ( const QString moduleName );
-
- /**
- * @fn invoke
- * @param data A list of QVariant variables.
- */
- QVariant invoke ( const QVariantList& data = QVariantList() );
-
- /**
- * @operator operator()
- * @brief Allow for functor-like capabilities for the Call object.
- */
- QVariant operator() ( const QVariantList& arguments = QVariantList() );
-
- static bool attemptInvocation( const Call* call );
- };
-
- typedef QSharedPointer<Call> CallPointer;
- } /* Procedure */
+namespace Procedure
+{
+class CallPrivate;
+class Call : public QObject
+{
+ Q_OBJECT;
+
+protected:
+ Q_DISABLE_COPY ( Call );
+ Q_DECLARE_PRIVATE ( Call );
+ QSharedPointer<CallPrivate> d_ptr;
+ Call ( CallPrivate* d );
+ Q_ENUMS ( Type );
+
+public:
+ /**
+ * @typedef Signature
+ *
+ * Provides the short-hand signature for Call methods.
+ */
+ typedef std::function<QVariant ( QVariantList ) > Signature;
+
+ /**
+ * @typedef Callback
+ *
+ * Provides the callback necessary for async calling.
+ */
+ typedef std::function<void ( QVariant ) > Callback;
+
+ /**
+ * @enum Type
+ *
+ * Defines the potential types a Call can take in the procedural system. In
+ * order to keep things clean, you can add your own types only if it's over
+ * 9000 (this was intentional)
+ */
+ enum Type {
+ TypeUndefined = 0x0000, // Undefined call. Don't bother with.
+
+ TypeResponse = 0x0001, // Represents a invoking call being responsed to.
+ TypeDispatch = 0x0002, // Represents a invoked call being sent to.
+ TypeSignal = 0x0003, // Represents a invoking signal being raised.
+
+ TypeInvocation = 0x0010, // Represents a call to be invoked.
+ TypeRemoteNoAuth = 0x0100, // This call deals with a remote network with no authentication.
+ TypeRemoteAuth = 0x0200, // This call deals with a remote network with authentication.
+
+ TypeUser = 0x1000 // Anything above this is available to the user space.
+ };
+ Q_FLAGS ( Type Types );
+
+ /**
+ * @ctor
+ * @fn Call
+ */
+ explicit Call ( QObject* parent );
+
+ /**
+ * @dtor
+ * @fn ~Call
+ */
+ virtual ~Call ();
+
+ /**
+ * @fn name
+ * @brief Obtains the name of the call.
+ */
+ QString name() const;
+
+ /**
+ * @fn type
+ * @brief Obtains the type of call this is.
+ *
+ * Obtains the type of message that this exposes.
+ */
+ Type type() const;
+
+ /**
+ * @fn toString
+ * @brief Generates a string representation of this call.
+ */
+ QString toString() const;
+
+ static Call* fromString ( const QString& data );
+
+ /**
+ * @fn recipient
+ * @brief Obtains the name of the module to recieve this message.
+ *
+ * Obtains the qualified module name that this Call is sending a message
+ * to.
+ */
+ QString recipient() const;
+
+ /**
+ * @fn setRecipient
+ * @brief Changes the recipient of this Call.
+ */
+ void setRecipient ( const QString moduleName );
+
+ /**
+ * @fn invoke
+ * @param data A list of QVariant variables.
+ */
+ QVariant invoke ( const QVariantList& data = QVariantList() );
+
+ /**
+ * @operator operator()
+ * @brief Allow for functor-like capabilities for the Call object.
+ */
+ QVariant operator() ( const QVariantList& arguments = QVariantList() );
+
+ static bool attemptInvocation ( const Call* call );
+};
+
+typedef QSharedPointer<Call> CallPointer;
+} /* Procedure */
} /* Wintermute */
#endif /* WINTERMUTE_CORE_PROCEDURE_CALL_HPP */
View
14 src/Wintermute/Procedure/dispatcher.cpp
@@ -29,20 +29,20 @@ using Wintermute::Events::CallEvent;
QList<Dispatcher*> Wintermute::Procedure::DispatcherPrivate::dispatchers = QList<Dispatcher*>();
Dispatcher::Dispatcher() :
- QObject(wntrApp)
+ QObject ( wntrApp )
{
- DispatcherPrivate::addDispatcher(this);
+ DispatcherPrivate::addDispatcher ( this );
}
void
-Dispatcher::postDispatch(const Call* call)
+Dispatcher::postDispatch ( const Call* call )
{
- winfo(staticMetaObject.className(), "Caught a call; passing into the event loop.");
- CallEvent* event = new CallEvent(CallEvent::TypeDispatch, call);
- QCoreApplication::postEvent(wntrApp, event);
+ winfo ( staticMetaObject.className(), "Caught a call; passing into the event loop." );
+ CallEvent* event = new CallEvent ( CallEvent::TypeDispatch, call );
+ QCoreApplication::postEvent ( wntrApp, event );
}
Dispatcher::~Dispatcher()
{
- DispatcherPrivate::removeDispatcher(this);
+ DispatcherPrivate::removeDispatcher ( this );
}
View
32 src/Wintermute/Procedure/dispatcher.hpp
@@ -24,23 +24,23 @@
namespace Wintermute
{
- namespace Procedure
- {
- class Module;
- class DispatcherPrivate;
- class Dispatcher : public QObject
- {
- Q_OBJECT;
- friend class ModulePrivate;
- friend class DispatcherPrivate;
+namespace Procedure
+{
+class Module;
+class DispatcherPrivate;
+class Dispatcher : public QObject
+{
+ Q_OBJECT;
+ friend class ModulePrivate;
+ friend class DispatcherPrivate;
- protected:
- explicit Dispatcher();
- virtual ~Dispatcher();
- virtual void sendMessage(const Call* call) = 0;
- static void postDispatch(const Call* call);
- };
- }
+protected:
+ explicit Dispatcher();
+ virtual ~Dispatcher();
+ virtual void sendMessage ( const Call* call ) = 0;
+ static void postDispatch ( const Call* call );
+};
+}
}
#endif
View
17 src/Wintermute/Procedure/dummy_dispatcher.cpp
@@ -30,21 +30,20 @@ using Wintermute::Procedure::ReceiverPrivate;
DummyDispatcher::DummyDispatcher() :
Dispatcher()
{
- wdebug(this, "Hey, I'm a dummy.");
+ wdebug ( this, "Hey, I'm a dummy." );
}
void
-DummyDispatcher::sendMessage(const Call* call)
+DummyDispatcher::sendMessage ( const Call* call )
{
- wdebug(this,
- QString("Sending out %1 bytes for dispatching...").arg(call->toString().length()));
- DummyReceiver* ds =
- (static_cast<DummyReceiver*>(ReceiverPrivate::receivers[0]));
-
- ds->receiveMessage(call);
+ wdebug ( this,
+ QString ( "Sending out %1 bytes for dispatching..." ).arg ( call->toString().length() ) );
+ DummyReceiver* ds =
+ ( static_cast<DummyReceiver*> ( ReceiverPrivate::receivers[0] ) );
+ ds->receiveMessage ( call );
}
DummyDispatcher::~DummyDispatcher()
{
- wdebug(this, "Hey, this dummy is gone!");
+ wdebug ( this, "Hey, this dummy is gone!" );
}
View
2  src/Wintermute/Procedure/dummy_dispatcher.hpp
@@ -34,7 +34,7 @@ class DummyDispatcher : public Dispatcher
virtual ~DummyDispatcher();
protected:
- virtual void sendMessage(const Call* call);
+ virtual void sendMessage ( const Call* call );
};
}
}
View
9 src/Wintermute/Procedure/dummy_receiver.cpp
@@ -27,15 +27,14 @@ using Wintermute::Procedure::ReceiverPrivate;
DummyReceiver::DummyReceiver() :
Receiver()
{
-
}
void
-DummyReceiver::receiveMessage(const Call* call)
+DummyReceiver::receiveMessage ( const Call* call )
{
- wdebug(this, QString("We got %1 from %2").
- arg(call->toString(), call->recipient()));
- Receiver::receiveMessage(call);
+ wdebug ( this, QString ( "We got %1 from %2" ).
+ arg ( call->toString(), call->recipient() ) );
+ Receiver::receiveMessage ( call );
}
DummyReceiver::~DummyReceiver()
View
23 src/Wintermute/Procedure/dummy_receiver.hpp
@@ -21,17 +21,20 @@
#include <Wintermute/Procedure/Receiver>
-namespace Wintermute {
- namespace Procedure {
- class DummyReceiver : public Receiver {
- Q_OBJECT;
+namespace Wintermute
+{
+namespace Procedure
+{
+class DummyReceiver : public Receiver
+{
+ Q_OBJECT;
- public:
- explicit DummyReceiver();
- void receiveMessage(const Call* call);
- virtual ~DummyReceiver();
- };
- }
+public:
+ explicit DummyReceiver();
+ void receiveMessage ( const Call* call );
+ virtual ~DummyReceiver();
+};
+}
}
#endif
View
10 src/Wintermute/Procedure/method_call.cpp
@@ -28,7 +28,7 @@ MethodCall::MethodCall ( const QString& module, const QString& method, const QVa
Call ( new MethodCallPrivate ( this ) )
{
Q_D ( MethodCall );
- setRecipient(module);
+ setRecipient ( module );
d->type = Call::TypeInvocation;
d->data["method"] = method;
d->data["arguments"] = arguments;
@@ -38,19 +38,19 @@ QVariantList
MethodCall::arguments() const
{
Q_D ( const MethodCall );
- return d->data.value("arguments").toList();
+ return d->data.value ( "arguments" ).toList();
}
void
-MethodCall::dispatch(Module* module)
+MethodCall::dispatch ( Module* module )
{
- Q_D( MethodCall );
+ Q_D ( MethodCall );
QMap<QString, QVariant> appData;
appData["pid"] = QCoreApplication::applicationPid();
appData["version"] = QCoreApplication::applicationVersion();
appData["module"] = module->qualifiedName();
d->data["sender"] = appData;
- module->dispatch(*this);
+ module->dispatch ( *this );
}
MethodCall::~MethodCall()
View
4 src/Wintermute/Procedure/method_call.hpp
@@ -48,7 +48,7 @@ class MethodCall : public Call
* network.
*/
explicit MethodCall ( const QString& module, const QString& method,
- const QVariantList arguments = QVariantList() );
+ const QVariantList arguments = QVariantList() );
/**
* @dtor
@@ -71,7 +71,7 @@ class MethodCall : public Call
* @fn dispatch
* @brief A helper method to dispatch calls to a remote module.
*/
- void dispatch(Module* module = wntrApp->module());
+ void dispatch ( Module* module = wntrApp->module() );
};
}
}
View
5 src/Wintermute/Procedure/module.cpp
@@ -45,10 +45,9 @@ QVariant
Module::invoke ( const QString callName, const QVariantList data )
{
Q_D ( Module );
- if ( !d->calls.contains ( callName ) )
- {
+ if ( !d->calls.contains ( callName ) ) {
werr ( this, QString ( "The call '%1' doesn't exist in the module '%2'." )
- .arg ( callName, qualifiedName() ) );
+ .arg ( callName, qualifiedName() ) );
return QVariant ( -1 );
}
CallPointer call = d->calls[callName];
View
10 src/Wintermute/Procedure/module.hpp
@@ -79,12 +79,12 @@ class Module : public QObject
Q_SLOT virtual void start() = 0;
protected:
- /**
- * @fn invoke
- * @brief Looks for the named call and invoke with the provided data.
- */
+ /**
+ * @fn invoke
+ * @brief Looks for the named call and invoke with the provided data.
+ */
QVariant invoke ( const QString name, const QVariantList data = QVariantList() );
-
+
/**
* @fn setDomain
* @brief Sets the domain of this module.
View
4 src/Wintermute/Procedure/process_module.cpp
@@ -27,14 +27,14 @@ ProcessModule::ProcessModule() : Module ( Wintermute::Application::instance() )
{
setDomain ( WINTERMUTE_DOMAIN );
setPackage ( "process" );
- connect(wntrApp, SIGNAL(started()), SLOT(start()));
+ connect ( wntrApp, SIGNAL ( started() ), SLOT ( start() ) );
}
void
ProcessModule::start()
{
// TODO: What?
- winfo(this, QString("Currently %1 modules loaded so far.").arg(wntrApp->modules().length()));
+ winfo ( this, QString ( "Currently %1 modules loaded so far." ).arg ( wntrApp->modules().length() ) );
}
void
View
27 src/Wintermute/Procedure/receiver.cpp
@@ -36,29 +36,26 @@ using Wintermute::Events::CallEvent;
QList<Receiver*> Wintermute::Procedure::ReceiverPrivate::receivers = QList<Receiver*>();
Receiver::Receiver() :
- QObject(wntrApp)
+ QObject ( wntrApp )
{
- ReceiverPrivate::addReceiver(this);
+ ReceiverPrivate::addReceiver ( this );
}
void
-Receiver::receiveMessage(const Call* call)
+Receiver::receiveMessage ( const Call* call )
{
- winfo(this, QString("Caught a call for '%1'; passing it into event loop.").arg(call->recipient()));
- Procedure::Module* module = wntrApp->findModule(call->recipient());
- if (module != nullptr)
- {
- winfo(this, QString("Raising the call for '%1' throughout the event loop...").arg(module->qualifiedName()));
- CallEvent* event = new CallEvent(CallEvent::TypeReceive, call);
- QCoreApplication::postEvent(wntrApp, event);
- }
- else
- {
- wwarn(this, QString("Couldn't find the module '%1' to invoke this call with.").arg(call->recipient()));
+ winfo ( this, QString ( "Caught a call for '%1'; passing it into event loop." ).arg ( call->recipient() ) );
+ Procedure::Module* module = wntrApp->findModule ( call->recipient() );
+ if ( module != nullptr ) {
+ winfo ( this, QString ( "Raising the call for '%1' throughout the event loop..." ).arg ( module->qualifiedName() ) );
+ CallEvent* event = new CallEvent ( CallEvent::TypeReceive, call );
+ QCoreApplication::postEvent ( wntrApp, event );
+ } else {
+ wwarn ( this, QString ( "Couldn't find the module '%1' to invoke this call with." ).arg ( call->recipient() ) );
}
}
Receiver::~Receiver()
{
- ReceiverPrivate::removeReceiver(this);
+ ReceiverPrivate::removeReceiver ( this );
}
View
2  src/Wintermute/Procedure/receiver.hpp
@@ -33,7 +33,7 @@ class Receiver : public QObject
protected:
explicit Receiver();
virtual ~Receiver();
- Q_SLOT virtual void receiveMessage(const Call* call);
+ Q_SLOT virtual void receiveMessage ( const Call* call );
};
}
}
View
28 src/Wintermute/application.cpp
@@ -50,19 +50,17 @@ int
Application::run ( int& argc, char** argv )
{
int returnCode = -1;
- if ( Application::instance() == 0 )
- {
+ if ( Application::instance() == 0 ) {
Application::self = new Application ( argc, argv );
Logger* log = wlog ( Application::self );
self->d_ptr->initialize();
- log->info(QString("Wintermute is starting; PID %1. Let's play.").
- arg(QCoreApplication::applicationPid()));
+ log->info ( QString ( "Wintermute is starting; PID %1. Let's play." ).
+ arg ( QCoreApplication::applicationPid() ) );
self->start();
-
log->debug ( "Starting event loop." );
returnCode = self->d_ptr->exec();
log->info ( "Event loop ended; ended with" +
- QString( "exit code %1" ).arg ( returnCode ) );
+ QString ( "exit code %1" ).arg ( returnCode ) );
}
return returnCode;
}
@@ -88,10 +86,9 @@ Application::stop ( int exitcode )
log->info ( "Stopping Wintermute..." );
QCoreApplication::quit();
emit this->stopped();
- log->info ( "Wintermute is stopping " + QString("with exit code %1.")
- .arg(exitcode) );
-
- if (QCoreApplication::startingUp() || QCoreApplication::closingDown()){
+ log->info ( "Wintermute is stopping " + QString ( "with exit code %1." )
+ .arg ( exitcode ) );
+ if ( QCoreApplication::startingUp() || QCoreApplication::closingDown() ) {
exit ( exitcode );
}
}
@@ -100,8 +97,7 @@ QString
Application::processName() const
{
Q_D ( const Application );
- if ( !d->module )
- {
+ if ( !d->module ) {
return QString::null;
}
return d->module->qualifiedName();
@@ -119,10 +115,8 @@ Application::findModule ( const QString& name ) const
{
// NOTE: This could be so much more functional.
Q_D ( const Application );
- Q_FOREACH(Module * mod, d->modules)
- {
- if ( mod->domain().contains ( name ) )
- {
+ Q_FOREACH ( Module * mod, d->modules ) {
+ if ( mod->domain().contains ( name ) ) {
return mod;
}
}
@@ -160,5 +154,5 @@ Application::~Application()
{
this->stop();
this->deleteLater();
- winfo(this, "Application singleton deleted.");
+ winfo ( this, "Application singleton deleted." );
}
View
273 src/Wintermute/application.hpp
@@ -25,148 +25,147 @@
namespace Wintermute
{
- namespace Procedure
- {
- class Module;
- class ModulePrivate;
+namespace Procedure
+{
+class Module;
+class ModulePrivate;
+}
+class Version;
+class ApplicationPrivate;
+
+/**
+ * @class Application
+ *
+ * The `Application` class in Wintermute serves as an object hierarchy
+ * anchor. It's the first object to be created and fights to the death to be
+ * the last one destroyed.
+ */
+class Application : public QObject
+{
+ Q_OBJECT;
+ Q_DECLARE_PRIVATE ( Application );
+ Q_DISABLE_COPY ( Application );
+
+ QScopedPointer<ApplicationPrivate> d_ptr;
+ static Application* self;
+ friend class Procedure::ModulePrivate;
+
+ /**
+ * @fn Application
+ * @brief Private initialization of application.
+ * @constructor
+ *
+ * @param argc Argument count (native-value)
+ * @param argv Arguemnt array (native-value)
+ */
+ Application ( int& argc, char** argv );
+
+public:
+ virtual ~Application();
+ /**
+ * @fn instance
+ * @brief Provides a pointer to an instance of Wintermute::Application.
+ *
+ * In order to keep Wintermute's instance running smoothly,
+ * a shared pointer to the instance of the application that's running
+ * and handling Wintermute's lower-level work. It's strongly recommended
+ * that you use this method if desired.
+ *
+ * @return A shared pointer to the working instance of Wintermute::Application.
+ */
+ static inline Application* instance() {
+ return self;
}
- class Version;
- class ApplicationPrivate;
/**
- * @class Application
+ * @fn run
+ * @brief Starts Wintermute.
*
- * The `Application` class in Wintermute serves as an object hierarchy
- * anchor. It's the first object to be created and fights to the death to be
- * the last one destroyed.
+ * This once-invokable method begins the low-level initialization of
+ * Wintermute. It's invoked from Wintermute's `main()` method and cannot
+ * be run a second time.
*/
- class Application : public QObject
- {
- Q_OBJECT;
- Q_DECLARE_PRIVATE ( Application );
- Q_DISABLE_COPY ( Application );
-
- QScopedPointer<ApplicationPrivate> d_ptr;
- static Application* self;
- friend class Procedure::ModulePrivate;
-
- /**
- * @fn Application
- * @brief Private initialization of application.
- * @constructor
- *
- * @param argc Argument count (native-value)
- * @param argv Arguemnt array (native-value)
- */
- Application ( int& argc, char** argv );
-
- public:
- virtual ~Application();
- /**
- * @fn instance
- * @brief Provides a pointer to an instance of Wintermute::Application.
- *
- * In order to keep Wintermute's instance running smoothly,
- * a shared pointer to the instance of the application that's running
- * and handling Wintermute's lower-level work. It's strongly recommended
- * that you use this method if desired.
- *
- * @return A shared pointer to the working instance of Wintermute::Application.
- */
- static inline Application* instance()
- {
- return self;
- }
-
- /**
- * @fn run
- * @brief Starts Wintermute.
- *
- * This once-invokable method begins the low-level initialization of
- * Wintermute. It's invoked from Wintermute's `main()` method and cannot
- * be run a second time.
- */
- static int run ( int& argc, char** argv );
-
- /**
- * @fn setting
- * @brief Obtains a setting from Wintermute's local configuration.
- *
- * @note These options are global to the Wintermute application.
- */
- static QVariant setting ( const QString& path, const QVariant defaultValue = QVariant() );
-
- /** @fn setSetting
- * @brief Changes a value of the setting for Wintermute
- *
- * @note These options are global to the Wintermute application.
- */
- static void setSetting ( const QString& path, const QVariant value );
-
- /**
- * @fn version
- * @brief Obtains the current version of Wintermute.
- *
- * Extremely direct and to the point, this returns the version of Wintermute
- * running in this process.
- */
- Version version() const;
-
- /**
- * @fn processName
- * @brief Obtains the stringifed process name used by Wintermute.
- *
- * Obtains the process name of this running instance of Wintermute. This
- * is typically in the form of `domain.application:$PID`, a bit similar
- * to package paths in Java. The :$PID portion is added to help increase
- * the precision of finding specific processes. Process names are formed
- * from the formulated name of the 'root module'.
- *
- * @see setModule()
- * @see module()
- */
- QString processName() const;
-
- /**
- * @fn module()
- * @brief Defines the root module of the process.
- */
- Procedure::Module* module() const;
-
- /**
- * @fn findModule
- * @brief Finds a method by its specified module.
- */
- Procedure::Module* findModule ( const QString& name ) const;
-
- /**
- * @fn modules
- * @brief Obtains a list of the modules registered locally.
- */
- QList<Procedure::Module*> modules() const;
-
- /**
- * @fn start
- * @brief
- *
- * Starts the initial processing required for execution in Wintermute
- * and begins the event loop.
- */
- void start();
-
- /**
- * @fn stop
- * @brief
- *
- * Stops the started processes in `start()` and begins the clean up for
- * the event loop.
- */
- void stop ( int exitcode = 0x0 );
-
- // TODO: Do documentation.
- Q_SIGNAL void started();
- Q_SIGNAL void stopped();
- };
+ static int run ( int& argc, char** argv );
+
+ /**
+ * @fn setting
+ * @brief Obtains a setting from Wintermute's local configuration.
+ *
+ * @note These options are global to the Wintermute application.
+ */
+ static QVariant setting ( const QString& path, const QVariant defaultValue = QVariant() );
+
+ /** @fn setSetting
+ * @brief Changes a value of the setting for Wintermute
+ *
+ * @note These options are global to the Wintermute application.
+ */
+ static void setSetting ( const QString& path, const QVariant value );
+
+ /**
+ * @fn version
+ * @brief Obtains the current version of Wintermute.
+ *
+ * Extremely direct and to the point, this returns the version of Wintermute
+ * running in this process.
+ */
+ Version version() const;
+
+ /**
+ * @fn processName
+ * @brief Obtains the stringifed process name used by Wintermute.
+ *
+ * Obtains the process name of this running instance of Wintermute. This
+ * is typically in the form of `domain.application:$PID`, a bit similar
+ * to package paths in Java. The :$PID portion is added to help increase
+ * the precision of finding specific processes. Process names are formed
+ * from the formulated name of the 'root module'.
+ *
+ * @see setModule()
+ * @see module()
+ */
+ QString processName() const;
+
+ /**
+ * @fn module()
+ * @brief Defines the root module of the process.
+ */
+ Procedure::Module* module() const;
+
+ /**
+ * @fn findModule
+ * @brief Finds a method by its specified module.
+ */
+ Procedure::Module* findModule ( const QString& name ) const;
+
+ /**
+ * @fn modules
+ * @brief Obtains a list of the modules registered locally.
+ */
+ QList<Procedure::Module*> modules() const;
+
+ /**
+ * @fn start
+ * @brief
+ *
+ * Starts the initial processing required for execution in Wintermute
+ * and begins the event loop.
+ */
+ void start();
+
+ /**
+ * @fn stop
+ * @brief
+ *
+ * Stops the started processes in `start()` and begins the clean up for
+ * the event loop.
+ */
+ void stop ( int exitcode = 0x0 );
+
+ // TODO: Do documentation.
+ Q_SIGNAL void started();
+ Q_SIGNAL void stopped();
+};
}
/**
View
54 src/Wintermute/factory.cpp
@@ -32,15 +32,14 @@ Factory* Factory::self = 0;
Factory::Factory() : QObject ( Application::instance() ), d_ptr ( new FactoryPrivate )
{
- connect(wntrApp, SIGNAL(started()), SLOT(start()));
- connect(wntrApp, SIGNAL(stopped()), SLOT(stop()));
+ connect ( wntrApp, SIGNAL ( started() ), SLOT ( start() ) );
+ connect ( wntrApp, SIGNAL ( stopped() ), SLOT ( stop() ) );
}
Factory*
Factory::instance()
{
- if ( !self )
- {
+ if ( !self ) {
self = new Factory;
}
return self;
@@ -68,9 +67,9 @@ Factory::activePlugins() const
}
bool
-Factory::loadedPlugin(const QString& name)
+Factory::loadedPlugin ( const QString& name )
{
- return activePlugins().contains(name);
+ return activePlugins().contains ( name );
}
// TODO: Ensure plug-in loading process.
@@ -79,30 +78,24 @@ Factory::loadPlugin ( const QString& id )
{
Q_D ( Factory );
Logger* log = wlog ( this );
-
- if (this->loadedPlugin(id))
- {
- log->warn( QString("Already loaded plug-in %1.").arg(id));
+ if ( this->loadedPlugin ( id ) ) {
+ log->warn ( QString ( "Already loaded plug-in %1." ).arg ( id ) );
return true;
}
-
QPluginLoader* loader = d->obtainBinary ( id );
Plugin* plugin = 0;
- if ( !loader )
- {
+ if ( !loader ) {
log->debug ( QString ( "Couldn't find binary for plugin '%1'." ).arg ( id ) );
return false;
}
log->debug ( QString ( "Found binary for plugin '%1', loading symbols..." ).arg ( id ) );
plugin = qobject_cast<Plugin*> ( loader->instance() );
- if ( !plugin )
- {
- log->error ( QString( "Failed to load plugin; %1" ).arg( loader->errorString() ) );
+ if ( !plugin ) {
+ log->error ( QString ( "Failed to load plugin; %1" ).arg ( loader->errorString() ) );
return false;
}
d->active.insert ( id, plugin );
-
- log->info( QString( "Invoking start of %1..." ).arg( plugin->name() ) );
+ log->info ( QString ( "Invoking start of %1..." ).arg ( plugin->name() ) );
plugin->start();
emit plugin->started();
log->info ( QString ( "%1 is loaded." ).arg ( id ) );
@@ -115,8 +108,7 @@ Factory::unloadPlugin ( const QString& id )
{
Q_D ( Factory );
Plugin* plugin = d->plugin ( id );
- if ( !plugin->isLoaded() )
- {
+ if ( !plugin->isLoaded() ) {
return true;
}
plugin->stop();
@@ -130,27 +122,21 @@ bool
Factory::autoloadPlugins()
{
Logger* log = wlog ( this );
- QVariant autoload = Wintermute::Application::setting ( "Plugins/Autoload", QStringList());
+ QVariant autoload = Wintermute::Application::setting ( "Plugins/Autoload", QStringList() );
QStringList autoloadList = autoload.value<QStringList>();
QStringList all = this->availablePlugins();
log->info ( QString ( "Loading %1 of %2 plugins..." ).
arg ( autoloadList.length() ).arg ( all.length() ) );
-
- if (autoloadList.empty())
- {
- log->warn("No plug-ins were specified for auto-loading.");
+ if ( autoloadList.empty() ) {
+ log->warn ( "No plug-ins were specified for auto-loading." );
}
-
- Q_FOREACH ( QString plugin, autoloadList )
- {
- if (!all.contains(plugin))
- {
- log->info( QString("The plugin '%1' is not available.").arg(plugin) );
+ Q_FOREACH ( QString plugin, autoloadList ) {
+ if ( !all.contains ( plugin ) ) {
+ log->info ( QString ( "The plugin '%1' is not available." ).arg ( plugin ) );
}
bool pluginLoaded = this->loadPlugin ( plugin );
- if ( !pluginLoaded )
- {
- log->info ( QString ( "Autoload of %1 failed;").arg(plugin) +
+ if ( !pluginLoaded ) {
+ log->info ( QString ( "Autoload of %1 failed;" ).arg ( plugin ) +
" thus cancelling the auto-loading process." );
this->unloadAllPlugins();
return false;
View
2  src/Wintermute/factory.hpp
@@ -118,7 +118,7 @@ class Factory : public QObject
*/
bool unloadPlugin ( const QString& name );
- bool loadedPlugin( const QString& name );
+ bool loadedPlugin ( const QString& name );
/**
* @function autoloadPlugins
*
View
8 src/Wintermute/logging.cpp
@@ -28,7 +28,7 @@ using Log4Qt::Logger;
Logging* Logging::self = nullptr;
-Logging::Logging() :
+Logging::Logging() :
QObject ( Application::instance() ), d_ptr ( new LoggingPrivate )
{
}
@@ -45,8 +45,7 @@ Logger*
Logging::obtainLogger ( const QObject* object )
{
if ( object == 0 )
- return Logging::obtainLogger(wntrApp);
-
+ { return Logging::obtainLogger ( wntrApp ); }
return Logging::obtainLogger ( object->metaObject()->className() );
}
@@ -54,8 +53,7 @@ Logging*
Logging::instance()
{
if ( !self )
- self = new Logging();
-
+ { self = new Logging(); }
return self;
}
View
6 src/Wintermute/private/Procedure/call.hpp
@@ -38,12 +38,10 @@ class CallPrivate
explicit CallPrivate ( Call* q ) : q_ptr ( q ),
recipient(), name(), function ( nullptr ),
- type ( Call::TypeUndefined ), data()
- {
+ type ( Call::TypeUndefined ), data() {
}
- virtual ~CallPrivate()
- {
+ virtual ~CallPrivate() {
}
};
}
View
64 src/Wintermute/private/Procedure/dispatcher.hpp
@@ -30,59 +30,45 @@ class DispatcherPrivate
public:
static QList<Dispatcher*> dispatchers;
- static bool isDispatcherKnown(Dispatcher* dispatcher)
- {
- Q_FOREACH(Dispatcher * aDispatcher, DispatcherPrivate::dispatchers)
- {
- if (aDispatcher->metaObject()->className() == dispatcher->metaObject()->className())
- return true;
+ static bool isDispatcherKnown ( Dispatcher* dispatcher ) {
+ Q_FOREACH ( Dispatcher * aDispatcher, DispatcherPrivate::dispatchers ) {
+ if ( aDispatcher->metaObject()->className() == dispatcher->metaObject()->className() )
+ { return true; }
}
-
return false;
}
- static void dispatch(const QString& data)
- {
- if (dispatchers.empty())
- {
- wwarn(wntrApp, "Wintermute is running with no dispatchers.");
- }
- else
- {
- Q_FOREACH(Dispatcher * dispatchClient, dispatchers)
- {
- dispatchClient->sendMessage(Call::fromString(data));
- wdebug(dispatchClient, QString("Sent data to %1 for dispatching.")
- .arg(dispatchClient->metaObject()->className()));
+ static void dispatch ( const QString& data ) {
+ if ( dispatchers.empty() ) {
+ wwarn ( wntrApp, "Wintermute is running with no dispatchers." );
+ } else {
+ Q_FOREACH ( Dispatcher * dispatchClient, dispatchers ) {
+ dispatchClient->sendMessage ( Call::fromString ( data ) );
+ wdebug ( dispatchClient, QString ( "Sent data to %1 for dispatching." )
+ .arg ( dispatchClient->metaObject()->className() ) );
}
}
}
- static bool addDispatcher(Dispatcher* dispatcher)
- {
- if (!dispatcher)
- return false;
-
- if (isDispatcherKnown(dispatcher))
- {
- wdebug(dispatcher, "Already added into dispatcher index.");
+ static bool addDispatcher ( Dispatcher* dispatcher ) {
+ if ( !dispatcher )
+ { return false; }
+ if ( isDispatcherKnown ( dispatcher ) ) {
+ wdebug ( dispatcher, "Already added into dispatcher index." );
return false;
}
-
DispatcherPrivate::dispatchers << dispatcher;
- wdebug(dispatcher, QString("%1 added to dispatcher pool.").
- arg(dispatcher->metaObject()->className()));
+ wdebug ( dispatcher, QString ( "%1 added to dispatcher pool." ).
+ arg ( dispatcher->metaObject()->className() ) );
return true;
}
- static bool removeDispatcher(Dispatcher* dispatcher)
- {
- if (!isDispatcherKnown(dispatcher))
- return false;
-
- DispatcherPrivate::dispatchers.removeAll(dispatcher);
- wdebug(dispatcher, QString("%1 removed from dispatcher pool.").
- arg(dispatcher->metaObject()->className()));
+ static bool removeDispatcher ( Dispatcher* dispatcher ) {
+ if ( !isDispatcherKnown ( dispatcher ) )
+ { return false; }
+ DispatcherPrivate::dispatchers.removeAll ( dispatcher );
+ wdebug ( dispatcher, QString ( "%1 removed from dispatcher pool." ).
+ arg ( dispatcher->metaObject()->className() ) );
return true;
}
};
View
24 src/Wintermute/private/Procedure/module.hpp
@@ -42,31 +42,25 @@ class ModulePrivate
QMap<QString, CallPointer> calls;
ModulePrivate ( Module* q ) :
- q_ptr ( q ), package ( "" ), domain ( "" ), calls()
- {
+ q_ptr ( q ), package ( "" ), domain ( "" ), calls() {
winfo ( q_ptr, "Module setting up..." );
}
- void checkQualifiedName()
- {
- if (!domain.isEmpty() && !package.isEmpty())
- {
- if (!wntrApp->findModule(q_ptr->qualifiedName()))
- {
- (new MethodCall(WINTERMUTE_DOMAIN ".heartbeat",
- "greet", QVariantList()))->dispatch(q_ptr);
+ void checkQualifiedName() {
+ if ( !domain.isEmpty() && !package.isEmpty() ) {
+ if ( !wntrApp->findModule ( q_ptr->qualifiedName() ) ) {
+ ( new MethodCall ( WINTERMUTE_DOMAIN ".heartbeat",
+ "greet", QVariantList() ) )->dispatch ( q_ptr );
wntrApp->d_ptr->modules << q_ptr;
}
}
}
- void sendData ( const QString& data ) const
- {
- Dispatcher::postDispatch(Call::fromString(data));
+ void sendData ( const QString& data ) const {
+ Dispatcher::postDispatch ( Call::fromString ( data ) );
}
- virtual ~ModulePrivate ()
- {
+ virtual ~ModulePrivate () {
winfo ( q_ptr, "We out!" );
}
};
View
39 src/Wintermute/private/Procedure/receiver.hpp
@@ -31,40 +31,31 @@ class ReceiverPrivate
public:
static QList<Receiver*> receivers;
- static bool isReceiverKnown(Receiver* receiver)
- {
- Q_FOREACH(Receiver * aReceiver, ReceiverPrivate::receivers)
- {
- if (aReceiver->metaObject()->className() == receiver->metaObject()->className())
- return true;
+ static bool isReceiverKnown ( Receiver* receiver ) {
+ Q_FOREACH ( Receiver * aReceiver, ReceiverPrivate::receivers ) {
+ if ( aReceiver->metaObject()->className() == receiver->metaObject()->className() )
+ { return true; }
}
-
return false;
}
- static bool addReceiver(Receiver* receiver)
- {
- if (!receiver)
- return false;
-
- if (isReceiverKnown(receiver))
- {
- wdebug(receiver, "Already added into receiver index.");
+ static bool addReceiver ( Receiver* receiver ) {
+ if ( !receiver )
+ { return false; }
+ if ( isReceiverKnown ( receiver ) ) {
+ wdebug ( receiver, "Already added into receiver index." );
return false;
}
-
ReceiverPrivate::receivers << receiver;
- wdebug(receiver, QString("%1 added to receiver pool.").arg(receiver->metaObject()->className()));
+ wdebug ( receiver, QString ( "%1 added to receiver pool." ).arg ( receiver->metaObject()->className() ) );
return true;
}
- static bool removeReceiver(Receiver* receiver)
- {
- if (!isReceiverKnown(receiver))
- return false;
-
- ReceiverPrivate::receivers.removeAll(receiver);
- wdebug(receiver, QString("%1 removed from receiver pool.").arg(receiver->metaObject()->className()));
+ static bool removeReceiver ( Receiver* receiver ) {
+ if ( !isReceiverKnown ( receiver ) )
+ { return false; }
+ ReceiverPrivate::receivers.removeAll ( receiver );
+ wdebug ( receiver, QString