Changeset 3016 in Sophya


Ignore:
Timestamp:
Jul 17, 2006, 2:28:12 PM (19 years ago)
Author:
ansari
Message:

modification SophyaInitiator avec enregistrement list de modules - pret pour tag V2 Reza 17/7/2006

Location:
trunk/SophyaLib/BaseTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/sophyainit.cc

    r2830 r3016  
    2020#include "sversion.h"
    2121
     22#include <iostream>
     23#include <map>
     24
    2225// ---  Classe d'initialisation de SOPHYA, (PPersistMgr en particulier)
    2326int SophyaInitiator::FgInit = 0;
     27// Module version number - 2.0 , Jul 2006
     28#define MOD_VERS   2.0
     29
     30// Pour garder la liste des modules et leurs numeros de version
     31map<string, double>* ModListP = NULL;
    2432
    2533/*!
     
    3442  be a sub-class of SophyaInitiator. 
    3543*/
     44
    3645
    3746SophyaInitiator::SophyaInitiator()
     
    4655
    4756  InitFailNewHandler();
     57  ModListP = new map<string, double>;
     58 
    4859
    4960  #ifdef xx__mac__
     
    149160
    150161  // si var env SOPHYA_NOPRTVER definie pas de print
    151   if(!getenv("SOPHYA_NOPRTVER")) Version(true);
     162  if(!getenv("SOPHYA_NOPRTVER")) PrintVersion(false);
    152163
    153164  int pnice;
     
    157168  nice(pnice);
    158169
     170  SophyaInitiator::RegisterModule("BaseTools", MOD_VERS);  // Module name and version number registration 
    159171}
    160172
     
    171183}
    172184
    173 double SophyaInitiator::Version(bool fgprt)
    174 {
    175 if (fgprt) {
     185/*!
     186  \brief Return the SOPHYA version number.
     187  \param svers contain the complete in addition the SOPHYA tag, the compiler name
     188  and the compilation date
     189*/
     190double SophyaInitiator::GetVersion(string& svers)
     191{
    176192  char* compiler = 0;
    177193  #ifdef __GNUG__
     
    186202  #ifdef __KCC__
    187203  compiler = const_cast<char *>("KCC ") ;
     204  #endif
     205  #ifdef __IBMCPP__
     206  compiler = const_cast<char *>("IBM-xlC ") ;
     207  #endif
     208  #ifdef __INTEL_COMPILER
     209  compiler = const_cast<char *>("Intel-icc ") ;
    188210  #endif
    189211  #ifdef __SGICC__
     
    197219  compiler = const_cast<char *>("Codewarrior ");
    198220  #endif
    199   fprintf(stderr,"SOPHYA Version %4.1f Revision %d (%s) -- %s %s %s\n",
     221
     222  char buff[512];
     223  sprintf(buff,"SOPHYA Version %4.1f Revision %d (%s) -- %s %s %s",
    200224          SOPHYA_VERSION, SOPHYA_REVISION, SOPHYA_TAG,
    201225          __DATE__, __TIME__, compiler);
    202 }
    203 return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
    204 }
    205 
     226  svers = buff;
     227 
     228  return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
     229}
     230
     231//! Print the SOPHYA version string and optionaly the list of registered modules
     232void SophyaInitiator::PrintVersion(bool fglist)
     233{
     234  string svers;
     235  GetVersion(svers);
     236  cout << svers << endl;
     237  if (fglist) ListModules(cout);   
     238}
     239
     240//! Should be called by sub-classes to register module name and version
     241int SophyaInitiator::RegisterModule(const char * name, double version)
     242{
     243  if (ModListP == NULL)
     244    throw NullPtrError("SophyaInitiator::RegisterModule() ModListP= NULL !");
     245  map<string, double>& modlist = *ModListP;
     246  modlist[string(name)] = version;
     247  return modlist.size();
     248}
     249
     250//! List of registered module names and version number
     251int SophyaInitiator::ListModules(ostream& os)
     252{
     253  if (ModListP == NULL)
     254    throw NullPtrError("SophyaInitiator::ListModules() ModListP= NULL !");
     255  os << "--- SophyaInitiator::ListModules() Name / VersionNumber --- " << endl;
     256  map<string, double>& modlist = *ModListP;
     257  int k = 1;
     258  for(map<string, double>::iterator it = modlist.begin(); it != modlist.end(); it++, k++)
     259    os << k << " : " << (*it).first << " V= " << (*it).second << endl;
     260  os << " ----------------------------------------------------------- " << endl;
     261  return modlist.size();
     262}
     263
     264//! Return the SOPHYA version number: VERS + REV/1000
    206265double SOPHYA::SophyaVersion()
    207266{
     
    211270// On met un objet initiator en statique, pour les loaders qui savent
    212271// appeler le constructeur des objets statiques   Reza 08/98
    213 #if !defined(Darwin)
    214272// La presence de l'objet statique psophyainit semble poserun probleme
    215273// sur MacOSX 10.2 qui se plante a l'initialisation avec les shared-libs
     274// Suppression de #if !defined(Darwin) en Juil 2006
    216275static SophyaInitiator psophyainit;
    217 #endif
     276
  • trunk/SophyaLib/BaseTools/sophyainit.h

    r913 r3016  
    66
    77#include "machdefs.h"
     8#include <string>
    89
    910namespace SOPHYA {
     
    2122                        SophyaInitiator();
    2223  virtual               ~SophyaInitiator();
    23   virtual double        Version(bool fgprt=true);
     24
     25  static double         GetVersion(string& svers);
     26  static void           PrintVersion(bool fglist=false);
     27
     28  static int            RegisterModule(const char* name, double version);
     29  static int            ListModules(ostream& os);
    2430};
    2531
  • trunk/SophyaLib/BaseTools/sversion.h

    r2931 r3016  
    22#define SVERSION_H
    33
    4 #define SOPHYA_VERSION   1.9
    5 #define SOPHYA_REVISION  33
    6 #define SOPHYA_TAG       "V_Mar2006"
     4#define SOPHYA_VERSION   2.0
     5#define SOPHYA_REVISION  0
     6#define SOPHYA_TAG       "V_Jul2006"
    77
    88#endif
Note: See TracChangeset for help on using the changeset viewer.