diff --git a/src/proc/mobject/mobject.cpp b/src/proc/mobject/mobject.cpp index 022c3f9ff..8ac73a1d2 100644 --- a/src/proc/mobject/mobject.cpp +++ b/src/proc/mobject/mobject.cpp @@ -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 diff --git a/src/proc/mobject/mobject.hpp b/src/proc/mobject/mobject.hpp index c8f831bf2..3944c06b5 100644 --- a/src/proc/mobject/mobject.hpp +++ b/src/proc/mobject/mobject.hpp @@ -34,10 +34,9 @@ #include #include -#include +#include -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: -*/ diff --git a/src/proc/mobject/session/abstractmo.cpp b/src/proc/mobject/session/abstractmo.cpp index e3ebffd4f..89cb0cf8b 100644 --- a/src/proc/mobject/session/abstractmo.cpp +++ b/src/proc/mobject/session/abstractmo.cpp @@ -22,22 +22,39 @@ #include "proc/mobject/session/abstractmo.hpp" +#include "lib/util.hpp" -namespace mobject +#include + +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 diff --git a/src/proc/mobject/session/abstractmo.hpp b/src/proc/mobject/session/abstractmo.hpp index 69e1c409f..eff1d5d0c 100644 --- a/src/proc/mobject/session/abstractmo.hpp +++ b/src/proc/mobject/session/abstractmo.hpp @@ -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; }; diff --git a/src/proc/mobject/session/auto.hpp b/src/proc/mobject/session/auto.hpp index 68320fd45..0ec133bc0 100644 --- a/src/proc/mobject/session/auto.hpp +++ b/src/proc/mobject/session/auto.hpp @@ -42,6 +42,12 @@ namespace mobject template class Auto : public Meta, public ParamProvider { + string + initShortID() const + { + return buildShortID("Auto"); + } + public: //////////////////////////////TICKET #566 diff --git a/src/proc/mobject/session/binding.hpp b/src/proc/mobject/session/binding.hpp index 135482e57..05c51fd74 100644 --- a/src/proc/mobject/session/binding.hpp +++ b/src/proc/mobject/session/binding.hpp @@ -50,6 +50,12 @@ namespace session { { PSequence boundSequence_; + string + initShortID() const + { + return buildShortID("Binding"); + } + bool isValid() const; public: diff --git a/src/proc/mobject/session/clip.cpp b/src/proc/mobject/session/clip.cpp index 09b271b4c..a99f7c5df 100644 --- a/src/proc/mobject/session/clip.cpp +++ b/src/proc/mobject/session/clip.cpp @@ -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(); } diff --git a/src/proc/mobject/session/clip.hpp b/src/proc/mobject/session/clip.hpp index 4674e0003..09aeda4c7 100644 --- a/src/proc/mobject/session/clip.hpp +++ b/src/proc/mobject/session/clip.hpp @@ -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; diff --git a/src/proc/mobject/session/effect.hpp b/src/proc/mobject/session/effect.hpp index 23250b3bc..ba0f08e8c 100644 --- a/src/proc/mobject/session/effect.hpp +++ b/src/proc/mobject/session/effect.hpp @@ -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; diff --git a/src/proc/mobject/session/label.hpp b/src/proc/mobject/session/label.hpp index e83221f29..d2b6c3616 100644 --- a/src/proc/mobject/session/label.hpp +++ b/src/proc/mobject/session/label.hpp @@ -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) diff --git a/src/proc/mobject/session/meta.hpp b/src/proc/mobject/session/meta.hpp index 3f3f02ec9..bea5bdb25 100644 --- a/src/proc/mobject/session/meta.hpp +++ b/src/proc/mobject/session/meta.hpp @@ -43,6 +43,12 @@ namespace session { { /////////// //////////////////////////////TICKET #448 what to do with the length here?? + + string + initShortID() const + { + return buildShortID("MetaMO"); + } }; diff --git a/src/proc/mobject/session/root.hpp b/src/proc/mobject/session/root.hpp index b6457bd77..8d5b744ad 100644 --- a/src/proc/mobject/session/root.hpp +++ b/src/proc/mobject/session/root.hpp @@ -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: diff --git a/src/proc/mobject/session/track.hpp b/src/proc/mobject/session/track.hpp index 3b40922c0..0bff48744 100644 --- a/src/proc/mobject/session/track.hpp +++ b/src/proc/mobject/session/track.hpp @@ -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; }; diff --git a/src/proc/mobject/test-dummy-mobject.hpp b/src/proc/mobject/test-dummy-mobject.hpp index 9f18cc7e8..adbeeb313 100644 --- a/src/proc/mobject/test-dummy-mobject.hpp +++ b/src/proc/mobject/test-dummy-mobject.hpp @@ -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: