C++ Class Organization


You use the C++ class library by constructing C++ objects provided by the class library and invoking their member functions. Also, the provided classes may be used as base classes for your classes that modify or extend the functionality of the SmartSockets C++ class library.

Relation to C Language API

The SmartSockets C++ class library is implemented as a layered product whose internals make calls to the C language API. Although this C++ class library provides all the functionality of the underlying C language API at the C++ level, the features of the conventional C language API remain fully available if you wish to call the C language API directly. Figure 1 and Figure 2 relate the conventional C language SmartSockets API to particular C++ classes provided in the SmartSockets C++ class library:

Figure 1 A Programmer’s View of the SmartSockets API

Figure 2 A Programmer’s View of the SmartSockets C++ Classes

As indicated in Figure 2, some of the C language API of SmartSockets, more specifically the utility (Tut*) calls, are not wrapped in the SmartSockets C++ class library. Therefore, you must call these C functions directly from C++ when required. All other C language API calls (including, for example, all the TipcConn*, TipcSrv*, TipcMon*, TipcMsg*, and TipcMt* calls) are available using either the provided C++ wrapper methods from the C++ class library or through direct calls to the C language API.

It is recommended that you try to consistently use either the C++ class library or C API, not both.

Inheritance Hierarchy

The SmartSockets C++ class library includes a number of classes organized into an inheritance hierarchy. These classes are either directly or indirectly derived from the Tobj base class, as shown in Figure 3.

Figure 3 Inheritance Hierarchy

The organization of the SmartSockets class hierarchy reflects and clarifies several object-oriented aspects of SmartSockets that are already present in its C language implementation.

Clear Identification of System Objects

In the C API, the fundamental objects of interest are messages, message types, peer-to-peer connections, RTclient functionality, and monitoring. These system objects are naturally expressed by the SmartSockets classes TipcMsg, TipcMt, TipcConn, TipcSrv, and TipcMon.

Grouping of Functions by Similarity

In the C API, functions are grouped by C language prefixes to indicate similarities in functionality. For example, the functions TipcMtLookup and TipcMtTraverse share the TipcMt prefix. Such similarity is expressed in C++ using member functions. The corresponding C++ class library methods are TipcMt::Lookup and TipcMt::Traverse.

Likewise, consider the SmartSockets functions TipcSrvGetNumQueued and TipcSrvGetSocket. These two functions are represented in the C++ class library by the TipcSrv class member functions TipcSrv::NumQueued() and TipcSrv::Socket().

In C, the corresponding set method to TipcSrvGetSocket is called TipcSrvSetSocket. In C++, the set method TipcSrv::Socket is differentiated from its get variant by its requiring an argument. The corresponding set C++ prototype is TipcSrv::Socket(T_INT4 socket_arg).

Implied Derivation of Functionality

The C language functionality of RTclient (the TipcSrv* API) expands the capabilities of purely peer-to-peer, connection-based message passing (the TipcConn* API) by adding a publish-subscribe message routing capability.

In C++, the augmentation and possible modification of a set of base capabilities is expressed using inheritance and virtual member functions. In the SmartSockets C++ class library, the functionality that SmartSockets connections and RTserver connections have in common is first expressed in the TipcConn base class using virtual functions that the TipcSrv derived class then reimplements.

One example of such common functionality reimplemented in the derived class is represented by the functions TipcConn::Timeout() and TipcSrv::Timeout(). The former member function implementation calls the C function TipcConnGetTimeout(), while the latter reimplements the method, calling TipcSrvGetTimeout() instead.

Functional Abstraction

In C++, an abstract class is a class used only as a base class of some other class; no objects of an abstract class may be created except as objects of a class from which it is derived. Abstract classes are used to express the notion of a general concept (such as shape) of which only concrete variants (such as rectangle or triangle) can actually be used. One such SmartSockets abstract base class is the Tobj class, which manages the error handling conventions that many Tipc* C API functions have in common.

Mapping the C API to C++ Class Member Functions

The TIBCO SmartSockets Application Programming Interface describes in detail the functionality of each of the C API functions. Generally speaking, each such C language function corresponds to a particular member function of a SmartSockets C++ class whose identity can be determined from Table 1.

Table 1 Relationship of C Language API to C++ Classes
For the C Language API Prefix
Functionality Found in the C++ Class
TipcCb*
(Callback only; not wrapped)
TipcConn*
TipcConn
TipcConnCreate*
TipcConn
TipcConnServer
TipcConnClient
TipcMon*
TipcMon
TipcMonClient*
TipcMonClient
TipcMonServer*
TipcMonServer
TipcMsg*
TipcMsg
TipcMt*
TipcMt
TipcSrv*
TipcConn
TipcSrv

How to Find Class Member Function Wrappers of the C API

The index of this guide contains an entry for most C API functions that are wrapped by a C++ class. The C API functions are listed in the index under the entry C API. Go to the page listed for the C API function you are looking up. That page contains information about the C++ member function that wraps that particular C API function.

C++ classes wrapping C API functions that support multiple connections are included with the sscpp library. For more information, see the TIBCO SmartSockets C++ User’s Guide.


TIBCO SmartSockets™ cxxipc Class Library
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com