Objective-C API Library Reference  4.3.0-42-g45f162a
 All Classes Functions Typedefs Properties Pages
Public Functions | Properties | List of all members
PWApplicationState Class Reference

The PWApplicationState class manages changes between the service and the client application.

Application state is an XML hierarchical tree of properties and values which resides on both the service and the client; it provides a synchronized data store between these components. To maintain application state synchronicity, the differences in state are automatically transmitted between the client and the service; these differences are contained in a diff script, generated whenever PureWeb executes the difference method.

Methods in this class acquire a lock on application state internally; you can also use acquireLock (PWApplicationState) to explicitly lock application state before interacting with it.

See also the PWXmlStateManager class, which provides methods for finer-grained interactions with application state.

Constructors

(id) - init
 

Public Functions

(PWXmlStateLock *) - acquireLock
 
(void) - clear
 
(void) - clearChanges
 
(PWXmlElement *) - copyState
 
(PWXmlElement *) - copyState:
 
(PWXmlElement *) - difference
 
(void) - finishChanges
 
(NSString *) - getValueWithAppStatePath:
 
(void) - initialize:
 
(void) - merge:
 
(void) - setAppStatePathWithValue:value:
 
(void) - startChanges
 
(BOOL) - tryAcquireLock:stateLock:
 

Properties

BOOL isChanged
 
EventHandler * synchronized
 

Methods Descriptions

- (PWXmlStateLock *) acquireLock

Locks the application state. This is necessary if you want the lock to be held for longer than a single operation, for example to perform atomic changes to multiple paths of the application state tree.

Note
Once you acquire the lock, you will need to use the methods in PWXmlStateLock to interact with application state.
- (void) clear

Empties the application state and clears any changes.

- (void) clearChanges

Clears any changes in application state.

- (PWXmlElement *) copyState

Returns a copy of the entire application state.

- (PWXmlElement *) copyState: (NSString *)  path

Returns a copy of the section of application state at the specified path.

- (PWXmlElement *) difference

Compares the application state tree on the client with the application state tree on the service. Returns an XML diff script that describes the differences. At the end of the operation, all changes are cleared.

- (void) finishChanges

Ends the batch changes that were started using startChanges. Any suppressed events will be fired. Note that the lock must be held to call this method.

- (NSString *) getValueWithAppStatePath: (NSString *)  appStatePath

Returns the value currently set at specified path in the application state tree.

- (id) init

Initializes a new instance of PWApplicationState.

- (void) initialize: (PWXmlElement *)  state

Initializes the application state tree to a copy of the specified value.

- (void) merge: (PWXmlElement *)  diffScript

Applies the specified diff script to the application state.

- (void) setAppStatePathWithValue: (NSString *)  appStatePath
value: (NSString *)  value 

Sets the value of the element at the specified path in the application state tree.

- (void) startChanges

Starts batch changes to application state. Events will be suppressed until finishChanges is called. Note that the lock must be held to call this method.

- (BOOL) tryAcquireLock: (NSTimeInterval)  timeout
stateLock: (PWXmlStateLock **)  stateLock 

Attempts to acquire a lock on the application state, timing out if unable to obtain the lock within the specified timeout interval.

Note
If you acquire the lock, you will need to use the methods in PWXmlStateLock to interact with application state.

Properties Descriptions

- (BOOL) isChanged
readnonatomicassign

A Boolean value that indicates whether application state is changed.

- (EventHandler*) synchronized
readwritenonatomicstrong

An event that fires when the client-side application state is synchronized from the service-side application state.