X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHEXABLOCK%2FHex.cxx;h=d3a7e6ad8cd39b0b9adcccbbb298bc1ef500ab03;hb=b807e66955ae476b30f59bc29f1fe6c813837063;hp=08a672d34410b8badb9b9629c112f9f693229066;hpb=8681e72f844274a0c2fc2cd64bbf2451bd8db77b;p=modules%2Fhexablock.git diff --git a/src/HEXABLOCK/Hex.cxx b/src/HEXABLOCK/Hex.cxx old mode 100755 new mode 100644 index 08a672d..d3a7e6a --- a/src/HEXABLOCK/Hex.cxx +++ b/src/HEXABLOCK/Hex.cxx @@ -1,12 +1,12 @@ // C++ : La clase principale de Hexa -// Copyright (C) 2009-2012 CEA/DEN, EDF R&D +// Copyright (C) 2009-2022 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,24 +21,27 @@ // #include "Hex.hxx" +#include "HexEltBase.hxx" #include "HexDocument.hxx" +#include "HexGlobale.hxx" #include BEGIN_NAMESPACE_HEXA +Hex* Hex::first_instance = NULL; + // ======================================================== Constructeur Hex::Hex () { - setlocale (LC_NUMERIC, "C"); + //setlocale (LC_NUMERIC, "C"); // VSR 2020-03-11: commented out - initial locale has to be restored somewhere... + glob = Globale::getInstance (); } // ======================================================== Destructeur Hex::~Hex () { -#ifndef NO_CASCADE int nbre = liste_documents.size(); for (int nd=0 ; nddump.start ("hexablock", "removeDocument"); + if (actif) + glob->dump << doc; + int nbre = liste_documents.size(); for (int nd=0 ; nddump.close (actif); return; } } // Pas trouve dans la liste. On detruit quand meme + glob->dump.close (actif); delete doc; } // ======================================================== addDocument Document* Hex::addDocument (cpchar nomdoc) { - Document* doc = new Document (nomdoc); + bool actif = glob->dump.start ("hexablock", "addDocument"); + if (actif) + glob->dump << nomdoc; + + std::string name; + makeName (nomdoc, name); + Document* doc = new Document (name.c_str(), this); + liste_documents.push_back (doc); + + glob->dump.close (actif, doc); return doc; } // ======================================================== loadDocument -Document* Hex::loadDocument (const char* filename) +Document* Hex::loadDocument (cpchar filename) { - Document* doc = addDocument ("xxxx"); + bool actif = glob->dump.start ("hexablock", "loadDocument"); + if (actif) + glob->dump << filename; + + Document* doc = addDocument ("default"); doc->loadXml (filename); + + glob->dump.close (actif, doc); return doc; } +// ======================================================== loadAllDocs +int Hex::loadAllDocs (cpchar stream) +{ + int posit = 0; + int car = ' '; + int nbdocs = 0; + + while ( (car=stream[posit++]) != '>') + if (car>='0' && car <='9') + nbdocs = 10*nbdocs + car - '0'; + + for (int nro = 0; nrosetXml (stream, posit); + } + + PutData (posit); + return HOK; +} +// ======================================================== saveAllDocs +int Hex::saveAllDocs (cpchar filename) +{ + FILE* fic = fopen (filename, "w"); + if (fic==NULL) + return HERR; + + int nbdocs = countDocument (); + fprintf (fic, "<%d>", nbdocs); + + for (int nro = 0; nroappendXml (fic); + } + + fclose (fic); + return HOK; +} +// ======================================================== findDocument +Document* Hex::findDocument (cpchar name) +{ + int nbdocs = liste_documents.size(); + for (int nro = 0; nrogetName ())) + return doc; + } + return NULL; +} +// ======================================================== makeName +void Hex::makeName (cpchar radical, std::string& name) +{ + char cnum [8]; + int numero = 0; + while (true) + { + name = radical; + if (numero>0) + { + sprintf (cnum, "_%d", numero); + name += cnum; + } + numero ++; + if (findDocument (name)==NULL) + return; + } +} +// ======================================================== lockDump +void Hex::lockDump () +{ + glob->dump.lock (); +} +// ======================================================== restoreDump +void Hex::restoreDump () +{ + glob->dump.restore (DumpActif); +} +// ====================================================== getInstance +Hex* Hex::getInstance () +{ + if (first_instance==NULL) + first_instance = new Hex (); + + return first_instance; +} +// ======================================================== what (?) +void Hex::what () +{ + bool actif = glob->dump.start ("hexablock", "what", false); + + Globale* glob = Globale::getInstance (); + glob->mess.printMessage(); + + glob->dump.close (actif); +} +// ======================================================== sizeofMessage +int Hex::sizeofMessage () +{ + return glob->mess.sizeofMessage (); +} +// ======================================================== getMessageLine +cpchar Hex::getMessageLine (int nlig) +{ + return glob->mess.getLine (nlig); +} +// ======================================================== hex_instance +Hex* hex_instance () +{ + Hex* hexa = Hex::getInstance (); + return hexa; +} +// ======================================================== what (fonction) +void what () +{ + Hex* hexa = Hex::getInstance (); + hexa->what (); +} + END_NAMESPACE_HEXA