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


C++ Operation::apply方法代码示例

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


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

示例1: apply_restored

void Journallable::apply_restored(const Operation &op)
{
   TRACEPX(PCOMN_Journal, DBGL_MIDLEV, "Applying restored " << op << " to " << *this) ;

   NOXCHECK(state() == ST_RESTORING) ;
   NOXCHECK(is_op_compatible(op)) ;

   try {
      // Needn't lock, needn't store
      op.apply(*this) ;

      atomic_op::preinc(&_changecnt) ;
   }
   catch (const std::runtime_error &x)
   {
      // We may choose to ignore an exception: when an operation is being stored into
      // the journal, it is written _before_ applying; so, although do_lock_target
      // (which is called _before_ storing the operation) can check whether the
      // operation is applicable, such check may be noncomprehensive, e.g. due to
      // performance/locking issues. As a result, the operation may fail after having
      // been saved (though leaving the Journallable in consistent state).
      // Such operation will also inevitably fail while being restored but failure may
      // (and should!) be ignored.
      if (!op.is_ignorable_exception(x))
      {
         LOGPXERR(PCOMN_Journal, "Non-ignorable exception restoring " << op
                   << " to " << *this << ": " << STDEXCEPTOUT(x)) ;
         throw ;
      }
      LOGINFO("Ignorable exception restoring " << op << " to " << *this << ": " << STDEXCEPTOUT(x)) ;
   }

   TRACEPX(PCOMN_Journal, DBGL_MIDLEV, "OK applied restored " << op) ;
}
开发者ID:ymarkovitch,项目名称:libpcomn,代码行数:34,代码来源:journal.cpp

示例2: apply

	void apply(int number, char op) {
		Operation newOperation(number, op);

		int i = opStack.size() - 1;
		while (i >= 0) {
			Operation next = opStack[i--];
			if (Operators::rank(next.op) >= Operators::rank(op)) {
				newOperation.number = next.apply(newOperation.number);
				opStack.pop_back();
			} else {
				break;
			}
		}

		opStack.push_back(newOperation);
	}
开发者ID:DariaP,项目名称:coding,代码行数:16,代码来源:calculator.cpp

示例3: apply_created

void Journallable::apply_created(const Operation &op)
{
   TRACEPX(PCOMN_Journal, DBGL_MIDLEV, "Applying new " << op << " to " << *this) ;

   NOXCHECK((pcomn::one_of<ST_RESTORED, ST_ACTIVE, ST_CHECKPOINT>::is(state()))) ;
   NOXCHECK(is_op_compatible(op)) ;

   op.lock_target(*this, true) ;

   try {
      if (state() != ST_RESTORED)
      {
         TRACEPX(PCOMN_Journal, DBGL_LOWLEV, "Storing " << op << " to " << *unlocked_journal()) ;

         unlocked_journal()->store_operation(op) ;
      }
      TRACEPX(PCOMN_Journal, DBGL_VERBOSE, "Actually applying " << op) ;

      op.apply(*this) ;

      atomic_op::preinc(&_changecnt) ;
   }
   catch (const std::exception &x) {
      LOGPXERR_CALL(PCOMN_FAIL, PCOMN_Journal, STDEXCEPTOUT(x) << "\nwhile applying " << op
                    << "\nto " << *unlocked_journal() << ".\nThe operation is NOT applied") ;
      return ;
   }
   catch (...) {
      LOGPXERR_CALL(PCOMN_FAIL, PCOMN_Journal, "Unknown exception while applying " << op
                    << "\nto " << *unlocked_journal() << ".\nThe operation is NOT applied") ;
      return ;
   }

   op.lock_target(*this, false) ;

   TRACEPX(PCOMN_Journal, DBGL_MIDLEV, "OK applied new " << op) ;
}
开发者ID:ymarkovitch,项目名称:libpcomn,代码行数:37,代码来源:journal.cpp


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