Skip to content
Snippets Groups Projects
Select Git revision
  • a3221785cab590b387209068b407cbd5e61faf80
  • master default protected
  • dof-renumbering
  • gdemesy-master-patch-30528
  • eval-space-time
  • oscillating_multiharm
  • MH_movement
  • axisqu
  • write_vtu_and_ensight_formats
  • movingband
  • CP_1972_add_vtu_file_writing
  • mortar
  • fast_freq_sweep_Resolution
  • applyresolvent_again
  • marteaua-master-patch-54323
  • patch-1
  • binde-master-patch-08072
  • binde-master-patch-52461
  • BCGSL
  • resolvent
  • TreeElementsOf
  • getdp_3_5_0
  • getdp_3_4_0
  • getdp_3_3_0
  • getdp_3_2_0
  • getdp_3_1_0
  • getdp_3_0_4
  • getdp_3_0_3
  • getdp_3_0_2
  • getdp_3_0_1
  • getdp_3_0_0
  • onelab_mobile_2.1.0
  • getdp_2_11_3 protected
  • getdp_2_11_2 protected
  • getdp_2_11_1 protected
  • getdp_2_11_0 protected
  • getdp_2_10_0 protected
  • getdp_2_9_2 protected
  • getdp_2_9_1 protected
  • getdp_2_9_0 protected
  • getdp_2_8_0 protected
41 results

F_Geometry.cpp

Blame
  • FunctionManager.cpp 1.82 KiB
    /* $Id: FunctionManager.cpp,v 1.5 2001-01-01 20:48:40 geuzaine Exp $ */
    #include <stdio.h>
    #include <stack>
    #include <map>
    #include "FunctionManager.h"
    
    struct ltstr
    {
      bool operator()(const char* s1, const char* s2) const
      {
        return strcmp(s1, s2) < 0;
      }
    };
    
    class File_Position 
    {
      public :
        int lineno;
        fpos_t position;
        FILE *file;
    };
    
    // Pour utiliser un namespace global sur SGI, il faut compiler avec
    // -LANG:std, et ajouter "use namespace std;". Dans tous les cas, il
    // FAUT creer les librairies avec 'CC -ar', et pas avec 'ar'.
    
    class mystack
    {
    public:
      //std::stack<File_Position> s;
      stack<File_Position> s;
    };
    class mymap
    {
    public :
      //std::map<char*,File_Position,ltstr> m;
      map<char*,File_Position,ltstr> m;
    };
    
    FunctionManager *FunctionManager::instance = 0;
    
    FunctionManager::FunctionManager()
    {
      functions = new mymap;
      calls = new mystack;
    }
    
    FunctionManager* FunctionManager::Instance()
    {
      if(!instance)
        {
          instance = new FunctionManager;
        }
      return instance;
    }
    
    bool FunctionManager::enterFunction(char *name, FILE **f, int &lno) const
    {
      if(functions->m.find(name) == functions->m.end())return false;
      File_Position fpold;
      fpold.lineno = lno;
      fpold.file = *f;
      fgetpos(fpold.file,&fpold.position);
      calls->s.push(fpold);
      File_Position fp = (functions->m)[name];
      fsetpos(fp.file,&fp.position);
      *f = fp.file;
      lno = fp.lineno;
      return true;
    }
    
    bool FunctionManager::leaveFunction(FILE **f,int &lno)
    {
      if(!calls->s.size())return false;
      File_Position fp;
      fp = calls->s.top();
      calls->s.pop();
      fsetpos(fp.file,&fp.position);
      *f = fp.file;
      lno = fp.lineno;
      return true;
    }
    
    bool FunctionManager::createFunction(char *name, FILE *f, int lno)
    {
      File_Position fp;
      fp.file = f;
      fp.lineno = lno;
      fgetpos(fp.file,&fp.position);
      (functions->m)[name] = fp;
      return true;
    }