/* CommandBasic(Test) - checking simple ProcDispatcher command definition and execution Copyright (C) Lumiera.org 2009, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *****************************************************/ #include "lib/test/run.hpp" //#include "proc/asset/media.hpp" //#include "proc/mobject/session.hpp" //#include "proc/mobject/session/edl.hpp" //#include "proc/mobject/session/testclip.hpp" //#include "proc/mobject/test-dummy-mobject.hpp" #include "lib/p.hpp" //#include "proc/mobject/placement.hpp" //#include "proc/mobject/placement-index.hpp" //#include "proc/mobject/explicitplacement.hpp" #include "proc/control/command-def.hpp" #include "lib/lumitime.hpp" //#include "lib/util.hpp" #include "lib/meta/typelist.hpp" #include "lib/meta/typelistutil.hpp" #include //#include //#include #include using std::tr1::bind; //using std::tr1::placeholders::_1; //using std::tr1::placeholders::_2; using std::tr1::function; //using boost::format; using lumiera::Time; //using util::contains; using std::string; //using std::cout; namespace lumiera { namespace typelist{ ////////////////////////////////////////////TODO braindump template< typename SIG> struct FunctionSignature; template< typename RET> struct FunctionSignature< function > { typedef RET Ret; typedef Types<> Args; }; template< typename RET , typename A1 > struct FunctionSignature< function > { typedef RET Ret; typedef Types Args; }; template< typename RET , typename A1 , typename A2 > struct FunctionSignature< function > { typedef RET Ret; typedef Types Args; }; template< typename RET , typename A1 , typename A2 , typename A3 > struct FunctionSignature< function > { typedef RET Ret; typedef Types Args; }; template< typename RET , typename A1 , typename A2 , typename A3 , typename A4 > struct FunctionSignature< function > { typedef RET Ret; typedef Types Args; }; template< typename RET , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 > struct FunctionSignature< function > { typedef RET Ret; typedef Types Args; }; template struct FunctionTypedef; template< typename RET> struct FunctionTypedef > { typedef function Func; typedef RET Sig(); }; template< typename RET , typename A1 > struct FunctionTypedef > { typedef function Func; typedef RET Sig(A1); }; template< typename RET , typename A1 , typename A2 > struct FunctionTypedef > { typedef function Func; typedef RET Sig(A1,A2); }; template< typename RET , typename A1 , typename A2 , typename A3 > struct FunctionTypedef > { typedef function Func; typedef RET Sig(A1,A2,A3); }; template< typename RET , typename A1 , typename A2 , typename A3 , typename A4 > struct FunctionTypedef > { typedef function Func; typedef RET Sig(A1,A2,A3,A4); }; template< typename RET , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 > struct FunctionTypedef > { typedef function Func; typedef RET Sig(A1,A2,A3,A4,A5); }; template struct Prepend; template< typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename IGN > struct Prepend > { typedef Types Tuple; }; template struct Tuple; template<> struct Tuple { typedef Types<> Type; }; template struct Tuple > { typedef typename Prepend::Type >::Tuple Type; }; }} // namespace lumiera::typelist namespace control { namespace test { // using session::test::TestClip; using lumiera::P; using lumiera::typelist::FunctionSignature; using lumiera::typelist::FunctionTypedef; using lumiera::typelist::Tuple; using lumiera::typelist::Append; template struct BuildUndoCapturing_Signature { typedef typename FunctionSignature< function >::Args Args; typedef typename FunctionTypedef::Sig type; }; template struct BuildUndoOperation_Signature { typedef typename FunctionSignature< function >::Args::List Args; typedef typename Append::List ExtendedArglist; typedef typename Tuple::Type ExtendedArgs; typedef typename FunctionTypedef::Sig type; }; class CommDef { Symbol id_; template struct UndoDefinition { typedef typename BuildUndoOperation_Signature::type UndoSig; UndoDefinition undoOperation (UndoSig& how_to_Undo) { function opera3 (how_to_Undo); } }; template struct BasicDefinition { template UndoDefinition captureUndo (typename BuildUndoCapturing_Signature::type& how_to_capture_UndoState) { typedef typename BuildUndoCapturing_Signature::type UndoCapSig; function opera2 (how_to_capture_UndoState); } }; public: CommDef (Symbol cmdID) : id_(cmdID) { } template BasicDefinition operation (SIG& operation_to_define) { function opera1 (operation_to_define); } }; ///////////////////////////// ///////////////////////////// /* bind: opFunc(a,b,c) -> op(void) curry(opFunc) (a) (b) (c) pAppl(func, x) -> func2 (b, c) return bind( recursion(), param) */ namespace command1 { void operate (P