-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArchivoRegistros.h
88 lines (71 loc) · 1.81 KB
/
ArchivoRegistros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef ARCHIVOREGISTROS_H_INCLUDED
#define ARCHIVOREGISTROS_H_INCLUDED
#include <fstream>
#include <string>
#include "Registro.h"
#include "ManagerFreeReg.h"
using namespace std;
/**
* class ArchivoRegistros
*/
class ArchivoRegistros
{
private:
fstream archivo;
string nombre; // nombre del archivo
int sizeReg; // tamano de cada registro fijo.
Registro* registro;
public:
// Constructors/Destructors
ArchivoRegistros(string nombre, Registro* reg);
~ArchivoRegistros();
/**
*
* @pre :
* @post : Se graba el registro en el archivo.
* @param archivo donde se grabara el registro.
* @param registro a grabar.
*/
bool alta(Registro* ® );
/**
*
* @pre :
* @post : Se devuelve el registro pedido del archivo y devuelve TRUE
* Si no existe, devuelve FALSE.
* @param registro a devolver.
*/
bool getRegistro(Registro* ®);
/**
*
* @pre : El registro debe existir.
* @post : Marca el registro como borrado.
*/
bool borrar(Registro* ®);
/**
*
* @pre : El archivo fue abierto con exito en el constructor.
* @post : Devulve el tamaño en bytes del archivo.
*/
unsigned int sizeOfFile();
/**
* Obtiene la lista de registros libres, de este modo:
* Busca el primer registro Libre, una vez encontrado,
* obtiene los demas registros libres utilizando el encadenamiento
* de registro libres, evitando de este modo leer todo el archivo.
*/
void levantarListaRegLibres();
/**
* Actualiza el encadenamiento de registros libres en el archivo.
*/
void actualizarEncadenamiento();
private:
/**
* Abre el archivo
*/
bool abrir();
/**
* Cierra el archivo
*/
void cerrar();
};
#endif // ArchivoRegistros_H_INCLUDED