DI: adjust codebase to the new DependInject configuration API

This commit is contained in:
Fischlurch 2018-03-30 23:55:42 +02:00
parent 80207ea224
commit fe10ab92dc
31 changed files with 109 additions and 64 deletions

View file

@ -102,15 +102,17 @@ main (int, char**)
Depend<BlackHoleService> mystery;
cout << microbenchmark<1> ([&]()
thread_local int64_t cnt = 0;
cout << microbenchmark<8> ([&]()
{
0 == mystery().readMe();
cnt += mystery().readMe();
}
,5000000000)
,50000000)
<< endl;
LifecycleHook::trigger (ON_GLOBAL_SHUTDOWN);
// cout << "\n.gulp.\n";
cout << "\n.gulp.\n";
return 0;
}

View file

@ -69,7 +69,7 @@ namespace engine {
EngineConfig();
~EngineConfig();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<EngineConfig>;
public:
/** access point to the Engine Interface.

View file

@ -46,6 +46,8 @@
#include "common/query/defs-manager.hpp"
#include "common/query/defs-registry.hpp"
#include "common/config-rules.hpp"
#include "proc/mobject/session/query/fake-configrules.hpp"
#include "lib/depend-inject.hpp"
#include "lib/format-string.hpp"
#include "lib/error.hpp"
@ -66,7 +68,12 @@ namespace query {
DefsManager::DefsManager () throw()
: defsRegistry_(new DefsRegistry)
{
TODO ("setup basic technical defaults of the session?");
INFO (session, "Configure technical defaults of the session.");
// PLANNED: use an embedded Prolog-System or similar rules engine.
// For the time being, we use preconfigured fake answers for some common Config-Queries
lib::DependInject<ConfigResolver>::useSingleton<proc::mobject::session::query::MockConfigRules>();
}

View file

@ -85,6 +85,14 @@
** - for sake of completeness, we can also require a specific element to
** be purged from knowledge
**
** ## Fake implementation
** As of 2018, the Lumiera project still has to reach the goal of a complete
** running engine; we are proceeding with partial integrations for the time being.
** And we postpone advanced topics, like integration of an actual rules solver
** to future milestones. Meanwhile, we use a [fake implementation](\ref MockConfigRules)
** with preconfigured, hard-wired "answers" to some frequently encountered standard queries.
** This Fake implementation is configured and instantiated by the [Defaults Manager](\ref DefsManager)
**
** @see DefsManager_test
** @see DefsManagerImpl_test
**

View file

@ -30,7 +30,7 @@
** - and sends a "mark" message towards some UI demo widget
** - which in turn displays the mark text
**
** @todo WIP as of 8/20176 ////////////////////////////////////////////////////////////////////////TICKET #1099
** @todo WIP as of 8/2017 ////////////////////////////////////////////////////////////////////////TICKET #1099
**
** @see CallQueue_test
** @see notification-service.hpp
@ -84,7 +84,7 @@ namespace gui {
DemoGuiRoundtrip();
~DemoGuiRoundtrip();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<DemoGuiRoundtrip>;
public:
/** access point to set up the scaffolding.

View file

@ -81,7 +81,7 @@ namespace lumiera {
private:
Config();
~Config();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<Config>;
};

View file

@ -35,6 +35,7 @@
#include "lib/sync.hpp"
#include "lib/error.hpp"
#include "proc/asset.hpp"
#include "lib/depend-inject.hpp"
#include <memory>
#include <unordered_map>
@ -109,7 +110,7 @@ namespace asset {
clear();
}
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<DB>;
public:

View file

@ -100,7 +100,7 @@ namespace asset {
/** deregister and evict all known Assets.
* @note the actual object instances are managed by reference count,
* i.e. typically the Assets will be kept alive by MObjects from the sesison
* i.e. typically the Assets will be kept alive by MObjects from the session
* @warning unsure if this design is sane. Asset subsystem needs a rework ////////////////////////////TICKET #691
* @todo verify this actually works, especially with session shutdown ////////////////////////////TICKET #154
*/
@ -124,9 +124,9 @@ namespace asset {
friend Asset::Asset (Asset::Ident const& idi);
AssetManager ();
AssetManager();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<AssetManager>;
};

View file

@ -31,16 +31,17 @@
#include "lib/error.hpp"
#include "proc/config-resolver.hpp"
#include "proc/mobject/session/query/fake-configrules.hpp"
namespace proc {
using lib::buildSingleton;
/** Singleton factory instance, configured with the actual implementation type. */
lib::Depend<ConfigResolver> ConfigResolver::instance (buildSingleton<proc::mobject::session::query::MockConfigRules>());
/** Singleton factory instance, configured with the actual implementation type.
* @see DefsManager::DefsManager()
* @see defs-manager-impl.hpp
*/
lib::Depend<ConfigResolver> ConfigResolver::instance;
} // namespace proc

View file

@ -326,6 +326,9 @@ namespace control {
/* ======== ProcDispatcher implementation ======== */
ProcDispatcher::ProcDispatcher() { }
ProcDispatcher::~ProcDispatcher() { }
/** starting the ProcDispatcher means to start the session subsystem.
* @return `false` when _starting_ failed since it is already running...
* @remark this function implements the start operation for the »session subsystem«.

View file

@ -87,7 +87,6 @@ namespace control {
unique_ptr<DispatcherLoop> runningLoop_;
bool active_{false};
public:
static lib::Depend<ProcDispatcher> instance;
@ -104,6 +103,10 @@ namespace control {
private:
void endRunningLoopState();
~ProcDispatcher();
ProcDispatcher();
friend class lib::DependencyFactory<ProcDispatcher>;
};

View file

@ -86,11 +86,11 @@ namespace control {
STypeManager() ;
~STypeManager();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<STypeManager>;
/** Lifecycle: reset all type registration information
* to the <i>generic pristine default</i> state. This includes
* hard wired defaults and defauls provided by type plugins, but
* hard wired defaults and defaults provided by type plugins, but
* excludes everything added by the session
*/
void reset() ;

View file

@ -73,7 +73,7 @@ namespace engine {
DiagnosticBufferProvider();
~DiagnosticBufferProvider();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<DiagnosticBufferProvider>;
public:
/** build a new Diagnostic Buffer Provider instance,

View file

@ -71,7 +71,7 @@ namespace session {
DummySessionConnection();
~DummySessionConnection();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<DummySessionConnection>;
public:
/** access point to set up the scaffolding.

View file

@ -289,8 +289,8 @@ namespace session {
>
{
protected:
MockConfigRules (); ///< to be used only by the singleton factory
friend class lib::DependencyFactory;
MockConfigRules (); ///< to be used only by the singleton factory
friend class lib::DependencyFactory<MockConfigRules>;
virtual ~MockConfigRules() {}

View file

@ -99,7 +99,7 @@ namespace session {
protected:
ScopeLocator();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<ScopeLocator>;
private:
lumiera::QueryResolver const& theResolver();

View file

@ -66,7 +66,7 @@ namespace session {
unique_ptr<LifecycleAdvisor> lifecycle_;
SessManagerImpl() throw();
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<SessManagerImpl>;
~SessManagerImpl() ;

View file

@ -88,7 +88,7 @@ namespace play {
private:
OutputDirector() ;
~OutputDirector() ;
friend class lib::DependencyFactory;
friend class lib::DependencyFactory<OutputDirector>;
void bringDown (SigTerm completedSignal);

View file

@ -35,7 +35,7 @@
#include <string>
using lib::test::Depend4Test;
using lib::DependInject;
using lib::Literal;
using std::string;
@ -46,7 +46,6 @@ namespace test {
/****************************************************************************//**
* @test inject a Mock object replacing the backend_interface::MediaAccessFacade.
* Verify if the Mock object behaves as expected when calling the Facade.
@ -57,7 +56,7 @@ namespace test {
virtual void run(Arg)
{
Depend4Test<MediaAccessMock> within_this_scope;
DependInject<MediaAccessFacade>::Local<MediaAccessMock> useMockMedia;
queryScenario ("test-1");
queryScenario ("test-2");

View file

@ -26,6 +26,7 @@
** information from the data backend. The Mock implementation instead holds
** a map of fixed response which will be delivered when querying some magic
** filenames.
** @todo this facility was occasionally used until 2011, yet never really completed
**
** @see mediaaccessmocktest.cpp validating the Mock
** @see MediaAccessFactory the real thing
@ -83,7 +84,9 @@ namespace test {
private:
static int _i_;
ChanHandle genH()
ChanHandle
genH()
{
return reinterpret_cast<ChanHandle> (++_i_);
}
@ -111,7 +114,8 @@ namespace test {
// ----------------------------------------------------------------------TESTCASES
}
bool known (string key)
bool
known (string key)
{
const_iterator i = find (key);
return (i != end());
@ -130,7 +134,7 @@ namespace test {
{
if (isnil (name))
throw Invalid ("empty filename passed to MediaAccessFacade.");
if (!testCases().known(name))
throw Invalid ("unable to use media file \""+name+"\"."
"Hint: you're using a test-mock file access, "
@ -145,7 +149,7 @@ namespace test {
{
Response const& res (*reinterpret_cast<Response*> (&h));
if (res.channels.size() <= chanNo)
if (res.channels.size() <= chanNo)
return NULLResponse;
else
return res.channels[chanNo];

View file

@ -45,13 +45,11 @@ namespace test {
* Mock implementation of the MediaAccessFacade.
* Provides preconfigured responses for some Test-Filenames.
*/
class MediaAccessMock : public MediaAccessFacade
class MediaAccessMock
: public MediaAccessFacade
{
MediaDesc& queryFile (string const& name) const;
ChanDesc queryChannel (MediaDesc&, uint chanNo) const;
public:
typedef MediaAccessFacade ServiceInterface;
MediaDesc& queryFile (string const& name) const override;
ChanDesc queryChannel (MediaDesc&, uint chanNo) const override;
};

View file

@ -37,7 +37,6 @@
#include "backend/media-access-mock.hpp"
#include "lib/depend-inject.hpp"
using lib::test::Depend4Test;
using util::isnil;
using std::string;
@ -45,6 +44,9 @@ using std::string;
namespace proc {
namespace asset{
namespace test {
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
@ -57,7 +59,7 @@ namespace test {
{
virtual void run(Arg arg)
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
createMedia();
factoryVariants();

View file

@ -34,16 +34,17 @@
#include "proc/asset/clip.hpp"
#include "lib/util.hpp"
using lib::test::Depend4Test;
using util::contains;
using util::isnil;
namespace proc {
namespace asset{
namespace test {
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
@ -199,7 +200,7 @@ namespace test {
*/
void checkRealAssetDependencyRegistration ()
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
// -----Media and Clip--------------------------------
typedef lib::P<Media> PM;

View file

@ -37,7 +37,6 @@
#include "backend/media-access-mock.hpp"
#include "lib/depend-inject.hpp"
using lib::test::Depend4Test;
using util::isnil;
using std::string;
@ -46,6 +45,9 @@ namespace proc {
namespace asset{
namespace test {
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
@ -76,7 +78,7 @@ namespace test {
*/
void createDuplicate()
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
PM mm1 = asset::Media::create ("test-1.mov", VIDEO);

View file

@ -37,7 +37,6 @@
#include "backend/media-access-mock.hpp"
#include "lib/depend-inject.hpp"
using lib::test::Depend4Test;
using util::contains;
using util::isnil;
using std::string;
@ -48,6 +47,9 @@ namespace proc {
namespace asset{
namespace test {
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
@ -63,7 +65,7 @@ namespace test {
virtual void run (Arg)
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
PM mm = asset::Media::create("test-1", VIDEO);

View file

@ -36,7 +36,6 @@
#include "backend/media-access-mock.hpp"
#include "lib/depend-inject.hpp"
using lib::test::Depend4Test;
using util::isnil;
using std::string;
@ -45,6 +44,9 @@ namespace proc {
namespace asset{
namespace test {
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
@ -65,7 +67,7 @@ namespace test {
{
virtual void run(Arg)
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
Asset::Ident key1("test-1", Category(AUDIO), "ichthyo", 5);

View file

@ -50,8 +50,10 @@ namespace test {
using session::Clip;
using session::AbstractMO;
using lib::test::Depend4Test;
using namespace mobject::test;
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
@ -115,7 +117,7 @@ namespace test {
virtual void
run(Arg)
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
TestTool t1;

View file

@ -55,7 +55,6 @@ namespace test {
// using lib::test::showSizeof;
using lib::Symbol;
using lib::test::Depend4Test;
using lib::time::Duration;
using lib::time::FSecs;
using lib::time::Time;
@ -64,6 +63,9 @@ namespace test {
// using session::Clip;
// using session::PMedia;
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
using namespace mobject::test;
typedef TestPlacement<DummyMO> PDummy;
@ -85,7 +87,7 @@ namespace test {
virtual void
run (Arg)
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
PMO testClip1 = asset::Media::create("test-1", asset::VIDEO)->createClip();

View file

@ -44,7 +44,6 @@
#include "lib/util.hpp"
using lib::test::Depend4Test;
using lib::test::showSizeof;
using lib::time::Duration;
using lib::time::FSecs;
@ -84,6 +83,9 @@ namespace test {
using session::SessionServiceMockIndex;
using session::PPIdx;
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
/***********************************************************************//**
@ -107,7 +109,7 @@ namespace test {
virtual void
run (Arg)
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
// create data simulating a "Session"

View file

@ -39,7 +39,6 @@
using lib::HashIndexed;
using lib::test::Depend4Test;
namespace proc {
@ -52,6 +51,9 @@ namespace test {
using namespace mobject::test;
using lumiera::error::LUMIERA_ERROR_ASSERTION;
using MediaAccessMock = lib::DependInject<backend::MediaAccessFacade>
::Local<backend::test::MediaAccessMock>;
/***********************************************************************************//**
* @test creating placements specifically typed, forming an hierarchy of placement types
@ -65,9 +67,9 @@ namespace test {
{
virtual void
run (Arg)
run (Arg)
{
Depend4Test<backend::test::MediaAccessMock> within_this_scope;
MediaAccessMock useMockMedia;
typedef Placement<MObject> PMObj;

View file

@ -41,18 +41,20 @@ namespace test {
using lib::time::Time;
using lib::time::Duration;
typedef shared_ptr<asset::Media> PM;
typedef backend_interface::MediaAccessFacade MAF;
using backend::test::MediaAccessMock;
using asset::VIDEO;
using PM = shared_ptr<asset::Media>;
using MAF = backend_interface::MediaAccessFacade;
using MediaAccessMock = lib::DependInject<MAF>::Local<backend::test::MediaAccessMock>;
asset::Media &
createTestMedia ()
{
// install Mock-Interface to Lumiera backend
lib::test::Depend4Test<MediaAccessMock> withinThisScope;
MediaAccessMock useMockMedia;
return *asset::Media::create("test-2", VIDEO); // query magic filename
}