O'Reilly logo

Practical VoIP Using VOCAL by Luan Dang, Cullen Jennings, David Kelly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Class Structure

Implementing an application on top of the base code requires writing a collection of states, one for every state in the state machine, which inherit from the base state class (vocal-1.3.0/proxies/base/state.hxx). This section discusses the operator, state feature, and builder classes.

Operator Class

Most of the operators share a common structure in which all of the work is completed by a function called process, which processes events. As events are passed into this function, the first task performed is a “relevance check.” If the event is not relevant to the operator, the process function returns a zero. If the event is relevant, the process function goes to work on the event. If the operator is not concerned with transforming the state machine into a new state, it returns zero after processing the event. If it is concerned with transforming the machine, it returns an enumerate-type value that indicates the next state or simply returns the type of the next state.

State Class

The state classes also share a common structure. These classes define a name function, their current name, which enables printing out a representation of the state name for debugging purposes. In the constructor, the names of the operators that must be executed in this state must be added by writing an add operator call in which the state creates a new instance of the operator, by creating a new instance of the operator class.

Operators can also be added to run at any time that the state machine ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required