add ability to generate a short-ID to MObject hierarchy
This commit is contained in:
parent
b15a1c2d3c
commit
b9e99a2be2
14 changed files with 162 additions and 51 deletions
|
|
@ -23,9 +23,11 @@
|
|||
|
||||
#include "proc/mobject/mobject.hpp"
|
||||
#include "proc/mobject/session/mobjectfactory.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
namespace mobject
|
||||
{
|
||||
using util::isnil;
|
||||
|
||||
namespace mobject {
|
||||
|
||||
using ::NOBUG_FLAG(memory);
|
||||
NOBUG_CPP_DEFINE_FLAG_PARENT(mobjectmem, memory);
|
||||
|
|
@ -35,6 +37,25 @@ namespace mobject
|
|||
*/
|
||||
session::MObjectFactory MObject::create;
|
||||
|
||||
|
||||
MObject::MObject()
|
||||
: length_()
|
||||
, shortID_()
|
||||
{ }
|
||||
|
||||
|
||||
MObject::~MObject() { };
|
||||
|
||||
|
||||
|
||||
string const&
|
||||
MObject::shortID() const
|
||||
{
|
||||
if (isnil (shortID_))
|
||||
shortID_ = initShortID();
|
||||
return shortID_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace mobject
|
||||
|
|
|
|||
|
|
@ -34,10 +34,9 @@
|
|||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
using std::list;
|
||||
|
||||
#include "proc/assetmanager.hpp"
|
||||
using proc_interface::IDA; //TODO finally not needed?
|
||||
|
|
@ -46,6 +45,7 @@ using proc_interface::AssetManager;
|
|||
|
||||
namespace mobject {
|
||||
|
||||
using std::string;
|
||||
using lumiera::P;
|
||||
|
||||
//NOBUG_DECLARE_FLAG (mobjectmem);
|
||||
|
|
@ -71,10 +71,12 @@ namespace mobject {
|
|||
typedef lumiera::Time Time;
|
||||
|
||||
// TODO: how to represent time intervals best?
|
||||
Time length;
|
||||
Time length_;
|
||||
|
||||
MObject() {}
|
||||
virtual ~MObject() {};
|
||||
mutable string shortID_;
|
||||
|
||||
MObject() ;
|
||||
virtual ~MObject() ;
|
||||
|
||||
friend class session::MObjectFactory;
|
||||
|
||||
|
|
@ -82,13 +84,23 @@ namespace mobject {
|
|||
public:
|
||||
static session::MObjectFactory create;
|
||||
|
||||
/** a short readable ID as a single name-token,
|
||||
* denoting both the kind of MObject and some sort of
|
||||
* instance identity. Not necessarily unique but should
|
||||
* be reasonable unique in most cases */
|
||||
string const& shortID() const;
|
||||
|
||||
/** MObject self-test (usable for asserting) */
|
||||
virtual bool isValid() const =0;
|
||||
|
||||
virtual Time& getLength() =0; ///< @todo how to deal with the time/length field?? ////TICKET #448
|
||||
|
||||
|
||||
virtual bool operator== (const MObject& oo) const =0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual string initShortID() const =0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -98,10 +110,3 @@ namespace mobject {
|
|||
|
||||
} // namespace mobject
|
||||
#endif
|
||||
/*
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// c-file-style: "gnu"
|
||||
// indent-tabs-mode: nil
|
||||
// End:
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -22,22 +22,39 @@
|
|||
|
||||
|
||||
#include "proc/mobject/session/abstractmo.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
namespace mobject
|
||||
#include <boost/format.hpp>
|
||||
|
||||
using boost::format;
|
||||
using util::isnil;
|
||||
|
||||
namespace mobject {
|
||||
namespace session {
|
||||
|
||||
/** default/fallback implementation of equality
|
||||
* using literal object identity (same address)
|
||||
*/
|
||||
bool
|
||||
AbstractMO::operator== (const MObject& oo) const
|
||||
{
|
||||
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
|
||||
|
||||
} // namespace mobject
|
||||
return (this == &oo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
string
|
||||
AbstractMO::buildShortID (lib::Literal typeID, string suffix) const
|
||||
{
|
||||
static uint i=0;
|
||||
static format namePattern ("%s.%03d");
|
||||
|
||||
REQUIRE (!isnil (typeID));
|
||||
if (!isnil (suffix))
|
||||
return typeID+"."+suffix;
|
||||
else
|
||||
return str(namePattern % typeID % (++i) );
|
||||
}
|
||||
|
||||
|
||||
}} // namespace mobject::session
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#define MOBJECT_SESSION_ABSTRACTMO_H
|
||||
|
||||
#include "proc/mobject/mobject.hpp"
|
||||
#include "lib/symbol.hpp"
|
||||
|
||||
|
||||
|
||||
|
|
@ -36,18 +37,30 @@ namespace session {
|
|||
* abstract base class of all MObjects for providing common services.
|
||||
* @todo seems that we don't need this intermediate class...
|
||||
*/
|
||||
class AbstractMO : public MObject
|
||||
class AbstractMO
|
||||
: public MObject
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/* some dummy implementations used to make the code compile... */
|
||||
|
||||
virtual Time& getLength() { return length; }
|
||||
|
||||
/* === some default implementations === */
|
||||
|
||||
DEFINE_PROCESSABLE_BY (builder::BuilderTool);
|
||||
|
||||
virtual bool operator== (const MObject& oo) const;
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("MObject");
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Time&
|
||||
getLength()
|
||||
{
|
||||
return length_;
|
||||
}
|
||||
|
||||
bool operator== (const MObject& oo) const;
|
||||
|
||||
protected:
|
||||
void
|
||||
|
|
@ -58,6 +71,7 @@ namespace session {
|
|||
"or similarly broken internal assumptions.");
|
||||
}
|
||||
|
||||
string buildShortID (lib::Literal typeID, string suffix ="") const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ namespace mobject
|
|||
template<class VAL>
|
||||
class Auto : public Meta, public ParamProvider<VAL>
|
||||
{
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("Auto");
|
||||
}
|
||||
|
||||
public:
|
||||
//////////////////////////////TICKET #566
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@ namespace session {
|
|||
{
|
||||
PSequence boundSequence_;
|
||||
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("Binding");
|
||||
}
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace session {
|
|||
Clip::isValid () const
|
||||
{
|
||||
TODO ("check consistency of clip length def, implies accessing the underlying media def");
|
||||
return length > Time(0);
|
||||
return length_ > Time(0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ namespace session {
|
|||
Clip::setupLength()
|
||||
{
|
||||
TODO ("really calculate the length of a clip and set length field");
|
||||
this->length = mediaDef_.getLength();
|
||||
this->length_ = mediaDef_.getLength();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,8 +52,19 @@ namespace session {
|
|||
* because it depends on the actual media type, and we want to encapsulate
|
||||
* all these details as much as possible.
|
||||
*/
|
||||
class Clip : public AbstractMO
|
||||
class Clip
|
||||
: public AbstractMO
|
||||
{
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("Clip");
|
||||
}
|
||||
|
||||
void setupLength();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
/** start position in source */
|
||||
Time start_;
|
||||
|
|
@ -72,10 +83,8 @@ namespace session {
|
|||
friend class MObjectFactory;
|
||||
|
||||
|
||||
virtual void setupLength();
|
||||
|
||||
public:
|
||||
virtual bool isValid() const;
|
||||
bool isValid() const;
|
||||
|
||||
/** access the underlying media asset */
|
||||
PMedia getMedia () const;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ namespace session {
|
|||
|
||||
class Effect : public AbstractMO
|
||||
{
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("Effect");
|
||||
}
|
||||
|
||||
protected:
|
||||
/** Identifier of the Plug-in to be used */
|
||||
string pluginID;
|
||||
|
|
|
|||
|
|
@ -46,10 +46,16 @@ namespace session {
|
|||
class Label : public Meta
|
||||
{
|
||||
///////////TODO: timespan fields here or already in class Meta??
|
||||
|
||||
|
||||
Symbol typeID_;
|
||||
|
||||
virtual bool isValid() const;
|
||||
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("Label");
|
||||
}
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
public:
|
||||
Label (Symbol type)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ namespace session {
|
|||
{
|
||||
///////////
|
||||
//////////////////////////////TICKET #448 what to do with the length here??
|
||||
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("MetaMO");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,12 @@ namespace session {
|
|||
///////////TODO: timespan fields here or already in class Meta??
|
||||
///////////TODO: any idea about the purpose of root's "timespan"?? ///////TICKET #448
|
||||
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("Root","(✼)");
|
||||
}
|
||||
|
||||
virtual bool isValid() const;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -76,6 +76,15 @@ namespace session {
|
|||
Time start_;
|
||||
TrackID id_;
|
||||
|
||||
|
||||
string
|
||||
initShortID() const
|
||||
{
|
||||
return buildShortID("Fork");
|
||||
}
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
protected:
|
||||
Track (TrackID const&);
|
||||
friend class MObjectFactory;
|
||||
|
|
@ -87,7 +96,6 @@ namespace session {
|
|||
|
||||
bool isSameID (string const&);
|
||||
|
||||
virtual bool isValid() const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -81,8 +81,9 @@ namespace test {
|
|||
|
||||
DEFINE_PROCESSABLE_BY (BuilderTool);
|
||||
|
||||
virtual bool isValid() const { return true;}
|
||||
virtual operator string() const { return display("DummyMO"); }
|
||||
virtual bool isValid() const { return true;}
|
||||
virtual string initShortID() const { return buildShortID("DummyMO"); }
|
||||
virtual operator string() const { return display("DummyMO"); }
|
||||
static void killDummy (MObject* dum) { delete (DummyMO*)dum; }
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Reference in a new issue