refactor to use the customized lumiera::P<Type> instead of shared_ptr<Type>
This commit is contained in:
parent
3e8996005e
commit
aea5ed323a
28 changed files with 128 additions and 103 deletions
|
|
@ -46,6 +46,7 @@
|
|||
#ifndef LUMIERA_CONFIGRULES_H
|
||||
#define LUMIERA_CONFIGRULES_H
|
||||
|
||||
#include "common/p.hpp"
|
||||
#include "common/query.hpp"
|
||||
#include "common/typelistutil.hpp"
|
||||
#include "common/singletonsubclass.hpp"
|
||||
|
|
@ -57,14 +58,13 @@
|
|||
#include "proc/asset/track.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <tr1/memory>
|
||||
|
||||
|
||||
|
||||
namespace lumiera
|
||||
{
|
||||
using std::string;
|
||||
using std::tr1::shared_ptr;
|
||||
using lumiera::P;
|
||||
|
||||
|
||||
|
||||
|
|
@ -148,13 +148,13 @@ namespace lumiera
|
|||
* @query any goals to be fulfilled by the solution.
|
||||
* @return false if resolution failed. In this case, solution ptr is empty.
|
||||
*/
|
||||
virtual bool resolve (shared_ptr<TY>& solution, const Query<TY>& q) = 0;
|
||||
virtual bool resolve (P<TY>& solution, const Query<TY>& q) = 0;
|
||||
};
|
||||
|
||||
// TODO: the Idea is to provide specialisations for the concrete types
|
||||
// we want to participate in the ConfigRules system....
|
||||
// Thus we get the possibility to create a specific return type,
|
||||
// e.g. return a shared_ptr<Pipe> but a Placement<Track>, using the appropriate factory.
|
||||
// e.g. return a P<Pipe> but a Placement<Track>, using the appropriate factory.
|
||||
// Of course then the definitions need to be split up in separate headers.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace lumiera
|
|||
|
||||
/** a traits-class to define the smart-ptr to wrap the result */
|
||||
template<class TY>
|
||||
struct WrapReturn { typedef shared_ptr<TY> Wrapper; };
|
||||
struct WrapReturn { typedef P<TY> Wrapper; };
|
||||
|
||||
template<>
|
||||
struct WrapReturn<ProcPatt> { typedef PProcPatt Wrapper; };
|
||||
|
|
|
|||
|
|
@ -41,12 +41,13 @@ using std::string;
|
|||
|
||||
namespace asset
|
||||
{
|
||||
using lumiera::P;
|
||||
|
||||
class Proc;
|
||||
class ProcPatt;
|
||||
|
||||
typedef shared_ptr<const asset::Proc> PProc;
|
||||
typedef shared_ptr<const asset::ProcPatt> PProcPatt;
|
||||
typedef P<const asset::Proc> PProc;
|
||||
typedef P<const asset::ProcPatt> PProcPatt;
|
||||
|
||||
|
||||
static Symbol CURRENT = "current";
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace asset
|
|||
|
||||
};
|
||||
|
||||
typedef shared_ptr<const asset::Clip> PClipAsset;
|
||||
typedef P<const asset::Clip> PClipAsset;
|
||||
|
||||
const string CLIP_SUBFOLDER = "clips"; // TODO: handling of hard-wired constants....
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace asset
|
|||
bool del (ID<Asset> hash) { return table.erase (hash); }
|
||||
|
||||
template<class KIND>
|
||||
shared_ptr<KIND>
|
||||
P<KIND>
|
||||
get (ID<KIND> hash) const
|
||||
{
|
||||
return dynamic_pointer_cast<KIND,Asset> (find (hash));
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ namespace asset
|
|||
* @throw Invalid if the given media asset is not top-level,
|
||||
* but rather part or a multichannel (compound) media
|
||||
*/
|
||||
shared_ptr<asset::Clip>
|
||||
P<asset::Clip>
|
||||
MediaFactory::operator() (asset::Media& mediaref) throw(lumiera::error::Invalid)
|
||||
{
|
||||
if (mediaref.checkCompound())
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ namespace asset
|
|||
class MediaFactory;
|
||||
class ProcPatt;
|
||||
|
||||
using lumiera::P;
|
||||
using lumiera::Time;
|
||||
|
||||
|
||||
|
|
@ -74,9 +75,9 @@ namespace asset
|
|||
const Time len_;
|
||||
|
||||
public:
|
||||
typedef shared_ptr<Media> PMedia;
|
||||
typedef shared_ptr<asset::Clip> PClip;
|
||||
typedef shared_ptr<asset::ProcPatt> PProcPatt;
|
||||
typedef P<Media> PMedia;
|
||||
typedef P<asset::Clip> PClip;
|
||||
typedef P<asset::ProcPatt> PProcPatt;
|
||||
typedef mobject::session::PClipMO PClipMO;
|
||||
|
||||
|
||||
|
|
@ -142,7 +143,7 @@ namespace asset
|
|||
class MediaFactory : public lumiera::Factory<asset::Media>
|
||||
{
|
||||
public:
|
||||
typedef shared_ptr<asset::Media> PType;
|
||||
typedef P<asset::Media> PType;
|
||||
|
||||
PType operator() (Asset::Ident& key, const string& file="");
|
||||
PType operator() (const string& file, const Category& cat);
|
||||
|
|
@ -152,7 +153,7 @@ namespace asset
|
|||
PType operator() (const char* file, const Category& cat);
|
||||
PType operator() (const char* file, asset::Kind);
|
||||
|
||||
shared_ptr<asset::Clip>
|
||||
P<asset::Clip>
|
||||
operator() (asset::Media& mediaref) throw(lumiera::error::Invalid);
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ namespace asset
|
|||
class MetaFactory : public lumiera::Factory<asset::Meta>
|
||||
{
|
||||
public:
|
||||
typedef shared_ptr<asset::Meta> PType;
|
||||
typedef P<asset::Meta> PType;
|
||||
|
||||
PType operator() (Asset::Ident& key); ////////////TODO define actual operation
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,10 @@
|
|||
|
||||
namespace asset
|
||||
{
|
||||
using lumiera::P;
|
||||
|
||||
class Pipe;
|
||||
typedef shared_ptr<Pipe> PPipe;
|
||||
typedef P<Pipe> PPipe;
|
||||
|
||||
|
||||
template<>
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace asset
|
|||
class Proc;
|
||||
class ProcFactory;
|
||||
|
||||
typedef shared_ptr<const Proc> PProc;
|
||||
typedef P<const Proc> PProc;
|
||||
|
||||
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ namespace asset
|
|||
class ProcFactory : public lumiera::Factory<asset::Proc>
|
||||
{
|
||||
public:
|
||||
typedef shared_ptr<asset::Proc> PType;
|
||||
typedef P<asset::Proc> PType;
|
||||
|
||||
PType operator() (Asset::Ident& key); ////////////TODO define actual operation
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace asset
|
|||
* some ProcPatt as a template for creating more
|
||||
* spezialized patterns.
|
||||
*/
|
||||
shared_ptr<ProcPatt>
|
||||
P<ProcPatt>
|
||||
ProcPatt::newCopy (string newID) const
|
||||
{
|
||||
TODO ("implement the Pattern-ID within the propDescriptor!");
|
||||
|
|
|
|||
|
|
@ -35,13 +35,14 @@ using std::vector;
|
|||
|
||||
namespace asset
|
||||
{
|
||||
using lumiera::P;
|
||||
using lumiera::Symbol;
|
||||
|
||||
class Proc;
|
||||
class ProcPatt;
|
||||
class BuildInstruct;
|
||||
typedef shared_ptr<const asset::Proc> PProc;
|
||||
typedef shared_ptr<const asset::ProcPatt> PProcPatt;
|
||||
typedef P<const asset::Proc> PProc;
|
||||
typedef P<const asset::ProcPatt> PProcPatt;
|
||||
|
||||
typedef vector<BuildInstruct> InstructionSequence;
|
||||
|
||||
|
|
@ -61,14 +62,13 @@ namespace asset
|
|||
friend class StructFactoryImpl;
|
||||
|
||||
public:
|
||||
shared_ptr<ProcPatt> newCopy (string newID) const;
|
||||
P<ProcPatt> newCopy (string newID) const;
|
||||
|
||||
ProcPatt& attach (Symbol where, PProc& node);
|
||||
ProcPatt& operator+= (PProcPatt& toReuse);
|
||||
|
||||
};
|
||||
|
||||
typedef shared_ptr<const asset::ProcPatt> PProcPatt;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -89,10 +89,10 @@ namespace asset
|
|||
* created as a side effect of calling the concrete Struct subclass ctor.
|
||||
*/
|
||||
template<class STRU>
|
||||
shared_ptr<STRU>
|
||||
P<STRU>
|
||||
StructFactory::operator() (const Query<STRU>& capabilities)
|
||||
{
|
||||
shared_ptr<STRU> res;
|
||||
P<STRU> res;
|
||||
QueryHandler<STRU>& typeHandler = ConfigRules::instance();
|
||||
typeHandler.resolve (res, capabilities);
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ namespace asset
|
|||
* @see ProcPatt
|
||||
* @see DefaultsManager
|
||||
*/
|
||||
shared_ptr<Pipe>
|
||||
P<Pipe>
|
||||
StructFactory::operator() (string pipeID, string streamID)
|
||||
{
|
||||
normalizeID (pipeID);
|
||||
|
|
@ -147,9 +147,9 @@ namespace asset
|
|||
namespace asset
|
||||
{
|
||||
|
||||
template shared_ptr<Pipe> StructFactory::operator() (const Query<Pipe>& query);
|
||||
template shared_ptr<Track> StructFactory::operator() (const Query<Track>& query);
|
||||
template PProcPatt StructFactory::operator() (const Query<const ProcPatt>& query);
|
||||
template P<Pipe> StructFactory::operator() (const Query<Pipe>& query);
|
||||
template P<Track> StructFactory::operator() (const Query<Track>& query);
|
||||
template PProcPatt StructFactory::operator() (const Query<const ProcPatt>& query);
|
||||
|
||||
|
||||
} // namespace asset
|
||||
|
|
|
|||
|
|
@ -120,12 +120,12 @@ namespace asset
|
|||
|
||||
|
||||
public:
|
||||
typedef shared_ptr<asset::Struct> PType;
|
||||
typedef P<asset::Struct> PType;
|
||||
|
||||
template<class STRU>
|
||||
shared_ptr<STRU> operator() (const Query<STRU>& query); ////////////TODO actually do something sensible here
|
||||
P<STRU> operator() (const Query<STRU>& query); ////////////TODO actually do something sensible here
|
||||
|
||||
shared_ptr<Pipe> operator() (string pipeID, string streamID);
|
||||
P<Pipe> operator() (string pipeID, string streamID);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace asset
|
|||
};
|
||||
|
||||
|
||||
typedef shared_ptr<const Track> PTrack;
|
||||
typedef P<const Track> PTrack;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -130,11 +130,11 @@ namespace asset
|
|||
* of the stored object differs and can't be casted.
|
||||
*/
|
||||
template<class KIND>
|
||||
shared_ptr<KIND>
|
||||
P<KIND>
|
||||
AssetManager::getAsset (const ID<KIND>& id)
|
||||
throw(lumiera::error::Invalid)
|
||||
{
|
||||
if (shared_ptr<KIND> obj = registry.get (id))
|
||||
if (P<KIND> obj = registry.get (id))
|
||||
return obj;
|
||||
else
|
||||
if (known (id)) // provide Ident tuple of existing Asset
|
||||
|
|
@ -143,14 +143,14 @@ namespace asset
|
|||
throw UnknownID (id);
|
||||
}
|
||||
|
||||
/** convienience shortcut for fetching the registered shared_ptr
|
||||
/** convienience shortcut for fetching the registered smart-ptr
|
||||
* which is in charge of the given asset instance. By querying
|
||||
* directly asset.id (of type ID<Asset>), the call to registry.get()
|
||||
* can bypass the dynamic cast, because the type of the asset
|
||||
* is explicitely given by type KIND.
|
||||
*/
|
||||
template<class KIND>
|
||||
shared_ptr<KIND>
|
||||
P<KIND>
|
||||
AssetManager::wrap (const KIND& asset)
|
||||
{
|
||||
ENSURE (instance().known(asset.id),
|
||||
|
|
@ -169,7 +169,7 @@ namespace asset
|
|||
{
|
||||
return ( registry.get (ID<Asset>(id)) );
|
||||
} // query most general Asset ID-kind and use implicit
|
||||
// conversion from shared_ptr to bool (test if empty)
|
||||
// conversion from smart-ptr to bool (test if empty)
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -245,18 +245,18 @@ namespace asset
|
|||
template ID<Asset> AssetManager::reg (Asset* obj, const Asset::Ident& idi);
|
||||
|
||||
|
||||
template shared_ptr<Asset> AssetManager::getAsset (const ID<Asset>& id) throw(lumiera::error::Invalid);
|
||||
template shared_ptr<Media> AssetManager::getAsset (const ID<Media>& id) throw(lumiera::error::Invalid);
|
||||
template shared_ptr<Proc> AssetManager::getAsset (const ID<Proc>& id) throw(lumiera::error::Invalid);
|
||||
template shared_ptr<Struct> AssetManager::getAsset (const ID<Struct>& id) throw(lumiera::error::Invalid);
|
||||
template shared_ptr<Meta> AssetManager::getAsset (const ID<Meta>& id) throw(lumiera::error::Invalid);
|
||||
template P<Asset> AssetManager::getAsset (const ID<Asset>& id) throw(lumiera::error::Invalid);
|
||||
template P<Media> AssetManager::getAsset (const ID<Media>& id) throw(lumiera::error::Invalid);
|
||||
template P<Proc> AssetManager::getAsset (const ID<Proc>& id) throw(lumiera::error::Invalid);
|
||||
template P<Struct> AssetManager::getAsset (const ID<Struct>& id) throw(lumiera::error::Invalid);
|
||||
template P<Meta> AssetManager::getAsset (const ID<Meta>& id) throw(lumiera::error::Invalid);
|
||||
|
||||
template shared_ptr<Asset> AssetManager::wrap (const Asset& asset);
|
||||
template shared_ptr<Media> AssetManager::wrap (const Media& asset);
|
||||
template shared_ptr<Clip> AssetManager::wrap (const Clip& asset);
|
||||
template shared_ptr<Track> AssetManager::wrap (const Track& asset);
|
||||
template shared_ptr<Pipe> AssetManager::wrap (const Pipe& asset);
|
||||
template shared_ptr<ProcPatt> AssetManager::wrap (const ProcPatt& asset);
|
||||
template P<Asset> AssetManager::wrap (const Asset& asset);
|
||||
template P<Media> AssetManager::wrap (const Media& asset);
|
||||
template P<Clip> AssetManager::wrap (const Clip& asset);
|
||||
template P<Track> AssetManager::wrap (const Track& asset);
|
||||
template P<Pipe> AssetManager::wrap (const Pipe& asset);
|
||||
template P<ProcPatt> AssetManager::wrap (const ProcPatt& asset);
|
||||
|
||||
|
||||
} // namespace asset
|
||||
|
|
|
|||
|
|
@ -73,13 +73,13 @@ namespace asset
|
|||
/** provide the unique ID for given Asset::Ident tuple */
|
||||
static ID<Asset> getID (const Asset::Ident&);
|
||||
|
||||
/** retrieve the registerd shared_ptr for any asset */
|
||||
/** retrieve the registerd smart-ptr for any asset */
|
||||
template<class KIND>
|
||||
static shared_ptr<KIND> wrap (const KIND& asset);
|
||||
static P<KIND> wrap (const KIND& asset);
|
||||
|
||||
/** find and return corresponging object */
|
||||
template<class KIND>
|
||||
shared_ptr<KIND> getAsset (const ID<KIND>& id) throw(lumiera::error::Invalid);
|
||||
P<KIND> getAsset (const ID<KIND>& id) throw(lumiera::error::Invalid);
|
||||
|
||||
|
||||
/** @return true if the given id is registered in the internal asset DB */
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
/* common types frequently used... */
|
||||
|
||||
#include "common/p.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "common/time.hpp"
|
||||
#include "common/error.hpp" ///< pulls in NoBug via nobugcfg.hpp
|
||||
|
|
|
|||
|
|
@ -26,17 +26,18 @@
|
|||
|
||||
#include "pre.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <tr1/memory>
|
||||
|
||||
#include "proc/lumiera.hpp"
|
||||
#include "proc/mobject/builder/buildertool.hpp"
|
||||
#include "proc/mobject/placement.hpp"
|
||||
#include "proc/asset.hpp" // TODO finally not needed?
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
#include <list>
|
||||
|
||||
|
||||
using std::list;
|
||||
using std::tr1::shared_ptr;
|
||||
|
||||
#include "proc/assetmanager.hpp"
|
||||
using proc_interface::IDA; // TODO finally not needed?
|
||||
|
|
@ -45,6 +46,7 @@ using proc_interface::AssetManager;
|
|||
|
||||
namespace mobject
|
||||
{
|
||||
using lumiera::P;
|
||||
|
||||
namespace session
|
||||
{
|
||||
|
|
@ -58,7 +60,10 @@ namespace mobject
|
|||
* manipulated and finally rendered within Lumiera's EDL
|
||||
* are MObjects.
|
||||
*/
|
||||
class MObject : public Buildable
|
||||
class MObject
|
||||
: public Buildable,
|
||||
boost::noncopyable,
|
||||
boost::equality_comparable< MObject >
|
||||
{
|
||||
protected:
|
||||
typedef lumiera::Time Time;
|
||||
|
|
@ -79,6 +84,8 @@ namespace mobject
|
|||
virtual bool isValid() const =0;
|
||||
|
||||
virtual Time& getLength() =0; ///< @todo how to deal with the time/length field??
|
||||
|
||||
virtual bool operator== (const MObject& oo) const =0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,14 @@ namespace mobject
|
|||
namespace session
|
||||
{
|
||||
|
||||
/** */
|
||||
|
||||
/** default/fallback implementation of equality
|
||||
* using literal object identity (same address)
|
||||
*/
|
||||
bool
|
||||
AbstractMO::operator== (const MObject& oo) const
|
||||
{
|
||||
return (this == &oo);
|
||||
}
|
||||
|
||||
|
||||
} // namespace mobject::session
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ namespace mobject
|
|||
|
||||
DEFINE_PROCESSABLE_BY (builder::BuilderTool);
|
||||
|
||||
virtual bool operator== (const MObject& oo) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ namespace mobject
|
|||
namespace session
|
||||
{
|
||||
using asset::Media;
|
||||
typedef shared_ptr<Media> PMedia;
|
||||
typedef shared_ptr<asset::Clip> PClipAsset;
|
||||
typedef P<Media> PMedia;
|
||||
typedef P<asset::Clip> PClipAsset;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace mobject
|
|||
{
|
||||
namespace session
|
||||
{
|
||||
using std::tr1::shared_ptr;
|
||||
using lumiera::P;
|
||||
|
||||
|
||||
|
||||
|
|
@ -52,10 +52,10 @@ namespace mobject
|
|||
|
||||
|
||||
template<class TAR>
|
||||
shared_ptr<TAR>
|
||||
P<TAR>
|
||||
DefsManager::search (const Query<TAR>& capabilities)
|
||||
{
|
||||
shared_ptr<TAR> res;
|
||||
P<TAR> res;
|
||||
QueryHandler<TAR>& typeHandler = ConfigRules::instance();
|
||||
for (DefsRegistry::Iter<TAR> i = defsRegistry->candidates(capabilities);
|
||||
res = *i ; ++i )
|
||||
|
|
@ -69,10 +69,10 @@ namespace mobject
|
|||
|
||||
|
||||
template<class TAR>
|
||||
shared_ptr<TAR>
|
||||
P<TAR>
|
||||
DefsManager::create (const Query<TAR>& capabilities)
|
||||
{
|
||||
shared_ptr<TAR> res;
|
||||
P<TAR> res;
|
||||
QueryHandler<TAR>& typeHandler = ConfigRules::instance();
|
||||
typeHandler.resolve (res, capabilities);
|
||||
if (res)
|
||||
|
|
@ -83,9 +83,9 @@ namespace mobject
|
|||
|
||||
template<class TAR>
|
||||
bool
|
||||
DefsManager::define (const shared_ptr<TAR>& defaultObj, const Query<TAR>& capabilities)
|
||||
DefsManager::define (const P<TAR>& defaultObj, const Query<TAR>& capabilities)
|
||||
{
|
||||
shared_ptr<TAR> candidate (defaultObj);
|
||||
P<TAR> candidate (defaultObj);
|
||||
QueryHandler<TAR>& typeHandler = ConfigRules::instance();
|
||||
typeHandler.resolve (candidate, capabilities);
|
||||
if (!candidate)
|
||||
|
|
@ -97,17 +97,17 @@ namespace mobject
|
|||
|
||||
template<class TAR>
|
||||
bool
|
||||
DefsManager::forget (const shared_ptr<TAR>& defaultObj)
|
||||
DefsManager::forget (const P<TAR>& defaultObj)
|
||||
{
|
||||
return defsRegistry->forget (defaultObj);
|
||||
}
|
||||
|
||||
|
||||
template<class TAR>
|
||||
shared_ptr<TAR>
|
||||
P<TAR>
|
||||
DefsManager::operator() (const Query<TAR>& capabilities)
|
||||
{
|
||||
shared_ptr<TAR> res (search (capabilities));
|
||||
P<TAR> res (search (capabilities));
|
||||
if (res)
|
||||
return res;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@
|
|||
#define MOBJECT_SESSION_DEFSMANAGER_H
|
||||
|
||||
|
||||
#include "common/p.hpp"
|
||||
#include "common/query.hpp"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
#include <tr1/memory>
|
||||
|
||||
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ namespace mobject
|
|||
{
|
||||
namespace session
|
||||
{
|
||||
using std::tr1::shared_ptr;
|
||||
using lumiera::P;
|
||||
using boost::scoped_ptr;
|
||||
|
||||
class DefsRegistry;
|
||||
|
|
@ -69,14 +69,14 @@ namespace mobject
|
|||
* is considered \e misconfiguration.
|
||||
*/
|
||||
template<class TAR>
|
||||
shared_ptr<TAR> operator() (const lumiera::Query<TAR>&);
|
||||
P<TAR> operator() (const lumiera::Query<TAR>&);
|
||||
|
||||
|
||||
/** search through the registered defaults, never create anything.
|
||||
* @return object fulfilling the query, \c empty ptr if not found.
|
||||
*/
|
||||
template<class TAR>
|
||||
shared_ptr<TAR> search (const lumiera::Query<TAR>&);
|
||||
P<TAR> search (const lumiera::Query<TAR>&);
|
||||
|
||||
/** retrieve an object fulfilling the query and register it as default.
|
||||
* The resolution is delegated to the ConfigQuery system (which may cause
|
||||
|
|
@ -84,7 +84,7 @@ namespace mobject
|
|||
* @return object fulfilling the query, \c empty ptr if no solution.
|
||||
*/
|
||||
template<class TAR>
|
||||
shared_ptr<TAR> create (const lumiera::Query<TAR>&);
|
||||
P<TAR> create (const lumiera::Query<TAR>&);
|
||||
|
||||
/** register the given object as default, after ensuring it fulfills the
|
||||
* query. The latter may cause some properties of the object to be set,
|
||||
|
|
@ -93,13 +93,13 @@ namespace mobject
|
|||
* @note only a weak ref to the object is stored
|
||||
*/
|
||||
template<class TAR>
|
||||
bool define (const shared_ptr<TAR>&, const lumiera::Query<TAR>&);
|
||||
bool define (const P<TAR>&, const lumiera::Query<TAR>&);
|
||||
|
||||
/** remove the defaults registration of the given object, if there was such
|
||||
* @return false if nothing has been changed because the object wasn't registered
|
||||
*/
|
||||
template<class TAR>
|
||||
bool forget (const shared_ptr<TAR>&);
|
||||
bool forget (const P<TAR>&);
|
||||
|
||||
|
||||
// Q: can we have something along the line of...?
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "common/multithread.hpp"
|
||||
#include "common/query.hpp"
|
||||
#include "common/util.hpp"
|
||||
#include "common/p.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
|
@ -41,10 +42,10 @@ namespace mobject
|
|||
{
|
||||
namespace session
|
||||
{
|
||||
using std::tr1::shared_ptr;
|
||||
using std::tr1::weak_ptr;
|
||||
using lumiera::Thread;
|
||||
using lumiera::P;
|
||||
using lumiera::Query;
|
||||
using lumiera::Thread;
|
||||
using std::tr1::weak_ptr;
|
||||
|
||||
using std::string;
|
||||
using boost::format;
|
||||
|
|
@ -60,7 +61,7 @@ namespace mobject
|
|||
|
||||
/** we maintain an independent defaults registry
|
||||
* for every participating kind of objects */
|
||||
typedef std::vector<shared_ptr<TableEntry> > Table;
|
||||
typedef std::vector< P<TableEntry> > Table;
|
||||
|
||||
uint maxSlots (0); ///< number of different registered Types
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ namespace mobject
|
|||
Query<TAR> query;
|
||||
weak_ptr<TAR> objRef;
|
||||
|
||||
Record (const Query<TAR>& q, const shared_ptr<TAR>& obj)
|
||||
Record (const Query<TAR>& q, const P<TAR>& obj)
|
||||
: degree (lumiera::query::countPraed (q)),
|
||||
query (q),
|
||||
objRef (obj)
|
||||
|
|
@ -85,15 +86,15 @@ namespace mobject
|
|||
|
||||
struct Search ///< Functor searching for a specific object
|
||||
{
|
||||
Search (const shared_ptr<TAR>& obj)
|
||||
Search (const P<TAR>& obj)
|
||||
: obj_(obj) { }
|
||||
|
||||
const shared_ptr<TAR>& obj_;
|
||||
const P<TAR>& obj_;
|
||||
|
||||
bool
|
||||
operator() (const Record& rec)
|
||||
{
|
||||
shared_ptr<TAR> storedObj (rec.objRef.lock());
|
||||
P<TAR> storedObj (rec.objRef.lock());
|
||||
return storedObj && (storedObj == obj_);
|
||||
}
|
||||
};
|
||||
|
|
@ -110,7 +111,7 @@ namespace mobject
|
|||
};
|
||||
|
||||
operator string () const { return str (dumpRecord % degree % query % dumpObj()); }
|
||||
string dumpObj () const { shared_ptr<TAR> o (objRef.lock()); return o? string(*o):"dead"; }
|
||||
string dumpObj () const { P<TAR> o (objRef.lock()); return o? string(*o):"dead"; }
|
||||
};
|
||||
|
||||
/** every new kind of object (Type) creates a new
|
||||
|
|
@ -186,7 +187,7 @@ namespace mobject
|
|||
typedef typename Slot<TAR>::Registry::iterator II;
|
||||
|
||||
II p,i,e;
|
||||
shared_ptr<TAR> next, ptr;
|
||||
P<TAR> next, ptr;
|
||||
|
||||
Iter (II from, II to) ///< just ennumerates the given range
|
||||
: p(from), i(from), e(to)
|
||||
|
|
@ -201,7 +202,7 @@ namespace mobject
|
|||
operator++ (); // init to first element (or to null if emty)
|
||||
}
|
||||
|
||||
shared_ptr<TAR> findNext () throw()
|
||||
P<TAR> findNext () throw()
|
||||
{
|
||||
while (!next)
|
||||
{
|
||||
|
|
@ -214,9 +215,9 @@ namespace mobject
|
|||
|
||||
|
||||
public:
|
||||
shared_ptr<TAR> operator* () { return ptr; }
|
||||
bool hasNext () { return next || findNext(); }
|
||||
Iter operator++ (int) { Iter tmp=*this; operator++(); return tmp; }
|
||||
P<TAR> operator* () { return ptr; }
|
||||
bool hasNext () { return next || findNext(); }
|
||||
Iter operator++ (int) { Iter tmp=*this; operator++(); return tmp; }
|
||||
Iter& operator++ ()
|
||||
{
|
||||
ptr=findNext();
|
||||
|
|
@ -237,7 +238,7 @@ namespace mobject
|
|||
template<class TAR>
|
||||
Iter<TAR> candidates (const Query<TAR>& query)
|
||||
{
|
||||
shared_ptr<TAR> dummy;
|
||||
P<TAR> dummy;
|
||||
Record<TAR> entry (query, dummy);
|
||||
typedef typename Slot<TAR>::Registry Registry;
|
||||
Registry& registry = Slot<TAR>::access(table_);
|
||||
|
|
@ -261,7 +262,7 @@ namespace mobject
|
|||
* case, also the param obj shared-ptr is rebound!
|
||||
*/
|
||||
template<class TAR>
|
||||
bool put (shared_ptr<TAR>& obj, const Query<TAR>& query)
|
||||
bool put (P<TAR>& obj, const Query<TAR>& query)
|
||||
{
|
||||
Record<TAR> entry (query, obj);
|
||||
typedef typename Slot<TAR>::Registry Registry;
|
||||
|
|
@ -272,7 +273,7 @@ namespace mobject
|
|||
if ( pos!=registry.end()
|
||||
&& pos->query == query)
|
||||
{
|
||||
shared_ptr<TAR> storedObj (pos->objRef.lock());
|
||||
P<TAR> storedObj (pos->objRef.lock());
|
||||
if (storedObj)
|
||||
return (storedObj == obj);
|
||||
else
|
||||
|
|
@ -290,7 +291,7 @@ namespace mobject
|
|||
* @return false if the object wasn't registered at all.
|
||||
*/
|
||||
template<class TAR>
|
||||
bool forget (const shared_ptr<TAR>& obj)
|
||||
bool forget (const P<TAR>& obj)
|
||||
{
|
||||
typedef typename Slot<TAR>::Registry Registry;
|
||||
typedef typename Record<TAR>::Search SearchFunc;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace mobject
|
|||
class Track;
|
||||
class Effect;
|
||||
|
||||
typedef shared_ptr<asset::Track> PTrackAsset;
|
||||
typedef P<asset::Track> PTrackAsset;
|
||||
|
||||
|
||||
class MObjectFactory
|
||||
|
|
|
|||
|
|
@ -34,11 +34,13 @@ namespace mobject
|
|||
{
|
||||
namespace session
|
||||
{
|
||||
using lumiera::P;
|
||||
|
||||
class Track;
|
||||
typedef asset::Track TrackAsset;
|
||||
|
||||
typedef shared_ptr<Track> PTrack;
|
||||
typedef shared_ptr<TrackAsset> PTrackAsset;
|
||||
typedef P<Track> PTrack;
|
||||
typedef P<TrackAsset> PTrackAsset;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "proc/mobject/session/defsregistry.hpp"
|
||||
#include "common/factory.hpp"
|
||||
#include "common/query.hpp"
|
||||
#include "common/p.hpp"
|
||||
|
||||
#include "../common/query/querydiagnostics.hpp"
|
||||
|
||||
|
|
@ -35,11 +36,11 @@
|
|||
#include <cstdlib>
|
||||
#include <map>
|
||||
|
||||
using lumiera::P;
|
||||
using lumiera::Query;
|
||||
using lumiera::query::test::garbage_query;
|
||||
using util::isnil;
|
||||
|
||||
using std::tr1::shared_ptr;
|
||||
using boost::scoped_ptr;
|
||||
using boost::format;
|
||||
using std::string;
|
||||
|
|
@ -75,7 +76,9 @@ namespace mobject
|
|||
{
|
||||
static string name;
|
||||
string instanceID;
|
||||
operator string () const { return instanceID; }
|
||||
operator string () const { return instanceID; }
|
||||
bool operator== (const Dummy& odu) const { return this == &odu; }
|
||||
|
||||
|
||||
Dummy () : instanceID (newID (name)) {}
|
||||
};
|
||||
|
|
@ -99,8 +102,8 @@ namespace mobject
|
|||
{
|
||||
scoped_ptr<DefsRegistry> reg_;
|
||||
|
||||
typedef shared_ptr<Dummy<13> > O;
|
||||
typedef shared_ptr<Dummy<23> > P;
|
||||
typedef P<Dummy<13> > O;
|
||||
typedef P<Dummy<23> > P;
|
||||
|
||||
typedef Query<Dummy<13> > Q13;
|
||||
typedef Query<Dummy<23> > Q23;
|
||||
|
|
|
|||
Loading…
Reference in a new issue