summaryrefslogtreecommitdiff
path: root/tags/START/glagen/dll/classes
diff options
context:
space:
mode:
author(no author) <(no author)@0f7e0d06-a6f9-0310-a55f-d5f984f55e4c>2005-02-10 23:10:52 +0000
committer(no author) <(no author)@0f7e0d06-a6f9-0310-a55f-d5f984f55e4c>2005-02-10 23:10:52 +0000
commit695965a636bddfbafa0e8b8c66bfd3e7efa5d440 (patch)
tree92da17b074c1122ebdcd53f4cd5bc6b34151c83c /tags/START/glagen/dll/classes
parent1761afd30c5baeb038b666a6d838309e1040eb60 (diff)
This commit was manufactured by cvs2svn to create tag 'START'.
git-svn-id: file:///usr/local/opt/svn/repos/glagen@6 0f7e0d06-a6f9-0310-a55f-d5f984f55e4c
Diffstat (limited to 'tags/START/glagen/dll/classes')
-rw-r--r--tags/START/glagen/dll/classes/Data_property.cc30
-rw-r--r--tags/START/glagen/dll/classes/Data_property.hh88
-rw-r--r--tags/START/glagen/dll/classes/Data_string.cc1
-rw-r--r--tags/START/glagen/dll/classes/Data_string.hh62
-rw-r--r--tags/START/glagen/dll/classes/GLG-libraries-devel.cc32
-rw-r--r--tags/START/glagen/dll/classes/GLG-libraries-devel.hh1
-rw-r--r--tags/START/glagen/dll/classes/dot.cc100
-rw-r--r--tags/START/glagen/dll/classes/dot.hh49
-rw-r--r--tags/START/glagen/dll/classes/libclass.cc391
-rw-r--r--tags/START/glagen/dll/classes/libclass.hh91
-rw-r--r--tags/START/glagen/dll/classes/matrix.cc3
-rw-r--r--tags/START/glagen/dll/classes/matrix.hh324
-rw-r--r--tags/START/glagen/dll/classes/node.cc11
-rw-r--r--tags/START/glagen/dll/classes/node.hh82
14 files changed, 1265 insertions, 0 deletions
diff --git a/tags/START/glagen/dll/classes/Data_property.cc b/tags/START/glagen/dll/classes/Data_property.cc
new file mode 100644
index 0000000..3be4b27
--- /dev/null
+++ b/tags/START/glagen/dll/classes/Data_property.cc
@@ -0,0 +1,30 @@
+//=============================================================================
+//
+// Glagen : a planet sized landscape generator
+// Copyright (C) 2002 Julien Guertault, Hugues Hiegel, Meng-Tih Lam
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+//
+// Glagen : GPL LAndscape GENerator
+//
+// Data_property.cc for Glagen : made by Titi (Meng-tih LAM)
+//
+// www.glagen.org
+//
+//=============================================================================
+
+#include "Data_property.hh"
diff --git a/tags/START/glagen/dll/classes/Data_property.hh b/tags/START/glagen/dll/classes/Data_property.hh
new file mode 100644
index 0000000..b4d0c4d
--- /dev/null
+++ b/tags/START/glagen/dll/classes/Data_property.hh
@@ -0,0 +1,88 @@
+//=============================================================================
+//
+// Glagen : a planet sized landscape generator
+// Copyright (C) 2002 Julien Guertault, Hugues Hiegel, Meng-Tih Lam
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+//
+// Glagen : GPL LAndscape GENerator
+//
+// Data_property.hh for Glagen : made by Titi (Meng-tih LAM)
+//
+// www.glagen.org
+//
+//=============================================================================
+
+#ifndef DATA_PROPERTY_HH_
+# define DATA_PROPERTY_HH_
+
+#include <iostream>
+#include <string>
+#include <unistd.h> // Pour write/read
+
+#include <errno.h>
+
+#include "../../3d/data_glagen.hh"
+
+class Data_property
+{
+public:
+ Data_property() : _data(0), _size(0), _type(kind_lib_t(none)) {}
+ Data_property(void* data, size_t size, kind_lib_t type)
+ : _data(data),
+ _size(size),
+ _type(type)
+ {}
+
+ void write_data(const int& fd) const
+ {
+ write(fd, &_type, sizeof(int));
+ write(fd, &_size, sizeof(int));
+ write(fd, _data, _size * sizeof(void *));
+ }
+
+ void read_data(const int& fd)
+ {
+ do
+ {
+ errno = 0;
+ read(fd, &_type, sizeof(int));
+ }
+ while (errno == 4);
+
+ do
+ {
+ errno = 0;
+ read(fd, &_size, sizeof(int));
+ }
+ while (errno == 4);
+
+ do
+ {
+ errno = 0;
+ read(fd, _data, _size * sizeof(void *));
+ }
+ while (errno == 4);
+ }
+
+protected:
+ void *_data;
+ size_t _size;
+ kind_lib_t _type;
+};
+
+#endif // DATA_PROPERTY_HH_
diff --git a/tags/START/glagen/dll/classes/Data_string.cc b/tags/START/glagen/dll/classes/Data_string.cc
new file mode 100644
index 0000000..49fe4ff
--- /dev/null
+++ b/tags/START/glagen/dll/classes/Data_string.cc
@@ -0,0 +1 @@
+#include "Data_string.hh"
diff --git a/tags/START/glagen/dll/classes/Data_string.hh b/tags/START/glagen/dll/classes/Data_string.hh
new file mode 100644
index 0000000..a5f9131
--- /dev/null
+++ b/tags/START/glagen/dll/classes/Data_string.hh
@@ -0,0 +1,62 @@
+#ifndef DATA_STRING_HH_
+# define DATA_STRING_HH_
+
+#include <iostream>
+#include <string>
+#include <unistd.h> // Pour write/read
+
+#include <errno.h>
+
+using namespace std;
+
+class Data_string
+{
+public:
+ Data_string() : _str("") {};
+ Data_string(const string& str) : _str(str) {};
+
+ void write_data(const int& fd) const
+ {
+
+ std::cout << "Donnees envoyes" << std::endl << _str << std::endl;
+ unsigned int size = _str.size();
+ write(fd, &size, sizeof(unsigned int));
+ for (unsigned int i = 0; i < size; ++i)
+ {
+ char car = _str[i];
+ write(fd, &car, sizeof(char));
+ }
+ }
+
+ void read_data(const int& fd)
+ {
+ unsigned int size = 0;
+ do
+ {
+ errno = 0;
+ read(fd, &size, sizeof(size));
+ }
+ while (errno == 4);
+
+ _str = "";
+ for (unsigned int i = 0; i < size; ++i)
+ {
+ char car;
+ do
+ {
+ errno = 0;
+ read(fd, &car, sizeof(char));
+ }
+ while (errno == 4);
+ _str += car;
+ }
+
+ std::cout << "Reception message sur le file descriptor :" << fd
+ << std::endl << _str << std::endl;
+ }
+
+private:
+ string _str;
+};
+
+#endif // DATA_STRING
diff --git a/tags/START/glagen/dll/classes/GLG-libraries-devel.cc b/tags/START/glagen/dll/classes/GLG-libraries-devel.cc
new file mode 100644
index 0000000..002d479
--- /dev/null
+++ b/tags/START/glagen/dll/classes/GLG-libraries-devel.cc
@@ -0,0 +1,32 @@
+//=============================================================================
+//
+// Glagen : a planet sized landscape generator
+// Copyright (C) 2002 Julien Guertault, Hugues Hiegel, Meng-Tih Lam
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+//
+// Glagen : GPL LAndscape GENerator
+//
+// GLG-libraries-devel.cc for Glagen : made by Hugues HIEGEL
+//
+// www.glagen.org
+//
+//=============================================================================
+
+#include "GLG-libraries-devel.hh"
+#include "libclass.hh"
+
diff --git a/tags/START/glagen/dll/classes/GLG-libraries-devel.hh b/tags/START/glagen/dll/classes/GLG-libraries-devel.hh
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/tags/START/glagen/dll/classes/GLG-libraries-devel.hh
@@ -0,0 +1 @@
+
diff --git a/tags/START/glagen/dll/classes/dot.cc b/tags/START/glagen/dll/classes/dot.cc
new file mode 100644
index 0000000..10e766a
--- /dev/null
+++ b/tags/START/glagen/dll/classes/dot.cc
@@ -0,0 +1,100 @@
+//
+// dot.cc for Glagen in ~/Galgen/3d
+//
+// Made by Zavie
+// Login <guerta_j@epita.fr>
+//
+// Started on Fri Aug 16 17:08:16 2002 Zavie
+//
+
+#include <cstdio>
+#include <cstdlib>
+#include <cmath>
+#include "data_glagen.hh"
+#include "dot.hh"
+
+// Constructor and destructor
+Dot :: Dot (double x, double y, double z)
+{
+ int current;
+
+ _x = x;
+ _y = y;
+ _z = z;
+ _use = 0;
+ _property = new void *[GL_property];
+ for (current = 0; current < GL_property; current++)
+ _property[current] = NULL;
+ step = GL_step;
+}
+
+Dot :: ~Dot ()
+{
+ int current;
+
+ for (current = 0; current < GL_property; current++)
+ if (_property[current] != NULL)
+ delete _property[current];
+}
+
+// Reading
+double Dot :: x () { return _x; }
+double Dot :: y () { return _y; }
+double Dot :: z () { return _z; }
+
+void *Dot :: Property (int i)
+{
+ return _property[i];
+}
+bool Dot :: Is_checked () { return (step == GL_step); }
+
+// Writing
+void Dot :: set (double x, double y, double z)
+{
+ _x = x;
+ _y = y;
+ _z = z;
+}
+
+void Dot :: Use () { _use = _use + 1; }
+
+void Dot :: Drop ()
+{
+ _use = _use - 1;
+ if (0 == _use)
+ {
+ delete this;
+ printf("destroy !\n");
+ }
+}
+
+void Dot :: Del_property (int i)
+{
+ delete _property[i];
+ _property[i] = NULL;
+}
+
+void Dot :: Set_property (int i, void *property)
+{
+ _property[i] = property;
+}
+
+void Dot :: Checked () { step = GL_step; }
+
+// Other tools
+Dot *Dot :: Middle (Dot *b)
+{
+ double xc;
+ double yc;
+ double zc;
+ double adjust;
+
+ xc = (this->x () + b->x ()) / 2;
+ yc = (this->y () + b->y ()) / 2;
+ zc = (this->z () + b->z ()) / 2;
+ adjust = sqrt (GL_square_size / (xc * xc + yc * yc + zc * zc));
+ xc = xc * adjust;
+ yc = yc * adjust;
+ zc = zc * adjust;
+ return new Dot (xc, yc, zc);
+}
diff --git a/tags/START/glagen/dll/classes/dot.hh b/tags/START/glagen/dll/classes/dot.hh
new file mode 100644
index 0000000..e13f23c
--- /dev/null
+++ b/tags/START/glagen/dll/classes/dot.hh
@@ -0,0 +1,49 @@
+//
+// dot.hh for Glagen in ~/Galgen/3d
+//
+// Made by Zavie
+// Login <guerta_j@epita.fr>
+//
+// Started on Fri Aug 16 17:08:16 2002 Zavie
+//
+
+#ifndef DOT_HH_
+# define DOT_HH_
+
+class Dot
+{
+public:
+
+ // Constructor and destructor
+ Dot (double x, double y, double z);
+ ~Dot ();
+
+ // Reading
+ double x ();
+ double y ();
+ double z ();
+
+ void *Property (int i);
+ bool Is_checked ();
+
+ // Writing
+ void set (double x, double y, double z);
+ void Use ();
+ void Drop ();
+ void Del_property (int i);
+ void Set_property (int i, void *property);
+ void Checked ();
+
+ // Other tools
+ Dot *Middle (Dot *b);
+
+protected:
+ double _x;
+ double _y;
+ double _z;
+ unsigned char _use;
+ void **_property;
+ char step;
+};
+
+#endif // DOT_HH_
diff --git a/tags/START/glagen/dll/classes/libclass.cc b/tags/START/glagen/dll/classes/libclass.cc
new file mode 100644
index 0000000..730026f
--- /dev/null
+++ b/tags/START/glagen/dll/classes/libclass.cc
@@ -0,0 +1,391 @@
+//=============================================================================
+//
+// Glagen : a planet sized landscape generator
+// Copyright (C) 2002 Julien Guertault, Hugues Hiegel, Meng-Tih Lam
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+//
+// Glagen : GPL LAndscape GENerator
+//
+// libclass.cc for Glagen : made by Hugues HIEGEL
+//
+// www.glagen.org
+//
+//=============================================================================
+//--LIBRARY CLASS IMPLEMENTATION--//
+
+#include <iostream>
+#include <dlfcn.h>
+#include <cstdio>
+#include <string>
+#include <list>
+
+#include "../includes/errors.hh"
+#include "libclass.hh"
+
+using std::cout;
+using std::cerr;
+using std::endl;
+
+/******************************************
+* Constructors *
+* && Destructors *
+******************************************/
+Library::Library()
+{
+}
+
+Library::Library(string Filename)
+{
+ this->Filename = Filename;
+ this->properties.clear();
+}
+
+Library::~Library()
+{
+ if (this->handler)
+ this->UnloadLib();
+ this->Filename = "";
+ this->properties.clear();
+}
+
+/******************************************
+* Loaders *
+* -just loads libs files- *
+******************************************/
+int Library::LoadLib(string Filename)
+{
+ this->Filename = Filename;
+ return this->LoadLib();
+}
+
+int Library::LoadLib()
+{
+
+ this->properties.clear();
+
+ /*
+ ** Tries to open the library itself
+ */
+ this->handler = dlopen(Filename.c_str(), RTLD_LAZY);
+
+ if (!(this->handler)) /* This is not a library */
+ {
+ cerr << "#Err " << ERR_OPENLIB
+ << ": " << dlerror() << "" << endl;
+ return ERR_OPENLIB;
+ }
+
+ typedef string (*name_t)();
+ name_t Name = (name_t) dlsym(this->handler, "GLG_Name");
+ if (!Name)
+ {
+ cerr << "#Err " << ERR_LIBSYMBOL
+ << ": Missing symbol 'string GLG_Name()' in "
+ << this->Filename << "" << endl;
+ return ERR_LIBSYMBOL;
+ }
+
+ cout << "Loading library: ";
+ cout << Name();
+
+ // This shows the dependancies in loading time.
+ list<string> deps;
+ std::list<string>::iterator deps_i;
+ deps = this->getDependancies();
+ if (! deps.empty())
+ {
+ cout << " {";
+ for (deps_i = deps.begin();
+ deps_i != deps.end();
+ deps_i++)
+ cout << *deps_i << ", ";
+ cout << "}";
+ }
+ cout << endl;
+
+ typedef void* (*hello_t)();
+ hello_t Hello = (hello_t) dlsym(this->handler, "GLG_Hello");
+ if (Hello)
+ Hello();
+
+ return 0;
+}
+
+int Library::Initialize()
+{
+ cout << "Moteur\tlibrary::initialize " << endl ;
+
+ // typedef int (*init_t)(void*, Library*);
+ // init_t Init = (init_t) dlsym(this->handler, "GLG_Init");
+ // if (Init)
+ // Init(palloc, this);
+
+ /***********************************************
+ ** typedef struct dot_property_t { **
+ ** int pos; **
+ ** size_t size; **
+ ** }; **
+ ** **
+ ** std::list<dot_property_t> this->properties **
+ ***********************************************/
+ return 0;
+
+}
+
+int Library::MainLoop(Dot* dot)
+{
+ cout << "Moteur\tlibrary::mainloop " << endl ;
+
+ typedef int (*main_t)(Dot*, void*);
+ main_t _Main = (main_t) dlsym(this->handler, "GLG_Main");
+ if (_Main)
+ _Main(dot, NULL);
+
+ return 0;
+
+}
+
+/******************************************
+* Miscellaneous stuffs *
+* Useful functions *
+******************************************/
+list<string> Library::getDependancies() const
+{
+
+ /*
+ ** Gets all library's dependancies
+ */
+
+ typedef list<string> (*deps_t)();
+ deps_t Deps = (deps_t) dlsym(this->handler, "GLG_Dependancies");
+
+ list<string> deps;
+ deps.clear();
+
+ if (!Deps)
+ return deps;
+
+ deps = Deps();
+ return deps;
+}
+
+string Library::getName() const
+{
+
+ /*
+ ** Gets the library's basename
+ */
+
+ typedef string (*name_t)();
+ name_t Name = (name_t) dlsym(this->handler, "GLG_Name");
+
+ if (!Name)
+ return this->Filename;
+
+ return Name();
+}
+
+
+string Library::getFilename() const
+{
+ return this->Filename;
+}
+
+list<dot_property_t> Library::getDotProperties() const
+{
+ return this->properties;
+}
+
+
+int Library::getRealPos(int pos) const
+{
+ std::list<dot_property_t>::const_iterator prop_i;
+ int i = 0;
+
+ for (prop_i = this->properties.begin();
+ (i < pos) && (prop_i != this->properties.end());
+ prop_i++)
+ i++;
+
+ if (i != pos)
+ return (-1);
+ return (prop_i->pos);
+}
+
+
+int Library::AccesAllowed(string& ToLib) const
+{
+ if (ToLib == this->getName())
+ return 1;
+
+ int allowed = 0;
+
+ std::list<string> deps = this->getDependancies();
+ std::list<string>::const_iterator dep_i;
+
+ for (dep_i = deps.begin();
+ !allowed && (dep_i != deps.end());
+ dep_i++)
+ allowed = (*dep_i == ToLib);
+
+ return allowed;
+
+}
+
+/******************************************
+* Unloader *
+* -closes the library handler if exists- *
+******************************************/
+void Library::UnloadLib()
+{
+ using std::cout;
+ using std::cerr;
+ using std::endl;
+
+ /*
+ ** Asks the library to say 'Bye'
+ */
+ cout << "Closing library: ";
+
+ typedef string (*name_t)();
+ name_t Name = (name_t) dlsym(this->handler, "GLG_Name");
+ cout << Name() << endl;
+
+ typedef string (*bye_t)();
+ bye_t Bye = (bye_t) dlsym(this->handler, "GLG_Bye");
+ if (Bye)
+ Bye();
+
+ dlclose(this->handler);
+}
+
+/******************************************
+* _palloc *
+* stores infos on dot properties needed *
+******************************************/
+void Library::_palloc(kind_lib_t type, size_t size)
+{
+ // in (*this) handler, we will store all this shit.
+ GLG_property_pos++;
+
+ cout << "\tThis is this->_palloc" << endl;
+
+ dot_property_t property;
+ property.pos = GLG_property_pos;
+ property.size = size;
+ property.type = type;
+
+ this->properties.push_back(property);
+
+ return ;
+}
+
+
+/******************************************
+* Utilities *
+* external functions needed for developers*
+******************************************/
+
+/* I am sure I know that ?? */
+extern list<property_t> Client_DotPropertyTab;
+extern const list<Library> list_libs;
+
+Library* getLibraryByName(const string Name, const list<Library> list_libs)
+{
+ std::list<Library>::const_iterator lib_i;
+ for (lib_i = list_libs.begin();
+ (lib_i->getName() != Name) && (lib_i != list_libs.end());
+ lib_i++)
+ ;
+ /* Yeah, we got the library. */
+
+ Library* toto = NULL;
+ (*toto) = *lib_i;
+ return (toto);
+}
+
+void GLG_write(int pos, size_t size, void* data, Library* REF)
+{
+ int real_pos = REF->getRealPos(pos);
+ if (real_pos > -1)
+ {
+ std::list<property_t>::const_iterator prop_i;
+ int i = 0;
+ for (prop_i = Client_DotPropertyTab.begin();
+ (i < real_pos) && (prop_i != Client_DotPropertyTab.end());
+ prop_i++)
+ ;
+ if (i == real_pos)
+ memcpy(prop_i->data, data, size); /* ou alors j'ai rien compris */
+ }
+
+}
+
+void GLG_read(string& LibName, int pos, size_t size, void* data, Library* REF)
+{
+ cout << REF->getName() << " hvufidoshvuiovhfudsviofdhvudiso" << endl;
+
+ if (/*REF->AccessAllowed(LibName)*/ 1)
+ {
+
+ Library* Lib = getLibraryByName(LibName, list_libs);
+
+ int real_pos = Lib->getRealPos(pos);
+ if (real_pos > -1)
+ {
+ std::list<property_t>::const_iterator prop_i;
+ int i = 0;
+ for (prop_i = Client_DotPropertyTab.begin();
+ (i < real_pos) && (prop_i != Client_DotPropertyTab.end());
+ prop_i++)
+ ;
+ if (i == real_pos)
+ memcpy(data, prop_i->data, size); /* ou alors j'ai rien compris */
+ }
+ }
+
+ return ;
+}
+
+void GLG_read(int pos, size_t size, void* data, Library* REF)
+{
+ string toto = REF->getName();
+ GLG_read(toto, pos, size, data, REF);
+}
+
+void palloc(kind_lib_t type, size_t size, Library* REF)
+{
+ cout << "\tThis is palloc itself" << endl;
+
+ /*************************************************
+ ** **
+ ** From a .so, we cannot call a class method. **
+ ** But we need to do that !! **
+ ** **
+ ** So, I made this little shortcut : **
+ ** a function that takes a class pointer, **
+ ** and that calls the real method. **
+ ** **
+ ** So easy. **
+ ** **
+ *************************************************/
+
+ REF->_palloc(type, size);
+ return ;
+}
+
diff --git a/tags/START/glagen/dll/classes/libclass.hh b/tags/START/glagen/dll/classes/libclass.hh
new file mode 100644
index 0000000..33a2fde
--- /dev/null
+++ b/tags/START/glagen/dll/classes/libclass.hh
@@ -0,0 +1,91 @@
+//=============================================================================
+//
+// Glagen : a planet sized landscape generator
+// Copyright (C) 2002 Julien Guertault, Hugues Hiegel, Meng-Tih Lam
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=============================================================================
+//
+// Glagen : GPL LAndscape GENerator
+//
+// libclass.hh for Glagen : made by Hugues HIEGEL
+//
+// www.glagen.org
+//
+//=============================================================================
+//--LIBRARY CLASS DEFINITION--//
+
+#include <iostream>
+#include <string>
+#include <list>
+
+#include "../../3d/data_glagen.hh"
+#include "Data_property.hh"
+
+#ifndef LIBCLASS_HH_
+# define LIBCLASS_HH_
+
+using namespace std;
+extern int GLG_property_pos;
+
+typedef struct dot_property_t {
+ int pos;
+ size_t size;
+ kind_lib_t type;
+};
+
+class Library
+{
+public:
+
+ Library();
+ Library(string Filename);
+ virtual ~Library();
+
+ // int FirstLoad(); // ???
+ int LoadLib();
+ int LoadLib(string Filename);
+ int Initialize();
+ int MainLoop(Dot* dot);
+ void _palloc(kind_lib_t type, size_t size);
+
+ // int MainLoop(Dot* dot, ...);
+
+ int Uninitialize();
+ void UnloadLib();
+
+ list<string> getDependancies() const;
+ string getName() const;
+ string getFilename() const;
+ list<dot_property_t> getDotProperties() const;
+ int getRealPos(const int pos) const;
+ int AccesAllowed(string& ToLib) const;
+
+private:
+ string Filename;
+ void *handler;
+ std::list<string> dependancies;
+ std::list<dot_property_t> properties;
+
+};
+
+void palloc(kind_lib_t type, size_t size, Library* REF);
+
+void GLG_write(int pos, size_t size, void* data, Library* REF);
+void GLG_read(string& LibName, int pos, size_t size, void* data, Library* REF);
+void GLG_read(int pos, size_t size, void* data, Library* REF);
+
+#endif //LIBCLASS_HH_
diff --git a/tags/START/glagen/dll/classes/matrix.cc b/tags/START/glagen/dll/classes/matrix.cc
new file mode 100644
index 0000000..7991769
--- /dev/null
+++ b/tags/START/glagen/dll/classes/matrix.cc
@@ -0,0 +1,3 @@
+
+
+#include "matrix.hh"
diff --git a/tags/START/glagen/dll/classes/matrix.hh b/tags/START/glagen/dll/classes/matrix.hh
new file mode 100644
index 0000000..f49ea17
--- /dev/null
+++ b/tags/START/glagen/dll/classes/matrix.hh
@@ -0,0 +1,324 @@
+// matrix.hh
+
+#include <iostream>
+
+#ifndef REALMATRIX_HH_
+# define REALMATRIX_HH_
+
+// la class TYPE ne peut etre que de type nombre (ex: double, int, long,...)
+
+template <class TYPE> class Matrix
+{
+public:
+ // Constructor
+ Matrix(const unsigned int i, const unsigned int j)
+ {
+ this->_i = i;
+ this->_j = j;
+ this->_lines = new _line[i]; // Create lines...
+ for (unsigned int k = 0; k < i; ++k)
+ this->_lines[k] = new TYPE[j]; // ...and create column
+ for (unsigned int k = 0; k < i; ++k)
+ for (unsigned int l = 0; l < j; ++l)
+ this->_lines[k][l] = 0;
+ }
+
+ // Constructor by copy
+ Matrix(const Matrix& mat)
+ {
+ this->_i = mat._i;
+ this->_j = mat._j;
+ this->_lines = new _line[this->_i];
+ for (unsigned int k = 0; k < this->_i; ++k)
+ {
+ this->_lines[k] = new TYPE[this->_j];
+ for (unsigned int l = 0; l < this->_j; ++l)
+ this->_lines[k][l] = mat._lines[k][l];
+ }
+ }
+
+ // Destructor
+ ~Matrix()
+ {
+ if (this->_i != 0 || this->_j != 0)
+ {
+ for (unsigned int i = 0; i < this->_i; i++)
+ delete [] this->_lines[i];
+ delete [] this->_lines;
+ }
+ }
+
+ // Affected operator
+ Matrix& operator=(const Matrix& mat)
+ {
+ if (&mat != this)
+ {
+ if (mat._i != this->_i || mat._j != this->_j) // Test dim
+ {
+ this->~Matrix(); // Destroy...
+ this->_i = mat._i;
+ this->_j = mat._j;
+ this->_lines = new _line[this->_i]; // ...and realloc
+ for (unsigned int i = 0; i < this->_i; ++i)
+ this->_lines[i] = new TYPE[this->_j];
+ }
+ for (unsigned int i = 0; i < this->_i; ++i) // Copy
+ for (unsigned int j = 0; j < this->_j; ++j)
+ this->_lines[i][j] = mat._lines[i][j];
+ }
+ return (*this);
+ }
+
+ // Add elements to matrix
+ Matrix& add_elems(const int& nb)
+ {
+ Matrix mat(this->_i + nb, this->_j + nb);
+ for (unsigned int i = 0; i < this->_i; i++)
+ for (unsigned int j = 0; j < this->_j; j++)
+ mat(i, j) = this->_lines[i][j];
+ *this = mat;
+ return (*this);
+ }
+
+ // Add matrix to matrix
+ Matrix& add_mat(const Matrix& mat)
+ {
+ unsigned int i = this->_i;
+ unsigned int j = this->_j;
+ this->add_elems(mat._i);
+ for (unsigned int k = i; k < this->_i; k++)
+ for (unsigned int l = j; l < this->_j; l++)
+ this->_lines[k][l] = mat(k - i, l - j);
+ return (*this);
+ }
+
+ // Add of matrix
+ Matrix operator+(const Matrix& mat)
+ {
+ Matrix mat_tmp(this->_i, mat._j);
+ if (this->_i != mat._i || this->_j != mat._j)
+ {
+ std::cerr << "Error of addiction of 2 matrix (dimensions)"\
+ << std::endl;
+ return (mat_tmp);
+ }
+ for (unsigned int i = 0; i < this->_i; ++i)
+ for (unsigned int j = 0; j < this->_j; ++j)
+ mat_tmp._lines[i][j] = this->_lines[i][j] + mat._lines[i][j];
+ return (mat_tmp);
+ }
+
+ Matrix operator+(const Matrix& mat) const
+ {
+ Matrix mat_tmp(this->_i, mat._j);
+ if (this->_i != mat._i || this->_j != mat._j)
+ {
+ std::cerr << "Error of addiction of 2 matrix (dimensions)"\
+ << std::endl;
+ return (mat_tmp);
+ }
+ for (unsigned int i = 0; i < this->_i; ++i)
+ for (unsigned int j = 0; j < this->_j; ++j)
+ mat_tmp._lines[i][j] = this->_lines[i][j] + mat._lines[i][j];
+ return (mat_tmp);
+ }
+
+ // Sub matrix
+ Matrix operator-(const Matrix& mat)
+ {
+ Matrix mat_tmp(this->_i, mat._j);
+ if (this->_i != mat._i || this->_j != mat._j)
+ {
+ std::cerr << "Error of substraction of 2 matrix (dimensions)"\
+ << std::endl;
+ return (mat_tmp);
+ }
+ for (unsigned int i = 0; i < this->_i; ++i)
+ for (unsigned int j = 0; j < this->_j; ++j)
+ mat_tmp._lines[i][j] = this->_lines[i][j] - mat._lines[i][j];
+ return (mat_tmp);
+ }
+
+ Matrix operator-(const Matrix& mat) const
+ {
+ Matrix mat_tmp(this->_i, mat._j);
+ if (this->_i != this->_j || this->_i != mat._i || mat._i != mat._j)
+ {
+ std::cerr << "Error of substraction of 2 matrix (dimensions)"\
+ << std::endl;
+ return (mat_tmp);
+ }
+ for (unsigned int i = 0; i < this->_i; ++i)
+ for (unsigned int j = 0; j < this->_j; ++j)
+ mat_tmp._lines[i][j] = this->_lines[i][j] - mat._lines[i][j];
+ return (mat_tmp);
+ }
+
+ // Multiplication of matrix
+ Matrix operator*(const Matrix& mat)
+ {
+ Matrix mat_tmp(this->_i, mat._j);
+ if (this->_j != mat._i) // Check dimension
+ {
+ std::cerr << "Error of produce of 2 matrix (dimensions)"\
+ << std::endl;
+ return (mat_tmp);
+ }
+ for (unsigned int i = 0; i < this->_i; ++i)
+ {
+ for (unsigned int j = 0; j < mat._j; ++j)
+ {
+ TYPE res = 0;
+ // Produce lines and column of matrix
+ for (unsigned int k = 0; k < this->_j; ++k)
+ res += this->_lines[i][k] * mat._lines[k][j];
+ mat_tmp._lines[i][j] = res;
+ }
+ }
+ return (mat_tmp);
+ }
+
+ // Multiplication with real
+ Matrix& operator*(const TYPE& nbr)
+ {
+ for (unsigned int i = 0; i < this->_i; i++)
+ for (unsigned int j = 0; j < this->_j; j++)
+ {
+ this->_lines[i][j] *= nbr;
+ }
+ return (*this);
+ }
+
+ // Divide with real
+ Matrix& operator/(const TYPE& nbr)
+ {
+ for (unsigned int i = 0; i < this->_i; i++)
+ for (unsigned int j = 0; j < this->_j; j++)
+ {
+ this->_lines[i][j] /= nbr;
+ }
+ return (*this);
+ }
+
+ //Get dimension of matrix
+ const int get_dim() const
+ {
+ if (this->_i != this->_j)
+ {
+ std::cerr << "Matrix isn't nxn, cannot give dimension" << std::endl;
+ return (0);
+ }
+ return (this->_i);
+ }
+
+ // Operator to change mat(i, j)
+ // to can write mat(i, j) = ...
+ TYPE& operator()(unsigned int i, unsigned int j)
+ {
+ return (this->_lines[i][j]);
+ }
+
+ // Operator to access mat(i, j)
+ // to can write int x = mat(i, j)
+ TYPE operator()(unsigned int i, unsigned int j) const
+ {
+ return (this->_lines[i][j]);
+ }
+
+ // Test matrix nul
+ const bool test_nul() const
+ {
+ for (unsigned int i = 0; i < this->_i; i++)
+ for (unsigned int j = 0; j < this->_j; j++)
+ if (this->_lines[i][j] != 0)
+ return (0);
+ return (1);
+ }
+
+ // Test diagonal matrix nul
+ const int test_diag() const
+ {
+ for (unsigned int i = 0; i < this->_i; i++)
+ if (this->_lines[i][i] != 0)
+ return (i);
+ return (-1);
+ }
+
+ // Test diagonal matrix nul with element
+ const int test_diag(const unsigned int& j) const
+ {
+ for (unsigned int i = 0; i < this->_i; i++)
+ if (this->_lines[i][i] != 0 && i == j)
+ return (i);
+ return (-1);
+ }
+
+ // Calculate trace
+ const TYPE trace() const
+ {
+ TYPE res = 0;
+ if (this->_i != this->_j)
+ {
+ std::cerr << "Matrix isn't nxn, cannot give trace" << std::endl;
+ return (0);
+ }
+ for (unsigned int i = 0; i < this->_i; i++)
+ res += this->_lines[i][i];
+ return (res);
+ }
+
+ // Transpose
+ Matrix& transpose()
+ {
+ if (this->_i != this->_j)
+ {
+ std::cerr << "Matrix isn't nxn, cannot transpose" << std::endl;
+ return (*this);
+ }
+ TYPE tmp = 0;
+ for (unsigned int i = 0; i < this->_i; i++)
+ for (unsigned int j = 0; j < i; j++)
+ {
+ tmp = this->_lines[i][j];
+ this->_lines[i][j] = this->_lines[j][i];
+ this->_lines[j][i] = tmp;
+ }
+ return (*this);
+ }
+
+ Matrix transpose() const
+ {
+ Matrix mat(this->_j, this->_i);
+ for (unsigned int i = 0; i < this->_i; i++)
+ for (unsigned int j = 0; j < this->_j; j++)
+ mat._lines[i][j] = this->_lines[j][i];
+ return (mat);
+ }
+
+ // Display matrix
+ void print(std::ostream &os) const
+ {
+ for (unsigned int i = 0; i < this->_i; ++i)
+ {
+ for (unsigned int j = 0; j < this->_j; ++j)
+ os << this->_lines[i][j] << " ";
+ os << std::endl;
+ }
+ }
+
+protected:
+ typedef TYPE* _line;
+ _line* _lines;
+ unsigned int _i; // Number of lines
+ unsigned int _j; // Number of column
+};
+
+template <class TYPE>
+inline std::ostream& operator<<(std::ostream& ostr, const Matrix<TYPE>& stream)
+{
+ stream.print(ostr);
+ return (ostr);
+}
+
+
+#endif // MATRIX_HH
diff --git a/tags/START/glagen/dll/classes/node.cc b/tags/START/glagen/dll/classes/node.cc
new file mode 100644
index 0000000..a3ae387
--- /dev/null
+++ b/tags/START/glagen/dll/classes/node.cc
@@ -0,0 +1,11 @@
+//
+// node.cc for in
+//
+// Made by meng-tih lam
+// Login <lam_m@epita.fr>
+//
+// Started on Fri Aug 16 02:40:40 2002 meng-tih lam
+// Last update Fri Aug 16 02:41:05 2002 meng-tih lam
+//
+
+#include "node.hh"
diff --git a/tags/START/glagen/dll/classes/node.hh b/tags/START/glagen/dll/classes/node.hh
new file mode 100644
index 0000000..3d8c838
--- /dev/null
+++ b/tags/START/glagen/dll/classes/node.hh
@@ -0,0 +1,82 @@
+
+#ifndef NODE_HH_
+# define NODE_HH_
+
+using namespace std;
+
+#include <list>
+#include <cassert>
+
+// Rajouter l'include correspondant a la template de TYPENODE
+// + implemente le std::cout abtrait pour les tests
+
+template<class TYPENODE> class Tree; // Declaration prealable
+
+template<class TYPENODE> class Node
+{
+ friend class Tree<TYPENODE>;
+
+public:
+ Node(const TYPENODE &d) : _link(new std::list<Node>), _data(d) {}
+
+ void add_child(const TYPENODE& value) { _link->push_back(Node(value)); }
+
+ void add_tree_node(const Node& value) { _link->push_back(value); }
+
+ TYPENODE get_data() const { return (_data); }
+
+ const unsigned int get_nb_childs() const { return (_link->size()); }
+
+ std::list<Node>* get_childs() const { return (_link); }
+
+ unsigned int get_number_node() const
+ {
+ unsigned int number_childs = _link->size();
+ std::list<Node>::const_iterator child = _link->begin();
+ unsigned int number_node = 1;
+ for (unsigned int tmp = 0; tmp != number_childs; ++tmp)
+ {
+ number_node += child->get_number_node();
+ ++child;
+ }
+ return (number_node);
+ }
+
+ // Renvoie le noeud fils suivant le numero a partir de 0
+ Node get_child(const unsigned int& i) const
+ {
+ assert(i < _link->size());
+ std::list<Node>::const_iterator child = _link->begin();
+ for (unsigned int tmp = 0; tmp != i; ++tmp)
+ ++child;
+ return (*child);
+ }
+
+ // Numerotation de l'arbre suivant un parcours en largeur de 0 a n
+ Node get_node_course_width(const int& ptr) const
+ {
+ int rptr = ptr;
+ std::list<Node> ptr_node = *new std::list<Node>;
+ ptr_node.push_back(*this);
+ while (ptr_node.size())
+ {
+ std::list<Node>::iterator childs = ptr_node.begin();
+ std::list<Node>::iterator child = childs->get_childs()->begin();
+ for (; child != childs->get_childs()->end(); ++child)
+ {
+ ptr_node.push_back(*child);
+ if (--rptr == 0)
+ return (*child);
+ }
+ ptr_node.pop_front();
+ }
+ return (*this);
+ }
+
+private:
+
+ std::list<Node> *_link; // Pointeur vers le sous-arbre
+ TYPENODE _data;
+};
+
+#endif // NODE_HH_