#include <ccc.h>
Public Types | |
typedef UINT32 | UserID |
enum | RESULT { CCR_OK = 0, CCR_INTERNAL_ERROR = 1, CCR_INVALID_ARGUMENT = 10, CCR_TOO_MANY_USERS = 100, CCR_INVALID_USER = 101 } |
Public Member Functions | |
ConcurrencyController () | |
Default constructor for the ConcurrencyController. | |
BOOL | Init () |
virtual | ~ConcurrencyController () |
Default destructor for the ConcurrencyController. | |
RESULT | StartUser (UserID *pNewUserID) |
Default destructor for the ConcurrencyController. | |
RESULT | EndUser (UserID UserWhosDone) |
Default destructor for the ConcurrencyController. | |
RESULT | PrepareForOperation (const Operation *const pOperation) |
Allows or disallows access to Operations. | |
RESULT | FinalizeOperation (const Operation *const pOperation) |
Default destructor for the ConcurrencyController. | |
RESULT | PrepareNodeForRead (Node *const pNode) |
Before reading data in a node or passing it as a parameter to a function, call this function to ensure the integrity of the document tree. This call should be accompanied by a subsequent call to FinalizeNodeRead(). The results of the read are undefined if not. See Also: PrepareNodeForUpdate(). | |
RESULT | FinalizeNodeRead (Node *const pNode) |
Once the given node has been read or passed as a parameter, call this function to free it for updates. This call should be accompanied by a prior call to PrepareNodeForRead(). The results of the read are undefined if not. See Also: FinalizeNodeUpdate(). | |
RESULT | PrepareNodeForUpdate (Node *const pNode) |
Before updating a node, call this function to ensure the integrity of the document tree. This call should be accompanied by a subsequent call to FinalizeNodeUpdate(). The results of the update are undefined if not. See Also: PrepareNodeForRead(). | |
RESULT | FinalizeNodeUpdate (Node *const pNode) |
Once the given node has been updated in the tree call this function to ensure its update is complete. This call should be accompanied by a prior call to PrepareForNodeUpdate(). The results of the update are undefined if not. See Also: FinalizeNodeRead(). | |
Protected Member Functions | |
UserID | GetNewUserID () |
Support function to provide a new user id. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (ConcurrencyController) | |
Static Private Attributes | |
static UserID | s_NextFreeUserID = 0 |
static UserID | s_OneAndOnlyUser = 0 |
static UINT32 | s_NumberOfUsers = 0 |
static UINT32 | s_NumberOfActiveOperations = 0 |
static const Operation * | s_pTheActiveOperation = NULL |
Definition at line 115 of file ccc.h.
|
|
|
Definition at line 128 of file ccc.h. 00129 { 00130 CCR_OK = 0, 00131 CCR_INTERNAL_ERROR = 1, 00132 CCR_INVALID_ARGUMENT = 10, 00133 CCR_TOO_MANY_USERS = 100, 00134 CCR_INVALID_USER = 101 00135 } RESULT;
|
|
Default constructor for the ConcurrencyController.
Definition at line 138 of file ccc.cpp.
|
|
Default destructor for the ConcurrencyController.
Definition at line 159 of file ccc.cpp. 00160 { 00161 if (s_NumberOfUsers > 1) 00162 { 00163 TRACEUSER( ME, _T("ConcurrencyController: Users still active\n")); 00164 } 00165 // CriticalSection::DeInit(); 00166 }
|
|
|
|
Default destructor for the ConcurrencyController.
Definition at line 219 of file ccc.cpp. 00220 { 00221 RESULT Result = CCR_OK; 00222 00223 CriticalSection UpdateUserID; 00224 // UpdateUserID.Start(); 00225 00226 if (UserWhosDone == s_OneAndOnlyUser) 00227 { 00228 s_OneAndOnlyUser = NULL; 00229 --s_NumberOfUsers; 00230 } 00231 else 00232 { 00233 Result = CCR_INVALID_USER; 00234 } 00235 00236 // UpdateUserID.End(); 00237 00238 return Result; 00239 }
|
|
Once the given node has been read or passed as a parameter, call this function to free it for updates. This call should be accompanied by a prior call to PrepareNodeForRead(). The results of the read are undefined if not. See Also: FinalizeNodeUpdate().
|
|
Once the given node has been updated in the tree call this function to ensure its update is complete. This call should be accompanied by a prior call to PrepareForNodeUpdate(). The results of the update are undefined if not. See Also: FinalizeNodeRead().
|
|
Default destructor for the ConcurrencyController.
Definition at line 291 of file ccc.cpp. 00293 { 00294 RESULT Result = CCR_OK; 00295 00296 CriticalSection UpdateOpTable; 00297 00298 if (pOperation == s_pTheActiveOperation) 00299 { 00300 ERROR2IF(s_NumberOfActiveOperations != 1, CCR_INTERNAL_ERROR, "ActiveOps not Unity"); 00301 00302 s_pTheActiveOperation = NULL; 00303 --s_NumberOfActiveOperations; 00304 } 00305 else 00306 { 00307 Result = CCR_INVALID_ARGUMENT; 00308 } 00309 00310 return Result; 00311 }
|
|
Support function to provide a new user id.
Definition at line 406 of file ccc.cpp. 00407 { 00408 UserID NextID = ++s_NextFreeUserID; 00409 00410 // if the NextID is zero, fail it always 00411 if (NextID == 0) 00412 { 00413 --s_NextFreeUserID; 00414 } 00415 return NextID; 00416 }
|
|
Definition at line 142 of file ccc.cpp. 00143 { 00144 // CriticalSection::Init(); 00145 00146 return TRUE; 00147 }
|
|
Allows or disallows access to Operations.
Definition at line 255 of file ccc.cpp. 00257 { 00258 RESULT Result = CCR_OK; 00259 00260 CriticalSection UpdateOpTable; 00261 // UpdateOpTable.Start(); 00262 00263 if (s_NumberOfActiveOperations == 0) 00264 { 00265 ERROR2IF(s_pTheActiveOperation != NULL, CCR_INTERNAL_ERROR, "ActiveOp not NULL"); 00266 00267 s_pTheActiveOperation = pOperation; 00268 ++s_NumberOfActiveOperations; 00269 } 00270 else 00271 { 00272 Result = CCR_TOO_MANY_USERS; 00273 } 00274 // UpdateOpTable.End(); 00275 00276 return Result; 00277 }
|
|
Before reading data in a node or passing it as a parameter to a function, call this function to ensure the integrity of the document tree. This call should be accompanied by a subsequent call to FinalizeNodeRead(). The results of the read are undefined if not. See Also: PrepareNodeForUpdate().
|
|
Before updating a node, call this function to ensure the integrity of the document tree. This call should be accompanied by a subsequent call to FinalizeNodeUpdate(). The results of the update are undefined if not. See Also: PrepareNodeForRead().
|
|
Default destructor for the ConcurrencyController.
Definition at line 179 of file ccc.cpp. 00180 { 00181 RESULT Result = CCR_OK; 00182 00183 CriticalSection UpdateUserID; 00184 // UpdateUserID.Start(); 00185 00186 if (s_NumberOfUsers == 0) 00187 { 00188 UserID NewUserID = GetNewUserID(); 00189 if (NewUserID != NULL) 00190 { 00191 ++s_NumberOfUsers; 00192 } 00193 else 00194 { 00195 Result = CCR_TOO_MANY_USERS; 00196 } 00197 *pNewUserID = NewUserID; 00198 } 00199 else 00200 { 00201 Result = CCR_TOO_MANY_USERS; 00202 } 00203 // UpdateUserID.End(); 00204 00205 return Result; 00206 }
|
|
|
|
|
|
|
|
|
|
|