From d9e6adfe020797e4ae3a5e3b859816883b9d8f22 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 23 Apr 2008 05:48:45 +0200 Subject: [PATCH] make Placement implement the interface Buildable. WIP: works, but isnt what I intended. Rather need a specialisation to be able to define functions treat (Placement) based on the concrete TY.... --- src/common/visitor.hpp | 2 +- src/common/visitorpolicies.hpp | 2 +- src/proc/mobject/explicitplacement.hpp | 3 ++ src/proc/mobject/placement.hpp | 4 +- src/proc/mobject/session/locatingpin.hpp | 5 +- .../proc/mobject/builder/buildertooltest.cpp | 47 +++++++++++++++---- 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/common/visitor.hpp b/src/common/visitor.hpp index 837ddf713..3d22f11e6 100644 --- a/src/common/visitor.hpp +++ b/src/common/visitor.hpp @@ -105,7 +105,7 @@ namespace lumiera typedef RET ReturnType; ///< Tool function invocation return type typedef Tool ToolBase; ///< for templating the Tag and Dispatcher - virtual ~Tool () { }; ///< use RTTI for all visiting tools + virtual ~Tool () { }; ///< use RTTI for all visiting tools /** allows discovery of the concrete Tool type when dispatching a * visitor call. Can be implemented by inheriting from ToolTag */ diff --git a/src/common/visitorpolicies.hpp b/src/common/visitorpolicies.hpp index e59a2f5b2..829dd5546 100644 --- a/src/common/visitorpolicies.hpp +++ b/src/common/visitorpolicies.hpp @@ -23,7 +23,7 @@ /** @file visitorpolicies.hpp ** Policies usable for configuring the lumiera::visitor::Tool for different kinds of error handling. - ** @see buildertool.hpp for another flavor (calling and catch-all-function) + ** @see buildertool.hpp for another flavour (calling an catch-all-function there) ** */ diff --git a/src/proc/mobject/explicitplacement.hpp b/src/proc/mobject/explicitplacement.hpp index 388a0ac82..cb5e424b5 100644 --- a/src/proc/mobject/explicitplacement.hpp +++ b/src/proc/mobject/explicitplacement.hpp @@ -60,6 +60,9 @@ namespace mobject { return *this; } + + /** */ /////////////////////////////////////////////////////////////TODO: wip-wip... + DEFINE_PROCESSABLE_BY (builder::BuilderTool); protected: /* @todo ichthyo considers a much more elegant implementation utilizing a subclass diff --git a/src/proc/mobject/placement.hpp b/src/proc/mobject/placement.hpp index c5d56169d..7bd3a9ce4 100644 --- a/src/proc/mobject/placement.hpp +++ b/src/proc/mobject/placement.hpp @@ -82,7 +82,7 @@ namespace mobject * be within the Session/EDL */ template - class Placement : protected shared_ptr + class Placement : public Buildable, protected shared_ptr { protected: typedef lumiera::Time Time; @@ -105,7 +105,7 @@ namespace mobject virtual ~Placement() {}; /** */ /////////////////////////////////////////////////////////////TODO: totmachen? - // DEFINE_PROCESSABLE_BY (builder::BuilderTool); + DEFINE_PROCESSABLE_BY (builder::BuilderTool); /** interface for defining the kind of placement diff --git a/src/proc/mobject/session/locatingpin.hpp b/src/proc/mobject/session/locatingpin.hpp index f978d4f4e..ecd82ab30 100644 --- a/src/proc/mobject/session/locatingpin.hpp +++ b/src/proc/mobject/session/locatingpin.hpp @@ -111,9 +111,12 @@ namespace mobject virtual LocatingPin* clone () const; virtual ~LocatingPin() {}; - protected: +// protected: LocatingPin () {}; +//TODO (for working out the buildable interface; ctor should be protected) +protected: + friend class Placement; /** diff --git a/tests/components/proc/mobject/builder/buildertooltest.cpp b/tests/components/proc/mobject/builder/buildertooltest.cpp index 8a445ef18..584b41ea0 100644 --- a/tests/components/proc/mobject/builder/buildertooltest.cpp +++ b/tests/components/proc/mobject/builder/buildertooltest.cpp @@ -1,5 +1,5 @@ /* - BuilderTool(Test) - specialized form of the acyclic visitor + BuilderTool(Test) - specialized visitor used within the builder for processing Placements Copyright (C) Lumiera.org 2008, Hermann Vosseler @@ -27,6 +27,9 @@ #include "proc/asset/media.hpp" #include "proc/mobject/session/clip.hpp" +#include "proc/mobject/explicitplacement.hpp" //////////TODO + + #include using std::string; using std::cout; @@ -48,15 +51,31 @@ namespace mobject public: DummyMO() { }; virtual bool isValid() const { return true;} - DEFINE_PROCESSABLE_BY (BuilderTool); +// DEFINE_PROCESSABLE_BY (BuilderTool); + + static void killDummy (AbstractMO* dum) { delete (DummyMO*)dum; } }; - - class TestTool - : public Applicable::List> + + + //////////////////////////////////////////////////////TODO: wip-wip + + class DummyPlacement : public Placement { public: - void treat (Clip& c) { cout << "media is: "<< str(c.getMedia()) <<"\n"; } - void treat (AbstractMO&){ cout << "unspecific MO.\n"; } + DummyPlacement() + : Placement::Placement(*new DummyMO, &DummyMO::killDummy) + { } + }; + //////////////////////////////////////////////////////TODO: wip-wip + + + + class TestTool + : public Applicable, Placement >::List> + { + public: + void treat (Placement& pC) { cout << "media is: "<< str(pC->getMedia()) <<"\n"; } + void treat (Placement&){ cout << "unspecific MO.\n"; } void onUnknown (Buildable&){ cout << "catch-all-function called.\n"; } }; @@ -88,10 +107,10 @@ namespace mobject TestTool t1; BuilderTool& tool (t1); - DummyMO dumm; + DummyPlacement dumm; PMO clip = asset::Media::create("test-1", asset::VIDEO)->createClip(); - clip->apply (tool); + clip.apply (tool); dumm.apply (tool); } }; @@ -105,5 +124,15 @@ namespace mobject } // namespace test } // namespace builder + + //////////////////////////////////////////////////////TODO: wip-wip + template<> + ExplicitPlacement + Placement::resolve () const + { + UNIMPLEMENTED ("just a test"); + } + //////////////////////////////////////////////////////TODO: wip-wip + } // namespace mobject