ConfigRules dependency problems solved by using the new SingletonSubclassFactory
This commit is contained in:
parent
e2ee8f081b
commit
edbf5fd733
4 changed files with 41 additions and 21 deletions
|
|
@ -40,9 +40,18 @@ namespace cinelerra
|
|||
ConfigRulesInterface<NullType>::~ConfigRulesInterface()
|
||||
{ };
|
||||
|
||||
|
||||
} // namespace query
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
/** type of the actual ConfigRules implementation to use */
|
||||
singleton::UseSubclass<query::MockConfigRules> typeinfo;
|
||||
}
|
||||
|
||||
|
||||
/** Singleton factory instance, parametrized to actual impl. type. */
|
||||
SingletonSub<ConfigRules> ConfigRules::instance (typeinfo);
|
||||
|
||||
|
||||
} // namespace cinelerra
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@
|
|||
#define CINELERRA_CONFIGRULES_H
|
||||
|
||||
#include "common/query.hpp"
|
||||
#include "common/singleton.hpp"
|
||||
#include "common/typelist.hpp"
|
||||
#include "common/singletonsubclass.hpp"
|
||||
|
||||
#include "proc/mobject/session/track.hpp"
|
||||
#include "proc/asset/procpatt.hpp"
|
||||
|
|
@ -65,7 +65,6 @@ namespace cinelerra
|
|||
using std::string;
|
||||
using std::tr1::shared_ptr;
|
||||
|
||||
namespace query { class MockConfigRules; } // TODO: need a better way to return a sub-type from a singleton
|
||||
|
||||
|
||||
|
||||
|
|
@ -163,26 +162,18 @@ namespace cinelerra
|
|||
{ };
|
||||
|
||||
|
||||
template
|
||||
< typename TYPES,
|
||||
class IMPL
|
||||
>
|
||||
template<typename TYPES>
|
||||
class ConfigRules
|
||||
: public ConfigRulesInterface<typename TYPES::List>
|
||||
{
|
||||
protected:
|
||||
ConfigRules () {}
|
||||
virtual ~ConfigRules() {}
|
||||
|
||||
public:
|
||||
static cinelerra::Singleton<IMPL> instance;
|
||||
|
||||
public:
|
||||
// TODO: find out what operations we need to support here for the »real solution« (using Prolog)
|
||||
};
|
||||
|
||||
/** storage for the Singleton instance factory */
|
||||
template<typename TYPES, class IMPL>
|
||||
cinelerra::Singleton<IMPL> ConfigRules<TYPES,IMPL>::instance;
|
||||
|
||||
|
||||
|
||||
|
|
@ -206,10 +197,18 @@ namespace cinelerra
|
|||
>
|
||||
InterfaceTypes;
|
||||
|
||||
typedef query::ConfigRules< InterfaceTypes, // List of Types to generate interface functions
|
||||
query::MockConfigRules // actual Implementation to use
|
||||
>
|
||||
ConfigRules; // user-visible Interface to the ConfigRules subsystem.
|
||||
/**
|
||||
* user-visible Interface to the ConfigRules subsystem.
|
||||
* Configured as Singleton (with hidden Implementation class)
|
||||
*/
|
||||
class ConfigRules
|
||||
: public query::ConfigRules<InterfaceTypes>
|
||||
{
|
||||
|
||||
public:
|
||||
static SingletonSub<ConfigRules> instance;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace cinelerra
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ namespace cinelerra
|
|||
* needs to know the actual class, because it allocates storage)
|
||||
*/
|
||||
template<class SU>
|
||||
SingletonSubclassFactory (singleton::UseSubclass<SU>)
|
||||
SingletonSubclassFactory (singleton::UseSubclass<SU>&)
|
||||
{
|
||||
typedef typename singleton::Adapter<Create,SI> Adapter;
|
||||
typedef typename Adapter::template TypedLink<SU> TypedLink;
|
||||
|
|
@ -154,7 +154,18 @@ namespace cinelerra
|
|||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default Singleton configuration (subclass creating factory)
|
||||
* @note all Policy template parameters taking default values
|
||||
*/
|
||||
template <class SI>
|
||||
struct SingletonSub
|
||||
: public SingletonSubclassFactory<SI>
|
||||
{
|
||||
template<typename TY>
|
||||
SingletonSub (TY ref) : SingletonSubclassFactory<SI>(ref) {}
|
||||
};
|
||||
|
||||
|
||||
} // namespace cinelerra
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
#include "proc/asset/procpatt.hpp"
|
||||
#include "proc/asset/port.hpp"
|
||||
#include "common/configrules.hpp"
|
||||
#include "common/query/mockconfigrules.hpp" // TODO: better way to handle the includes (rework singleton template?)
|
||||
#include "common/error.hpp"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
|
@ -38,6 +37,7 @@ using asset::ProcPatt;
|
|||
using asset::PProcPatt;
|
||||
|
||||
using cinelerra::ConfigRules;
|
||||
using cinelerra::query::QueryHandler;
|
||||
using cinelerra::query::CINELERRA_ERROR_CAPABILITY_QUERY;
|
||||
|
||||
namespace mobject
|
||||
|
|
@ -56,7 +56,8 @@ namespace mobject
|
|||
shared_ptr<TAR>
|
||||
DefsManager::operator() (const Query<TAR>& capabilities)
|
||||
{
|
||||
shared_ptr<TAR> res = cinelerra::ConfigRules::instance().resolve (capabilities);
|
||||
QueryHandler<TAR>& typeHandler = ConfigRules::instance();
|
||||
shared_ptr<TAR> res = typeHandler.resolve (capabilities);
|
||||
|
||||
if (!res)
|
||||
throw cinelerra::error::Config ( str(format("The following Query could not be resolved: %s.")
|
||||
|
|
|
|||
Loading…
Reference in a new issue