From 56cc59cf44ec64440ba4d1c0d005196195c758e6 Mon Sep 17 00:00:00 2001 From: hugues Date: Sat, 25 Mar 2006 15:07:51 +0000 Subject: Nettoyage du repository glagen git-svn-id: file:///usr/local/opt/svn/repos/glagen@12 0f7e0d06-a6f9-0310-a55f-d5f984f55e4c --- tags/START/glagen/dll/classes/Data_property.cc | 30 -- tags/START/glagen/dll/classes/Data_property.hh | 88 ----- tags/START/glagen/dll/classes/Data_string.cc | 1 - tags/START/glagen/dll/classes/Data_string.hh | 62 ---- .../glagen/dll/classes/GLG-libraries-devel.cc | 32 -- .../glagen/dll/classes/GLG-libraries-devel.hh | 1 - tags/START/glagen/dll/classes/dot.cc | 100 ------ tags/START/glagen/dll/classes/dot.hh | 49 --- tags/START/glagen/dll/classes/libclass.cc | 391 --------------------- tags/START/glagen/dll/classes/libclass.hh | 91 ----- tags/START/glagen/dll/classes/matrix.cc | 3 - tags/START/glagen/dll/classes/matrix.hh | 324 ----------------- tags/START/glagen/dll/classes/node.cc | 11 - tags/START/glagen/dll/classes/node.hh | 82 ----- 14 files changed, 1265 deletions(-) delete mode 100644 tags/START/glagen/dll/classes/Data_property.cc delete mode 100644 tags/START/glagen/dll/classes/Data_property.hh delete mode 100644 tags/START/glagen/dll/classes/Data_string.cc delete mode 100644 tags/START/glagen/dll/classes/Data_string.hh delete mode 100644 tags/START/glagen/dll/classes/GLG-libraries-devel.cc delete mode 100644 tags/START/glagen/dll/classes/GLG-libraries-devel.hh delete mode 100644 tags/START/glagen/dll/classes/dot.cc delete mode 100644 tags/START/glagen/dll/classes/dot.hh delete mode 100644 tags/START/glagen/dll/classes/libclass.cc delete mode 100644 tags/START/glagen/dll/classes/libclass.hh delete mode 100644 tags/START/glagen/dll/classes/matrix.cc delete mode 100644 tags/START/glagen/dll/classes/matrix.hh delete mode 100644 tags/START/glagen/dll/classes/node.cc delete mode 100644 tags/START/glagen/dll/classes/node.hh (limited to 'tags/START/glagen/dll/classes') diff --git a/tags/START/glagen/dll/classes/Data_property.cc b/tags/START/glagen/dll/classes/Data_property.cc deleted file mode 100644 index 3be4b27..0000000 --- a/tags/START/glagen/dll/classes/Data_property.cc +++ /dev/null @@ -1,30 +0,0 @@ -//============================================================================= -// -// 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 deleted file mode 100644 index b4d0c4d..0000000 --- a/tags/START/glagen/dll/classes/Data_property.hh +++ /dev/null @@ -1,88 +0,0 @@ -//============================================================================= -// -// 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 -#include -#include // Pour write/read - -#include - -#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 deleted file mode 100644 index 49fe4ff..0000000 --- a/tags/START/glagen/dll/classes/Data_string.cc +++ /dev/null @@ -1 +0,0 @@ -#include "Data_string.hh" diff --git a/tags/START/glagen/dll/classes/Data_string.hh b/tags/START/glagen/dll/classes/Data_string.hh deleted file mode 100644 index a5f9131..0000000 --- a/tags/START/glagen/dll/classes/Data_string.hh +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef DATA_STRING_HH_ -# define DATA_STRING_HH_ - -#include -#include -#include // Pour write/read - -#include - -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 deleted file mode 100644 index 002d479..0000000 --- a/tags/START/glagen/dll/classes/GLG-libraries-devel.cc +++ /dev/null @@ -1,32 +0,0 @@ -//============================================================================= -// -// 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 deleted file mode 100644 index 8b13789..0000000 --- a/tags/START/glagen/dll/classes/GLG-libraries-devel.hh +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tags/START/glagen/dll/classes/dot.cc b/tags/START/glagen/dll/classes/dot.cc deleted file mode 100644 index 10e766a..0000000 --- a/tags/START/glagen/dll/classes/dot.cc +++ /dev/null @@ -1,100 +0,0 @@ -// -// dot.cc for Glagen in ~/Galgen/3d -// -// Made by Zavie -// Login -// -// Started on Fri Aug 16 17:08:16 2002 Zavie -// - -#include -#include -#include -#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 deleted file mode 100644 index e13f23c..0000000 --- a/tags/START/glagen/dll/classes/dot.hh +++ /dev/null @@ -1,49 +0,0 @@ -// -// dot.hh for Glagen in ~/Galgen/3d -// -// Made by Zavie -// Login -// -// 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 deleted file mode 100644 index 730026f..0000000 --- a/tags/START/glagen/dll/classes/libclass.cc +++ /dev/null @@ -1,391 +0,0 @@ -//============================================================================= -// -// 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 -#include -#include -#include -#include - -#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 deps; - std::list::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 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 Library::getDependancies() const -{ - - /* - ** Gets all library's dependancies - */ - - typedef list (*deps_t)(); - deps_t Deps = (deps_t) dlsym(this->handler, "GLG_Dependancies"); - - list 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 Library::getDotProperties() const -{ - return this->properties; -} - - -int Library::getRealPos(int pos) const -{ - std::list::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 deps = this->getDependancies(); - std::list::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 Client_DotPropertyTab; -extern const list list_libs; - -Library* getLibraryByName(const string Name, const list list_libs) -{ - std::list::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::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::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 deleted file mode 100644 index 33a2fde..0000000 --- a/tags/START/glagen/dll/classes/libclass.hh +++ /dev/null @@ -1,91 +0,0 @@ -//============================================================================= -// -// 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 -#include -#include - -#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 getDependancies() const; - string getName() const; - string getFilename() const; - list getDotProperties() const; - int getRealPos(const int pos) const; - int AccesAllowed(string& ToLib) const; - -private: - string Filename; - void *handler; - std::list dependancies; - std::list 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 deleted file mode 100644 index 7991769..0000000 --- a/tags/START/glagen/dll/classes/matrix.cc +++ /dev/null @@ -1,3 +0,0 @@ - - -#include "matrix.hh" diff --git a/tags/START/glagen/dll/classes/matrix.hh b/tags/START/glagen/dll/classes/matrix.hh deleted file mode 100644 index f49ea17..0000000 --- a/tags/START/glagen/dll/classes/matrix.hh +++ /dev/null @@ -1,324 +0,0 @@ -// matrix.hh - -#include - -#ifndef REALMATRIX_HH_ -# define REALMATRIX_HH_ - -// la class TYPE ne peut etre que de type nombre (ex: double, int, long,...) - -template 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 -inline std::ostream& operator<<(std::ostream& ostr, const Matrix& 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 deleted file mode 100644 index a3ae387..0000000 --- a/tags/START/glagen/dll/classes/node.cc +++ /dev/null @@ -1,11 +0,0 @@ -// -// node.cc for in -// -// Made by meng-tih lam -// Login -// -// 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 deleted file mode 100644 index 3d8c838..0000000 --- a/tags/START/glagen/dll/classes/node.hh +++ /dev/null @@ -1,82 +0,0 @@ - -#ifndef NODE_HH_ -# define NODE_HH_ - -using namespace std; - -#include -#include - -// Rajouter l'include correspondant a la template de TYPENODE -// + implemente le std::cout abtrait pour les tests - -template class Tree; // Declaration prealable - -template class Node -{ - friend class Tree; - -public: - Node(const TYPENODE &d) : _link(new std::list), _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* get_childs() const { return (_link); } - - unsigned int get_number_node() const - { - unsigned int number_childs = _link->size(); - std::list::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::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 ptr_node = *new std::list; - ptr_node.push_back(*this); - while (ptr_node.size()) - { - std::list::iterator childs = ptr_node.begin(); - std::list::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 *_link; // Pointeur vers le sous-arbre - TYPENODE _data; -}; - -#endif // NODE_HH_ -- cgit v1.2.3