[ale] Object databases and Interperters

Omar Loggiodice ologgio at vrainn.com
Sat Aug 17 19:52:09 EDT 1996


Douglas Todd Writes :
:
:Hello Everyone:
:
:Have an interesting project, and am looking for an unusual piece of
:code.
:What I'm trying to do is to develop a server application which can
:retrieve
:run time ( pcode or otherwise ) executable images  from a data base, 
:execute it as an instance and allow cooperative multitasking of that
:code immage. 

:Thanks much,
:
:Douglas Todd

Hi Douglas,

   If I understand correctly, what you want is a distributed OO system that
allows you to load executable content at runtime. There are many ways to 
approach this, but I strongly recommend you don't try to write everything
from scratch. We can all benefit much more if you use your talent to augment
and improve the work that has already been done in these areas. Now to the
details....

Without knowing much about the problem domain you are targetting here are 
some options:

1. Write your own client/server system, using the variety of networking C++
libraries available (Check the C++ Libraries FAQ in rtfm.mit.edu for a 
large list of available C++ class libraries in all kinds of problem domains).

2. Augment already available persistant object DBs (such as texas) to
support remote objects and dynamically loadable code on a distributed
environment. (This is not an easy task)

3. Write an object request broker (ORB) that works in conjunction with
persistant OODBs (reusing some of the networking libraries found in 1)

4. Reuse already available CORBA-compliant ORBs that you can find on the net,
and providing an Object framework to support dynamically loadable code


There are many more options, some of them mixtures of the above. I
recommend you use #4. Whatever you use, take a look at the common
object request broker architecture (CORBA) standard being developed by the
Object Management Group, at www.omg.org.

Since I'm suggesting you use #4 I'll give you some more details:

- Grab /pub/Linux/devel/corba/ilu-2.0alpha8.src.tgz from any Linux mirror
site, this is a (mostly) CORBA compliant system developed by a research team
in Xerox, it provides everything you need to create distributed OO systems
that follow the CORBA architecture. Look at the examples in the examples 
directory....

BTW, CORBA is a language independent standard, and you can create your
distributed objects in any language that is supported by your
implementation. The 2.0 alpha release of ilu supports ANSI C, C++,
and Python.    

Check the README file as soon as you download it.

- Develop an object framework to support loadable objects

I suggest you tackle this initially by using dynamically loadable libraries,
and using design techniques such as the "prototype design pattern" described 
in the "Design Patterns" book by Erich Gamma et. al.

Later on you could try other methods to hold object libraries (such as
an OODB)

A VERY bare bones example of this pattern applied to your problem is:

class dynamicObject
{
   public:
      // Executes whatever code
      virtual execute(request& req) = 0;
      
      // Makes a deep copy of the object
      virtual clone() = 0;
      
      // Make sure destructors are virtual in derived classes
      virtual ~dynamicObject()
      
      virtual registrationInfo& getRegistrationInfo() const;
}


class myCodeLibrary
{
   public:
      bool registerNewObject(dynamicObject *o, dynamicObjectKey& k);
      vector<dynamicObjectKey> listAvailableObjects();
      dynamicObject* getPrototype(dynamicObjectKey& k);
}

class myExecutionFramework
{
   public:
      dynamicObject* CreateNewDynamicObject(dynamicObject* prototype);
      {
      ...
      ...
         return myNewDynamicObject = prototype->clone();
      ...
      }
      
      dynamicObjectKey& letTheUserChooseAnObject()
      {
      // Get the user to choose the object by selecting the key
      // use listAvailableObjects()
      ...
      }
      
      execute(request& req)
      {
      
      ...
      ...
         newObj = CreateNewDynamicObject(getPrototype(k));
	 newObj->execute(req);
      }
}


Like I said, this is a bare bones example, but hope it helps. 
The main point is that creation of new objects is possible
by calling a clone() function in the object; which, in turn
returns a copy of itself. It is similar to how fork() works on
Unix systems.  

The builders of executable objects (dynamicObjects) develop their libraries
(a shared library for example) and register the object by calling
registerNewObject(object,key). The key has to have enough information so
that a prorotype object instance can be loaded at runtime from the shared
library (such as the symbol name of the instance that is part of the shared
library and the name of the library itself). The key could also have
a description to display when the user is allowed to browse through the
available objects..... OR you could implement the object library using
any OODB........

After the library is created and the object is registered the
execution engine can call getPrototype(k) to get the prototype instance
and later on it can use the clone() function to create new objects 
as more users come into the system wanting to use that type of object.

This allows you to add and create new objects and classes AT RUNTIME, which,
as far as I understood is what you wanted. The only requirement is that the
new classes need to be derived from dynamicObject .....

The virtual function mechanism will take care of calling whatever the 
new object functionality is.


Bundle this on top of your CORBA implementation, debug it for 5 years :) ,
and you will have dynamically loadable objects in a distributed environment.


BTW, you mentioned writing an interpreter...I wouldn't do this unless my
real purpose was to create a new language/interpreter/compiler. If you want
to do that check PCCTS, it's a very nice compiler-compiler tool with infinite
look-ahead grammar, semantic predicates (which let your rules behave
differently based on semantics as opposed to pure sytactic rules) and a 
bundled-in lexical analyzer. You can get it from ftp.parr-research.com... 

It's enough work to do the distributed dynamic object part by itself :)


-- 
____________________________________________________________________
            /   __  __  __  - __  __ / - _  __  ologgio at vrainn.com
  Omar R.  /__ /_/ /_/ /_/ / /_/ /_/ / /_  /-_  CIS: 74040,1543
                  __/ __/                         
___C++/6_yrs____Virtual Reality/4_yrs____Vorl_____Linux(free)_______
PCCTS instead of YACC - LL(k) grammars, infinite look-ahead






More information about the Ale mailing list