Public Member Functions | Static Public Member Functions | List of all members
DesignHistoryRestore Class Reference

#include <DesignHistoryRestore.h>

Public Member Functions

void SetDontForceModelDelete (bool)
 
 DesignHistoryRestore ()
 Initializes the DesignHistoryRestore object but does not actually do the work. See Restore. More...
 
 ~DesignHistoryRestore ()
 Release resources used. More...
 

Static Public Member Functions

static bool CanRestore (DesignHistory &dh, RevisionNumbersForFile &revs, ElementChangeRecordFilter const &ssfilter)
 Test if Restore is possible. More...
 
static bool IsRollback (RevisionNumber &targetRev, DesignHistory &dh, RevisionNumbersForFile &revs, ElementChangeRecordFilter const &ssfilter)
 Test if Restore using the specified parameters would be equivalent to rolling back the state of the file. More...
 
static long GetUndoPos ()
 Used to undo failed attempt to restore. More...
 

Restore history versions

StatusInt Restore (DgnFileR file, RevisionNumber const &targetRev, bool fromUndo=false)
 Restores all elements to specified point in history. More...
 
StatusInt Restore (DgnFileR file, RevisionNumber const &targetRev, ModelsToElementChangesMap const &elements)
 Restore selected elements to specified point in history. More...
 
StatusInt Restore (DgnFileR file, RevisionNumber const &targetRev, IElementQueryResultFilter &csfilter, ElementChangeRecordFilter const &ssfilter)
 Restore selected elements to specified point in history. More...
 
static RestoreType IsRestoreInProgress (DgnFileR file)
 Check if DesignHistoryRestore is currently updating the specified file. More...
 

Constructor & Destructor Documentation

Initializes the DesignHistoryRestore object but does not actually do the work. See Restore.

Release resources used.

Member Function Documentation

static bool CanRestore ( DesignHistory dh,
RevisionNumbersForFile revs,
ElementChangeRecordFilter const &  ssfilter 
)
static

Test if Restore is possible.

Restore is not possible if ssfilter selects only some change types or if revs does not define a contiguous range of revisions.

Returns
false if restore is not possible.
Parameters
dhThe history that would be queried
revsThe revisions to be restored
ssfilterThe server-side filter that would be used
static long GetUndoPos ( )
static

Used to undo failed attempt to restore.

static RestoreType IsRestoreInProgress ( DgnFileR  file)
static

Check if DesignHistoryRestore is currently updating the specified file.

Parameters
fileIN the file to check
static bool IsRollback ( RevisionNumber targetRev,
DesignHistory dh,
RevisionNumbersForFile revs,
ElementChangeRecordFilter const &  ssfilter 
)
static

Test if Restore using the specified parameters would be equivalent to rolling back the state of the file.

This is false if ssfilter selects only some change types or if revs does not define a contiguous range of revisions beginning with the tip revision or Recent, if there are recent changes.

Parameters
[out]targetRevOn return, this is set to the revision just before the earliest revision in the range.
[in]dhThe history that would be queried
[in]revsThe revisions to be restored
[in]ssfilterThe server-side filter that would be used
Returns
false if restore is not equivalent to rolling back the file.
StatusInt Restore ( DgnFileR  file,
RevisionNumber const &  targetRev,
bool  fromUndo = false 
)

Restores all elements to specified point in history.

This is non-selective restore. It does the following:

  1. Rolls back the entire file by adding, deleting, and rewriting the affected elements.
  2. Calls Handler::_OnHistoryRestore on the affected elements

Handler::RestoreHistoricalVersion is not called.

When a reference file is attached as of a revision, MicroStation uses non-selective restore. Handler::_OnHistoryRestore is called, but handlers can ignore it, since it pertains to elements that are not in the master file.

Returns
SUCCESS if the file was modified to match the specified historical state. Otherwise, a non-zero error status is returned to indicate that the file was not modified. The error status could be HISTORY_ERROR_NOCHANGES if targetRev does not identify a revision in the file's history.
See also
DesignHistoryCodeSamples, DesignHistoryHookFunctions
Parameters
filefile to modify
targetRevpoint in history to which file should be restored
fromUndotrue if we are actually restoring only one revision, but it's the latest revision.
StatusInt Restore ( DgnFileR  file,
RevisionNumber const &  targetRev,
ModelsToElementChangesMap const &  elements 
)

Restore selected elements to specified point in history.

Selective restore does the following:

  1. Creates an temporary in-memory copy of the design file,
  2. Restores the copy to the specified revision, and then
  3. Calls Handler::RestoreHistoricalVersion on the affected elements

The _RestoreHistoricalVersion method

Design History restore delegates the element restore operation to handlers by calling Handler::RestoreHistoricalVersion. The base class implementation of RestoreHistoricalVersion is to handle updates by first deleting the element and then calling mdlElmdscr_copy (preserving ElementIDs). It then calls Handler::_OnHistoryRestore. A handler can override this method to call subsystem API functions, as appropriate.

ChangeTrack callbacks are also triggered.

In most cases, Design History restore will also invoke Handler::OnHistoryRestore callbacks. Normally, you should implement Handler::OnHistoryRestore to call your Redo hook.

Complex Components

When doing a selective, element-level restore, Design History will attempt to restore complex components individually. While this is normally a bad idea, this gives Table handlers and others a chance to implement RestoreHistoricalVersion to restore components intelligently. The base class implementation ignores components.

Note: For Table elements, it is usually appropriate to override RestoreHistoricalVersion in both the table and the entry handlers. The table handler should ignore the request to restore the header element. The entry handler should patch the table as appropriate to restore the entry.

See also
DesignHistoryCodeSamples, DesignHistoryHookFunctions
Returns
SUCCESS if the file was modified to match the specified historical state. Otherwise, a non-zero error status is returned to indicate that the file was not modified. The error status could be HISTORY_ERROR_NOCHANGES if targetRev does not identify a revision in the file's history.
Parameters
filefile to modify
targetRevpoint in history to which file should be restored
elementsthe specific elements to restore
StatusInt Restore ( DgnFileR  file,
RevisionNumber const &  targetRev,
IElementQueryResultFilter csfilter,
ElementChangeRecordFilter const &  ssfilter 
)

Restore selected elements to specified point in history.

p> This function uses the supplied filters to identify the elements of interest and then calls selective Restore.

See also
DesignHistoryCodeSamples, DesignHistoryHookFunctions
Parameters
filefile to modify
targetRevpoint in history to which file should be restored
csfilterselects which elements to restore (applied on client)
ssfilterselects which elements to restore (applied on server)
void SetDontForceModelDelete ( bool  )

The documentation for this class was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.