Skip to content
Browse files

A bit of formatting.

  • Loading branch information...
1 parent 4efa70d commit a1fd9b6eb337ae0c0a6fd83c18e394cd721f4527 @jalcine committed
Showing with 594 additions and 690 deletions.
  1. +1 −1 .astylerc
  2. +1 −1 lib/daemon/plugin.cpp
  3. +7 −6 lib/dbus/dispatcher.cpp
  4. +14 −11 lib/dbus/dispatcher.hpp
  5. +1 −1 lib/dbus/module.cpp
  6. +7 −5 lib/heartbeat/calls/greet.hpp
  7. +2 −3 lib/heartbeat/module.cpp
  8. +2 −2 lib/heartbeat/plugin.cpp
  9. +12 −12 lib/zeromq/dispatcher.cpp
  10. +16 −13 lib/zeromq/dispatcher.hpp
  11. +5 −5 lib/zeromq/module.cpp
  12. +1 −1 lib/zeromq/plugin.cpp
  13. +12 −12 lib/zeromq/receiver.cpp
  14. +17 −14 lib/zeromq/receiver.hpp
  15. +16 −19 src/Wintermute/Events/Filters/call.cpp
  16. +2 −2 src/Wintermute/Events/Filters/call.hpp
  17. +2 −4 src/Wintermute/Events/call.cpp
  18. +1 −1 src/Wintermute/Events/call.hpp
  19. +15 −19 src/Wintermute/Procedure/call.cpp
  20. +117 −117 src/Wintermute/Procedure/call.hpp
  21. +7 −7 src/Wintermute/Procedure/dispatcher.cpp
  22. +16 −16 src/Wintermute/Procedure/dispatcher.hpp
  23. +8 −9 src/Wintermute/Procedure/dummy_dispatcher.cpp
  24. +1 −1 src/Wintermute/Procedure/dummy_dispatcher.hpp
  25. +4 −5 src/Wintermute/Procedure/dummy_receiver.cpp
  26. +13 −10 src/Wintermute/Procedure/dummy_receiver.hpp
  27. +5 −5 src/Wintermute/Procedure/method_call.cpp
  28. +2 −2 src/Wintermute/Procedure/method_call.hpp
  29. +2 −3 src/Wintermute/Procedure/module.cpp
  30. +5 −5 src/Wintermute/Procedure/module.hpp
  31. +2 −2 src/Wintermute/Procedure/process_module.cpp
  32. +12 −15 src/Wintermute/Procedure/receiver.cpp
  33. +1 −1 src/Wintermute/Procedure/receiver.hpp
  34. +11 −17 src/Wintermute/application.cpp
  35. +136 −137 src/Wintermute/application.hpp
  36. +20 −34 src/Wintermute/factory.cpp
  37. +1 −1 src/Wintermute/factory.hpp
  38. +3 −5 src/Wintermute/logging.cpp
  39. +2 −4 src/Wintermute/private/Procedure/call.hpp
  40. +25 −39 src/Wintermute/private/Procedure/dispatcher.hpp
  41. +9 −15 src/Wintermute/private/Procedure/module.hpp
  42. +15 −24 src/Wintermute/private/Procedure/receiver.hpp
  43. +17 −33 src/Wintermute/private/application.hpp
  44. +17 −34 src/Wintermute/private/factory.hpp
  45. +3 −6 src/Wintermute/private/logging.hpp
  46. +4 −8 src/Wintermute/private/plugin.hpp
  47. +0 −1 src/main.cpp
  48. +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 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
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
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
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
10 lib/zeromq/module.cpp
@@ -35,14 +35,14 @@ 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)
+ m_context ( new QtZeroMQ::PollingContext ( this ) ), m_dispatcher ( 0 ), m_receiver ( 0 )
{
setDomain ( WINTERMUTE_DOMAIN );
setPackage ( "zeromq" );
- 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()));
+ 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
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(""));
- 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 ( "%1 removed from receiver pool." ).arg ( receiver->metaObject()->className() ) );
return true;
}
};
View
50 src/Wintermute/private/application.hpp
@@ -43,74 +43,58 @@ class ApplicationPrivate
Wintermute::Application* q_ptr;
ApplicationPrivate ( int& argc, char** argv, Wintermute::Application* q ) :
- app(), module(), modules(), settings ( 0 ), q_ptr( q )
- {
+ app(), module(), modules(), settings ( 0 ), q_ptr ( q ) {
app = QSharedPointer<QCoreApplication> ( new QCoreApplication ( argc, argv ) );
module.clear();
modules.clear();
-
this->installEventFilters();
}
- void installEventFilters()
- {
+ void installEventFilters() {
Events::Filters::CallFilter* callFilter = new Events::Filters::CallFilter();
- callFilter->setParent(q_ptr);
-
- app->installEventFilter(callFilter);
+ callFilter->setParent ( q_ptr );
+ app->installEventFilter ( callFilter );
}
- void addLibraryPaths()
- {
+ void addLibraryPaths() {
app->addLibraryPath ( WINTERMUTE_PLUGIN_LIBRARY_DIR );
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
-
- if (env.contains("WINTERMUTE_PLUGIN_LIBRARY_DIR"))
- {
- QStringList envLibDirs = env.value("WINTERMUTE_PLUGIN_LIBRARY_DIR").split(":", QString::SkipEmptyParts);
- Q_FOREACH(const QString libDir, envLibDirs)
- {
+ if ( env.contains ( "WINTERMUTE_PLUGIN_LIBRARY_DIR" ) ) {
+ QStringList envLibDirs = env.value ( "WINTERMUTE_PLUGIN_LIBRARY_DIR" ).split ( ":", QString::SkipEmptyParts );
+ Q_FOREACH ( const QString libDir, envLibDirs ) {
app->addLibraryPath ( libDir );
}
}
}
- void initialize()
- {
+ void initialize() {
this->addLibraryPaths();
Logging::instance();
Arguments::instance();
Factory::instance();
}
- int exec()
- {
+ int exec() {
return app->exec();
}
- void loadProcessModule()
- {
+ void loadProcessModule() {
Procedure::DummyDispatcher* dummyDsptcher = new Procedure::DummyDispatcher;
Procedure::DummyReceiver* dummyRcvr = new Procedure::DummyReceiver;
- dummyDsptcher->setParent(app.data());
- dummyRcvr->setParent(app.data());
+ dummyDsptcher->setParent ( app.data() );
+ dummyRcvr->setParent ( app.data() );
module = QSharedPointer<Procedure::ProcessModule> ( new Procedure::ProcessModule );
}
- void loadCurrentMode()
- {
+ void loadCurrentMode() {
const QString mode = Arguments::instance()->argument ( "mode" ).toString();
- if ( mode == "daemon" || mode == "d" )
- {
+ if ( mode == "daemon" || mode == "d" ) {
bool daemonLoaded = Factory::instance()->loadPlugin ( "wintermute-daemon" );
- if ( !daemonLoaded )
- {
+ if ( !daemonLoaded ) {
werr ( Application::instance(), "Can't load daemon plugin; bailing out!" );
Application::instance()->stop ( 127 );
}
- }
- else if ( mode == "plugin" || mode == "p" )
- {
+ } else if ( mode == "plugin" || mode == "p" ) {
wdebug ( Application::instance(), "Booting plugin..." );
const QString pluginName ( Arguments::instance()->argument ( "plugin" ).toString() );
Factory::instance()->loadPlugin ( pluginName );
View
51 src/Wintermute/private/factory.hpp
@@ -45,14 +45,12 @@ class FactoryPrivate
*
* TODO: Incorporate a means of collecting a remote list of plug-ins?
*/
- QStringList availablePlugins() const
- {
+ QStringList availablePlugins() const {
// Grab a list of plug-ins in the definition folder.
QDir pluginDefDir ( WINTERMUTE_PLUGIN_DEFINITION_DIR );
QStringList files = pluginDefDir.entryList ( QStringList() << "*.spec", QDir::Files );
QStringList plugins;
- Q_FOREACH ( QString pluginFile, files )
- {
+ Q_FOREACH ( QString pluginFile, files ) {
QString name = pluginFile.remove ( ".spec" );
wdebug ( wntrFactory, QString ( "Found plugin file '%1'." ).arg ( name ) );
plugins << name;
@@ -60,25 +58,20 @@ class FactoryPrivate
return plugins;
}
- QStringList activePlugins() const
- {
+ QStringList activePlugins() const {
return active.keys();
}
- Plugin* plugin ( const QString& name ) const
- {
- if ( active.contains ( name ) )
- {
+ Plugin* plugin ( const QString& name ) const {
+ if ( active.contains ( name ) ) {
return active[name];
}
return 0;
}
- QSettings* obtainConfiguration ( const QString& name ) const
- {
+ QSettings* obtainConfiguration ( const QString& name ) const {
const QString settingsPath = QString ( WINTERMUTE_PLUGIN_DEFINITION_DIR "/" + name + ".spec" );
- if ( QFile::exists ( settingsPath ) )
- {
+ if ( QFile::exists ( settingsPath ) ) {
QSettings* settings = new QSettings ( settingsPath, QSettings::IniFormat, Factory::instance() );
winfo ( Factory::instance(), QString ( "Found configuraton for plug-in '%1' at '%2'." ).arg ( name ).arg ( settingsPath ) );
return settings;
@@ -88,41 +81,31 @@ class FactoryPrivate
}
QPluginLoader*
- obtainBinary ( const QString& name ) const
- {
+ obtainBinary ( const QString& name ) const {
QString path;
QPluginLoader* loader = nullptr;
const QString libraryName = "lib" + name + ".so";
-
- if ( QLibrary::isLibrary ( libraryName ) )
- {
+ if ( QLibrary::isLibrary ( libraryName ) ) {
wwarn ( Factory::instance(),
QString ( "Library not found on operating system: '%1'" ).arg ( libraryName ) );
-
- Q_FOREACH ( QString libraryPath, QCoreApplication::libraryPaths() )
- {
+ Q_FOREACH ( QString libraryPath, QCoreApplication::libraryPaths() ) {
path = libraryPath + "/" + libraryName;
wdebug ( Factory::instance(), QString ( "Trying library path '%1'..." ).arg ( path ) );
-
if ( QLibrary::isLibrary ( path ) )
- break;
+ { break; }
else
- path = QString::null;
+ { path = QString::null; }
}
-
if ( path == QString::null )