119 lines
3.8 KiB
C++
119 lines
3.8 KiB
C++
/*
|
|
CORE-SERVICE.hpp - service to address the application core from the UI
|
|
|
|
Copyright (C) Lumiera.org
|
|
2015, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation; either version 2 of
|
|
the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
/** @file core-service.hpp
|
|
** Dedicated service node within the UI-Bus to handle command invocation
|
|
** and presentation state. Mostly, the UI-Bus is just a star shaped network
|
|
** with one central [routing hub][ctrl::Nexus], and serves to distribute
|
|
** generic state and update messages. But there are some special messages
|
|
** which need central processing: The command preparation and invocation
|
|
** messages and the presentation state tracking messages (state marks).
|
|
** The Nexus is configured such as to forward these special messages
|
|
** to the [CoreService] terminal, which invokes the dedicated services.
|
|
**
|
|
** # Lifecycle
|
|
** CoreService is a PImpl to manage all the technical parts of actual
|
|
** service provision. When it goes down, all services are decommissioned.
|
|
** A part of these lifecycle technicalities is to manage the setup of the
|
|
** [UI-Bus main hub](\ref ctrl::Nexus), which requires some trickery, since
|
|
** both CoreService and Nexus are mutually interdependent from an operational
|
|
** perspective, since they exchange messages in both directions.
|
|
**
|
|
** @see AbstractTangible_test
|
|
** @see BusTerm_test
|
|
**
|
|
*/
|
|
|
|
|
|
#ifndef GUI_CTRL_CORE_SERVICE_H
|
|
#define GUI_CTRL_CORE_SERVICE_H
|
|
|
|
|
|
#include "lib/error.hpp"
|
|
#include "include/logging.h"
|
|
#include "lib/idi/entry-id.hpp"
|
|
#include "include/session-command-facade.h"
|
|
#include "gui/notification-service.hpp"
|
|
#include "gui/ctrl/command-handler.hpp"
|
|
#include "gui/ctrl/bus-term.hpp"
|
|
#include "gui/ctrl/nexus.hpp"
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
|
namespace gui {
|
|
namespace ctrl{
|
|
|
|
|
|
/**
|
|
* Attachment point to »central services« within the UI-Bus.
|
|
* This special implementation of the [BusTerm] interface receives and
|
|
* handles those messages to be processed by centralised services:
|
|
* - commands need to be sent down to Proc-Layer
|
|
* - presentation state messages need to be recorded and acted upon.
|
|
*/
|
|
class CoreService
|
|
: public BusTerm
|
|
, boost::noncopyable
|
|
{
|
|
|
|
Nexus uiBusBackbone_;
|
|
NotificationService activateNotificationService_;
|
|
|
|
virtual void
|
|
act (GenNode const& command) override
|
|
{
|
|
CommandHandler handler{command};
|
|
command.data.accept (handler);
|
|
}
|
|
|
|
|
|
virtual void
|
|
note (ID subject, GenNode const& mark) override
|
|
{
|
|
UNIMPLEMENTED ("receive and handle presentation state note messages.");
|
|
}
|
|
|
|
|
|
public:
|
|
explicit
|
|
CoreService (ID identity =lib::idi::EntryID<CoreService>())
|
|
: BusTerm(identity, uiBusBackbone_)
|
|
, uiBusBackbone_{*this}
|
|
, activateNotificationService_() // opens the GuiNotificationService instance
|
|
{
|
|
INFO (gui, "UI-Backbone operative.");
|
|
}
|
|
|
|
~CoreService()
|
|
{
|
|
if (0 < uiBusBackbone_.size())
|
|
ERROR (gui, "Some UI components are still connected to the backbone.");
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}} // namespace gui::ctrl
|
|
#endif /*GUI_CTRL_CORE_SERVICE_H*/
|