13
0

r115@gandalf: fugalh | 2006-06-23 12:36:05 -0600

pass the object instead of an id


git-svn-id: svn://localhost/ardour2/branches/undo@654 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Fugal 2006-06-29 18:45:41 +00:00
parent 7968974c01
commit 5b289d3006

View File

@ -38,7 +38,7 @@ using std::string;
/* One of the joys of templates is that you have to do everything right here /* One of the joys of templates is that you have to do everything right here
* in the header file; you can't split this to make undo_command.cc */ * in the header file; you can't split this to make undo_command.cc */
template <class T1=nil, class T2=nil, class T3=nil, class T4=nil> template <class T_obj, class T1=nil, class T2=nil, class T3=nil, class T4=nil>
class UndoCommand class UndoCommand
{ {
public: public:
@ -47,39 +47,39 @@ class UndoCommand
* *
* UndoCommand<Foo> cmd(id, key, foo_instance); * UndoCommand<Foo> cmd(id, key, foo_instance);
*/ */
UndoCommand(id_t object_id, string key) UndoCommand(T_obj &object, string key)
: _obj_id(object_id), _key(key) : _obj(object), _key(key)
{ {
_slot = mem_fun( get_object(object_id), get_method(key) ); _slot = mem_fun( _obj, get_method(_key) );
} }
UndoCommand(id_t object_id, string key, T1 &arg1) UndoCommand(T_obj &object, string key, T1 &arg1)
: _obj_id(object_id), _key(key) : _obj(object), _key(key)
{ {
_slot = bind( mem_fun( get_object(object_id), get_method(key) ), _slot = bind( mem_fun( _obj, get_method(_key) ),
arg1); arg1);
_args.push_back(&arg1); _args.push_back(&arg1);
} }
UndoCommand(id_t object_id, string key, T1 &arg1, T2 &arg2) UndoCommand(T_obj &object, string key, T1 &arg1, T2 &arg2)
: _obj_id(object_id), _key(key) : _obj(object), _key(key)
{ {
_slot = bind( mem_fun( get_object(object_id), get_method(key) ), _slot = bind( mem_fun( _obj, get_method(_key) ),
arg1, arg2); arg1, arg2);
_args.push_back(&arg1); _args.push_back(&arg1);
_args.push_back(&arg2); _args.push_back(&arg2);
} }
UndoCommand(id_t object_id, string key, T1 &arg1, T2 &arg2, T3 &arg3) UndoCommand(T_obj &object, string key, T1 &arg1, T2 &arg2, T3 &arg3)
: _obj_id(object_id), _key(key) : _obj(object), _key(key)
{ {
_slot = bind( mem_fun( get_object(object_id), get_method(key) ), _slot = bind( mem_fun( _obj, get_method(_key) ),
arg1, arg2, arg3); arg1, arg2, arg3);
_args.push_back(&arg1); _args.push_back(&arg1);
_args.push_back(&arg2); _args.push_back(&arg2);
_args.push_back(&arg3); _args.push_back(&arg3);
} }
UndoCommand(id_t object_id, string key, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4) UndoCommand(T_obj &object, string key, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4)
: _obj_id(object_id), _key(key) : _obj(object), _key(key)
{ {
_slot = bind( mem_fun( get_object(object_id), get_method(key) ), _slot = bind( mem_fun( _obj, get_method(_key) ),
arg1, arg2, arg4); arg1, arg2, arg4);
_args.push_back(&arg1); _args.push_back(&arg1);
_args.push_back(&arg2); _args.push_back(&arg2);
@ -91,9 +91,8 @@ class UndoCommand
XMLNode &serialize(); XMLNode &serialize();
protected: protected:
template <class T_object> T_object &get_object(id_t);
template <class T_method> T_method &get_method(string); template <class T_method> T_method &get_method(string);
id_t _obj_id; T_obj &_obj;
string _key; string _key;
slot<void> _slot; slot<void> _slot;