Using Yed objects in your applications

Using Yed objects in your applications is very simple. Every Yed object starts to live with a call like this:

OBJ *p= New(OBJ);

where OBJ is Yed object type you want to use.

For example, if you want to use YedXml object:

#include ".../yedstd.h"
#include ".../yedxml.h"
...
YedXml *p = New(YedXml);

Naturally, you have to include Yed header files in your source code, else C compiler cannot resolve Yed symbols.

After the invocation of Yed constructor, pointer 'p' is the 'this' pointer of the object you have created, and it must be passed as first parameter of any method of Yed object, like this:

p->method_of_OBJ(p,...);

In our example:

#include ".../yedstd.h"
#include ".../yedxml.h"
...
YedXml *p = New(YedXml);
...
p->Get_XML_Buffer(p,"./prova.xml");
s=p->Load_Tree(p);

Passing 'this' pointer to Yed object instance it relates to, allows to create many Yed objects having the same type in the same scope, or in a multithreading environment, because every object instance has its own 'this' pointer, exactly as it should be. Naturally, a method can have more than one parameter: they will come after 'this' pointer.

When Yed object that you have created is no longer needed, you must invoke the destructor of Yed object, in the form:

Delete(OBJ,p);

Our example becomes:

#include ".../yedstd.h"
#include ".../yedxml.h"
...
YedXml *p = New(YedXml);
...
p->Get_XML_Buffer(p,"./prova.xml");
s=p->Load_Tree(p);
...
Delete(YedXml,p);

Every Yed object is always created in heap memory: then, if you don't invoke Yed object's destructor, you don't free related heap memory. Always remember to delete Yed objects' instances when they are no longer needed!!!


http://yed.sourceforge.net