本文整理汇总了C++中Change类的典型用法代码示例。如果您正苦于以下问题:C++ Change类的具体用法?C++ Change怎么用?C++ Change使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Change类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/// Performs an document-change undo.
void TextUndoStack::undoDocumentChange()
{
// first make sure ALL controller-changes are back to the document change-level
QMap<TextEditorController*, int>::iterator itr;
for( itr = controllerIndexMap_.begin(); itr != controllerIndexMap_.end(); ++itr) {
TextEditorController* controller = itr.key();
while( undoControllerChange(controller) ) {}; // undo all controller operations
}
// next perform an undo of the document operations
Change* change = findUndoChange();
if( change ) {
Q_ASSERT( change->controllerContext() == 0 );
change->revert( documentRef_ );
// next move the pointers to first 'related' change
for( itr = controllerIndexMap_.begin(); itr != controllerIndexMap_.end(); ++itr) {
TextEditorController* controller = itr.key();
controllerIndexMap_[controller] = findUndoIndex( changeIndex_-1, controller ) + 1; // +1 because the pointer points AFTER the found index
}
// and finally move the document pointer
setChangeIndex( findUndoIndex( changeIndex_-1 ) + 1 ); // +1 because the pointer points AFTER the found index
emit undoExecuted( change);
}
}
示例2: main
int main()
{
cout << "\n";
Create create;
Change change;
create.fillPointerBuffer();
cout << "main()---------------------------------" << endl;
//cout << "create.num: " << create.num << endl;
cout << "create.bufferPtr: " << create.bufferPtr << endl;
cout << "change.process(create.bufferPtr, create.size)" << endl;
cout << "---------------------------------------" << endl;
cout << "\n";
change.process(create.bufferPtr, create.size);
cout << "\n";
cout << "main()---------------------------------" << endl;
cout << "create.bufferPtr: " << create.bufferPtr << endl;
cout << "create.size: " << create.size << endl;
cout << "---------------------------------------" << endl;
cout << "\n";
cout << "----------SUMMARY-------------" << endl;
cout << "create.bufferPtr: " << create.bufferPtr << endl;
cout << "create.size: " << create.size << endl;
for (int i=0; i<create.size; i++) {
cout << "create.bufferPtr[" << i << "]: " << create.bufferPtr[i] << endl;
}
cout << "------------------------------" << endl;
cout << "\n";
return 0;
}
示例3: _txnClose
void WiredTigerRecoveryUnit::_abort() {
try {
bool notifyDone = !_prepareTimestamp.isNull();
if (_session && _isActive()) {
_txnClose(false);
}
_setState(State::kAborting);
if (MONGO_FAIL_POINT(WTAlwaysNotifyPrepareConflictWaiters)) {
notifyDone = true;
}
if (notifyDone) {
_sessionCache->notifyPreparedUnitOfWorkHasCommittedOrAborted();
}
for (Changes::const_reverse_iterator it = _changes.rbegin(), end = _changes.rend();
it != end;
++it) {
Change* change = it->get();
LOG(2) << "CUSTOM ROLLBACK " << redact(demangleName(typeid(*change)));
change->rollback();
}
_changes.clear();
} catch (...) {
std::terminate();
}
_setState(State::kInactive);
}
示例4: Change
void Reduce::on_pushButton_clicked()
{
Change *win = new Change() ;
win->show();
win->setWindowTitle("bazgasht");
win->resize(700,600);
close();
}
示例5: pass_mock_by_ref
void pass_mock_by_ref()
{
Mock<Change> mock;
Change* change = &mock.get();
When(Method(mock, change)).AlwaysReturn();
change->change(1, 2, 3);
assertChanged(mock, 1, 2, 3);
}
示例6: updateChanges
void KConfigPropagator::commit()
{
updateChanges();
Change *c;
for( c = mChanges.first(); c; c = mChanges.next() ) {
c->apply();
}
}
示例7: move
void Movebase::move(Change &change) {
timer.start();
timer_move.start();
cnt++;
change.clear();
_move(change);
if (change.empty())
timer.stop();
timer_move.stop();
}
示例8: at
/// This method finds the index of the given stackitem from the given index
/// @param index the previous index
/// @param controller the controller context
/// @return the previous index -1, if there's no previous index
int TextUndoStack::findUndoIndex( int index, TextEditorController* controller)
{
if( index > 0 ) {
for( --index; index >= 0; --index ) {
Change* change = at(index);
TextEditorController* context = change->controllerContext();
if( context == 0 || context == controller ) { return index; }
}
}
return -1;
}
示例9: Q_ASSERT
/// This method undos the given controller change. This method does NOT undo document changes
/// @param controller the controller to undo the change form
/// @return true if a change has been undone.
bool TextUndoStack::undoControllerChange(TextEditorController* controller)
{
Q_ASSERT(controller);
int changeIdx = controllerIndexMap_.value(controller)-1; // -1, because the index is directly AFTER the item
Change* changeToUndo = findUndoChange( controller );
if( changeToUndo && changeToUndo->controllerContext() ) {
Q_ASSERT( changeToUndo->controllerContext() == controller );
changeToUndo->revert( documentRef_ );
controllerIndexMap_[controller] = findUndoIndex( changeIdx, controller )+1;
emit undoExecuted( changeToUndo );
return true;
}
return false;
}
示例10: ChangeHeuristic
//calculate the heuristic value of a pile of change
inline int ChangeHeuristic( const Change& change, const int* heuristic ) const
{
int score = 0;
for (const Coin *c=&COINLIST[0];c!=&COINLIST[COIN_COUNT];++c){
score += *heuristic++ * change.GetCount(*c);
}
return score;
}
示例11:
bool
operator== (const Change& x, const Change& y)
{
if (!(x.effects () == y.effects ()))
return false;
if (!(x.script () == y.script ()))
return false;
if (!(x.extension () == y.extension ()))
return false;
if (!(x.type () == y.type ()))
return false;
if (!(x.object () == y.object ()))
return false;
return true;
}
示例12: _txnClose
void TerarkDbRecoveryUnit::_abort() {
try {
if (_active) {
_txnClose(false);
}
for (Changes::const_reverse_iterator it = _changes.rbegin(), end = _changes.rend();
it != end;
++it) {
Change* change = *it;
LOG(2) << "CUSTOM ROLLBACK " << demangleName(typeid(*change));
change->rollback();
}
_changes.clear();
invariant(!_active);
} catch (...) {
std::terminate();
}
}
示例13: AFX_MANAGE_STATE
IChange* Changes::Item(LONG Index)
{
AFX_MANAGE_STATE(AfxGetAppModuleState());
if (m_pDocument == NULL)
{
AfxThrowOleDispatchException(1100, L"The object has been deleted.");
}
if (Index <= 0 || Index > GetCount())
AfxThrowOleDispatchException(1103, L"Index out of range.");
if (m_vChanges[Index-1] == NULL)
{
Change* pChange = new Change(m_pDocument, Index-1);
pChange->InternalAddRef();
m_vChanges[Index - 1] = pChange;
}
return m_vChanges[Index-1]->GetComObject();
}
示例14: currentIndex
/// returns true if the undo-stack is on a persisted index
bool TextUndoStack::isPersisted()
{
int curIdx = currentIndex();
if( persistedIndex_ == curIdx ) { return true; }
if( persistedIndex_ < 0 ) { return false;}
// check if all changes are non-persistable
int startIdx = qMax( 0, qMin( curIdx, persistedIndex_ ));
int endIdx = qMin( qMax( curIdx, persistedIndex_ ), changeList_.size());
for( int idx=startIdx; idx<endIdx; ++idx ) {
Change* change = changeList_.at(idx);
// only check document changes
if( change->isDocumentChange() ) {
if( change->isPersistenceRequired() ) {
return false;
}
}
}
return true;
}
示例15: findRedoIndex
/// redo a document change
void TextUndoStack::redoDocumentChange()
{
// first find the redo operation
int redoIndex = findRedoIndex( currentIndex(0), 0 );
Change* redo = findRedoChange(0);
if( redo ) { ++redoIndex; }
// first move all controller redo-operation to the given redo found redo location
QMap<TextEditorController*, int>::iterator itr;
for( itr = controllerIndexMap_.begin(); itr != controllerIndexMap_.end(); ++itr) {
TextEditorController* controller = itr.key();
while( redoControllerChange(controller) ) {}; // undo all controller operations
itr.value() = redoIndex; // move the position after the DOC operation
}
// is there a document redo? execute it
if( redo ) {
redo->execute(documentRef_);
setChangeIndex(redoIndex);
emit redoExecuted( redo );
}
}