ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/solveur/src/sl_solution.cpp
Revision: 253
Committed: Tue Jul 13 19:40:46 2010 UTC (14 years, 10 months ago) by francois
File size: 1337 byte(s)
Log Message:
changement de hiearchie et utilisation de ccmake + mise a jour

File Contents

# User Rev Content
1 5 #include "gestionversion.h"
2     #include <math.h>
3     #include <iostream>
4     #include <stdlib.h>
5     #include <string.h>
6    
7     #include "sl_solution.h"
8    
9     #include "ot_mathematique.h"
10    
11    
12     #include <stdio.h> // pour la fonction remove() qui remplace DeleteFile
13    
14    
15     SL_SOLUTION::SL_SOLUTION(int nb,char* chemin,int code)
16     {
17     nb_champs=nb;
18    
19    
20     nom_fichier=new char[strlen(chemin)+2];
21     strcpy(nom_fichier,chemin);
22     if (code!=0)
23     {
24     in=fopen(nom_fichier,"wb");
25     for (int i=0;i<code;i++)
26     for (int j=0;j<nb;j++)
27     {
28     double val=0.0;
29     fwrite(&val,sizeof(double),1,in);
30     }
31     fclose(in);
32     }
33     in=fopen(nom_fichier,"r+b");
34     }
35    
36    
37     SL_SOLUTION::~SL_SOLUTION()
38     {
39     if (in!=NULL) fclose(in);
40     }
41    
42     void SL_SOLUTION::efface(void)
43     {
44     fclose(in);
45     remove(nom_fichier);
46     in=NULL;
47     }
48    
49     double SL_SOLUTION::lire(int i,int j)
50     {
51     long pos=(nb_champs*i+j)*sizeof(double);
52     fseek(in,pos,SEEK_SET);
53     double val;
54     fread(&val,sizeof(double),1,in);
55     return (val);
56     }
57    
58     void SL_SOLUTION::ecrire(int i,int j,double val)
59     {
60     long pos=(nb_champs*i+j)*sizeof(double);
61     fseek(in,pos,SEEK_SET);
62     fwrite(&val,sizeof(double),1,in);
63     fflush(in);
64     }
65    
66    
67    
68     int SL_SOLUTION::get_nb_champ(void)
69     {
70     return nb_champs;
71     }
72    
73    
74    
75    
76    
77    
78