-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformazione.cpp
More file actions
141 lines (124 loc) · 3.87 KB
/
Copy pathformazione.cpp
File metadata and controls
141 lines (124 loc) · 3.87 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <QList>
#include <QListIterator>
#include "formazione.h"
#include "titolo.h"
// CLASSE Formazione_rapp
class Formazione::Formazione_rapp {
public:
QList<SmartTitolo> titlesList;
int references;
/** Costruttore ad 1 parametro con 1 parametro di default.
* Inizializza ad 1 il numero dei riferimenti.
*/
Formazione_rapp( QList<SmartTitolo> l = QList<SmartTitolo>() ) :
titlesList( l ),
references( 1 ) // Gestito da Formazione
{}
/** Distruttore Formazione_rapp.
* Invoca il metodo clear() sulla lista dei titoli di studio dell'utente.
*
* @param void* p Puntatore all'oggetto Formazione_rapp.
*/
void operator delete( void* p ) {
if( p ) {
Formazione_rapp* p_aux = static_cast<Formazione_rapp*>( p );
p_aux->references--;
if( !p_aux->references )
p_aux->titlesList.clear();
}
}
/** Metodo di utilità necessario per creare copie profonde di oggetti di tipo Formazione_rapp.
*
* @return Formazione_rapp * Copia implicita della lista delle esperienze lavorative.
*/
Formazione_rapp *clone() const {
return new Formazione_rapp( titlesList );
}
};
// COSTRUTTORE Formazione
Formazione::Formazione() :
titles( new Formazione_rapp ),
user_ref( 1 )
{}
// COSTRUTTORE di COPIA Formazione
Formazione::Formazione( const Formazione& ed ) :
titles( ed.titles )
{
user_ref++;
titles->references++;
}
// DISTRUTTORE Formazione
Formazione::~Formazione() {
titles->references--;
if( titles->references == 0 )
delete titles;
}
// CLASSE Iteratore_rapp
class Formazione::Iteratore::Iteratore_rapp {
public:
QListIterator<SmartTitolo> it;
/** Costruttore ad 1 paramtro.
* Costruttore di default non disponibile.
*
* @param QList<SmartTitolo> Lista di SmartTitolo sulla quale iterare.
*/
Iteratore_rapp( QList<SmartTitolo> list ) : it( list ) {}
};
// METODO Formazione::Iteratore::hasNext
bool Formazione::Iteratore::hasNext() const {
if( iterator )
return iterator->it.hasNext();
return false;
}
// METODO Formazione::Iteratore::next
SmartTitolo Formazione::Iteratore::next() {
return iterator->it.next();
}
// METODO Formazione::Iteratore::begin
Formazione::Iteratore Formazione::begin() const {
Iteratore aux;
aux.iterator = new Iteratore::Iteratore_rapp( titles->titlesList );
return aux;
}
// METODO Formazione::Iteratore::addEducation( SmartTitolo )
void Formazione::addEducation( const SmartTitolo& t ) {
titles->titlesList.append( t );
}
// METODO Formazione::Iteratore::removeEducation( SmartTitolo )
void Formazione::removeEducation( const SmartTitolo& t ) {
titles->titlesList.removeOne( t );
}
// METODO getTitlesList Formazione
QVector<SmartTitolo> Formazione::getEducationsList() const {
QVector<SmartTitolo> v;
QListIterator<SmartTitolo> it( titles->titlesList );
while( it.hasNext() )
v.push_back( SmartTitolo( it.next() ) );
return v;
}
// METODO Formazione::setEducationsList
void Formazione::setEducationsList( QVector<SmartTitolo> v ) {
if( titles ) {
delete titles;
titles = 0;
}
titles = new Formazione_rapp();
for( int i = 0; i < v.size(); i++ )
addEducation( v[i] );
}
// OPERATOR << Formazione
QDebug& operator <<( QDebug& qdbg, const Formazione& e ) {
qdbg << "FORMAZIONE: " << "\n";
QVector<SmartTitolo> ed = e.getEducationsList();
if( ed.size() == 0 )
qdbg << " ** Nessun titolo di studio! **" << "\n";
else {
for( int i = 0; i < ed.size(); i++ ) {
qdbg << " Scuola: " << ed[i]->getSchool() << "\n";
qdbg << " Data diploma: " <<
ed[i]->getDateAttended().toString( "yyyy" ) << "\n";
qdbg << " Campo di studio: " << ed[i]->getFieldOfStudy() << "\n";
}
}
return qdbg;
}