When an object is successfully modified, the ChangeMgr will send a change notification via the Notification Manager to subscribers registered for the datastore's notifyType, if specified during registration. The notification specifies the type of change and the object affected. A process that plans to make a sequence of modifications can cause a single notification to be sent for the entire sequence by using the ChangeMgr's batch modify API.
The Change Manager does not deal with object content in its "native" form. As a result, it cannot be used to modify objects outside of a synchronization session. Because the Change Manager may need to perform operations both before and after an object's content is changed, it provides begin and end functions that are meant to bracket content changes. The calling application should make the actual change in between calling the begin and end funnctions.
To maximize concurrency, applications should only hold read and write locks for short periods of time. Thus, in general, an application should not hold a read or write lock while waiting for a user to edit a record. Because concurrent edits to a record are possible when the application is not holding a lock, the following scenario is possible:
An application that registered its datastore with dbType kDbTypeSQLite, should perform the following steps to acquire a monitor for a single object:
An application that registered its datastore with dbType kDbTypeSQLite, should perform the following steps to acquire a monitor for the entire datastore:
|
||||||||||||||||
|
Acquire a monitor for an entire datastore.
|
|
||||||||||||||||||||
|
Acquire a monitor for a single object.
|
|
||||||||||||||||||||||||||||
|
Create a new object with an extended guid. This is a special version of alp_hscm_begin_modify for new objects. This version creates a special GUID called an extended GUID, which is a combination of 2 or more GUIDs. This extended GUID is the GUID for the new object. Just like alp_hscm_begin_modify for new objects, a new LUID is returned in pNewLuid. When the object has been created, call alp_hscm_end_modify as normal to tell the Change Manager to accept/reject the new object.
|
|
||||||||||||||||||||||||
|
Create a new object identified by the input GUID. This is a special version of alp_hscm_begin_modify for new objects that have already been assigned a GUID. The input pExternalGuid is the GUID for the new object. Just like alp_hscm_begin_modify for new objects, a new LUID is returned in pNewLuid. When the object has been created, call alp_hscm_end_modify as normal to tell the Change Manager to accept/reject the new object.
|
|
||||||||||||||||||||||||||||
|
Begin an object modify. When a process is ready to create, modify or delete an object it should perform the following steps:
When modifying an object, call this API with state set to kObjectStateModified, pId set to the object's local id and localForwardingAddress set to zero. When deleting an object, call this API with state set to kObjectStateDeleted, pId set to the object's local id and localForwardingAddress set to appropriate forwarding address, or zero if there isn't a forwarding address. If specified, the forwarding address must be a referenceable local id.
|
|
||||||||||||
|
Begin a batch of object modifications. Although the alp_hscm_begin_modify() and alp_hscm_end_modify() calls may be enclosed in a user defined transaction, the ChangeMgr will still send a single notification for each object modified during the transaction. This causes two distinct problems:
To address these problems, the ChangeMgr provides a batch modify mechanism. A call to alp_hscm_begin_modify_batch() starts a transaction that will include any modifications made by subsequent calls to alp_hscm_begin_modify(), alp_hscm_begin_create_with_external_guid(), alp_hscm_begin_create_with_extended_guid() and alp_hscm_end_modify(). A call to alp_hscm_end_modify_batch() ends the transaction by either committing or rolling back all changes since the call to begin the batch. If the batch is committed, the ChangeMgr will send a single notification for the entire batch that specifies the number of objects modified. No notification is sent if the batch fails (since all changes are rolled back).
|
|
||||||||||||||||
|
End an object modify. When modifySucceeded is true, this call causes the Change Manager to:
|
|
||||||||||||
|
End a batch of object modifications.
|
|
||||||||||||
|
Gets the policy associated with a monitor.
|
|
||||||||||||||||
|
Returns the status associated with a monitor. When passed an object monitor, this function will set pStatus->modifiedCount to 1 if the object has been modified since the monitor was acquired; it will set pStatus->deletedCount to 1 if the object has been deleted since the monitor was acquired. If either count is non-zero, an attempt to write the object will cause a conflict or an error, depending on the monitor's policy. When passed a datastore monitor, this function will set pStatus->modifiedCount and pStatus->deletedCount to the number of objects modified and deleted in the datastore since the monitor was acquired.
|
|
||||||||||||
|
Join an batch of object modifications. When datastores share storage, it can be useful to include all of them in a single batch. For example, when importing contacts from a SIM card the contacts application must create objects in three datastores that share the same sqlite database. Creating a batch that includes just one datastore prevents dependent changes from being made in the other contacts datastores. To address this problem, the ChangeMgr allows a datastore to join an existing batch, provided it shares the same database handle and registered for the same notify type. Any changes made to the datastore once it joins the batch become a part of the transaction started by alp_hscm_begin_modify_batch() and are either committed or rolled back when alp_hscm_end_modify_batch() is called.
|
|
||||||||||||
|
Release an object or datastore monitor. This function deallocates all resource associated with the input monitor.
|
|
||||||||||||
|
Sets the policy associated with a monitor.
|
Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.