So, you can establish inheritance relationships among objects or even, you can dynamically override virtual methods, while the applications is running. Working this way you can build more real_life-like models and simplify a lot of common operations which, in most cases, needs complex patterns. Design patterns like Factories, Facades, Proxies, etc... are implicit in the GNU EDMA programming model.
In addition to all this, the programming interface provided by GNU EDMA is mostly based on strings so, concepts like automation or component interactive managing are directly supported by the system in a very easy way.
As a final word, GNU/EDMA was developed using C language, and this is the full supported programming language by the system, so you can build your applications in an OO basis using C language.
The classes library is still barely populated, but we are working to add the basic components needed by most applications.
The use on autotools in this new release'll simplify the port to other paltforms.
On the other hand, there is no relationship with graphical components (JavaBeans, ActiveX) or distributed components (DCOM, CORBA-CCM). Any of this special kinds of components can be built using GNU EDMA, but GNU EDMA is a more general system. Actually, any of this system can be built in a easy way using GNU EDMA as its lower layer.
The other big diferences with other componet-based environments is that GNU EDMA does all the work at run-time, and allows to use OO programming on components, that is, you can, for example, use inheritance on components instead of complex aggregation/delegation systems.
For doing such a thing, GNU EDMA provides a set of primitives to add the information retrived by your parser in the system.
You can see an example on how to build such classes in: classes/systems/IngrIDF
So you can write new GNU EDMA classes that translates those GNU EDMA primitives in external calls to other system. For example, you can write a SIU Proxy (that is how this special classes are called), to interface GNU EDMA with any interpreted language like Java, Perl or Python, or even with other componet-based systems like CORBA-based ones.
In the section GNU/EDMA friends bellow you can check out some projects using GNU/EDMA SIU subsystem.
You can see a SIU Proxy example in: classes/systems/runnable
#includemain () { EDMAInit(); edma_printf ("Hello World from GNU/EDMA!\n"); EDMAEnd(); }
CC=gcc CFLAGS=`edma-config --cflags-exe` LIBS=`edma-config --libs-exe` all: your_application your_application: your_application.c $(CC) $(CFLAGS) $< -o $@ $(LIBS) clean: rm -f core *.o *~ your_application
myapp: error while loading shared libraries: libEDMA.so.0: cannot open shared object file: No such file or directory
This means that the dynamic linker can find GNU/EDMA lib. By default GNU/EDMA gets intalled in /usr/local/lib which isn't in the linker search path. Just add this path to your LD_LIBRARY_PATH environment variable or update your /etc/ld.so.conf file to include this directory, and then run ldconfig.
The code bellow shows an example on how to catch exceptions in your applications:
EDMA_TRY { id = edma_new_obj ("NON_EXISTING_CLASS"); } EDMA_CATCH (the_exception) { edma_met3 (the_exception, "print"); } EDMA_TRY_END;Current implementation uses preprocesor macros and longjmp calls to simulate exceptions. A better implementations will be provided in future versions.
Note that running this script while other GNU/EDMA applications are running will make them crash.
Anyway, you can install them manually following the steps listed bellow. Become root if necessary.
You can even install new versions of exsiting components while GNU/EDMA applications are running. In this case the existing objects continue using the old version of the class, but the new created objects will use the new version. This process will be improved in future versions, allowing to migrate existing objects to the new installed version if desired.
Note that in order to do not break running applications during this process, the new component version must provide the same interface the old version. The new version can add new properties and methods, but the old ones must be retained.
Procedding this way reduces granurality of the system in the sense that you can't update just one class.
For example, using static methods:
static ESint32 my_static_var = 0; ESint32 EDMAPROC MYCLASSget_static_var (CLASSID class_id) { return my_static_var; } EVoid EDMAPROC MYCLASSset_static_var (CLASSID class_id, ESint32 val) { my_static_var = val; }
GNU/EDMA inheritance is a run-time operation.
OBJID id = edma_new_obj ("ONE_CLASS"); edma_met3 (id, "A_SUPERCLASS<superclass_method"); edma_met3 (id, "A_SUBCLASS>subclass_method");
In the example above we begin with a simple class named ONE_CLASS. Then we add a superclass named A_SUPERCLASS just invoking a method of it. The < symbol means that this class must be attached above current class in the class hierarchy.
Second method invocation works the same way, but in this case adding a subclass.
One time the class has been attached we can use it without specifying the classpath.
OBJID id_obj = edma_new_obj ("SOME_CLASS"); CLASSID id_class = edma_get_class_id ("SUPERCLASS"); edma_add_superclass (id_obj, id_class, "SUPER1"); edma_add_superclass (id_obj, id_class, "SUPER2");Even, you can do this using On-Demand Inheritance.
OBJID id = edma_new_obj ("SOME_CLASS"); edma_met3 (id, "SUPERCLASS@SUPER1<a_method"); edma_met3 (id, "SUPERCLASS@SUPER2<a_method");
You can use class name or anchor points when building a classpath, and, as showed in previous question, you can use then to build repeated inheritance hierarchies.
Finally note that you can add a label for the uplink and for the downlink at the same time.
Take a look to this piece of code:
OBJID id = edma_new_obj ("PERSON"); edma_met3 (id, "PERSONALITY@JEKIL|WHO<work_at_lab"); edma_met3 (id, "PERSONALITY@HIDE|WHO<kill");
OBJID id = edma_new_obj ("DOG"); edma_wprop3 (id, "name", "Bobby"); edma_met3 (id, "BULLDOG@TYPE<bite"); /* Change bobby to be now a Fox Terrier */ edma_met3 (id, "FOX-TERRIER&lr;!bite");
Output will look like this:
----------------------------------------------------- Root ==> AP_TEST [0] SUPER ==> AP_TEST [1] SUPER ==> AP_TEST [2] MOST_TOP2 ==> AP_TEST [5] SUPER1 ==> AP_TEST [3] MOST_TOP ==> AP_TEST [4] ----------------------------------------------------- AP_TEST ==> AP_TEST [0] AP_TEST ==> AP_TEST [1] AP_TEST ==> AP_TEST [3] Root ==> AP_TEST [4]
Some of the available functions you can use are:
· edma_rename_superclass_ap: Renames superclasses anchor points
· edma_rename_subclass_ap: Renames subclasses anchor points
· edma_add_superclass: Adds a new superclass to a given object
· edma_add_subclass: Adds a new subclass to a given object
· edma_add_superobject: Adds a superobject to a given object
· edma_add_subobject: Adds a subobject to a given object
· edma_insert_superclass: Inserts a superclass up a given object
· edma_insert_subclass: Inserts a subclass down a given obejct
· edma_insert_superobject: Inserts a superobject up a given object
· edma_insert_subobject: Inserts a subobject down a given object
· edma_remove_superclass_ap: Remove a superclass from a given object
· edma_remove_subclass_ap: remove a subclass from a given objext
This simple applications is also a good example on how to use the GNU/EDMA reflection API.
With GNOME IDF Wizard you can generate .idf files, C language skeletons for the class implementation, or even a full directory tree to build your component using GNU autotools.
Take a look to classes/edma_tools/idf_wizard_support for examples. You can easely add new file types, just providing your own GNU/EDMA class and updating the builders.db file in /usr/local/share/edma.
A modified Perl interpreted, named pia, is supplied. Here you can see a simple example on how to use this extensions:
#!/usr/local/bin/pia use GNUEDMA; $id = GNUEDMA::new_obj ("NFILE"); GNUEDMA::met3x ($id, "open", "ZZ", "hello.txt", "wt"); GNUEDMA::met3x ($id, "puts", "Z", "Hello World from PIA!!!!\n"); GNUEDMA::met3x ($id, "close", ""); GNUEDMA::free_obj ($id);At this moment just the basic GNU/EDMA primitives are implemented, output parameters in methoid calls aren't supported, and method signatures are mandatory.
A Perl interpreter class is provided to embed Perl code in your applications and so use this language for scripting in them.
EDMAInit(); id = edma_new_obj ("PERL_INTERPRETER"); edma_met3 (id, "Run", "$hello=\"hello world!!\"; print $hello"); edma_free_obj (id); EDMAEnd();
The main problem is that Python do not support output parameters in an easy way. In fact the right way is to return the values changing (returning more than one value), what makes the interface a bit messy.
Here you can see a simple example on how an ANNA script looks like:
id = edma.new_obj ("NFILE"); edma.met3x (id, "open", "ZZ", "hello.txt", "wt"); edma.met3x (id, "puts", "ZS32", "Hello World!!!\n", 15); edma.met3x (id, "close" ); edma.free_obj (id);A Python interpreter class is provided to embed Python code in your applications and so use this language for scripting in them.
EDMAInit(); id = edma_new_obj ("ANNA_PYTHON_INTERP"); edma_met3 (id, "Initialize"); edma_met3 (id, "Run_SimpleString", "print 'Hello world from Python!!!\n'"); edma_met3 (id, "Run_Script", "./my_python_script.py"); edma_met3 (id, "Finalize"); EDMAEnd();
MONNA system allows you to run CLI bytecodes and to access classes they define. Bellow we can see a simple example on how to use this.
jit = edma_new_obj ("MONO_JIT"); id = edma_new_obj ("MONNA_PROXY:hello.exe|hello"); edma_met3 (id, "say", "Z", "Johnny"); edma_free_obj (id); edma_free_obj (jit);The example above runs a method named say in a class named hello included in the hello.exe file which first parameter is a string.
Inside a C# (for example) class we will can write code like this:
public void edma_test () { int id; id = GnuEDMA.new_obj ("HELLO_WORLD"); GnuEDMA.met3 (id, "say", "Johnny"); GnuEDMA.free_obj (id); }As happens with PIA and ANNA, CLI code can be executed from the GNU/EDMA applications. Here is a example showing how to run a CLI application.
id = edma_new_obj ("MONO_JIT"); edma_met3 (id, "run","hello.exe"); edma_free_obj (id);
This project is frozen until we found a solution to this problems.
Basically, it allows to just install the main application in a machine. When the application begin running, the components it requires will be downloaded from the network and installed if they do not exists in the local system.
So, you will get installed in each machine just the GNU/EDMA components you need for your applications, and you just need to install components in one machine.
Please send FSF & GNU inquiries & questions to gnu@gnu.org. There are also other ways to contact the FSF.
Please send comments on these web pages to webmasters@www.gnu.org, send other questions to gnu@gnu.org.
Copyright (C) 1998, 2001,2002 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
Updated: $Date: 2002/05/26 19:11:50 $ $Author: dmartin $