Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

Overview of librel

Fundamental components of librel:

=== VMap

The central piece of librel is a VMap. This is a virtual map interface, one which defines a map polymorphically rather then as a templetized type. A VMap can hold any type of value, keyed to a string key (or any other possible key type).

=== 3 types of data Although we can store *any* type of value, there are a limited forms that type can take. It could be:

The hierarchy support built into VMap is two fold: Executable types are supported at the smart pointer level. [ The reason for pushing support so low is that this enables us to delay the execution until as late as possible. Simply passing around the smart pointer which is an executable type does not cause it's execution. ]

OpaqueValue / SmartPtr:

An SmartPtr is a templatized smart pointer class. There are many smart pointer classes in use - the reason is that one size does not fit all. I know that there are a million perfectly good implementations, so let me explain why I wasn't able to use an existing one.

The things that this smart pointer class does which might not be found in your favorite:

The "raw data" type is supported by having destructors (for a given type of object, there can be lots of simultanious destruction methods).

The "VMap" type is not built into SmartPtr (well, lets get back to that).

The "executable" type as part of the SmartPtr binds everything together. The means of execution is not set per-object, it is set per-type. For example, a pointer to a VMap (even if it is a VMap stored in an OpaqueValue - the smart pointer equiv. of a void*), is always "executable" as any other VMap would be. If you attempt to execut the value, the execution mode for a VMap is a find() operation.

It wouldn't be of much use to have VMap executable if you couldn't pass the operation arguments (a VMap.find("") doesn't do much). So, when executing a value, the input is an OpaqueValue (the argument itself could be anything). The result is that the smart pointer changes to be the result (the result may be any type - including another executable if desired).

So, for those reasons, librel has its own smart pointer class. This could change if one day another smart pointer class was usable in its place, but currently it seems unlikely that other smart pointers woulc implement an "executable" type - it just isn't necessary for most libraries.. (If you still feel strongly about it, you could look for a way to change how executable types are achieved).

=== TypeStream / Path

A TypeStream is a generic concept, as it isn't important to the TypeStream users just how a type stream is implemented. There are three levels of the stream API:

TypeStream does have a default implementation -- that way all programs which use librel have at least one stream type in common.

A Path is type of TypeStream, which uses string storage and has support for parsing simple paths. To see why it is nicer for directory lookups, consider using Path vs. the type of thing you'd do by hand:

    // lookup the value of "dir/subdir/value" using Path (the prefered method)
    OpaqueValue result = map->find( Path("dir/subdir/value") );


    // lookup the value of "dir/subdir/value" using only TypeStream..
    // first, create an IODevice
    StringIODevice iodev;
    // create a coder which knows how to read/write basic types
    StreamCoder coder(SmartPtr<IODevice>(&iodev, OpaqueValue::No_Destructor));
    // create a TypeStream, which reads/writes typed information from stream
    TypeStream st(SmartPtr<StreamCoder>(&coder, OpaqueValue::No_Destructor));

    OpaqueValue result = map->find( st );


Generated at Sat Sep 22 02:20:00 2001 for librel by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001