Dynamic C++ expressions

0. Contents

This is the documentation of dynbisq-1.0.1.1.
   1. Contents
      1.1. Dynamic expressions template
      1.2. Dynamic classes
         1.2.1. papa.cc (example of a dynamic class)
   2. Copying
   3. Downloading

1. Contents

1.1. Dynamic expressions template

Allows you to write code like this:
    dyn<int> a,b,c;
    
    a = 5;
    b = 2;
    c = a+b;
    b = 4;
    cout << c;
And get 9 as result instead of 7.
(Ok, actually cout << c does not current work for safety reasons. cout << c.value() does.)

1.2. Dynamic classes

The archive contains also a completely different thing: dynamically linked C++ classes and a shared object pool which allows you to pick up inherited objects by name. Demonstration of the latter:
proteus:~/src/dyn$ ./dyntest
Loading lib './libmama.so'
Loading sym 'Mama'
Loading sym 'Baby'
Loading lib './libpapa.so'
Loading sym 'Papa'

Testing Papa.
 Papa comes.
 Papa waves.
 Papa goes.
Unloading sym 'Papa'
Unloading lib './libpapa.so' (it is no longer in use)

Getting 'Baby'
  Baby comes.
  Baby waves its hand happily.
  Baby goes.
Unloading sym 'Baby'

Getting 'Mama'
 Mama comes.
 Mama waves.
 Mama goes.
Unloading sym 'Mama'
Unloading sym 'Mama'
Unloading sym 'Baby'
Unloading lib './libmama.so' (it is no longer in use)
(Papa, Mama and Baby are derived types from Thing-class, which is the only thing the dyntest executable knows of.)

This dynlib thing has been designed to be used fairly easily without much needed changes to get it working. Here's the papa.cc as an example (BASETYPE_THING is defined in thing.hh, and describes the base type of the class for the loader):

1.2.1. papa.cc (example of a dynamic class)

#include <cstdio>
#include "thing.hh"

class Papa : public Thing
{
public:
    Papa() { std::printf(" Papa comes.\n"); }
    virtual ~Papa() { std::printf(" Papa goes.\n"); }
    virtual void Wave() { std::printf(" Papa waves.\n"); }
};

#include "dynlib.hh"

static void *newpapa(void) { return new Papa; }

dyncontent contents[] =
{
    { BASETYPE_THING, "Papa", newpapa },
    { 0, NULL, NULL }
};

2. Copying

This code has been written by Joel Yliluoma, a.k.a. Bisqwit,
and is distributed under the following terms:
* No warranty. You are free to modify this source and to
* distribute the modified sources, as long as you keep the
* existing copyright messages intact and as long as you
* remember to add your own copyright markings.
* You are not allowed to distribute the program or modified versions
* of the program without including the source code (or a reference to
* the publicly available source) and this notice with it.

3. Downloading

The official home page of dynbisq is at http://oktober.stc.cx/source/dynbisq.html.
Check there for new versions.

Generated from progdesc.php (last updated: Fri, 18 Oct 2002 22:37:54 +0300)
with docmaker.php (last updated: Tue, 13 Aug 2002 14:17:29 +0300)
at Fri, 18 Oct 2002 22:38:20 +0300