Package Overview
Note: You must have a license for the OPNET Development Kit to use the Client State package.
The Client State package provides an API that allows your code (the client) to store your structures (the state) with Riverbed Modeler objects. The Client State package helps keep track of your structures when a network model object (node, link, subnet, or path) is copied or destroyed. The package also provides the necessary functions for you to read/write (from/to disk) a serialized form of your structure in either Block or XML format.
To use this package, you must first register an initialization function with Riverbed Modeler. (For information on how to do this, see the documentation on the ets_initialization attribute in “netbiz.ets File Structure“ on page 22.) During initialization, your code must register one or more client state classes. When you register the client state class, you must provide a name for the state class, as well as callback functions for deallocating, copying, reading from and writing to your state.
After you have registered your client state class, you can get and set your state on nodes, links, subnets, and paths. If an object with client state is removed from the network (i.e. cut), or if the model with that object is closed, the deallocation callback is invoked to free the memory that the state used. If an object with a client state is copied to the clipboard, the copy callback function is called.
You use different callback functions to save to or read from disks, depending on the format, as shown in the following table.
Table 6: Callback Functions for Disk I/O
| Operation | Format | Function Called |
|---|---|---|
| Saved to disk | Block | write callback |
| Saved to disk | XML | export callback |
| Read from disk | Block | read callback |
| Read from disk | XML | import callback |
The functions that are called when an object is read from or written to disk are passed the client state, as well as a data structure called a block. The block holds the serialized form of state data in preparation for writing to disk. Your read/write callback function must be able to read/write integers, strings, and double values into the block by calling the appropriate Ets_State_Block_ functions.