BASICS

Platform independent class library

Edition $Revision: 1.5 $, for BASICS version 1.2

$Date: 1998/04/16 22:50:41


Overview

The BASICS class library was written to create a uniform class API for system services frequently used by control programs. Most operating systems support these services but have their own API structure which makes writing code for multiple platforms cumbersome. BASICS is intended to hide these differences, but also add things missing on a specific platform.

This class library is used by the High Energy Physics experiment CLEO, located at Cornell University, Ithaca NY. Therefore the scope of the implemented classes is limited to the use in a monitoring and control system consisting of C++ objects in a networked environment. But I hope it is useful for similar purposes elsewhere.

Supported Platforms

Version 1.2 supports the following platforms:

Installation

The BASICS source comes with a directory tree that can contain other packages related to the CLEO experiment. When you unpack the tar file for the BASICS package, the root directory contains a configure script to create the correct Makefiles for your platform. The source itself can be found in `src/basics'.

Follow the global steps listed here to compile and install BASICS. Also check comments about special considerations for some platforms at the end of this chapter

  1. Run the configure script `./configure'. You might need to set some environment variables to set the correct compilers and/or give parameter(s) to the script like `--srcdir='.
  2. Say `make' to create the libraries.
  3. Say `make install' to install the libraries and headers at the correct places (the default or set with `--prefix='.
  4. If you want to run some test programs using parts of the library, use `make test' to create those executables.

Standard Header File

During the configuration process certain choices are made depending on the capabilites of the C++ compiler and installed third-party/system software. These choices are made by setting C preprocessor macros in the file `sc_config.h' (located at the root of the directory tree).

To insure the correct use of these flags all header (.hxx) and all source files (.cxx) must include the file `sc_stddef.h' as the first header before any other statement! This file contains a `sub-include' command to read `sc_config.h' and subsequent definitions and other macros, some of them depending on the taken choices!

Additionally, some BASICS functions (calling system routines) return a numeric value reflecting the success or not success of this call. Following the UNIX convention, a `0' (zero) means success and a non-zero value means error, decoding the reason for this error (the `error condition').

On the other hand, there are functions returning numbers, that actually represent a boolean value. In this case a 0 (zero) means false signalling an error! In the same category are functions returning a pointer, here NULL reflects an error.

In the BASICS library, we will clarify this situation by using two typedef commands in the `sc_stddef.h' file:

Special Installation Instructions

Class Description

The Cosmic Base Class

Header file: `bsobject.hxx'

Class: bsobject
Let's start with a caveat: You do not need to use this base class, so it is not really the "cosmic" parent to all things in your code. But I found it a very helpful class to get easy readable and traceable debug/error messages from my code during run time. You should seriously consider to make it a/the base class to all important classes in your program.

The main purpose of this class is to name class instantiations, keep a run-time record of RCS version tags, and provide simple means to create readable debug output.

All following functions are useful, when called inside a class method of a class derived from `bsobject'. They will report the file name and line number from where they were called, and the name if the instance, set at construction time.

Additionally, BCO_cout() is a static function of `bsobject', that you can call anytime. It returns the `current output stream' of the BASICS library, which is cout by default, or any output stream set with setOutput(). It will not insert any instance or code line information into the stream.

Constructor: bsobject::bsobject (const char* name, const char* rcs)
Constructor of the bsobject class. It stores the pointer in the private variables of the class.

Example:


class example : virtual public bsobject
{
  example(const char* name) :
 bsobject(name,
 "$Id: basics.texi,v 1.5 1998/04/16 22:50:41 ahw Exp $") {}
};

This code shows, how to pass the name of an instantiation to the bsobject base class, and how the RCS id string is generated. The derived classes should normally use the virtual public base class qualifiers. This generates a single bsobject instantiation, even if a class has multiple base classes, each having bsobject in their class tree.

Constructor: bsobject::bsobject ()
Constructor of the bsobject class with no string parameters. In rare cases the class information is not needed, so we also provide a "default constructor".

Destructor: virtual bsobject::~bsobject ()
Destructor of the bsobject class. It is declared virtual to anticipate access to the correct destructor of any derived classes through this function. The body of this function is empty.

Method: const char* bo_name ()
Retrieves the string pointer from the bsobject data part that contains the name string for this instantiation. This string is also used for the debug output, so you know, which instantiation of a certain object has produced it.

Method: const char* rcs_id ()
Retrieves the string pointer from the bsobject data part that contains the RCS id string.

All objects have one RCS id. Therefore the "last" object in the inheritance tree sets this value, since its constructor is called last.

Method: void setOutput (ostream& strm)
Redirects the output of BCO_...() and CCO_...() to the given output stream (see section Debug Help for Non-Class Functions for the CCO_...... functions).

Method: void setDateSwitch (Boolean value)
Changes the global `switch', whether date/time information is printed in the debug output. TRUE adds the date to the output.

Method: Boolean getDateSwitch ()
Returns the current value of the global `switch', whether to include date/time information in debug output.

Method: ostream& BCO_error ()
Generates an error message following the "Emacs standard" format.

Example:


BCO_error()<< "Could not open file!" <<endl;

-|Example.cxx:123: **ERROR**: Could not open file!

Method: ostream& BCO_warning ()
Generates a warning message following the "Emacs standard" format.

Example:


BCO_warning()<< "Configuration data stale!" <<endl;

-|ConfigDB.cxx:1202: Warning: Configuration data stale!

Method: ostream& BCO_info ()
Generates an information message following the "Emacs standard" format.

Example:


BCO_info()<< "Checking HV..." <<endl;

-|Interlock.cxx:410: Info: Checking HV...

Method: ostream& BCO_debug ()
Generates a debug message following the "Emacs standard" format. It also adds the name of the instance generating this output.

All these messages are switched off, if during compile time the switch _DEBUG is not defined.

Example:


BCO_debug()<< "List was empty." <<endl;

-|Example.cxx:132: Debug (Test): List was empty.

Method: ostream& BCO_cout ()
Just returns the current stream for text output. This is a static method, which means you can call it even without using any instance of the class `bsobject'. (Do not forget to provide the namespace, though)

Example:


BCO_cout()<< "Version 1.03 started!" <<endl;

-|Version 1.03 started!

Method: basics::Result initOutput (int& argc, char** argv)
This method can be called to allow the runtime option `-logFile' to switch the output stream of `bsobject' to a file. Also, you can change the output format by suppressing the date/time tag in front of the output. The option is called `-logNoDate'.

This method uses the `runtime' library internally to extract the parameters from the given runtime option(s). (see section Runtime Option Parsing)

Private data: bsobject symName
This pointer holds the reference to the name string. bsobject does not duplicate the string given in the constructor! It only copies the pointer value. Since almost all the time, the name string is given as a fixed string (e.g. using "Example"), this is no problem and saves time.

Private data: bsobject rcsid
This pointer holds the reference to the RCS id string. As in the case of symName only the reference is stored, since this id is always a fixed string.

Class Representing a Time

Header file `btime.hxx'

Class: btime
This class stores date/time information internally and can be used to manipulate them or convert them to other formats.

It is not allowed to create an `empty' btime class instance! Always use a provided static function to create it, like getNow(). All functions with a name starting with get are in fact static and return a copy of a valid btime instance. Use these functions to initialize or set any variable of type btime. This can be done at declaration time, calling the copy constructor to store the data in the local variable.

Example:


 static btime midnight_1_1_1970 =
   btime::getFromUTCText("UTC: 01/01/1970 00:00:00");

There are many conversion and comparison operators to allow for a convenient user API of a btime instance. Its main use inside BASICS is the "tagging" of debug output generated by bsobject functions with the current date/time (see section The Cosmic Base Class).

The correctness of local date/time output depends on the correct choice of the timezone you are working in. Internally, no time zones or Daylight Saving Time periods are used, only Unversal Time Coordinated (UTC) times!

Normally, the configuration steps will use the timezone found on the machine this library was compiled on and compile it into the code as default. But you can force the `configure' script to use a different timezone with the option `--with-timezone'. See section Time Zone Problem how a timezone is specified.

struct: preciseTime
A machine-dependent structure containing the most precise time information available. It is used internally to create the current time and is available for the user for special cases.

Constructor: btime::btime (btime&)
Construct a new instance and copy value of given btime.

Destructor: virtual btime::~btime ()
Empty destructor.

Set virtual to correctly call destructors of derived classes.

Method: btime getNow ()
A static function to create an instance of btime that contains the current time.

This is a costly method, so if you want to use a temporary btime variable avoid using this function to fill it.

Method: btime getFromTimeval (preciseTime* tp)
Copy/convert data stored in structure into an btime instance.

This structure is machine-dependent.

Method: btime getFromJulianDate (long JDint, double JDfraction)
Use date/time given as a Julian date and create a btime instance.

Note: Use this method to fill a temporary btime variable


 btime tmp = btime::getFromJulianDate(0, 0);

Remember, that this (astronomical) time representation uses the Universal Time Coordinated (UTC) time and starts a day at 12:00 noon, UTC.

Method: btime getFromLocalText (const char* text)
Converts a date and time given as text for the current location into a btime instance.

The format of the string is "<TimeZone>: MM/DD/YYYY HH:MM:SS.ssssss". Timezone is a string describing the current location's time zone. (see section Time Zone Problem) It will complain, if the strings do not match. This might also happen, if the given time is actually in a different DST period than indicated by this string.

Method: btime getFromUTCText (const char* text)
Converts a date and time given as text for the Universal Time Coordinated (UTC) `time zone' into a btime instance.

The format of the string is "UTC: MM/DD/YYYY HH:MM:SS.ssssss".

Method: btime getFromUTCTmStruct (struct tm* theTime, double us = 0.0)
Copy/convert data stored in the ANSI-C tm structure into a btime instance. You can also provide sub-seconds expressed in usec. It is assumed, the date and time was given in the UTC time zone.

Method: btime getFromLocalTmStruct (struct tm* theTime, double us = 0.0)
Copy/convert data stored in the ANSI-C tm structure into a btime instance. You can also provide sub-seconds expressed in usec. It is assumed, the date and time was given in the local time zone setup inside of the time library (see section Time Zone Problem).

Method: btime getFromTimeT (time_t seconds1970, double us = 0.0)
Convert the given number of seconds since Jan 1 1970, midnight UTC, to a btime instance. You can also provide sub-seconds expressed in usec.

Method: btime E2000()
Returns a btime representing Jan 1st, 2000, 12:00 midnight, UTC.

This is useful for astronomical programs using the `epoch 2000' as reference.

Method: btime aSecond (double mul = 1.0)
Static function returning a btime instance representing a time difference of multiple of seconds. Useful in conjunction with the `+', `-', and comparison operators.

Example:


  btime timer = btime::getFromJulianDate(2450781l, 0.5000);
  timer += btime::aSecond();

The default parameter value creates exactly 1 second.

Method: btime aMinute (double mul = 1.0)
Static function returning a btime instance representing a time difference of multiple of minutes. Useful in conjunction with the `+', `-', and comparison operators.

Example:


  btime timer = btime::getFromJulianDate(2450781l, 0.5000);
  timer += btime::aMinute();

The default parameter value creates exactly 1 minute.

Method: btime aHour (double mul = 1.0)
Static function returning a btime instance representing a time difference of multiple of hours. Useful in conjunction with the `+', `-', and comparison operators.

Example:


  btime timer = btime::getFromJulianDate(2450781l, 0.5000);
  timer += btime::aHour();

The default parameter value creates exactly 1 hour.

Method: btime aDay (double mul = 1.0)
Static function returning a btime instance representing a time difference of multiple of days. Useful in conjunction with the `+', `-', and comparison operators.

Example:


  btime timer = btime::getFromJulianDate(2450781l, 0.5000);
  timer += btime::aDay();

The default parameter value creates exactly 1 day.

Method: btime aWeek (double mul = 1.0)
Static function returning a btime instance representing a time difference of multiple of weeks. Useful in conjunction with the `+', `-', and comparison operators.

Example:


  btime timer = btime::getFromJulianDate(2450781l, 0.5000);
  timer += btime::aWeek();

The default parameter value creates exactly 1 week.

Method: double inSeconds ()
Convert the time in this instance (interpreted as a time difference) into seconds.

Method: double inMinutes ()
Convert the time in this instance (interpreted as a time difference) into minutes.

Method: double inHours ()
Convert the time in this instance (interpreted as a time difference) into hours.

Method: double inDays ()
Convert the time in this instance (interpreted as a time difference) into days.

Example:


  btime timeDiff = timerNow - timer;
  cout << timeDiff.inDays()<<"d = "<<timeDiff.inHours()<<"h" << endl;

Method: void convertToJulianDate (long& JDint, double& JDfraction) const
Extract the current time in this instance and convert it into a Julian date and its fraction.

Remember, that this (astronomical) time representation uses the Universal Time Coordinated (UTC) time and starts a day at 12:00 noon, UTC.

Method: void convertToTmStruct(struct tm* theTime, double* usec = NULL) const
Extract the current time in this instance, convert it into an ANSI-C struct tm for the UTC time zone, and (if needed) the sub-second part expressed in usec.

Method: void convertToTmStruct(struct tm* theTime, double* usec = NULL) const
Extract the current time in this instance, convert it into an ANSI-C struct tm for the local time zone, and (if needed) the sub-second part expressed in usec.

Method: void convertToTimeVal (preciseTime* theTime) const
Extract the current time in this instance and convert it into the machine-dependent structure preciseTime.

Method: time_t convertToTimeT () const
Extract the current time in this instance and convert it into the ANSI-C time_t value, representing the number of seconds since Jan 1st, 1970, midnight UTC.

Method: void convertToLocalText (char*& text) const
Extract the current time in this instance and convert it into a readable text representing the time at the current location.

Format: <TimeZone>: MM/DD/YYYY HH:MM:SS.ssssss

Since time zones and daylight saving times are correctly handled, <Timezone> will be the currently used zone. (see section Time Zone Problem)

Note: This call overwrites the pointer text. The new value points to a character string which was allocated on the free store. The caller has to free this memory with "delete [] text" later!

Method: void convertToUTCText (char*& text) const
Extract the current time in this instance and convert it into a readable text representing the time in Universal Time Coordinated (UTC) time.

Format: UTC: MM/DD/YYYY HH:MM:SS.ssssss

Note: This call overwrites the pointer text. The new value points to a character string which was allocated on the free store. The caller has to free this memory with "delete [] text" later!

Method: double convertToMJD () const
Extract the current time in this instance and convert it into `modified Julian Date' the fits in a double with enough sub-day resolution.

Used by many astronomical tools. MJD is defined as mjd = jd - 2440000.

Operations: btime =
Assignment operator to copy a time into a variable.

Operations: btime +
Add to times.

Operations: btime -
Subtract a time from another time.

Operations: btime +=
Add to a time and store it back.

Operations: btime -=
Subtract from a time and store it back.

Operations: btime ==
Operator to check for equivalence of times.

Operations: btime ==
Operator to check for not equivalence of times.

Operations: btime >
Operator to compare the order of times. Larger means `later' in the time order.

Operations: btime <
Operator to compare the order of times. Smaller means `earlier' in the time order.

Operations: btime >=
Operator to compare the order of times. Larger means `later' in the time order.

Operations: btime <=
Operator to compare the order of times. Smaller means `earlier' in the time order.

Time Zone Problem

There is nothing worse than time zones and Daylight Saving Times!

But we stopped whining, and tried to implement a rudimentary management of this issue into the btime class. It might not work for all, but for the American and European zones it should be sufficient. Also, it can not accomodate for changes in the DST rules that happened over the last 100 years. We only try to manage the current rules, that's hard enough.

Method: void setTimezone (const char* TZstring)
This is how you can change the timezone of `local output'. It is a static function to set the time zone of all instances created after calling this function.

TZstring contains the following information:

A default value is already set at compile time and is selected at configuration time.

Method: void setThisTimezone (const char* TZstring)
Set the time zone of this particular instance of btime.

Method: const char* getTimezone ()
Get the time zone set for all future instances of btime.

Method: Boolean getTimezone () const
Get the value of the internal DST switch for this instance of btime. It is TRUE if the represented time is during the Daylight Savings Time (DST) period of the time zone set for this instance.

Method: const char* getCurrentZoneName () const
Get the name of the time zone this instance of btime is setup for. During Daylight Savings Time (DST) period the time zone might have a different name. Then it will return that name.

Method: basics::Result initTimezone (int& argc, char* * argv)
Call this static function to give the user the option to change the default `time zone offset' using a run time parameter. You should not call this function! Rather use basics::init, which in turn calls this method.

The option -TZ with a string as parameter is recognized by this function.

It uses the `runtime' library internally to extract this parameter from the given runtime option. (see section Runtime Option Parsing)

Runtime Option Parsing

Header file `runtime.hxx'

Class: basics
These are simple static functions, stored in the `namespace' basics:: to avoid messing with the global namespace.

They are meant to be called in the main part of a program to retreive any valid option given to the started process at run time. Additionally, they provide a `help' facility that describes the option(s) if the user starts the program with the `command' `-help'.

To signal the existence of an option, or that `-help' was found (which normally should terminate the program gracefully after printing the help lines) three return values are provided (coded in an enum): `NotFound', `Found', and `Help'.

VxWorks: There is a special function for VxWorks to transform a given string into the UNIX standard variables argc and argv: `runtimeTransform'.

Since VxWorks does not support a function main in a program, use a string parameter in the function that is called to start a program. You should use `#if ... #endif' commands in your code to make this work properly!

Example:


#if defined(__vxworks)
extern "C" int program(char* params);

int program(char* params)
{
  int argc;
  char** argv;

  basics::runtimeTransform(params, argc, argv);
#endif

#if defined(__unix)||defined(_WIN32)
int main(int argc, char **argv)
{
#endif
 ...
}

Enum: basics Result
An enum to return the parsing result to the caller. Possible values are

Method: Result runtime_switch_opt (int& argc, char** argv, const char* option_name, const char* variable_name, int& variable)
This function searches for a switch options. A `switch' is an option that is of boolean type and is FALSE or `off' if the options string is absent, and TRUE or `on' if the options string is present No further parameter is needed!

Pass the option string as `option_name', the explanation as `variable_name', and the actual (int) variable as `variable'. The function will remove the option from the `argv' array if it is found (adjusting `argc' also) and return `Found'. Otherwise it will return `NotFound' or `Help', if the option string `-help' was found.

(In this special case the return value corresponds directly with the value of `variable'.)

Example:


  basics::Result res;
  int onOff;

  res = basics::runtime_switch_opt(argc, argv,
                                   "-on", "Lamp switch",
                                   onOff);

Method: Result runtime_int_opt (int& argc, char** argv, const char* option_name, const char* variable_name, int& variable)
This function searches for a int options. An `int' is an option that is of int type (representing a number) and is left unchanged if the options string is absent, and set to the given value if the options string is present. After the option string has to follow a SPACE and then a string representing an integer numerical value.

Pass the option string as `option_name', the explanation as `variable_name', and the actual (int) variable as `variable'. The function will remove the option and the parameter from the `argv' array if it is found (adjusting `argc' also) and return `Found'. Otherwise it will return `NotFound' or `Help', if the option string `-help' was found.

Use this return value for changing the program's behaviour, or just use the default value you set before you called this function.

Example:


  basics::Result res;
  int number = 1;

  res = basics::runtime_int_opt(argc, argv,
                                "-times", "multiply by",
                                number);

Method: Result runtime_long_opt (int& argc, char** argv, const char* option_name, const char* variable_name, int& variable)
This function searches for a long options. An `int' is an option that is of long type (representing a number) and is left unchanged if the options string is absent, and set to the given value if the options string is present. After the option string has to follow a SPACE and then a string representing an integer numerical value.

Pass the option string as `option_name', the explanation as `variable_name', and the actual (long) variable as `variable'. The function will remove the option and the parameter from the `argv' array if it is found (adjusting `argc' also) and return `Found'. Otherwise it will return `NotFound' or `Help', if the option string `-help' was found.

Use this return value for changing the program's behaviour, or just use the default value you set before you called this function.

Example:


  basics::Result res;
  long date = 2450034l;

  res = basics::runtime_long_opt(argc, argv,
                                "-JD", "Julian Date",
                                date);

Method: Result runtime_size_t_opt (int& argc, char** argv, const char* option_name, const char* variable_name, size_t& variable)
This function searches for a size_t options. An `size_t' is an option that is of size_t type (representing a non-negative number, useful for e.g. buffer sizes) and is left unchanged if the options string is absent, and set to the given value if the option string is present. After the option string has to follow a SPACE and then a string representing a non-negative integer numerical value.

Pass the option string as `option_name', the explanation as `variable_name', and the actual (size_t) variable as `variable'. The function will remove the option and the parameter from the `argv' array if it is found (adjusting `argc' also) and return `Found'. Otherwise it will return `NotFound' or `Help', if the option string `-help' was found.

Use this return value for changing the program's behaviour, or just use the default value you set before you called this function.

Example:


  basics::Result res;
  size_t chunk = 16;

  res = basics::runtime_size_t_opt(argc, argv, "-chunk",
                                "chunk size",chunk);

Method: Result runtime_tm_opt (int& argc, char** argv, const char* option_name, const char* variable_name, struct tm& variable)
This function searches for a time options, stored as the tm structure. An `tm' is an option that is of tm type (representing a time) and is left unchanged if the options string is absent, and set to the given value if the option string is present. After the option string has to follow a SPACE and then a string representing a time.

The time string can have multiple formats:

All combinations are allowed and found until the next option (marked with a `-') or the end of option array is reached.

Note: If the library is compiled for it, the date string will have the day and month field swapped! Check the configuration file `sc_stddef.h' or read the explanation given by the `-help' switch.

Pass the option string as `option_name', the explanation as `variable_name', and the actual (tm) variable as `variable'. The function will remove the option and the parameter from the `argv' array if it is found (adjusting `argc' also) and return `Found'. Otherwise it will return `NotFound' or `Help', if the option string `-help' was found.

Use this return value for changing the program's behaviour, or just use the default value you set before you called this function.

Example:


  basics::Result res;
  time_t now = time(NULL);
  struct tm* when = localtime(&now);

  res = basics::runtime_tm_opt(argc, argv,
                               "-start", "Start time",
                               *when);

Method: Result runtime_float_opt (int& argc, char** argv, const char* option_name, const char* variable_name, float& variable)
This function searches for a float option. An `float' is an option that is of float type (representing a real number) and is left unchanged if the options string is absent, and set to the given value if the options string is present. After the option string has to follow a SPACE and then a string representing an real numerical value.

Pass the option string as `option_name', the explanation as `variable_name', and the actual (float) variable as `variable'. The function will remove the option and the parameter from the `argv' array if it is found (adjusting `argc' also) and return `Found'. Otherwise it will return `NotFound' or `Help', if the option string `-help' was found.

Use this return value for changing the program's behaviour, or just use the default value you set before you called this function.

Example:


  basics::Result res;
  float weight = 100.0;

  res = basics::runtime_float_opt(argc, argv, "-weight",
                     "weight of the users (in kg)", weight);

Method: Result runtime_double_opt (int& argc, char** argv, const char* option_name, const char* variable_name, double& variable)
This function searches for a double option. An `double' is an option that is of double type (representing a real number) and is left unchanged if the options string is absent, and set to the given value if the options string is present. After the option string has to follow a SPACE and then a string representing an real numerical value.

Pass the option string as `option_name', the explanation as `variable_name', and the actual (float) variable as `variable'. The function will remove the option and the parameter from the `argv' array if it is found (adjusting `argc' also) and return `Found'. Otherwise it will return `NotFound' or `Help', if the option string `-help' was found.

Use this return value for changing the program's behaviour, or just use the default value you set before you called this function.

Example:


  basics::Result res;
  double speed = 65.0;

  res = basics::runtime_double_opt(argc, argv, "-limit",
                         "speed limit (in mph)", speed);

Method: Result runtime_string_opt (int& argc, char** argv, const char* option_name, const char* variable_name, char*& variable)
This function searches for a string option. An `string' is an option that is of char* type (representing any text not containing a SPACE) and is left unchanged if the options string is absent, and set to the given value if the options string is present. After the option string has to follow a SPACE and then a string representing any text

Pass the option string as `option_name', the explanation as `variable_name', and the actual (float) variable as `variable'. The function will remove the option and the parameter from the `argv' array if it is found (adjusting `argc' also) and return `Found'. Otherwise it will return `NotFound' or `Help', if the option string `-help' was found.

Use this return value for changing the program's behaviour, or just use the default value you set before you called this function.

Example:


  basics::Result res;
  char* device = "/dev/null";

  res = basics::runtime_string_opt(argc, argv, "-dev",
                                "output device name", device);

Debug Help for Non-Class Functions

Header file: `console.hxx'

Class: (global)
These functions are not inside a class, but belong to the global name space. They can be called by any part of the program, so they do not contain any class information in their output.

They are also declared with the extern "C" keyword, so that any C code can call them, too. The text string is given the same way as for printf, first a format string and then variable number of parameters.

All functions names correspond to the output methods in the bsobject class, they only start with CCO instead of BCO. Secondly, you have to provide the macros __FILE__ and __LINE__ "by hand" when you call one of these functions.

Comment: The output of these functions can not be redirect but go all to stdout.

Function: void CCO_error (char* file, int line, char* fmt, ...)
Generates an error message following the "Emacs standard" format. It also uses the errno variable to generate a human--readable text containing the error. Example:

CCO_error(__FILE__,__LINE__,"Reading configuration.\n");

-|HV.cxx:490: file not found: (C): Reading configuration.

Function: void CCO_warning (char* file, int line, char* fmt, ...)
Generates a warning message following the "Emacs standard" format.

Example:


CCO_warning(__FILE__,__LINE__,
            "User `%s' unknown!  Hacking attempted?\n",
            password->user);

-|Password.cxx:312: warning (C): User `ahw' unknown!\
 Hacking attempted?

Function: void CCO_info (char* file, int line, char* fmt, ...)
Generates an information message following the "Emacs standard" format.

Example:


CCO_info(__FILE__,__LINE__,"Comitting to %s.\n", state);

-|RunControl.cxx:312: info (C): Comitting to Paused.

Function: void CCO_debug (char* file, int line, char* fmt, ...)
Generates a debug message following the "Emacs standard" format.

All these messages are switched off, if during compile time the switch _DEBUG is not defined.

Example:


CCO_debug(__FILE__,__LINE__,"List %s was empty.\n", group);

-|Alarm.cxx:132: debug (C): List Alarm was empty.

Function: void CCO_printf (char* fmt, ...)
Direct interface to printf, implemented for symmetry reasons.

Example:


CCO_printf("Going home...\n");

-|Going home...

Exit Manager Class

Header file: `xitman.hxx'

Class: BEX_xitman
Base classes: private BEX_func_list, virtual public bsobject

The exit manager class BEX_xitman is a list of C functions that get called when the "main thread" of a program exits or receives certain signals.

The list is setup using the "singleton" behavior, which means the constructor checks for the existence of this list in a place shared between all threads inside the program. Only if it does not exist, it will be created from scratch. Otherwise it will use the reference to the existing list.

The order of the added functions is preserved, and when the exit manager is "active" it will call all functions in the reverse order. Rule Always add a new function after you used resources! Then, these resources get cleaned up after your new `cleanup function' was called.

Example:


  class BEX_xitman *xm;

  // Get reference to exit manager, create it if necessary.
  xm = new BEX_xitman;
  assert( xm != NULL);

  // Insert destruction into exit manager
  if (-1 == xm->add(BSP_removeResources))
    BCO_warning() << "Add function to exit manager failed" << endl;

  // Remove reference. The real manager is static and
  // will not be touched
  delete xm;

Note: In order to use the BASICS library in a shared manner in VxWorks, normal user programs must not add any cleanup function to the xitman directly! Use the ANSI function atexit for this purpose!

Constructor: BEX_xitman::BEX_xitman (const char* name)
Constructor of the bsobject class.

Create the exit function list or return a reference to it.

Constructor: BEX_xitman::BEX_xitman ()
Constructor of the bsobject class. This time do not give it a name

Create the exit function list or return a reference to it.

Destructor: BEX_xitman::~BEX_xitman ()
Destructor of the bsobject class.

It does not remove the exit function list, so it is a dummy function for symmetry reasons. The list is removed when the thread exits, only.

Method: FuncReturn add (void (*f)())
Adds an exit function to the list.

The function's signature is fixed to return no value, and to receive no parameters.

Private Method: void init_class ()
The class initialiser function shared between the two constructors.

It checks the flag iamAlive and performs the following actions if it is FALSE:

  1. Install the C function BEX_cleanup as function to be called when the thread exits.
  2. Install a second C function as signal handler (BEX_signalexit) which will call exit after some informational output. This in turn will call BEX_cleanup to stop the thread.
  3. Set iamAlive to TRUE.

Private static data: BEX_xitman iamAlive
This variable is a flag, set to TRUE after the constructor was called for the first time. It is needed to implement the "singleton" behavior of the class.

Class: BEX_func_list
This is a simple list class to setup an ordered list of function pointers.

It is used by BEX_xitman by having it as a parent class. The list entries itself are stored in a globally accessible place so they are shared between all threads.

Constructor: BEX_func_list::BEX_func_list()
The constructor of the list, setting up an empty list.

Destructor: BEX_func_list::~BEX_func_list()
The destructor of the list.

Method: FuncReturn add (void (*f)())
Adds this function to the list. It is inserted at the start of the list, so that it is called first if it was added last.

Method: FuncReturn remove (void (*f)())
Removes this function of the list.

Comment: The following functions are changing the internal state of BEX_func_list and are therefore not thread safe. However, this is no problem at all, since these functions are used by the Operating System when performing the thread exit, so there is no other thread using this class!

Method: void(*first()) ()
Returns the first entry of the list or NULL if list is empty.

Method: void(*next()) ()
Returns the next entry of the list or NULL if it reached the end.

Semaphore Classes

Header file: `bsemaphore.hxx'

Class: BSP_Binary
Base classes: virtual public bsobject, private BSP_SBase

A class implementing a "binary semaphore".

This semaphore has two states: full or empty. Consequently, it has two basics methods: take and give. If the semaphore is "empty" a call of take will block the calling thread until the semaphore gets filled by some other thread. If multiple threads are waiting for the same semaphore, this give action will activate a single thread and keep the others blocked. This happens because the first action of the activated thread is to empty the semaphore. Which one of the threads is activated is not defined.

In contrast to a mutual exclusive semaphore, the give method can be called by any thread, not only by the one that called take last.

Constructor: BSP_Binary::BSP_Binary (const char* name)
The constructor of the semaphore. It gives the semaphore a name and puts it into the state "full".

Constructor: BSP_Binary::BSP_Binary ()
Another constructor of the semaphore. It performs the same actions as the constructor above, but it does not name the semaphore.

Destructor: virtual BSP_Binary::~BSP_Binary ()
Destructor of the semaphore. It releases all system resources related to this instance.

It is virtual so we can call the correct destructor of any derived class.

Method: FuncReturn take ()
Tries to empty a full semaphore. If the semaphore is already empty, it blocks the calling thread.

The return value reflects the success of the action.

Example:


BSP_Binary start;

while (TRUE)
  {
  start->take();
  action();
  }

This example shows an infinite loop that executes once per "event". The "event" is communicated to this thread by any other thread using give on the semaphore start.

Method: FuncReturn give ()
Fills the semaphore and activates a waiting thread, if necessary.

The return value reflects the success of the action.

Method: Boolean isEmpty ()
Returns TRUE if the semaphore is in the "empty" state, FALSE otherwise.

Example:


// Wait for timeout or actions through the semaphore
for (int i = 0; i < myRate/2; i++)
  {
  BPT_sleep(2);

  if (!mySynch->isEmpty())
    {
    BCO_debug()<< "Got wakeup call!" <<endl;
    mySynch->take();
    break;
    }
  }

This code waits for a signal through the semaphore, but also wants to stop after a timeout. So we avoid blocking the thread by only using isEmpty to check for the state of the semaphore.

Private Method: void init_class ()
The actual intialiser of the class, shared between the two constructors.

Class: BSP_Mutex
Base classes: virtual public bsobject, private BSP_SBase

A class implementing a "mutual exclusive semaphore".

Similar in behavior as the BSP_Binary class, once the semaphore is "locked" it can only by "unlocked" by the same thread. lock will block the calling thread, if the semaphore is already "locked". For this semaphore the same rules apply for activating threads after an unlock call as for BSP_Binary (see section Semaphore Classes).


BSP_Mutex protect;

protect->lock();
protected->change();
protect->unlock();

This example shows a class protected which is "guarded" by the semaphore protect. Only one thread can execute the function change at any time.

(This code is not a good template, since somebody could call change without using the semaphore. It is much better, to derive the protected class from BSP_Mutex or have a semaphore as data member and then let change test that it is actually locked.)

Constructor: BSP_Mutex::BSP_Mutex (const char* name)
The constructor of the semaphore. It gives the semaphore a name and puts it into the state "unlocked".

Constructor: BSP_Mutex::BSP_Mutex ()
Another constructor of the semaphore. It performs the same actions as the constructor above, but it does not name the semaphore.

Destructor: virtual BSP_Mutex::~BSP_Mutex ()
Destructor of the semaphore. It releases all system resources related to this instance.

It is virtual so we can call the correct destructor of any derived class.

Method: FuncReturn lock ()
Tries to lock a free semaphore. If the semaphore is already locked, it blocks the calling thread.

The return value reflects the success of the action.

Method: FuncReturn unlock ()
Unlocks a semaphore. If the semaphore was locked, it activates a blocked thread if necessary.

The return value reflects the success of the action.

Method: Boolean isLocked ()
Checks the state of the semaphore and returns TRUE if it is locked, FALSE otherwise.

Private Method: void init_class ()
The actual intialiser of the class, shared between the two constructors.

Class: BSP_SBase
All mentioned semaphore classes are using similar resources provided by the Operating System. They therefore are using the same cleanup function to remove those through the exit manager (see section Exit Manager Class). To reuse this code a base classe to all semaphore classes was written.

One of the most important design issues of this class is that it has the exit function used by the exit manager as a friend of the class.

Since all semaphore classes are derived from BSP_SBase the contruction of any of those will

  1. First call the constructor of BSP_SBase, eventually registering the cleanup function.
  2. Call the constructor of the particular class.
  3. This constructor will call memorizeSemaphore when the system resources are allocated in its function code.

Constructor: BSP_SBase::BSP_SBase ()
The constructor of the resource management class.

Destructor: virtual BSP_SBase::~BSP_SBase ()
The destructor of the resource management class. It is an empty function, since no resources are removed in here...

Method: FuncReturn memorizeSemaphore (SEM_ID sid)
Adds this semaphore to the list of actively used resources. The exit manager will delete those, if the thread exits without deleting them first. This is used in the semaphore constructor.

Method: FuncReturn forgetSemaphore (SEM_ID sid)
Removes the semaphore from the list of active resources. This is used in the semaphore destructor.

Private static data: BSP_SBase first_time
This variable is a flag, set to TRUE after the constructor was called for the first time. It is needed to flag whether the exit function is installed using an BEX_xitman (see section Exit Manager Class) instance.

Thread Class

Header file: `bthread.hxx'

Class: BPT_Pthread
Base class: virtual public bsobject

A class implementing a pseudo--POSIX thread. Although most of the supported platforms are supposed to have a POSIX thread library, there are multiple "flavors" of threads. This class presents an API which contains similar ideas but is tailored to the specific need of controll threads.

There are two ways of using this class:

  1. Deriving a subclass and overriding the virtual function execMethod.
    
    class MyThread : public BPT_Pthread
      {
      private:
        void* execMethod(BPT_ArgArray* Args);
    
      public:
        MyThread(const char *name) :
      bsobject(name,
      "$Id: basics.texi,v 1.5 1998/04/16 22:50:41 ahw Exp $"),
                     BPT_Pthread() {}
        ~MyThread() {}
      };
    
    
    This code will later define the function MyThread::execMethod which will be executed when the thread is started.
  2. Instantiating the class and giving the constructor a function pointer (Deprecated!).
    
    extern "C" void* thread_1(BPT_ArgArray* );
    
    BPT_Pthread c_thread("doomed", thread_1);
    
    
    Here the constructor receives the function pointer thread_1, and this function is called when this thread is started.

Constructor: BPT_Pthread (const char* name)
Creates all necessary system resources for starting a thread. It also names this instance.

The thread is not started yet. The function startThisThread is used for this, after the user has possibly changed same parameters how the thread is executed.

Constructor: BPT_Pthread ()
Same as above, but it does not name the object.

Constructor: BPT_Pthread (const char* name, void* (*f)(BPT_ArgArray*))
This constructor sets the "main function" of the thread to f.

Destructor: virtual ~BPT_Pthread ()
Removes the resources used in this class. It dose not influence any active threads.

Method: int identity (pthread_t& id)
This functions returns the id of the thread, which is a system dependent type. The one shown here is for systems that actually support POSIX threads.

The return value reflects the success of this call.

Method: FuncReturn changeAttr ()
This method is not yet implemented. It is meant to give a standard API to change the thread attributes before starting the thread.

Method: FuncReturn setArgument (int num, void* new_arg)
This is the only way to give parameters to a thread!

With this call the parameter number num is set to the value new_arg. The type of this parameter allows pointers and numbers with their size smaller than a pointer to be passed to the thread function.

The parameters are recorded in the class BPT_ArgArray, which has space for upto 10 parameters. This maximum number is the OS limit of the VxWorks system, so we have to enforce it anywhere. However, it should never be any real constraint.

Example:


c_t.setArgument(0, (void *)20);
c_t.startThisThread(0);

b_t.setArgument(0, (void *)&c_t);
b_t.startThisThread(0);

Method: virtual void* execMethod (BPT_ArgArray* args)
This function is called, when the thread is started. You can retreive parameters using the BPT_ArgArray class.

Example:


void *OtherThread::execMethod(BPT_ArgArray *Args)
  {
  BPT_Pthread* toJoin;

  if (Args)
    BPT_GetNextArg(Args, (void **)&toJoin);
  else
    {
    printf("NULL ptr argument\n");
    return("Not started");
    }
  ...
  }

Method: FuncReturn startThisThread (int prioOffset=0)
This method activates the thread, which will execute the selected function. The parameter sets the relative priority of the new thread compared to the calling thread. Higher numbers mean higher priority, but normally threads share the CPU on equal footing, so 0 is the default value.

The return value reflects the success of the method.

Example:


  BPT_Pthread* myClient;

  myClient = new GroupClientThread(myDataList, myThreadName);
  myClient->startThisThread(0);

How the sharing of the CPU time is performed is not defined. You should not assume anything or "the worst case" for you application. Use BPT_sleep to relinquish the CPU, if necessary.

Method: Boolean hasAThread ()
A test function to check for an active thread. Returns TRUE if there is a running thread for this object, FALSE otherwise.

Method: FuncReturn detachThisThread ()
Relinquish any controll over the thread started through this object. After this call you can no longer join or cancel this thread. It releases all thread specific resources and is usable to start a "clone" of this thread immediately.

Method: FuncReturn joinThisThread ()
This call blocks the calling thread until the thread started through this object has completed execution.

Method: void* getExitStatus ()
After you "joined" a thread you can access the return value, which has the type of void*.

Method: FuncReturn cancelThisThread
With this call the cancellation of a thread is requested. Whether and when this cancellation takes place depends on the state of the thread.

Normally, a thread can only be cancelled at a cancel point. These are either some selected system library calls, or a certain point or area of the thread's code.

This behavior can be changed to

  1. not allow any cancellations,
  2. or cancel thread immediately.

This feature is needed to protect threads from being stopped at places where they are still reserving resources that would not be released, if the thread would be cancelled at this point. Unfortunately, not all platforms support this mechanism, so the methods are empty functions for those systems.

All following functions are class static functions that can be called from inside the thread function without any reference to an instance of BPT_Pthread.

Example:


GroupClientThread::~GroupClientThread()
{
  cancelThisThread();
  delete myInterface;
}

This shows, how you can make the destructor of a class derived from BPT_Pthread cancel any active thread of this instance.

Method: FuncReturn disableAllCancel ()
Disable all cancellations of this thread. Be careful with this method, since the thread could tie up resources "forever".

Method: FuncReturn allowControlledCancel ()
Set the behavior of the thread towards cancel request to default, as described above.

Method: FuncReturn allowSuddenCancel ()
Cancellation requests are now stopping the thread as soon as possible. The setup of cancel points or areas is ignored.

Method: void cancelPoint ()
Mark this place in the code as allowed point of cancellation. Is only in effect, when the cancellation behavior is set "controlled".

Method: void startCancelArea ()
From this code line on, all cancellation request (new or pending) are "granted" and the thread is stopped.

Example:


  boa->obj_is_ready(myInterface);
  BPT_Pthread::startCancelArea();
  boa->impl_is_ready();

  return("X");

This shows the code fragment of a server program going into an infinite event loop (impl_is_ready()). Before you do this, you must allow for cancellation, which is done here by calling startCancelArea().

Method: void endCancelArea()
Stop the area of possible cancellation started with startCancelArea. Cancellation are restricted to selected oprating system calls

Private Data: BPT_Pthread hasThread
This is a flag variable used to mark an active thread for this instance.

Function: void BPT_sleep (int seconds)
Function to "sleep" for a number of seconds. Since each platform seems to have its own time resolution for "block" a task for a certain amount of time, the smallest time step supported by all systems is taken.

This function is declared with extern "C", so it can be called from a C function running as thread.

Private Data: BPT_Pthread cancelRequest
This is a flag variable used to memorize a pending cancellation request.

Private Data: BPT_Pthread tArgs
A pointer to an instance of BPT_ArgArray containing the arguments for this thread function

Private Method: void init_class (void* (*f)(BPT_ArgArray*))
The shared class initialiser function.

It sets up the correct function pointer to call the "main function", and creates the default attributes for the thread instance.

Class: BPT_ArgArry
A class to pass parameters to a thread when it starts.

When you use BPT_Pthread::setArgument to set parameters before activating a thread, all the values you give are stored inside an instance of BPT_ArgArry. A pointer to this instance is then passed on to the "main function".

The easiest way of retreiving those values is calling the methods of this object, which return the type void* and assign it to the expected type. There is no type--checking possible.

Example:


  long max = 10;

  if (Args)
    {
    void* arg_max;
    BPT_GetNextArg(Args, &arg_max);
    max = (long)arg_max;
    }

You can either retreive the parameter values using the getArg method of the class, or use the (C visible) friend BPT_GetNextArg function. It will return values one after the other.

Again it is a class static function, so any C program can call it, receiving the BPT_ArgArray instance as a pointer value as its first parameter. This way, C programs running as thread functions can use a type void * as parameter and retrieve parameters without being compiled as C++ code.

Constructor: BPT_ArgArray::BPT_ArgArray (size_t max)
Create an instance of this object with an array of max entries.

Destructor: BPT_ArgArray::~BPT_ArgArray ()
Destructor of the class, also releasing the argument array. Do not access any parameters after the destruction of this object.

Method: FuncReturn setArg (size_t num, void* arg)
Copies the argument value into the array, using the place at num.

Method: FuncReturn getArg (size_t num, void** arg)
Copies the argument value from the array, using the place at num, into the memory pointed to by arg.

Function: FuncReturn BPT_GetNextArg (BPT_ArgArray* args, void** value)
Function to retreive parameters from non-C++ compiled functions running as threads.

Private Data: BPT_ArgArray maxArgs
Unsigned number keeping the size of the parameter array. Set at construction.

Private Data: BPT_ArgArray friendCallcnt
Unsigned number keeping the index of the next array index to be used by BPT_GetNextArg.

Private Data: BPT_ArgArray args
Array holding the type void*. Allocated at construction time with the size maxArgs.

Socket Classes

Header file: `bsocket.hxx'

Class: BSO_Socket
Base class: virtual public bsobject

The base class to all socket classes. It can be used directly, but then needs more setting up to work with the correct address family and protocol.

These classes are useful to create networked connections, if a CORBA interface is not possible or has large overhead. With other words, this should be a rare case for the environment of CLEO! Try to avoid this, since these connection introduce hardware dependencies, like host names and IP addresses...

Constructor: BSO_Socket::BSO_Socket (const char* name, int addr_family, int type, int protocol)
Creates a class wrapping a socket connection using an address family, type, and protocol given as parameters. Also name the object instance.

No system resources are allocated or sockets openened at construction time.

Constructor: BSO_Socket::BSO_Socket (int addr_family, int type, int protocol)
The same as above, but it does not name the object.

Destructor: virtual BSO_Socket::BSO_Socket ()
Empty destructor. Set to be virtual so we are able to call the correct destructor of derived classes through this reference.

Method: virtual FuncReturn create ()
Function to create the actual socket resources. This kind of socket is meant to create a new socket, an can be overwritten so that additional preparations are possible before creating the socket.

The return value reflects the success of the method, it does not return the socket descriptor.

Method: virtual FuncReturn create (unsigned int sock)
Function to create socket resources by actually reusing another socket sock.

Comment: The type of the argument is platform dependent!

Method: virtual void close ()
Close the underlying socket to end connection and release resource.

Destructing the object only, does not close the connection properly. Always use close before deleting a socket object!

Method: FuncReturn getSockOpt (int optionName, void* optionValue, int* optionLen, int level)
Copies the value of a socket options into optionValue. The name and level of the option is set by numeric values found in the header files of the used socket type. optionLen is used to communicate the maximum memory size usable to copy the value.

Method: FuncReturn getSockOpt (int optionName, int* optionValue, int level)
Special version of this function to access options with int typed values. These are the most common ones, so it is nice to have an easier API to access them.

Method: FuncReturn setSockOpt (int optionName, void* optionValue, int optionLen, int level)
Sets the value of a socket options to optionValue. The name and level of the option is set by numeric values found in the header files of the used socket type. optionLen is used to communicate the memory size used by the value given.

Method: FuncReturn getSockOpt (int optionName, int optionValue, int level)
Special version of this function to set options with int typed values. These are the most common ones, so it is nice to have an easier API to work with them.

Method: FuncReturn accept (BSO_Socket& newSocket)
After a socket listens for connection requests (use listen for starting that), a call to this method will block the thread until a "client" has connected to this socket port. The thread will be activated and the returned BSO_socket instance is used to setup a new socket port to communicate with the new client.

Example:


  BSO_StreamSocket  test("Sock1");
  BSO_StreamSocket  newConn("Session");

  ...

  while (TRUE)
    {
    if (-1 == test.accept(newConn)) break;

    CCO_printf("Got a connection!\n");
    newConn.printInfo(TRUE);

    cnt = 0;
    do
      {
      ...
      }

    CCO_printf("Close connection after %d messages.\n", cnt);
    newConn.close();
    }

This example uses a derived class of BSO_Socket that automatically uses AF_INET address family (=TCP/IP), and the SOCK_STREAM protocol.

Method: FuncReturn listen (int backLog = 5)
Makes this instance of a socket a "server" listening for connection requests. The number of maximum pending requests is set as a parameter. If the server program is busy and not calling accept for a long time, requests are queued up until this number is reached. In this state connect requests fail until the server connects to one of the clients pending.

You can only listen to connections after you used bind to set the server's socket address.

Method: FuncReturn bind (struct sockaddr *socketAddress, int socketAddrLength)
Bind this socket instance to a specific socket address. The address structure is dependent of the address family, but this API is usable with all of them. The correct structures are defined in the header file of each family.

Method: FuncReturn bind (unsigned short socketPort, unsigned int octet)
This is the bind method to be used for the AF_INET address family. For this family the IP address (in host format), and the socket port number makes up an address.

Method: FuncReturn bind (unsigned short socketPort, const char* hostName)
This is the bind method to be used for the AF_INET address family. This version will use the Domain Name Service to find the correct IP octet for the given host.

Method: FuncReturn bind (unsigned short socketPort)
This is the bind method to be used for the AF_INET address family. This version will use the IP address of the host it is executed on.

Example:


class BSO_StreamSocket  test("Sock1");

test.create();
if (-1 == test.bind(16100))
  {
  CCO_error(__FILE__,__LINE__,"error calling bind.\n");
  return(-1);
  }

Method: FuncReturn connect(struct sockaddr *socketAddress, int socketAddrLength)
A "client" using a socket connection calls this function to connect to the "server". Again this is the API that works with all address families.

Method: FuncReturn connect(unsigned short socketPort, unsigned int octet)
Version to connect via the AF_INET address family. octet is the IP address in host format.

Method: FuncReturn connect(unsigned short socketPort, const char* hostName)
Version to connect via the AF_INET address family. hostName is the name of the host to connect to. It will be translated into an IP address using DNS.

Example:


  BSO_StreamSocketND test("Sock1");

  if (-1 == test.create()) return(-1);
  if (-1 == test.connect(16100, argv[1])) return(-1);

  ...

This example uses a derived class of BSO_Socket setting up a AF_INET connection.

Method: FuncReturn ioCtl (int func, void* arg)
Interface to the low level driver interface of the socket. func depends on the device driver and is defined in a header describing this device.

Use only for special cases, since not all of the functions are available on all devices.

Method: FuncReturn receive (void *buffer, int bufferLength, int flags)
Read data from the underlying socket device and store it in buffer. If no data is available the thread will block until data is sent from the other side of the socket. bufferLength is the maximum number of bytes that can be written to the buffer. If a "message" is too long for the buffer parts of it may be dropped depending on the type of the socket.

The flags parameter can be used to read "out--of--band" data or "peek" into the socket read buffer to check for available data.

The returned number gives the actually received bytes.

Example:


char oneMessage[1024];

oneSize = newConn.receive(oneMessage, sizeof(oneMessage), 0);

The example reads a message from the socket.

Method: FuncReturn receiveFrom (void *buffer, int bufferLength, struct sockaddr *socketAddress, int *socketAddrLength, int flags)
Alternative form to receive data from a socket. This socket was not setup to use listen/accept, but clients can write to it at any time.

This method will return the address of the client sending the "message" stored in buffer.

Method: FuncReturn receiveFrom (void *buffer, int bufferLength, unsigned short *socketPort, unsigned int *octet, int flags)
Version to be used with AF_INET, where an address consists of an "IP octet" and a port number.

Method: FuncReturn send (const void* buffer, int bufferLength, int flags)
Sends the "message" in buffer with the length bufferLength through the socket to the "other side". Again, this socket has to be in the "connected" state.

You can use flags to send the data as a "out--of--bounds" message.

The return value reflects if the call was successful.

Example:


for (countMessages = 0; countMessages < 10; countMessages++)
  {
  test.send(oneMessage, sizeof(oneMessage), 0);
  }

Method: FuncReturn sendTo (const void* buffer, int bufferLength, struct sockaddr *socketAddress, int socketAddrLength, int flags)
Send the message to an "unconnected" port. This API works with all address families.

Method: FuncReturn sendTo (const void* buffer, int bufferLength, unsigned short socketPort, unsigned int octet, int flags)
Send the message to an "unconnected" port. This API is meant for the AF_INET address family.

Method: FuncReturn shutdown (int mode)
Partial or complete graceful shutdown of the connection. Useful after errors that leave the socket in an "unknown" state.

A call to close on the socket will shutdown the socket in both directions, too.

Method: FuncReturn printInfo (int verbose)
Prints a description of the socket connection.

The verbose switch will increase the amount of output even more, if set to TRUE.

Method: Boolean isBroken ()
Sometimes the "other side" of a socket is not able to close a socket correctly before the socket connection is torn down. This call is a wrapper to system dependent code to test a socket connection and report its state.

Returns TRUE, if socket is no longer properly connected.

Operations: BSO_Socket ==
Operator to check for equivalence of two socket classes. Socket class instances are equivalent, if they control the same socket, i.e. the socket descriptors are equal.

Operations: BSO_Socket !=
Negated result of the == operator.

Class: BSO_StreamSocket
Base class: virtual public BSO_socket

Sets the address family and protocol to the values needed for TCP/IP connections when constructed.

All methods of BSO_Socket are inherited (what else...).

Constructor: BSO_StreamSocket::BSO_StreamSocket (const char* name)
Calls the constructor of the base class setting address family to AF_INET, and the protocol to SOCK_STREAM. It also names the instance using name.

Constructor: BSO_StreamSocket::BSO_StreamSocket ()
Same as above but does not name this instance.

Destructor: BSO_StreamSocket::~BSO_StreamSocket ()
Empty function, since no resources are to be deleted.

Class: BSO_StreamSocketND
Base class: virtual public BSO_socket

Sets the address family and protocol to the values needed for TCP/IP connections when constructed. Also switches off the TCP "delay mechanism", which enhances performance by concatenating messages into one IP packet if possible.

All methods of BSO_Socket are inherited (what else...), but create is overwritten to set TCP_NDELAY option in created socket.

Constructor: BSO_StreamSocketND::BSO_StreamSocketND (const char* name)
Calls the constructor of the base class setting address family to AF_INET, and the protocol to SOCK_STREAM. It also names the instance using name.

Constructor: BSO_StreamSocketND::BSO_StreamSocketND ()
Same as above but does not name this instance.

Destructor: virtual BSO_StreamSocketND::~BSO_StreamSocketND ()
Empty function, since no resources are to be deleted.

Method: FuncReturn create ()
Overloads the function inherited from BSO_Socket. This function sets the TCP_NDELAY option after the socket is created, and before it returns.

Method: FuncReturn create (unsigned int sock)
Like before, but reuses the socket with the descriptor sock.

Comment: The type of the parameter sock is platform dependent!

Class: BSO_UDPSocket
Base class: virtual public BSO_socket

Class to instantiate a socket using the UDP protocol. UDP is especially useful to broadcast messages to all nodes in an IP domain.

Constructor: BSO_UDPSocket::BSO_UDPSocket (const char* name)
Construtor of a AF_INET socket using the SOCK_DGRAM protocol. Give this instance also a name.

Constructor: BSO_UDPSocket::BSO_UDPSocket ()
Same as above but do not name this instance.

Destructor: virtual BSO_UDPSocket::~BSO_UDPSocket ()
Empty function like the other destructors.

Method: struct sockaddr_in* getBroadcastAddr (unsigned short port)
Method to create an address representing a broadcast address for the hosts domain.

Method: FuncReturn enableBroadcast (int yesno)
Switch on or off that broadcast packets are sent to the network domain.

Message Queue Class

Header file: `messageq.hxx'

Library classes to provide message queues visible to all threads/processes on a host.

Class: BMQ_messageQ

Class with a pseudo--POSIX API implementing a "Message Queue".

You can use a message queue to send complex messages to threads in the same process/node avoiding the overhead of a socket. The drawbacks are more restrictive resources and no way to communicate with other nodes using this class.

The API is modelled to resemble the interface of a BSO_socket class.

Constructor: BMQ_messageQ::BMQ_messageQ (const char* name)
Constructor of the class wrapper to the message queue. It names this instance with the string name.

Constructor: BMQ_messageQ::BMQ_messageQ ()
Same as above but it does not name the instance.

Destrcutor: virtual BMQ_messageQ::~BMQ_messageQ ()
Deletes object and frees system resources used.

Method: FuncReturn create (int key, int msg_size, int max_msg)
Actually creates the message queue by allocating the system resources. This queue can hold up to max_msg messages, with a length of msg_size bytes per message. The parameter key gives this queue a "name" so other threads can find it.

The thread calling create is marked as the "Creator of the queue" and has the privilege to deallocate the queue and its system resources.

Method: FuncReturn bind (int key, int msg_size)
Attach to a message queue without actually creating it. This call is only successful, if the queue is already created.

For cross check, the maximum size of the expected messages is compared to the setup of this queue.

Method: FuncReturn close ()
Close the connection to a message queue. If the thread was the "Creator" of the queue, it is also deallocated and the system resources freed.

Method: FuncReturn send (int flag, const void* msg, int msg_size=0)
Send the messages msg to the message queue. The size of the message is given in msg_size. It has to lower or equal the maximum size that was set when this instance was "bound". If you give 0 or no value, the maximum message size is sent.

Can block the calling thread, until space for the new message is available. This behavior is controlled by flag:

Example:


if ((que->send(BMQ_SEND_WAIT, &msg)))
  {
  CCO_error(__FILE__,__LINE__,"Error sending\n");
  return(-1);
  }

Method: int get (int flag, void* msg)
Read a messages from the message queue and store into msg. The maximum size of a message was set when this instance was "bound". The return value is the number of bytes received, or -1 if there was an error.

Can block the calling thread, until a message is available. This behavior is controlled by flag:

Example:


while (1)
  {
  if (que->get(BMQ_GET_WAIT, msg) == -1)
    {
    CCO_error(__FILE__,__LINE__,
        "Can`t read from queue %d!\n", 6819);
    return(-1);
    }

  CCO_printf("%s\n", msg);
  }

Method: Boolean isCreator ()
Check, whether this thread was the "Creator" of the queue. Returns TRUE if this is correct.

Method: Boolean isBound ()
Check, whether this instance is "connected" to a message queue. Returns TRUE if this is correct.

Method: int getKey ()
Returns the key of this queue.

Method: FuncReturn getStatus ()
Prints out a rather lengthy description of the status of the queue, including how much space is left for messages.

Private Method: void init_class ()
Shared class initialiser function.

Template Lists

Header file: `blists.hxx'

The CLEO software group has decided to use STL as their template library of choice. Unfortunately, there is no STL implementation for the real--time operating system running on all our embedded CPU: VxWorks.

To keep the environment of the CLEO Control System still the same on all platforms it is therefore strongly discouraged to use STL in this kind of code. Instead these template lists classes were introduced to BASICS as a (rather weak) substitute.

Our hope is, that at some point in time, we can "revert" to STL everywhere. But for now, we should try to cope with these classes.

Example:


struct Name
{
  char*    name;
  unsigned short prio;
};

// Convenient typedefs
typedef struct Name Name;
typedef BLS_MutexList<Name*> NameList;

class GroupListData
{
public:
  GroupListData(const char* name);
  virtual ~GroupListData();

  const char * groupName() const;
  NameList*    groupList();
  void         clearList();

  ...

private:
  ...

  NameList* myList;
  char * myGroup;
};

// A function using the list
void GroupListData::clearList()
{
  myList->lock();

  if (!myList->isEmpty())
    {
    // Remove all entries before deleting the list
    Name* name;
    Name* nxtname;

    for (name = myList->getHead(); ; name = nxtname)
      {
      // Last entry, so just delete
      if (myList->isLast(name))
        {
        // Unregister also!
        unregisterOld(name->name);

        myList->remove(name);
        delete name->name;
        delete name;
        break;
        }

      // There is another entry, remember where!
      nxtname = myList->getNext(name);

      // Unregister also!
      unregisterOld(name->name);
      // Now, we can delete
      myList->remove(name);
      delete name->name;
      delete name;
      }
    }
  myList->unlock();
}


This example shows the use of a Mutex protected list (a subclass of the simple list class). (Using typedef the code becomes much more readable!) The structure Name is managed with a list that contains pointers to each instance. All list classes in BASICS are tailored to use pointers to instances instead of copies of these. The "reasoning" behind this approach is, that lists are only tools to organize objects, they do not really "manage" the objects. This is still the job of the programmer!

This approach makes it possible to have the same object in more than one list (e.g. one sorted alphabetically, the other using times). If the object was copied into the list (or container) you would have two distinct instances of the object.

Secondly, all lists are made to contain only distinct items, like numbers or pointers. This makes it possible to "walk through the list" without changing the state of the list, and without keeping an iterator object around. You always deal with the list object directly. Do not add an item twice, it will break the list object!

(Whether this is an advantage or disadvantage is still an open question and depends very much on the view of programmer.)

template <class T> Class: BLS_List

Base class: virtual public bsobject

A doubly--linked list using the template syntax to be type--safe.

Constructor: BLS_List<T>::BLS_List<T> (const char* name)
Creates an empty list for the type T. It also names this list.

Constructor: BLS_List<T>::BLS_List<T> ()
Same as above, but does not give this instance a name.

Destructor: virtual BLS_List<T>::~BLS_List<T> ()
Deletes the list.

Since objects are not managed by the list, only the memory for the object pointers are freed. The user is responsible for deleting the objects pointed to!

Method: T getHead ()
Get item currently first in the list.

Do not call this method, if list is empty!

Method: T getTail ()
Get item currently last in the list.

Do not call this method, if list is empty!

Method: T getNext (const T& t)
Get next item after t.

Do not call this method, if t is last in the list!

Method: T getPrev (const T& t)
Get the item before t.

Do not call this method, if t is first in the list!

Method: Boolean isEmpty ()
Checks if there is any item in this class. Returns TRUE if empty, FALSE otherwise.

Method: Boolean isLast (const T& t)
Checks if there is any item after item t. Returns TRUE if not, FALSE otherwise.

Method: Boolean isFirst (const T& t)
Checks if there is any item before item t. Returns TRUE if not, FALSE otherwise.

Method: void add (const T& t)
Add a new item to the list. It will be inserted just at the start of the list.

Do not insert the same item more than once!

Method: void addAfter (const T& t, const T& prev)
Add a new item to the list. It will be inserted just after the item prev.

Do not insert the same item more than once!

Method: void addBefore (const T& t, const T& follow)
Add a new item to the list. It will be inserted just before the item follow.

Do not insert the same item more than once!

Method: void remove (const T& t)
Remove item t from the list.

This does not delete any object t might point to!

template <class T> Class: BLS_Queue
Base class: virtual public bsobject

A simple template class implementing a queue of items. You can add new items at the end, and remove items from the top.

Constructor: BLS_Queue<T>::BLS_Queue<T> (const char* name)
Creates an empty queue list for the type T. It also names this list.

Constructor: BLS_Queue<T>::BLS_Queue<T> ()
Same as above, but does not give this instance a name.

Destructor: virtual BLS_Queue<T>::~BLS_Queue<T> ()
Deletes the queue list.

Since objects are not managed by the list, only the memory for the object pointers are freed. The user is responsible for deleting the objects pointed to!

Method: Boolean isEmpty ()
Checks if this queue has any item in it. Returns TRUE if empty, FALSE otherwise.

Method: void add (const T& t)
Add this item to the end of the queue.

Method: T remove ()
Remove the top item of the queue and returns it.

Do not call this method if queue is empty!

template <class T> Class: BLS_MutexList
Base class: virtual public BLS_List<T>

This list has the same behavior as BLS_List, except that before you call any method, the list has to be locked by the calling thread. Failing to do so will result in run--time errors.

Constructor: BLS_MutexList<T>::BLS_MutexList<T> (const char* name)
Creates an empty list for the type T, and sets the protecting semaphore to "unlocked". It also names this list.

Constructor: BLS_MutexList<T>::BLS_MutexList<T> ()
Same as above, but does not give this instance a name.

Destructor: virtual BLS_MutexList<T>::~BLS_MutexList<T> ()
Deletes the list.

Since objects are not managed by the list, only the memory for the object pointers are freed. The user is responsible for deleting the objects pointed to!

Method: FuncReturn lock ()
Locks this list, so no other thread can change or access this list after this call.

The return value reflects the success of the call.

Method: FuncReturn unlock ()
Unlocks this list.

The return value reflects the success of the call.

Method: Boolean isLocked ()
Checks whether the semaphore is "locked". Returns TRUE if yes, FALSE otherwise.

Private Data: BLS_MutexList myMutex
The semaphore used to control access to the list. It has the type BSP_Mutex.

template <class T> Class: BLS_MutexQueue
Base class: virtual public BLS_Queue<T>

This list has the same behavior as BLS_Queue, except that before you call any method, the list has to be locked by the calling thread. Failing to do so will result in run--time errors.

Constructor: BLS_MutexQueue<T>::BLS_MutexQueue<T> (const char* name)
Creates an empty queue list for the type T, and sets the protecting semaphore to "unlocked". It also names this list.

Constructor: BLS_MutexQueue<T>::BLS_MutexQueue<T> ()
Same as above, but does not give this instance a name.

Destructor: virtual BLS_MutexQueue<T>::~BLS_MutexQueue<T> ()
Deletes the list.

Since objects are not managed by the list, only the memory for the object pointers are freed. The user is responsible for deleting the objects pointed to!

Method: FuncReturn lock ()
Locks this list, so no other thread can change or access this list after this call.

The return value reflects the success of the call.

Method: FuncReturn unlock ()
Unlocks this list.

The return value reflects the success of the call.

Method: Boolean isLocked ()
Checks whether the semaphore is "locked". Returns TRUE if yes, FALSE otherwise.

Private Data: BLS_MutexQueue myMutex
The semaphore used to control access to the list. It has the type BSP_Mutex.

Concept Index

b

  • BASICS Overview
  • Binary Semaphore class
  • Binding a Socket
  • Blocking
  • Broadcast Messages
  • BSP_SBase Construction
  • c

  • Cleanup Semaphore class
  • Connecting to a Socket
  • Console Functions
  • Cosmic Base class
  • d

  • Data Exchange using Queues
  • Debug Output
  • Detaching a Thread
  • e

  • Exit Functions
  • Exit Manager class
  • Exit Manager Example
  • f

  • Function List Container
  • l

  • List Class
  • List Class with Mutex
  • m

  • Manipulate Dates/Times
  • Messages between Threads
  • Mutual Exclusive Semaphore class
  • o

  • Object Shutdown
  • Option Parsing Functions
  • p

  • Platform Configuration
  • Platforms, supported
  • POSIX Message Queue
  • POSIX Thread API
  • Protected Template List Class
  • Protected Template Queue Class
  • q

  • Queue Class
  • Queue Class with Mutex
  • r

  • Reading from a Socket
  • Runtime Parameters
  • s

  • setTimezone
  • Setting Output Stream at Runtime
  • Setting Thread Parameters
  • Socket Classes
  • Socket for TCP/IP
  • Socket using UDP
  • Starting a Thread
  • Support
  • t

  • TCP/IP Socket Classes
  • Template double--linked List
  • Template List Classes
  • Template Queue Class
  • Thread Cancellation
  • Thread Class
  • Thread Exit
  • Thread Main Function
  • Thread Parameter Class
  • Time classes
  • Time zone problem
  • u

  • Using BPT_Pthread
  • v

  • Vanilla Socket
  • w

  • Waiting for a Thread
  • Waiting for Socket Connections
  • Writing to a Socket
  • Class Index

    b

  • basics
  • BEX_func_list
  • BEX_xitman
  • BLS_List
  • BLS_MutexList
  • BLS_MutexQueue
  • BLS_Queue
  • BMQ_messageQ
  • BPT_ArgArry
  • BPT_Pthread
  • BSO_Socket
  • BSO_StreamSocket
  • BSO_StreamSocketND
  • BSO_UDPSocket
  • bsobject
  • BSP_Binary
  • BSP_Mutex
  • BSP_SBase
  • btime
  • Public Function Index

    b

  • basics::runtime_double_opt(int& argc, char** argv, const char* option_name, const char* variable_name, double& variable)
  • basics::runtime_float_opt(int& argc, char** argv, const char* option_name, const char* variable_name, float& variable)
  • basics::runtime_int_opt(int& argc, char** argv, const char* option_name, const char* variable_name, int& variable)
  • basics::runtime_long_opt(int& argc, char** argv, const char* option_name, const char* variable_name, int& variable)
  • basics::runtime_size_t_opt(int& argc, char** argv, const char* option_name, const char* variable_name, size_t& variable)
  • basics::runtime_string_opt(int& argc, char** argv, const char* option_name, const char* variable_name, char*& variable)
  • basics::runtime_switch_opt(int& argc, char** argv, const char* option_name, const char* variable_name, int& variable)
  • basics::runtime_tm_opt(int& argc, char** argv, const char* option_name, const char* variable_name, struct tm& variable)
  • BEX_func_list::add(void (*f)())
  • BEX_func_list::BEX_func_list()
  • BEX_func_list::first()
  • BEX_func_list::next()
  • BEX_func_list::remove(void (*f)())
  • BEX_func_list::~BEX_func_list()
  • BEX_xitman::add(void (*f)())
  • BEX_xitman::BEX_xitman()
  • BEX_xitman::BEX_xitman(const char* name)
  • BEX_xitman::~BEX_xitman()
  • BLS_List<T>::add(const T& t)
  • BLS_List<T>::addAfter(const T& t, const T& prev)
  • BLS_List<T>::addBefore(const T& t, const T& follow)
  • BLS_List<T>::BLS_List<T>()
  • BLS_List<T>::BLS_List<T>(const char* name)
  • BLS_List<T>::getHead()
  • BLS_List<T>::getNext(const T& t)
  • BLS_List<T>::getPrev(const T& t)
  • BLS_List<T>::getTail()
  • BLS_List<T>::isEmpty()
  • BLS_List<T>::isFirst(const T& t)
  • BLS_List<T>::isLast(const T& t)
  • BLS_List<T>::remove(const T& t)
  • BLS_List<T>::~BLS_List<T>()
  • BLS_MutexList::isLocked()
  • BLS_MutexList::lock()
  • BLS_MutexList::unlock()
  • BLS_MutexList<T>::BLS_MutexList<T>()
  • BLS_MutexList<T>::BLS_MutexList<T>(const char* name)
  • BLS_MutexList<T>::~BLS_MutexList<T>()
  • BLS_MutexQueue::isLocked()
  • BLS_MutexQueue::lock()
  • BLS_MutexQueue::unlock()
  • BLS_MutexQueue<T>::BLS_MutexQueue<T>()
  • BLS_MutexQueue<T>::BLS_MutexQueue<T>(const char* name)
  • BLS_MutexQueue<T>::~BLS_MutexQueue<T>()
  • BLS_Queue<T>::add(const T& t)
  • BLS_Queue<T>::BLS_Queue<T>()
  • BLS_Queue<T>::BLS_Queue<T>(const char* name)
  • BLS_Queue<T>::isEmpty()
  • BLS_Queue<T>::remove()
  • BLS_Queue<T>::~BLS_Queue<T>()
  • BMQ_messageQ::bind(int key, int msg_size)
  • BMQ_messageQ::BMQ_messageQ()
  • BMQ_messageQ::BMQ_messageQ(const char* name)
  • BMQ_messageQ::close()
  • BMQ_messageQ::create(int key, int msg_size, int max_msg)
  • BMQ_messageQ::get(int flag, void* msg)
  • BMQ_messageQ::getKey()
  • BMQ_messageQ::getStatus()
  • BMQ_messageQ::isBound()
  • BMQ_messageQ::isCreator()
  • BMQ_messageQ::send(int flag, const void* msg, int msg_size=0)
  • BMQ_messageQ::~BMQ_messageQ()
  • BPT_ArgArray::BPT_ArgArray(size_t max)
  • BPT_ArgArray::getArg(size_t num, void** arg)
  • BPT_ArgArray::setArg(size_t num, void* arg)
  • BPT_ArgArry::~BPT_ArgArray()
  • BPT_GetNextArg(BPT_ArgArray* args, void** value)
  • BPT_Pthread::allowControlledCancel()
  • BPT_Pthread::allowSuddenCancel()
  • BPT_Pthread::BPT_Pthread()
  • BPT_Pthread::BPT_Pthread(const char* name)
  • BPT_Pthread::BPT_Pthread(const char* name, void* (*f)(BPT_ArgArray*))
  • BPT_Pthread::cancelPoint()
  • BPT_Pthread::cancelThisThread()
  • BPT_Pthread::changeAttr()
  • BPT_Pthread::detachThisThread()
  • BPT_Pthread::disableAllCancel()
  • BPT_Pthread::endCancelArea()
  • BPT_Pthread::execMethod(BPT_ArgArray* args)
  • BPT_Pthread::getExitStatus()
  • BPT_Pthread::hasAThread()
  • BPT_Pthread::identity(pthread_t& id)
  • BPT_Pthread::joinThisThread()
  • BPT_Pthread::setArgument(int num, void* new_arg)
  • BPT_Pthread::startCancelArea()
  • BPT_Pthread::startThisThread(int prioOffset)
  • BPT_Pthread::~BPT_Pthread()
  • BPT_sleep(int seconds)
  • BSO_Socket::accept(BSO_Socket& newSocket)
  • BSO_Socket::bind(struct sockaddr *socketAddress, int socketAddrLength)
  • BSO_Socket::bind(unsigned short socketPort)
  • BSO_Socket::bind(unsigned short socketPort, const char* hostName)
  • BSO_Socket::bind(unsigned short socketPort, unsigned int octet)
  • BSO_Socket::BSO_Socket(const char* name, int addr_family, int type, int protocol)
  • BSO_Socket::BSO_Socket(int addr_family, int type, int protocol)
  • BSO_Socket::close()
  • BSO_Socket::connect(struct sockaddr *socketAddress, int socketAddrLength)
  • BSO_Socket::connect(unsigned short socketPort, const char* hostName)
  • BSO_Socket::connect(unsigned short socketPort, unsigned int octet)
  • BSO_Socket::create()
  • BSO_Socket::create(unsigned int sock)
  • BSO_Socket::getSockOpt(int optionName, int optionValue, int level)
  • BSO_Socket::getSockOpt(int optionName, int* optionValue, int level)
  • BSO_Socket::getSockOpt(int optionName, void* optionValue, int* optionLen, int level)
  • BSO_Socket::ioCtl(int func, void* arg)
  • BSO_Socket::isBroken()
  • BSO_Socket::listen(int backLog)
  • BSO_Socket::operator!=(const BSO_Socket& )
  • BSO_Socket::operator==(const BSO_Socket& )
  • BSO_Socket::printInfo(int verbose)
  • BSO_Socket::receive(void *buffer, int bufferLength, int flags)
  • BSO_Socket::receiveFrom(void *buffer, int bufferLength, struct sockaddr *socketAddress, int *socketAddrLength, int flags)
  • BSO_Socket::receiveFrom(void *buffer, int bufferLength, unsigned short *socketPort, unsigned int *octet, int flags)
  • BSO_socket::send(const void* buffer, int bufferLength, int flags)
  • BSO_Socket::sendTo(const void* buffer, int bufferLength, struct sockaddr *socketAddress, int socketAddrLength, int flags)
  • BSO_Socket::sendTo(const void* buffer, int bufferLength, unsigned short socketPort, unsigned int octet, int flags)
  • BSO_Socket::setSockOpt(int optionName, void* optionValue, int optionLen, int level)
  • BSO_Socket::shutdown(int mode)
  • BSO_Socket::~BSO_Socket()
  • BSO_StreamSocket::BSO_StreamSocket()
  • BSO_StreamSocket::BSO_StreamSocket(const char* name)
  • BSO_StreamSocket::~BSO_StreamSocket()
  • BSO_StreamSocketND::BSO_StreamSocketND()
  • BSO_StreamSocketND::BSO_StreamSocketND(const char* name)
  • BSO_StreamSocketND::create()
  • BSO_StreamSocketND::create(unsigned int sock)
  • BSO_StreamSocketND::~BSO_StreamSocketND()
  • BSO_UDPSocket::BSO_UDPSocket()
  • BSO_UDPSocket::BSO_UDPSocket(const char* name)
  • BSO_UDPSocket::enableBroadcast(int yesno)
  • BSO_UDPSocket::getBroadcastAddr(unsigned short port)
  • BSO_UDPSocket::~BSO_UDPSocket()
  • bsobject::BCO_cout()
  • bsobject::BCO_debug()
  • bsobject::BCO_error()
  • bsobject::BCO_info()
  • bsobject::BCO_warning()
  • bsobject::bo_name()
  • bsobject::bsobject()
  • bsobject::bsobject(const char* name, const char* rcs)
  • bsobject::getDateSwitch()
  • bsobject::initOutput(int& argc, char** argv)
  • bsobject::rcs_id()
  • bsobject::setDateSwitch(Boolean value)
  • bsobject::setOutput(ostream& strm)
  • bsobject::~bsobject()
  • BSP_Binary::BSP_Binary()
  • BSP_Binary::BSP_Binary(const char* name)
  • BSP_Binary::give()
  • BSP_Binary::isEmpty()
  • BSP_Binary::take()
  • BSP_Binary::~BSP_Binary()
  • BSP_Mutex::BSP_Mutex()
  • BSP_Mutex::BSP_Mutex(const char* name)
  • BSP_Mutex::isLocked()
  • BSP_Mutex::lock()
  • BSP_Mutex::unlock()
  • BSP_Mutex::~BSP_Mutex()
  • BSP_SBase::BSP_SBase()
  • BSP_SBase::forgetSemaphore(SEM_ID sid)
  • BSP_SBase::memorizeSemaphore(SEM_ID sid)
  • BSP_SBase::~BSP_SBase()
  • btime::aDay(double mul = 1.0)
  • btime::aHour(double mul = 1.0)
  • btime::aMinute(double mul = 1.0)
  • btime::aSecond(double mul = 1.0)
  • btime::aWeek(double mul = 1.0)
  • btime::btime(btime& )
  • btime::convertToJulianDate(long& JDint, double& JDfraction)
  • btime::convertToLocalText(char*& text)
  • btime::convertToLocalTmStruct(struct tm* theTime, double* usec = NULL)
  • btime::convertToMJD()
  • btime::convertToTimeT()
  • btime::convertToTimeVal(preciseTime* theTime)
  • btime::convertToUTCText(char*& text)
  • btime::convertToUTCTmStruct(struct tm* theTime, double* usec = NULL)
  • btime::E2000()
  • btime::getCurrentZoneName()
  • btime::getDSTswitch()
  • btime::getFromJulianDate(long JDint, double JDfraction)
  • btime::getFromLocalText(const char* text)
  • btime::getFromLocalTmStruct(struct tm* theTime, double us = 0.0)
  • btime::getFromTimeT(time_t seconds1970, double us = 0.0)
  • btime::getFromTimeval(preciseTime* tp)
  • btime::getFromUTCText(const char* text)
  • btime::getFromUTCTmStruct(struct tm* theTime, double us = 0.0)
  • btime::getNow()
  • btime::getTimezone()
  • btime::inDays()
  • btime::inHours()
  • btime::initTimezone(int& argc, char* * argv)
  • btime::inMinutes()
  • btime::inSeconds()
  • btime::operator!=(const btime& )
  • btime::operator+(const btime& )
  • btime::operator+=(const btime& )
  • btime::operator-(const btime& )
  • btime::operator-=(const btime& )
  • btime::operator<(const btime& )
  • btime::operator<=(const btime& )
  • btime::operator=(const btime& )
  • btime::operator==(const btime& )
  • btime::operator>(const btime& )
  • btime::operator>=(const btime& )
  • btime::setThisTimezone(const char* TZstring)
  • btime::setTimezone(const char* TZstring)
  • btime::~btime()
  • c

  • CCO_debug(char* file, int line, char* fmt, ...)
  • CCO_error(char* file, int line, char* fmt, ...)
  • CCO_info(char* file, int line, char* fmt, ...)
  • CCO_printf(char* fmt, ...)
  • CCO_warning(char* file, int line, char* fmt, ...)
  • Private Declarations Index

    b

  • BEX_xitman::iamAlive
  • BEX_xitman::init_class()
  • BLS_MutexList::myMutex
  • BLS_MutexQueue::myMutex
  • BMQ_messageQ::init_class()
  • BPT_ArgArray::args
  • BPT_ArgArray::friendCallcnt
  • BPT_ArgArray::maxArgs
  • BPT_Pthread::cancelRequest
  • BPT_Pthread::hasThread
  • BPT_Pthread::init_class(void* (*f)(BPT_ArgArray*))
  • BPT_Pthread::tArgs
  • bsobject::rcsid
  • bsobject::symName
  • BSP_Binary::init_class()
  • BSP_Mutex::init_class()
  • BSP_SBase::first_time
  • Variable Index

    a

  • args
  • c

  • cancelRequest
  • f

  • first_time
  • friendCallcnt
  • h

  • hasThread
  • i

  • iamAlive
  • m

  • maxArgs
  • myMutex, myMutex
  • r

  • rcsid
  • Result
  • s

  • symName
  • t

  • tArgs

  • This document was generated on 1 May 1998 using the texi2html translator version 1.49.