tcdemo C++

Home Products Sales Support Contacting Us Library Search

tcdemo Ada
tcdemo C++

 

This version of tcdemo is written in C++ and uses POSIX Threads for multi tasking.

Source Code

You may download the source from here. The files are:

buffer.cpp makefile reader.h tcu.cpp telemetry.h thread.cpp
buffer.h mutex.h readme tcu.h term-erc.cpp thread.h
cond.h reader.cpp tcdemop.cpp telemetry.cpp term.h

Background

We wrote tcdemo2 using the GNU C++ programming language, and using an evaluation copy of a C++ OOP tool from Object Software International.

(Note: We do not endorse Object Software International or their products, but for the purposes of the demonstration we thought it would be interesting to use a commercial tool to assist with the programming.)

The C++ version was written from scratch, and makes use of object oriented program techniques where possible. Using the earlier ANSI C version as a guide, we wrote a C++ version, taking care to identify classes and instances of classes, and to associate these with files. Each object class is defined in a header file with a filename that is similar to the name of the class. And each class implementation is located in a single ".cpp" file.

Then after the C++ version was tested and shown to generate the same output as the ANSI C version, we reverse-engineered the C++ source into an OMT object model. Then after some refinement of the model, we arrived at a new set of sources.

The model (in OMT format) is shown in Figure 1.

Figure 1: Object Model for tcdemo

One particularly interesting feature of the demonstration is way we have created active objects. Such objects include a POSIX thread, and the thread executes the body code of the object. Other code, such as public operations is run by other threads, and is synchronized with the body code by means of a mutex and a number of condition variables.

The base class for all active objects is the class CThread. Classes derived from CThread are also active, and the body code is supplied by overriding the virtual function 'Body'.

 
Updated May 11, 2005
Copyright XGC Software