├── .cproject
├── .gitignore
├── .project
├── .settings
├── language.settings.xml
├── org.eclipse.cdt.codan.core.prefs
└── org.eclipse.cdt.managedbuilder.core.prefs
├── MVC-Example.cpp
├── README.md
├── mvcAndObserver.png
└── src
├── Student.cpp
├── Student.h
├── StudentController.cpp
├── StudentController.h
├── StudentController_test.cpp
├── StudentView.cpp
├── StudentView.h
├── StudentViewTwo.cpp
├── StudentViewTwo.h
├── StudentView_test.cpp
└── Student_test.cpp
/.cproject:
--------------------------------------------------------------------------------
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 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release/
3 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | MVC-Example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 |
11 |
12 | ?children?
13 | ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\||
14 |
15 |
16 | ?name?
17 |
18 |
19 |
20 | org.eclipse.cdt.make.core.append_environment
21 | true
22 |
23 |
24 | org.eclipse.cdt.make.core.autoBuildTarget
25 | all
26 |
27 |
28 | org.eclipse.cdt.make.core.buildArguments
29 |
30 |
31 |
32 | org.eclipse.cdt.make.core.buildCommand
33 | make
34 |
35 |
36 | org.eclipse.cdt.make.core.buildLocation
37 | ${workspace_loc:/MVC-Example/Debug}
38 |
39 |
40 | org.eclipse.cdt.make.core.cleanBuildTarget
41 | clean
42 |
43 |
44 | org.eclipse.cdt.make.core.contents
45 | org.eclipse.cdt.make.core.activeConfigSettings
46 |
47 |
48 | org.eclipse.cdt.make.core.enableAutoBuild
49 | true
50 |
51 |
52 | org.eclipse.cdt.make.core.enableCleanBuild
53 | true
54 |
55 |
56 | org.eclipse.cdt.make.core.enableFullBuild
57 | true
58 |
59 |
60 | org.eclipse.cdt.make.core.fullBuildTarget
61 | all
62 |
63 |
64 | org.eclipse.cdt.make.core.stopOnError
65 | true
66 |
67 |
68 | org.eclipse.cdt.make.core.useDefaultBuildCmd
69 | true
70 |
71 |
72 |
73 |
74 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
75 |
76 |
77 |
78 |
79 |
80 | org.eclipse.cdt.core.cnature
81 | org.eclipse.cdt.core.ccnature
82 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
83 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
84 |
85 |
86 |
--------------------------------------------------------------------------------
/.settings/language.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.cdt.codan.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning
3 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
4 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error
5 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
6 | org.eclipse.cdt.codan.checkers.noreturn=Error
7 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
8 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
10 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
12 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
14 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
16 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false}
18 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()}
20 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
22 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
23 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true}
24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
25 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
27 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
29 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
31 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
33 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
35 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
37 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
39 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
41 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
43 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
45 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
47 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
49 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
51 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
53 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()}
54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
55 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false}
56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
57 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false}
58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
59 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
61 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
63 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
65 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")}
66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
67 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
68 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.cdt.managedbuilder.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.231559386/CPATH/delimiter=\:
3 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.231559386/CPATH/operation=remove
4 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.231559386/CPLUS_INCLUDE_PATH/delimiter=\:
5 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.231559386/CPLUS_INCLUDE_PATH/operation=remove
6 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.231559386/C_INCLUDE_PATH/delimiter=\:
7 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.231559386/C_INCLUDE_PATH/operation=remove
8 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.231559386/append=true
9 | environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.231559386/appendContributed=true
10 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.231559386/LIBRARY_PATH/delimiter=\:
11 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.231559386/LIBRARY_PATH/operation=remove
12 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.231559386/append=true
13 | environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.231559386/appendContributed=true
14 |
--------------------------------------------------------------------------------
/MVC-Example.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * MVCPatternDemo.cpp
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | * Copyright: GPLv3
7 | * Version: 0.1
8 | * Description: C++ version of http://www.tutorialspoint.com/design_pattern/mvc_pattern.htm
9 | */
10 |
11 | #include
12 | #include "src/StudentController.h"
13 | #include "src/StudentView.h"
14 | #include "src/StudentViewTwo.h"
15 | #include "src/Student.h"
16 |
17 | using namespace ejemplo_mvc;
18 | using namespace std;
19 |
20 | Student retriveStudentFromDatabase() {
21 | Student s;
22 | s.setName("Pepito");
23 | s.setNollNo("10");
24 | return s;
25 | }
26 |
27 | int main() {
28 | // Recover student from database, actually the Controller should do this
29 | Student model = retriveStudentFromDatabase();
30 |
31 | // Create the view to print student details
32 | StudentView view = StudentView();
33 | // http://en.cppreference.com/w/cpp/language/lambda
34 | Connection c1 = model.connect([&] (const Student& mo) {
35 | view.printStudentDetails(mo);
36 | });
37 |
38 | // Add a second view to the model
39 | StudentViewTwo viewtwo = StudentViewTwo();
40 |
41 | Connection c2 = model.connect([&] (const Student& mo) {
42 | viewtwo.printStudentDetails(mo);
43 | });
44 |
45 | StudentController controller = StudentController(model);
46 |
47 | // Update data
48 | cout << " ------------------ Actualizamos el modelo (y la vista es notificada) ------------------ " << endl;
49 | controller.setStudentName("Juanito");
50 | cout << " ------------------ Actualizamos el modelo (y la vista es notificada) ------------------ " << endl;
51 | controller.setStudentName("Pepito");
52 |
53 | // Remove one of the views
54 | model.disconnect(c1);
55 | cout << " ------------------ Actualizamos el modelo (y la vista es notificada) ------------------ " << endl;
56 | controller.setStudentName("Nuevo");
57 |
58 | return 0;
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Model View Controller C++ Example
2 | =================================
3 |
4 | This example is based on the Java MVC example available at http://www.tutorialspoint.com/design_pattern/mvc_pattern.htm
5 |
6 | A Eclipse CDT project is included here. Just import the project after doing git clone.
7 |
8 | The MVC implemented uses the Observer pattern in a similar way described in the following figure:
9 |
10 | 
11 |
--------------------------------------------------------------------------------
/mvcAndObserver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javism/MVC-Example/9d0818a7df7593bd09f74787c0322f9b7f8cff16/mvcAndObserver.png
--------------------------------------------------------------------------------
/src/Student.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Student.cpp
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | */
7 |
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | #include "Student.h"
15 |
16 | using namespace std;
17 |
18 | namespace ejemplo_mvc {
19 |
20 | const string& Student::getName() const {
21 | return this->name;
22 | }
23 |
24 | void Student::setName(const string& name) {
25 | this->name = name;
26 | notify();
27 | }
28 |
29 | const string& Student::getNollNo() const {
30 | return nollNo;
31 | }
32 |
33 | void Student::setNollNo(const string& nollNo) {
34 | this->nollNo = nollNo;
35 | notify();
36 | }
37 |
38 | Connection Student::connect(Listener l) {
39 | return listeners_.insert(listeners_.end(), l);
40 | }
41 |
42 | // TODO: La conexión no se elimina de la lista.
43 | void Student::disconnect(Connection c) {
44 | listeners_.erase(c);
45 | }
46 |
47 | void Student::notify() const {
48 | for (const auto& listener : listeners_)
49 | listener(*this);
50 | }
51 |
52 | } /* namespace ejemplo_mvc */
53 |
54 |
--------------------------------------------------------------------------------
/src/Student.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Student.h
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | * C++ version of http://www.tutorialspoint.com/design_pattern/mvc_pattern.htm
7 | */
8 |
9 | #ifndef STUDENT_H_
10 | #define STUDENT_H_
11 |
12 | #include
13 | #include
14 | #include
15 |
16 | namespace ejemplo_mvc {
17 |
18 | class Student;
19 |
20 | using Listener = std::function;
21 | using Connection = std::list::iterator;
22 |
23 | class Student {
24 | public:
25 |
26 | const std::string& getName() const;
27 | void setName(const std::string& name);
28 |
29 | const std::string& getNollNo() const;
30 | void setNollNo(const std::string& nollNo);
31 |
32 | Connection connect(Listener l);
33 | void disconnect(Connection c);
34 |
35 | private:
36 | std::string nollNo;
37 | std::string name;
38 |
39 | // http://www.cplusplus.com/reference/list/list/
40 | std::list listeners_;
41 |
42 | void notify() const;
43 |
44 | };
45 |
46 | } /* namespace ejemplo_mvc */
47 | #endif /* STUDENT_H_ */
48 |
--------------------------------------------------------------------------------
/src/StudentController.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * StudentController.cpp
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | */
7 |
8 | #include
9 |
10 | #include "Student.h"
11 | #include "StudentController.h"
12 |
13 | using namespace std;
14 |
15 | namespace ejemplo_mvc {
16 |
17 | StudentController::StudentController(Student model) {
18 | // TODO Auto-generated constructor stub
19 | this->model = model;
20 |
21 | }
22 |
23 | StudentController::~StudentController() {
24 | // TODO Auto-generated destructor stub
25 | }
26 |
27 | void StudentController::setStudentName(string name) {
28 | model.setName(name);
29 | }
30 |
31 | string StudentController::getStudentName() {
32 | return model.getName();
33 | }
34 |
35 | void StudentController::setStudentRollNo(string r) {
36 | model.setNollNo(r);
37 | }
38 |
39 | string StudentController::getStudentRollNo() {
40 | return model.getNollNo();
41 | }
42 |
43 | } /* namespace ejemplo_mvc */
44 |
45 |
--------------------------------------------------------------------------------
/src/StudentController.h:
--------------------------------------------------------------------------------
1 | /*
2 | * StudentController.h
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | */
7 |
8 | #ifndef STUDENTCONTROLLER_H_
9 | #define STUDENTCONTROLLER_H_
10 |
11 | #include
12 |
13 | #include "Student.h"
14 | #include "StudentView.h"
15 |
16 | namespace ejemplo_mvc {
17 |
18 | class StudentController {
19 | public:
20 | StudentController(Student model);
21 | virtual ~StudentController();
22 |
23 | void setStudentName(std::string name);
24 | std::string getStudentName();
25 |
26 | void setStudentRollNo(std::string rollNo);
27 | std::string getStudentRollNo();
28 |
29 | private:
30 | Student model;
31 | };
32 |
33 | } /* namespace ejemplo_mvc */
34 | #endif /* STUDENTCONTROLLER_H_ */
35 |
--------------------------------------------------------------------------------
/src/StudentController_test.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * StudentController_test.cpp
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | */
7 |
8 | #include "StudentController.h"
9 |
10 | namespace ejemplo_mvc {
11 |
12 | } /* namespace ejemplo_mvc */
13 |
--------------------------------------------------------------------------------
/src/StudentView.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * StudentView.cpp
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | */
7 |
8 | #include
9 |
10 | #include "StudentView.h"
11 |
12 | using namespace std;
13 |
14 | namespace ejemplo_mvc {
15 |
16 | StudentView::StudentView() {
17 | // TODO Auto-generated constructor stub
18 |
19 | }
20 |
21 | StudentView::~StudentView() {
22 | // TODO Auto-generated destructor stub
23 | }
24 |
25 | void StudentView::printStudentDetails(Student s) {
26 | cout << "Student:" << endl;
27 | cout << "Name: " << s.getName() << endl;
28 | cout << "Roll No: " << s.getNollNo() << endl;
29 |
30 | }
31 |
32 | } /* namespace ejemplo_mvc */
33 |
--------------------------------------------------------------------------------
/src/StudentView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * StudentView.h
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | */
7 |
8 | #ifndef STUDENTVIEW_H_
9 | #define STUDENTVIEW_H_
10 |
11 | #include "Student.h"
12 |
13 | namespace ejemplo_mvc {
14 |
15 | class StudentView {
16 | public:
17 | StudentView();
18 | virtual ~StudentView();
19 |
20 | void printStudentDetails(Student s);
21 | };
22 |
23 | } /* namespace ejemplo_mvc */
24 | #endif /* STUDENTVIEW_H_ */
25 |
--------------------------------------------------------------------------------
/src/StudentViewTwo.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * StudentViewTwo.cpp
3 | *
4 | * Created on: 2/12/2014
5 | * Author: javi
6 | */
7 |
8 | #include
9 |
10 | #include "StudentViewTwo.h"
11 |
12 | using namespace std;
13 |
14 | namespace ejemplo_mvc {
15 |
16 | void StudentViewTwo::printStudentDetails(Student s) {
17 | cout << "\t\tESTUDIANTE:" << endl;
18 | cout << "\t\tNOMBRE: " << s.getName() << endl;
19 | cout << "\t\tNÚMERO: " << s.getNollNo() << endl;
20 |
21 | }
22 |
23 | } /* namespace ejemplo_mvc */
24 |
--------------------------------------------------------------------------------
/src/StudentViewTwo.h:
--------------------------------------------------------------------------------
1 | /*
2 | * StudentViewTwo.h
3 | *
4 | * Created on: 2/12/2014
5 | * Author: javi
6 | */
7 |
8 | #ifndef SRC_STUDENTVIEWTWO_H_
9 | #define SRC_STUDENTVIEWTWO_H_
10 |
11 | #include "Student.h"
12 |
13 | namespace ejemplo_mvc {
14 |
15 | class StudentViewTwo {
16 | public:
17 | void printStudentDetails(Student s);
18 | };
19 |
20 | } /* namespace ejemplo_mvc */
21 | #endif /* SRC_STUDENTVIEWTWO_H_ */
22 |
--------------------------------------------------------------------------------
/src/StudentView_test.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * StudentView_test.cpp
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | */
7 |
8 | #include "StudentView.h"
9 |
10 | namespace ejemplo_mvc {
11 |
12 | } /* namespace ejemplo_mvc */
13 |
--------------------------------------------------------------------------------
/src/Student_test.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Student_test.cpp
3 | *
4 | * Created on: 24/11/2014
5 | * Author: javi
6 | */
7 |
8 | #include "Student.h"
9 |
10 | namespace ejemplo_mvc {
11 |
12 | } /* namespace ejemplo_mvc */
13 |
--------------------------------------------------------------------------------