-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPersisteMemoriaClassificacao.cpp
64 lines (49 loc) · 1.61 KB
/
PersisteMemoriaClassificacao.cpp
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
#include "PersisteMemoriaClassificacao.h"
#include "Sistema.h"
typedef Classificacao Persistivel_local;
PersisteMemoriaClassificacao::PersisteMemoriaClassificacao(Persistivel* p) : AbsPersiste(p){}
PersisteMemoriaClassificacao::PersisteMemoriaClassificacao() : AbsPersiste(){}
PersisteMemoriaClassificacao::~PersisteMemoriaClassificacao(){}
//inherited methods
const bool PersisteMemoriaClassificacao::inserir()
{
//o primeiro passo é obter um ID para o objeto
Persistivel_local *persistivel_local = static_cast<Persistivel_local*>(persistivel);
persistivel_local->setId(Sistema::Identificadores::getNextIdClassificacao());
Sistema::getListaClassificacoes()->incluir(dynamic_cast<Persistivel*>(persistivel_local));
return true;
}
const bool PersisteMemoriaClassificacao::alterar()
{
return true;
}
const bool PersisteMemoriaClassificacao::remover()
{
return Sistema::getListaClassificacoes()->remover(dynamic_cast<Persistivel*>(this));
}
vector<Persistivel*> PersisteMemoriaClassificacao::carregarCadastros(const int id)
{
vector<Persistivel*> vLista;
Lista<Persistivel*>* lista = Sistema::getListaClassificacoes()->getLista();
if (lista->tamanho() > 0)
{
Persistivel_local* persistivel_local = new Persistivel_local();
Lista<Persistivel*>::Iterator it;
it = lista->begin();
while(it != lista->end())
{
persistivel_local = static_cast<Persistivel_local*>( *it );
if (id > 0 && persistivel_local->getId() == id)
{
vLista.push_back( static_cast<Persistivel*>(persistivel_local) );
return vLista;
}
else
{
vLista.push_back(persistivel_local);
it++;
}
}
}
return vLista;
}