Dynamic C++ expressions


   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

Downloading help

  • Do not download everything - you only need one file (newest version for your platform)!
  • Do not use download accelerators or you will be banned from this server before your download is complete!

Date (Y-md-Hi) acc        Size Name                
2002-1018-1938 r--       23354 dynbisq-1.0.1.1.tar.bz2
2002-1018-1938 r--        9395 patch-dynbisq-1.0.1-1.0.1.1.bz2
2002-0501-1944 r--       18219 dynbisq-1.0.1.rar
2002-0501-1945 r--       18895 dynbisq-1.0.1.tar.bz2
2002-0501-1944 r--       22875 dynbisq-1.0.1.zip
2002-0501-1945 r--        4321 patch-dynbisq-1.0.0-1.0.1.bz2
2002-0304-1919 r--       18130 dynbisq-1.0.0.rar
2002-0304-1919 r--       17378 dynbisq-1.0.0.tar.bz2
2002-0304-1919 r--       22875 dynbisq-1.0.0.zip
2002-0304-1919 r--        1136 patch-dynbisq-0.1.4-1.0.0.bz2
2002-0209-2133 r--       17842 dynbisq-0.1.4.rar
2002-0209-2133 r--       17132 dynbisq-0.1.4.tar.bz2
2002-0209-2133 r--       22309 dynbisq-0.1.4.zip
2002-0209-2133 r--        5077 patch-dynbisq-0.1.3-0.1.4.bz2
2002-0103-1659 r--       17378 dynbisq-0.1.3.rar
2002-0103-1659 r--       16719 dynbisq-0.1.3.tar.bz2
2002-0103-1659 r--       21851 dynbisq-0.1.3.zip
2002-0103-1659 r--       12479 patch-dynbisq-0.1.2-0.1.3.bz2
2002-0103-0758 r--       13312 dynbisq-0.1.2.rar
2002-0103-0758 r--       12991 dynbisq-0.1.2.tar.bz2
2002-0103-0758 r--       17115 dynbisq-0.1.2.zip
2002-0103-0758 r--        8383 patch-dynbisq-0.1.1.0-0.1.2.bz2
2001-1119-0123 r--       11948 dynbisq-0.1.1.0.rar
2001-1119-0123 r--       11698 dynbisq-0.1.1.0.tar.bz2
2001-1119-0123 r--       15669 dynbisq-0.1.1.0.zip
2001-1119-0123 r--        7479 patch-dynbisq-0.1.0-0.1.1.0.bz2
2001-1019-1342 r--        8130 dynbisq-0.1.0.rar
2001-1019-1342 r--        7949 dynbisq-0.1.0.tar.bz2
2001-1019-1342 r--       10747 dynbisq-0.1.0.zip
2001-1019-1342 r--        2350 patch-dynbisq-0.0.5-0.1.0.bz2
2001-1018-2319 r--        7697 dynbisq-0.0.5.rar
2001-1018-2319 r--        7502 dynbisq-0.0.5.tar.bz2
2001-1018-2319 r--       10295 dynbisq-0.0.5.zip
2001-1018-2319 r--        3606 patch-dynbisq-0.0.4-0.0.5.bz2
2001-1018-0231 r--        7085 dynbisq-0.0.4.rar
2001-1018-0231 r--        6915 dynbisq-0.0.4.tar.bz2
2001-1018-0231 r--        9570 dynbisq-0.0.4.zip
2001-1018-0231 r--        2695 patch-dynbisq-0.0.3-0.0.4.bz2
2001-1018-0049 r--        6035 dynbisq-0.0.3.rar
2001-1018-0049 r--        6067 dynbisq-0.0.3.tar.bz2
2001-1018-0049 r--        7725 dynbisq-0.0.3.zip
2001-1018-0049 r--        1485 patch-dynbisq-0.0.2-0.0.3.bz2
2001-1017-2314 r--        5172 dynbisq-0.0.2.rar
2001-1017-2314 r--        5184 dynbisq-0.0.2.tar.bz2
2001-1017-2314 r--        6074 dynbisq-0.0.2.zip
2001-1017-2314 r--        6127 patch-dynbisq-0.0.1-0.0.2.bz2
2000-1110-2119 r--        2975 dynbisq-0.0.1.tar.gz
2000-1110-2119 r--        1371 patch-dynbisq-0.0.0-0.0.1.bz2
2000-1001-1026 r--        2860 dynbisq-0.0.0.tar.gz
Back to the source directory index at Bisqwit's homepage