当前位置: 首页>>代码示例>>C++>>正文


C++ Args::canUndo方法代码示例

本文整理汇总了C++中Args::canUndo方法的典型用法代码示例。如果您正苦于以下问题:C++ Args::canUndo方法的具体用法?C++ Args::canUndo怎么用?C++ Args::canUndo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Args的用法示例。


在下文中一共展示了Args::canUndo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SIG_do

 /** @test simulate a complete command lifecycle with regards to the
  *        storage handling of the command parameters and state memento.
  */
 void
 simulateCmdLifecycle()
   {
     typedef void SIG_do(Tracker<TimeVar>, Tracker<string>, int);
     using Args      = StorageHolder<SIG_do, Tracker<string>>;
     using MemHolder = MementoTie<SIG_do, Tracker<string>>;
     
     Args args;
     CHECK (isnil (args));
     cout << showSizeof(args) << endl;
     
     // store a set of parameter values, later to be used on invocation
     args.storeTuple (
       make_tuple (TTime(randTime()), Tstr("Lumiera rocks"), twoRandomDigits() ));
     CHECK (!isnil (args));
     cout << args << endl;
     
     CHECK (!args.canUndo());
     VERIFY_ERROR(MISSING_MEMENTO,  args.memento() );
     
     MemHolder& memHolder = args.tie(undoIt,captureState);
     CHECK (!memHolder);   // no stored memento....
     CHECK (!args.canUndo());
     
     function<SIG_do> doItFun = doIt;
     function<SIG_do> undoFun = memHolder.tieUndoFunc();
     function<SIG_do> captFun = memHolder.tieCaptureFunc();
     
     typedef function<void()> OpFun;
     
     // now close all the functions with the stored parameter values...
     OpFun bound_doItFun = std::bind (&CmdClosure::invoke, args, CmdFunctor(doItFun));
     OpFun bound_undoFun = std::bind (&CmdClosure::invoke, args, CmdFunctor(undoFun));
     OpFun bound_captFun = std::bind (&CmdClosure::invoke, args, CmdFunctor(captFun));
     
     protocol.seekp(0);
     protocol << "START...";
     
     bound_captFun();
     cout << "captured state: " << args.memento() << endl;
     CHECK (memHolder);
     CHECK (!isnil (*args.memento()));
     CHECK (args.canUndo());
     cout << args << endl;
     
     bound_doItFun();
     cout << protocol.str() << endl;
     bound_undoFun();
     cout << protocol.str() << endl;
     
     // Commands can serve as prototype to be copied....
     Args argsCopy (args);
     bound_captFun();
     protocol.seekp(0);
     protocol << "RESET...";
     
     args.storeTuple (
       make_tuple (TTime(TimeValue(123456)), Tstr("unbelievable"), twoRandomDigits() ));
     cout << "modified: " << args     << endl;
     cout << "copied  : " << argsCopy << endl;    // holds still the old params & memento
     
     bound_undoFun();
     cout << protocol.str() << endl;
   }
开发者ID:Ichthyostega,项目名称:Lumiera,代码行数:67,代码来源:command-argument-test.cpp


注:本文中的Args::canUndo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。