Portable Tools Library

2.8.1

Table of Contents

Introduction

This document provides reference information for the PTLib C++ class library. It is not intended as a tutorial document.

Last updated 17 May, 2004

Copyright (C) 1999-2003 Equivalence Pty Ltd, All right reserved

Portions Copyright (C) 2004 Post Increment, All Rights Reserved

Overview

PTLib is a moderately large C++ class library that originated many years ago as a method to produce applications that run on both Microsoft Windows and Unix X-Windows systems. It also was to have a Macintosh port as well, but this never eventuated. In those days it was called the PWLib the Portable Windows Library.

Since then, the availability of multi-platform GUI toolkits such as KDE and wxWindows, and the development of the OpenH323 and OPAL projects as primary user of the library, has emphasised the focus on networking, I/O portability, multi-threading and protocol portability. Mostly, the library is used to create high performance and highly portable network-centric applications. So all the GUI abstractions ahave been dropped and it was renamed the Portable Tools Library that you see today.

In addition to these high level functions, basic "container" classes such as arrays, linear lists, sorted lists (RB Tree) and dictionaries (hash tables) are available. These were created before the emergence of STL as a standard, so unfortunately these constructs are incompatible with iterators and generic algorithms.

Development continues in this area, and future versions of PTLib will see increased use of, and compatibility with, STL, but it is a long and slow process.

The library is used extensively by many companies for both commercial and Open Source products. The motivation in making PTLib available as Open Source was primarily to support the OpenH323 and OPAL projects, but it is definitely useful as a stand-alone library to anyone that wishes to write portable applications.

The classes within PTLib are seperated into two types: Base Classes and Console Components The Base Classes contain all of the essential support for constructs such as containers, threads and sockets that are dependent on platform specific features. All PTLib programs will require the Base Classes

The Console Components implement functionality that is usually platform independent, and may not be required for all programs. On some platforms (notably Windows) the Base Classes and Console Components may be divided into discrete library archives. Other platforms (notably Unix platforms) combine all of the code into a single library and rely on the linker to omit code that is not required.

Note that previous versions of PTLib also contained GUI classes and GUI components, but support for these classes has been discontinued.

Using PTLib

Tutorial introductions for PTLib are available elsewhere (see http://toncar.cz/openh323/tut), but some information on how to create a simple program is always useful.

Here is the canonical "Hello world!" program written using the PTLib infrastructure.

// hello.cxx

#include <ptlib.h>

class Hello : public PProcess
{
  PCLASSINFO(Hello, PProcess)
  public:
	void Main();
};

PCREATE_PROCESS(Hello)

void Hello::Main()
{
  cout << "Hello world!\n";
}

// End of hello.cxx

The PCREATE_PROCESS macro actually defines the main()# function and creates an instance of Hello. This assures that everything is initialised in the correct order. C++ does initialisation of global statics badly (and destruction is even worse), so try to put everything into your PProcess descedent rather than globals.

Base Classes

Base Object Classes

I/O Channel Classes

Classes that perform general I/O using the PChannel abstraction

Socket Classes

Implementation of a network sockets abstraction (roughly based on Berkeley sockets)

Process and Thread Classes

Classes that handle processes, multi-threading and synchronsiation.

Miscellaneous Classes

Console Components

HTTP Classes

Implementation of the HTTP protocol

Protocol Classes

Implementation of various Internet-related protocols. Some of these are implemented within PTLib - some require external libraries for support

Miscellaneous Classes

ASN.1 Support Classes

History


Generated on Thu May 27 01:36:47 2010 for PTLib by  doxygen 1.4.7