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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: load_form.h File Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex"> <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>load_form.h File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
quick load of values from georges sheet (using a fast load with compacted file)<p>
<dl compact><dt><b>Id</b></dt><dd><a class="el" href="a04503.html">load_form.h</a>,v 1.31 2003/11/04 09:25:09 distrib Exp </dd></dl>
<p>
Definition in file <a class="el" href="a05926.html">load_form.h</a>.
<p>
<code>#include "<a class="el" href="a06590.html">nel/misc/types_nl.h</a>"</code><br>
<code>#include <map></code><br>
<code>#include <string></code><br>
<code>#include <vector></code><br>
<code>#include "<a class="el" href="a06168.html">nel/misc/path.h</a>"</code><br>
<code>#include "<a class="el" href="a05709.html">nel/misc/file.h</a>"</code><br>
<code>#include "<a class="el" href="a06385.html">nel/misc/sheet_id.h</a>"</code><br>
<code>#include "<a class="el" href="a06604.html">nel/georges/u_form_loader.h</a>"</code><br>
<code>#include "<a class="el" href="a06601.html">nel/georges/u_form.h</a>"</code><br>
<p>
<a href="a05926.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template<class T> void </td><td class="memItemRight" valign=bottom><a class="el" href="a04503.html#a6">loadForm</a> (const std::vector< std::string > &sheetFilters, const std::string &packedFilename, std::map< std::string, T > &container, bool updatePackedSheet=true, bool errorIfPackedSheetNotGood=true)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template<class T> void </td><td class="memItemRight" valign=bottom><a class="el" href="a04503.html#a5">loadForm</a> (const std::string &sheetFilter, const std::string &packedFilename, std::map< std::string, T > &container, bool updatePackedSheet=true, bool errorIfPackedSheetNotGood=true)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template<class T> void </td><td class="memItemRight" valign=bottom><a class="el" href="a04503.html#a4">loadForm</a> (const std::vector< std::string > &sheetFilters, const std::string &packedFilename, std::map< <a class="el" href="a03384.html">NLMISC::CSheetId</a>, T > &container, bool updatePackedSheet=true, bool errorIfPackedSheetNotGood=true)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>template<class T> void </td><td class="memItemRight" valign=bottom><a class="el" href="a04503.html#a3">loadForm</a> (const std::string &sheetFilter, const std::string &packedFilename, std::map< <a class="el" href="a03384.html">NLMISC::CSheetId</a>, T > &container, bool updatePackedSheet=true, bool errorIfPackedSheetNotGood=true)</td></tr>
<tr><td colspan=2><br><h2>Variables</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a04503.html#a0">PACKED_SHEET_HEADER</a> = 'PKSH'</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Dictionnaley entry for dependency information. <a href="#a0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a04503.html#a1">PACKED_SHEET_VERSION</a> = 5</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a04503.html#a2">PACKED_SHEET_VERSION_COMPATIBLE</a> = 0</td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="a6" doxytag="load_form.h::loadForm" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" colspan="4">
template<class T> </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> void loadForm </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const std::vector< std::string > & </td>
<td class="mdname" nowrap> <em>sheetFilters</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const std::string & </td>
<td class="mdname" nowrap> <em>packedFilename</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>std::map< std::string, T > & </td>
<td class="mdname" nowrap> <em>container</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>updatePackedSheet</em> = true, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>errorIfPackedSheetNotGood</em> = true</td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
This function is used to load values from georges sheet in a quick way. <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign=top><em>sheetFilter</em> </td><td>a vector of string to filter the sheet in the case you need more than one filter </td></tr>
<tr><td valign=top><em>packedFilename</em> </td><td>the name of the file that this function will generate (extension must be "packed_sheets") </td></tr>
<tr><td valign=top><em>container</em> </td><td>the map that will be filled by this function </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a05926.html#l00522">522</a> of file <a class="el" href="a05926.html">load_form.h</a>.
<p>
References <a class="el" href="a05708.html#l00531">NLMISC::COFile::close()</a>, <a class="el" href="a05708.html#l00255">NLMISC::CIFile::close()</a>, <a class="el" href="a05730.html#l00053">NLGEORGES::UFormLoader::createLoader()</a>, <a class="el" href="a06167.html#l00087">NLMISC::CPath::getFileList()</a>, <a class="el" href="a06167.html#l01485">NLMISC::CFile::getFileModificationDate()</a>, <a class="el" href="a06167.html#l01333">NLMISC::CFile::getFilename()</a>, <a class="el" href="a06552.html#l00055">NLMISC::CTime::getLocalTime()</a>, <a class="el" href="a05708.html#l00613">NLMISC::COFile::getPos()</a>, <a class="el" href="a02559.html#NLGEORGES_1_1UFormLoadera0">NLGEORGES::UFormLoader::loadForm()</a>, <a class="el" href="a06167.html#l00320">NLMISC::CPath::lookup()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a05622.html#l00154">nlerror</a>, <a class="el" href="a05622.html#l00111">nlinfo</a>, <a class="el" href="a05708.html#l00503">NLMISC::COFile::open()</a>, <a class="el" href="a05708.html#l00135">NLMISC::CIFile::open()</a>, <a class="el" href="a05926.html#l00120">PACKED_SHEET_HEADER</a>, <a class="el" href="a05926.html#l00121">PACKED_SHEET_VERSION</a>, <a class="el" href="a05926.html#l00123">PACKED_SHEET_VERSION_COMPATIBLE</a>, <a class="el" href="a05730.html#l00060">NLGEORGES::UFormLoader::releaseLoader()</a>, <a class="el" href="a05646.html#l01119">res</a>, <a class="el" href="a05708.html#l00586">NLMISC::COFile::seek()</a>, <a class="el" href="a06462.html#l00232">NLMISC::IStream::serial()</a>, <a class="el" href="a05708.html#l00355">NLMISC::CIFile::serialBuffer()</a>, <a class="el" href="a06462.html#l00520">NLMISC::IStream::serialCheck()</a>, <a class="el" href="a06462.html#l00324">NLMISC::IStream::serialCont()</a>, <a class="el" href="a06461.html#l00266">NLMISC::IStream::serialVersion()</a>, <a class="el" href="a05708.html#l00242">NLMISC::CIFile::setCacheFileOnOpen()</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a05981.html#l00099">sint32</a>, <a class="el" href="a06553.html#l00047">NLMISC::TTime</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00100">uint32</a>.
<p>
Referenced by <a class="el" href="a05926.html#l00132">loadForm()</a>.
<p>
<div class="fragment"><pre>00523 {
00524 std::vector<std::string> dictionnary;
00525 std::map<std::string, uint> dictionnaryIndex;
00526 std::map<std::string, std::vector<uint32> > dependencies;
00527 std::vector<uint32> dependencyDates;
00528
00529 <span class="comment">// check the extension (i know that file like "foo.packed_sheetsbar" will be accepted but this check is enough...)</span>
00530 <a class="code" href="a04199.html#a6">nlassert</a> (packedFilename.find (<span class="stringliteral">".packed_sheets"</span>) != std::string::npos);
00531
00532 std::string packedFilenamePath = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">NLMISC::CPath::lookup</a>(packedFilename, <span class="keyword">false</span>, <span class="keyword">false</span>);
00533 <span class="keywordflow">if</span> (packedFilenamePath.empty())
00534 {
00535 packedFilenamePath = packedFilename;
00536 }
00537
00538 <span class="comment">// make sure the CSheetId singleton has been properly initialised</span>
00539 <span class="comment">// NLMISC::CSheetId::init(updatePackedSheet);</span>
00540
00541 <span class="comment">// load the packed sheet if exists</span>
00542 <span class="keywordflow">try</span>
00543 {
00544 <a class="code" href="a02653.html">NLMISC::CIFile</a> ifile;
00545 ifile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea20">setCacheFileOnOpen</a>(<span class="keyword">true</span>);
00546 ifile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea12">open</a> (packedFilenamePath);
00547 <span class="comment">// an exception will be launch if the file is not the good version or if the file is not found</span>
00548
00549 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"loadForm(): Loading packed file '%s'"</span>, packedFilename.c_str());
00550
00551 <span class="comment">// read the header</span>
00552 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_0">serialCheck</a>(PACKED_SHEET_HEADER);
00553 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_0">serialCheck</a>(PACKED_SHEET_VERSION);
00554 <a class="code" href="a04558.html#a14">sint</a> loadFormVersion= ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_8">serialVersion</a>(PACKED_SHEET_VERSION_COMPATIBLE);
00555
00556 <span class="comment">// Read depend block size</span>
00557 <a class="code" href="a04558.html#a11">uint32</a> dependBlockSize;
00558 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(dependBlockSize);
00559
00560 <span class="comment">// Read the dependencies only if update packed sheet</span>
00561 <span class="keywordflow">if</span>(updatePackedSheet)
00562 {
00563 <span class="comment">// read the dictionnary</span>
00564 {
00565 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(dictionnary);
00566 }
00567 <span class="comment">// read the dependency data</span>
00568 {
00569 <a class="code" href="a04558.html#a11">uint32</a> depSize;
00570 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(depSize);
00571 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<depSize; ++i)
00572 {
00573 std::string sheetName;
00574
00575 <span class="comment">// Avoid copy, use []</span>
00576 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(sheetName);
00577 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(dependencies[sheetName]);
00578 }
00579 }
00580 }
00581 <span class="comment">// else dummy read one big block => no heavy reallocation / free</span>
00582 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(dependBlockSize>0)
00583 {
00584 std::vector<uint8> bigBlock;
00585 bigBlock.resize(dependBlockSize);
00586 ifile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea15">serialBuffer</a>(&bigBlock[0], dependBlockSize);
00587 }
00588
00589 <span class="comment">// read the packed sheet data</span>
00590 <a class="code" href="a04558.html#a11">uint32</a> nbEntries;
00591 <a class="code" href="a04558.html#a11">uint32</a> ver;
00592 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a> (nbEntries);
00593 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a> (ver);
00594 <span class="keywordflow">if</span>(ver != T::getVersion ())
00595 <span class="keywordflow">throw</span> <a class="code" href="a02482.html">Exception</a>(<span class="stringliteral">"The packed sheet version in stream is different of the code"</span>);
00596 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a> (container);
00597 ifile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea3">close</a> ();
00598 }
00599 <span class="keywordflow">catch</span> (<a class="code" href="a02482.html">NLMISC::Exception</a> &e)
00600 {
00601 <span class="comment">// clear the container because it can contains partially loaded sheet so we must clean it before continue</span>
00602 container.clear ();
00603 <span class="keywordflow">if</span> (!updatePackedSheet)
00604 {
00605 <span class="keywordflow">if</span> (errorIfPackedSheetNotGood)
00606 <a class="code" href="a04199.html#a3">nlerror</a> (<span class="stringliteral">"loadForm(): Exception during reading the packed file and can't reconstruct them (%s)"</span>, e.what());
00607 <span class="keywordflow">else</span>
00608 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"loadForm(): Exception during reading the packed file and can't reconstruct them (%s)"</span>, e.what());
00609
00610 <span class="keywordflow">return</span>;
00611 }
00612 <span class="keywordflow">else</span>
00613 {
00614 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"loadForm(): Exception during reading the packed file, I'll reconstruct it (%s)"</span>, e.what());
00615 }
00616 }
00617
00618 <span class="comment">// if we don't want to update packed sheet, we nothing more to do</span>
00619 <span class="keywordflow">if</span> (!updatePackedSheet)
00620 {
00621 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"Don't update the packed sheet with real sheet"</span>);
00622 <span class="keywordflow">return</span>;
00623 }
00624
00625 <span class="comment">// retreive the date of all dependency file</span>
00626 {
00627 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<dictionnary.size(); ++i)
00628 {
00629 std::string p = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">NLMISC::CPath::lookup</a> (dictionnary[i], <span class="keyword">false</span>, <span class="keyword">false</span>);
00630 <span class="keywordflow">if</span> (!p.empty())
00631 {
00632 <a class="code" href="a04558.html#a11">uint32</a> d = <a class="code" href="a02524.html#NLMISC_1_1CFilee9">NLMISC::CFile::getFileModificationDate</a>(p);
00633 dependencyDates.push_back(d);
00634 }
00635 <span class="keywordflow">else</span>
00636 {
00637 <span class="comment">// file not found !</span>
00638 <span class="comment">// write a future date to invalidate any file dependent on it</span>
00639 <a class="code" href="a04199.html#a0">nldebug</a>(<span class="stringliteral">"Can't find dependent file %s !"</span>, dictionnary[i].c_str());
00640 dependencyDates.push_back(0xffffffff);
00641 }
00642 }
00643 }
00644
00645 <span class="comment">// build a vector of the sheetFilters sheet ids (ie: "item")</span>
00646 std::vector<std::string> sheetNames;
00647 {
00648 std::vector<std::string>::const_iterator first(sheetFilters.begin()), last(sheetFilters.end());
00649 <span class="keywordflow">for</span> (; first != last; ++first)
00650 <a class="code" href="a03072.html#NLMISC_1_1CPathe10">NLMISC::CPath::getFileList</a>(*first, sheetNames);
00651
00652 }
00653
00654 <span class="comment">// if there s no file, nothing to do</span>
00655 <span class="keywordflow">if</span> (sheetNames.empty())
00656 <span class="keywordflow">return</span>;
00657
00658 <span class="comment">// set up the current sheet in container to remove sheet that are in the container and not in the directory anymore</span>
00659 std::map<std::string, bool> sheetToRemove;
00660 {
00661 <span class="keyword">typename</span> std::map<std::string, T>::iterator first(container.begin()), last(container.end());
00662 <span class="keywordflow">for</span>(; first != last; ++first)
00663 sheetToRemove.insert (make_pair(first->first, <span class="keyword">true</span>));
00664 }
00665
00666 <span class="comment">// check if we need to create a new .pitems or just read it</span>
00667 <a class="code" href="a04558.html#a11">uint32</a> packedFiledate = <a class="code" href="a02524.html#NLMISC_1_1CFilee9">NLMISC::CFile::getFileModificationDate</a>(packedFilenamePath);
00668
00669 <span class="keywordtype">bool</span> containerChanged = <span class="keyword">false</span>;
00670
00671 <a class="code" href="a02559.html">NLGEORGES::UFormLoader</a> *formLoader = NULL;
00672
00673 std::vector<uint> NeededToRecompute;
00674
00675 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; k < sheetNames.size(); k++)
00676 {
00677 std::string p = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">NLMISC::CPath::lookup</a> (sheetNames[k], <span class="keyword">false</span>, <span class="keyword">false</span>);
00678 <span class="keywordflow">if</span> (p.empty())
00679 {
00680 <span class="keywordflow">continue</span>;
00681 }
00682 <a class="code" href="a04558.html#a11">uint32</a> d = <a class="code" href="a02524.html#NLMISC_1_1CFilee9">NLMISC::CFile::getFileModificationDate</a>(p);
00683
00684 <span class="comment">// no need to remove this sheet</span>
00685 sheetToRemove[sheetNames[k]] = <span class="keyword">false</span>;
00686
00687 <span class="keywordflow">if</span>( d > packedFiledate || container.find (sheetNames[k]) == container.end())
00688 {
00689 NeededToRecompute.push_back(k);
00690 }
00691 <span class="keywordflow">else</span>
00692 {
00693 <span class="comment">// check the date of each parent</span>
00694 <a class="code" href="a04199.html#a6">nlassert</a>(dependencies.find(sheetNames[k]) != dependencies.end());
00695 std::vector<uint32> &depends = dependencies[sheetNames[k]];
00696
00697 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<depends.size(); ++i)
00698 {
00699 <span class="keywordflow">if</span> (dependencyDates[depends[i]] > packedFiledate)
00700 {
00701 <a class="code" href="a04199.html#a0">nldebug</a>(<span class="stringliteral">"Dependancy on %s for %s not up to date !"</span>,
00702 dictionnary[depends[i]].c_str(), sheetNames[k].c_str());
00703 NeededToRecompute.push_back(k);
00704 <span class="keywordflow">break</span>;
00705 }
00706 }
00707 }
00708 }
00709
00710 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"%d sheets checked, %d need to be recomputed"</span>, sheetNames.size(), NeededToRecompute.size());
00711
00712 <a class="code" href="a05378.html#a242">NLMISC::TTime</a> lastTime = <a class="code" href="a02142.html#NLMISC_1_1CTimee0">NLMISC::CTime::getLocalTime</a> ();
00713 <a class="code" href="a05378.html#a242">NLMISC::TTime</a> start = <a class="code" href="a02142.html#NLMISC_1_1CTimee0">NLMISC::CTime::getLocalTime</a> ();
00714
00715 <a class="code" href="a03408.html">NLMISC::CSmartPtr<NLGEORGES::UForm></a> form;
00716
00717 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> j = 0; j < NeededToRecompute.size(); j++)
00718 {
00719 <span class="keywordflow">if</span>(<a class="code" href="a02142.html#NLMISC_1_1CTimee0">NLMISC::CTime::getLocalTime</a> () > lastTime + 5000)
00720 {
00721 lastTime = <a class="code" href="a02142.html#NLMISC_1_1CTimee0">NLMISC::CTime::getLocalTime</a> ();
00722 <span class="keywordflow">if</span>(j>0)
00723 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"%.0f%% completed (%d/%d), %d seconds remaining"</span>, (<span class="keywordtype">float</span>)j*100.0/NeededToRecompute.size(),j,NeededToRecompute.size(), (NeededToRecompute.size()-j)*(lastTime-start)/j/1000);
00724 }
00725
00726 <span class="comment">// create the georges loader if necessary</span>
00727 <span class="keywordflow">if</span> (formLoader == NULL)
00728 {
00729 NLMISC::WarningLog->addNegativeFilter(<span class="stringliteral">"CFormLoader: Can't open the form file"</span>);
00730 formLoader = <a class="code" href="a02559.html#NLGEORGES_1_1UFormLoadere0">NLGEORGES::UFormLoader::createLoader</a> ();
00731 }
00732
00733 <span class="comment">// Load the form with given sheet id</span>
00734 form = formLoader-><a class="code" href="a02559.html#NLGEORGES_1_1UFormLoadera0">loadForm</a> (sheetNames[NeededToRecompute[j]].c_str ());
00735 <span class="keywordflow">if</span> (form)
00736 {
00737 <span class="comment">// build the dependency data</span>
00738 {
00739 std::vector<uint32> depends;
00740 std::set<std::string> dependFiles;
00741 form->getDependencies (dependFiles);
00742 <a class="code" href="a04199.html#a6">nlassert</a>(dependFiles.find(sheetNames[NeededToRecompute[j]]) != dependFiles.end());
00743 <span class="comment">// remove the sheet itself from the container</span>
00744 dependFiles.erase(sheetNames[NeededToRecompute[j]]);
00745
00746 std::set<std::string>::iterator first(dependFiles.begin()), last(dependFiles.end());
00747 <span class="keywordflow">for</span> (; first != last; ++first)
00748 {
00749 std::string p = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">NLMISC::CPath::lookup</a> (*first, <span class="keyword">false</span>, <span class="keyword">false</span>);
00750 <span class="keywordflow">if</span> (!p.empty())
00751 {
00752 <a class="code" href="a04558.html#a11">uint32</a> date = <a class="code" href="a02524.html#NLMISC_1_1CFilee9">NLMISC::CFile::getFileModificationDate</a>(p);
00753
00754 <a class="code" href="a04558.html#a15">uint</a> dicIndex;
00755 std::string <a class="code" href="a05377.html#a2">filename</a> = <a class="code" href="a02524.html#NLMISC_1_1CFilee10">NLMISC::CFile::getFilename</a>(p);
00756
00757 <span class="keywordflow">if</span> (dictionnaryIndex.find(filename) == dictionnaryIndex.end())
00758 {
00759 <span class="comment">// add a new dictionnary entry</span>
00760 dicIndex = dictionnary.size();
00761 dictionnaryIndex.insert(std::make_pair(filename, dictionnary.size()));
00762 dictionnary.push_back(filename);
00763 }
00764 <span class="keywordflow">else</span>
00765 {
00766 dicIndex = dictionnaryIndex.find(filename)->second;
00767 }
00768
00769 <span class="comment">// add the dependecy index</span>
00770 depends.push_back(dicIndex);
00771 }
00772 }
00773 <span class="comment">// store the dependency list with the sheet ID</span>
00774 dependencies[sheetNames[NeededToRecompute[j]]] = depends;
00775 }
00776
00777 <span class="comment">// add the new creature, it could be already loaded by the packed sheets but will be overwrite with the new one</span>
00778 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::map<std::string, T>::iterator TType1;
00779 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::pair<TType1, bool> TType2;
00780 TType2 <a class="code" href="a04223.html#a643">res</a> = container.insert(std::make_pair(sheetNames[NeededToRecompute[j]],T()));
00781
00782 (*<a class="code" href="a04223.html#a643">res</a>.first).second.readGeorges (form, sheetNames[NeededToRecompute[j]]);
00783 containerChanged = <span class="keyword">true</span>;
00784 }
00785 }
00786
00787 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"%d seconds to recompute %d sheets"</span>, (<a class="code" href="a04558.html#a11">uint32</a>)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size());
00788
00789 <span class="comment">// free the georges loader if necessary</span>
00790 <span class="keywordflow">if</span> (formLoader != NULL)
00791 {
00792 <a class="code" href="a02559.html#NLGEORGES_1_1UFormLoadere1">NLGEORGES::UFormLoader::releaseLoader</a> (formLoader);
00793 NLMISC::WarningLog->removeFilter (<span class="stringliteral">"CFormLoader: Can't open the form file"</span>);
00794 }
00795
00796 <span class="comment">// we have now to remove sheet that are in the container and not exist anymore in the sheet directories</span>
00797 <span class="keywordflow">for</span> (std::map<std::string, bool>::iterator it2 = sheetToRemove.begin(); it2 != sheetToRemove.end(); it2++)
00798 {
00799 <span class="keywordflow">if</span>(it2->second)
00800 {
00801 <span class="comment">// informe the contained object that it is no more needed.</span>
00802 container.find(it2->first)->second.removed();
00803 container.erase(it2->first);
00804 containerChanged = <span class="keyword">true</span>;
00805 dependencies.erase((*it2).first);
00806 }
00807 }
00808
00809 <span class="comment">// now, save the new container in the packedfile</span>
00810 <span class="keywordflow">try</span>
00811 {
00812 <span class="keywordflow">if</span>(containerChanged)
00813 {
00814 <a class="code" href="a03011.html">NLMISC::COFile</a> ofile;
00815 ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea9">open</a>(packedFilenamePath);
00816
00817 <span class="comment">// write the header.</span>
00818 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_0">serialCheck</a>(PACKED_SHEET_HEADER);
00819 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_0">serialCheck</a>(PACKED_SHEET_VERSION);
00820 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_8">serialVersion</a>(PACKED_SHEET_VERSION_COMPATIBLE);
00821
00822 <span class="comment">// Write a dummy block size for now</span>
00823 <a class="code" href="a04558.html#a10">sint32</a> posBlockSize= ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea4">getPos</a>();
00824 <a class="code" href="a04558.html#a11">uint32</a> dependBlockSize= 0;
00825 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(dependBlockSize);
00826
00827 <span class="comment">// write the dictionnary</span>
00828 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(dictionnary);
00829
00830 <span class="comment">// write the dependencies data</span>
00831 <a class="code" href="a04558.html#a11">uint32</a> depSize = dependencies.size();
00832 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(depSize);
00833 std::map<std::string, std::vector<uint32> >::iterator first(dependencies.begin()), last(dependencies.end());
00834 <span class="keywordflow">for</span> (; first != last; ++first)
00835 {
00836 std::string sheetName = first->first;
00837 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(sheetName);
00838 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(first->second);
00839 }
00840
00841 <span class="comment">// Then get the dicionary + dependencies size, and write it back to posBlockSize</span>
00842 <a class="code" href="a04558.html#a10">sint32</a> endBlockSize= ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea4">getPos</a>();
00843 dependBlockSize= (endBlockSize - posBlockSize) - 4;
00844 ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea10">seek</a>(posBlockSize, NLMISC::IStream::begin);
00845 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(dependBlockSize);
00846 ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea10">seek</a>(endBlockSize, NLMISC::IStream::begin);
00847
00848 <span class="comment">// write the sheet data</span>
00849 <a class="code" href="a04558.html#a11">uint32</a> nbEntries = sheetNames.size();
00850 <a class="code" href="a04558.html#a11">uint32</a> ver = T::getVersion ();
00851 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a> (nbEntries);
00852 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a> (ver);
00853 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(container);
00854 ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea0">close</a> ();
00855 }
00856 }
00857 <span class="keywordflow">catch</span> (<a class="code" href="a02482.html">NLMISC::Exception</a> &e)
00858 {
00859 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"loadForm(): Exception during saving the packed file, it will be recreated next launch (%s)"</span>, e.what());
00860 }
00861
00862 <span class="comment">// housekeeping</span>
00863 sheetNames.clear ();
00864 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="a5" doxytag="load_form.h::loadForm" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" colspan="4">
template<class T> </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> void loadForm </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const std::string & </td>
<td class="mdname" nowrap> <em>sheetFilter</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const std::string & </td>
<td class="mdname" nowrap> <em>packedFilename</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>std::map< std::string, T > & </td>
<td class="mdname" nowrap> <em>container</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>updatePackedSheet</em> = true, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>errorIfPackedSheetNotGood</em> = true</td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
This function is used to load values from georges sheet in a quick way. <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign=top><em>sheetFilter</em> </td><td>a string to filter the sheet (ie: ".item") </td></tr>
<tr><td valign=top><em>packedFilename</em> </td><td>the name of the file that this function will generate (extension must be "packed_sheets") </td></tr>
<tr><td valign=top><em>container</em> </td><td>the map that will be filled by this function </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a05926.html#l00508">508</a> of file <a class="el" href="a05926.html">load_form.h</a>.
<p>
References <a class="el" href="a05926.html#l00522">loadForm()</a>.
<p>
<div class="fragment"><pre>00509 {
00510 std::vector<std::string> vs;
00511 vs.push_back(sheetFilter);
00512 <a class="code" href="a04503.html#a6">loadForm</a>(vs, packedFilename, container, updatePackedSheet, errorIfPackedSheetNotGood);
00513 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="a4" doxytag="load_form.h::loadForm" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" colspan="4">
template<class T> </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> void loadForm </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const std::vector< std::string > & </td>
<td class="mdname" nowrap> <em>sheetFilters</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const std::string & </td>
<td class="mdname" nowrap> <em>packedFilename</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>std::map< <a class="el" href="a03384.html">NLMISC::CSheetId</a>, T > & </td>
<td class="mdname" nowrap> <em>container</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>updatePackedSheet</em> = true, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>errorIfPackedSheetNotGood</em> = true</td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
This function is used to load values from georges sheet in a quick way. <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign=top><em>sheetFilter</em> </td><td>a vector of string to filter the sheet in the case you need more than one filter </td></tr>
<tr><td valign=top><em>packedFilename</em> </td><td>the name of the file that this function will generate (extension must be "packed_sheets") </td></tr>
<tr><td valign=top><em>container</em> </td><td>the map that will be filled by this function </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a05926.html#l00145">145</a> of file <a class="el" href="a05926.html">load_form.h</a>.
<p>
References <a class="el" href="a06384.html#l00499">NLMISC::CSheetId::buildIdVector()</a>, <a class="el" href="a05708.html#l00531">NLMISC::COFile::close()</a>, <a class="el" href="a05708.html#l00255">NLMISC::CIFile::close()</a>, <a class="el" href="a05730.html#l00053">NLGEORGES::UFormLoader::createLoader()</a>, <a class="el" href="a06167.html#l01485">NLMISC::CFile::getFileModificationDate()</a>, <a class="el" href="a06167.html#l01333">NLMISC::CFile::getFilename()</a>, <a class="el" href="a06552.html#l00055">NLMISC::CTime::getLocalTime()</a>, <a class="el" href="a05708.html#l00613">NLMISC::COFile::getPos()</a>, <a class="el" href="a06384.html#l00304">NLMISC::CSheetId::init()</a>, <a class="el" href="a02559.html#NLGEORGES_1_1UFormLoadera0">NLGEORGES::UFormLoader::loadForm()</a>, <a class="el" href="a06167.html#l00320">NLMISC::CPath::lookup()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a05622.html#l00154">nlerror</a>, <a class="el" href="a05622.html#l00111">nlinfo</a>, <a class="el" href="a05708.html#l00503">NLMISC::COFile::open()</a>, <a class="el" href="a05708.html#l00135">NLMISC::CIFile::open()</a>, <a class="el" href="a05926.html#l00120">PACKED_SHEET_HEADER</a>, <a class="el" href="a05926.html#l00121">PACKED_SHEET_VERSION</a>, <a class="el" href="a05926.html#l00123">PACKED_SHEET_VERSION_COMPATIBLE</a>, <a class="el" href="a05730.html#l00060">NLGEORGES::UFormLoader::releaseLoader()</a>, <a class="el" href="a05646.html#l01119">res</a>, <a class="el" href="a05708.html#l00586">NLMISC::COFile::seek()</a>, <a class="el" href="a06462.html#l00232">NLMISC::IStream::serial()</a>, <a class="el" href="a05708.html#l00355">NLMISC::CIFile::serialBuffer()</a>, <a class="el" href="a06462.html#l00520">NLMISC::IStream::serialCheck()</a>, <a class="el" href="a06462.html#l00324">NLMISC::IStream::serialCont()</a>, <a class="el" href="a06461.html#l00266">NLMISC::IStream::serialVersion()</a>, <a class="el" href="a05708.html#l00242">NLMISC::CIFile::setCacheFileOnOpen()</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a05981.html#l00099">sint32</a>, <a class="el" href="a06553.html#l00047">NLMISC::TTime</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00100">uint32</a>.
<p>
<div class="fragment"><pre>00146 {
00147 std::vector<std::string> dictionnary;
00148 std::map<std::string, uint> dictionnaryIndex;
00149 std::map<NLMISC::CSheetId, std::vector<uint32> > dependencies;
00150 std::vector<uint32> dependencyDates;
00151
00152 <span class="comment">// check the extension (i know that file like "foo.packed_sheetsbar" will be accepted but this check is enough...)</span>
00153 <a class="code" href="a04199.html#a6">nlassert</a> (packedFilename.find (<span class="stringliteral">".packed_sheets"</span>) != std::string::npos);
00154
00155 std::string packedFilenamePath = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">NLMISC::CPath::lookup</a>(NLMISC::CFile::getFilename(packedFilename), <span class="keyword">false</span>, <span class="keyword">false</span>);
00156 <span class="keywordflow">if</span> (packedFilenamePath.empty())
00157 {
00158 packedFilenamePath = packedFilename;
00159 }
00160
00161 <span class="comment">// make sure the CSheetId singleton has been properly initialised</span>
00162 <a class="code" href="a03384.html#NLMISC_1_1CSheetIde8">NLMISC::CSheetId::init</a>(updatePackedSheet);
00163
00164 <span class="comment">// load the packed sheet if exists</span>
00165 <span class="keywordflow">try</span>
00166 {
00167 <a class="code" href="a02653.html">NLMISC::CIFile</a> ifile;
00168 ifile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea20">setCacheFileOnOpen</a>(<span class="keyword">true</span>);
00169 <span class="keywordflow">if</span> (!ifile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea12">open</a> (packedFilenamePath))
00170 {
00171 <span class="keywordflow">throw</span> <a class="code" href="a02482.html">NLMISC::Exception</a>(<span class="stringliteral">"can't open PackedSheet %s"</span>, packedFilenamePath.c_str());
00172 }
00173 <span class="comment">// an exception will be launch if the file is not the good version or if the file is not found</span>
00174
00175 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"loadForm(): Loading packed file '%s'"</span>, packedFilename.c_str());
00176
00177 <span class="comment">// read the header</span>
00178 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_0">serialCheck</a>(PACKED_SHEET_HEADER);
00179 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_0">serialCheck</a>(PACKED_SHEET_VERSION);
00180 <a class="code" href="a04558.html#a14">sint</a> loadFormVersion= ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_8">serialVersion</a>(PACKED_SHEET_VERSION_COMPATIBLE);
00181
00182 <span class="comment">// Read depend block size</span>
00183 <a class="code" href="a04558.html#a11">uint32</a> dependBlockSize;
00184 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(dependBlockSize);
00185
00186 <span class="comment">// Read the dependencies only if update packed sheet</span>
00187 <span class="keywordflow">if</span>(updatePackedSheet)
00188 {
00189 <span class="comment">// read the dictionnary</span>
00190 {
00191 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(dictionnary);
00192 }
00193 <span class="comment">// read the dependency data</span>
00194 {
00195 <a class="code" href="a04558.html#a11">uint32</a> depSize;
00196 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(depSize);
00197 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<depSize; ++i)
00198 {
00199 <a class="code" href="a03384.html">NLMISC::CSheetId</a> sheetId;
00200
00201 <span class="comment">// Avoid copy, use []</span>
00202 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(sheetId);
00203 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(dependencies[sheetId]);
00204 }
00205 }
00206 }
00207 <span class="comment">// else dummy read one big block => no heavy reallocation / free</span>
00208 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(dependBlockSize>0)
00209 {
00210 std::vector<uint8> bigBlock;
00211 bigBlock.resize(dependBlockSize);
00212 ifile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea15">serialBuffer</a>(&bigBlock[0], dependBlockSize);
00213 }
00214
00215 <span class="comment">// read the packed sheet data</span>
00216 <a class="code" href="a04558.html#a11">uint32</a> nbEntries;
00217 <a class="code" href="a04558.html#a11">uint32</a> ver;
00218 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a> (nbEntries);
00219 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a> (ver);
00220 <span class="keywordflow">if</span>(ver != T::getVersion ())
00221 <span class="keywordflow">throw</span> <a class="code" href="a02482.html">NLMISC::Exception</a>(<span class="stringliteral">"The packed sheet version in stream is different of the code"</span>);
00222 ifile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a> (container);
00223 ifile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea3">close</a> ();
00224 }
00225 <span class="keywordflow">catch</span> (<a class="code" href="a02482.html">NLMISC::Exception</a> &e)
00226 {
00227 <span class="comment">// clear the container because it can contains partially loaded sheet so we must clean it before continue</span>
00228 container.clear ();
00229 <span class="keywordflow">if</span> (!updatePackedSheet)
00230 {
00231 <span class="keywordflow">if</span> (errorIfPackedSheetNotGood)
00232 <a class="code" href="a04199.html#a3">nlerror</a> (<span class="stringliteral">"loadForm(): Exception during reading the packed file and can't reconstruct them (%s)"</span>, e.what());
00233 <span class="keywordflow">else</span>
00234 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"loadForm(): Exception during reading the packed file and can't reconstruct them (%s)"</span>, e.what());
00235
00236 <span class="keywordflow">return</span>;
00237 }
00238 <span class="keywordflow">else</span>
00239 {
00240 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"loadForm(): Exception during reading the packed file, I'll reconstruct it (%s)"</span>, e.what());
00241 }
00242 }
00243
00244 <span class="comment">// if we don't want to update packed sheet, we nothing more to do</span>
00245 <span class="keywordflow">if</span> (!updatePackedSheet)
00246 {
00247 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"Don't update the packed sheet with real sheet"</span>);
00248 <span class="keywordflow">return</span>;
00249 }
00250
00251 <span class="comment">// retreive the date of all dependency file</span>
00252 {
00253 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<dictionnary.size(); ++i)
00254 {
00255 std::string p = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">NLMISC::CPath::lookup</a> (dictionnary[i], <span class="keyword">false</span>, <span class="keyword">false</span>);
00256 <span class="keywordflow">if</span> (!p.empty())
00257 {
00258 <a class="code" href="a04558.html#a11">uint32</a> d = <a class="code" href="a02524.html#NLMISC_1_1CFilee9">NLMISC::CFile::getFileModificationDate</a>(p);
00259 dependencyDates.push_back(d);
00260 }
00261 <span class="keywordflow">else</span>
00262 {
00263 <span class="comment">// file not found !</span>
00264 <span class="comment">// write a future date to invalidate any file dependent on it</span>
00265 <a class="code" href="a04199.html#a0">nldebug</a>(<span class="stringliteral">"Can't find dependent file %s !"</span>, dictionnary[i].c_str());
00266 dependencyDates.push_back(0xffffffff);
00267 }
00268 }
00269 }
00270
00271 <span class="comment">// build a vector of the sheetFilters sheet ids (ie: "item")</span>
00272 std::vector<NLMISC::CSheetId> sheetIds;
00273 std::vector<std::string> filenames;
00274 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < sheetFilters.size(); i++)
00275 <a class="code" href="a03384.html#NLMISC_1_1CSheetIde4">NLMISC::CSheetId::buildIdVector</a>(sheetIds, filenames, sheetFilters[i]);
00276
00277 <span class="comment">// if there s no file, nothing to do</span>
00278 <span class="keywordflow">if</span> (sheetIds.empty())
00279 <span class="keywordflow">return</span>;
00280
00281 <span class="comment">// set up the current sheet in container to remove sheet that are in the container and not in the directory anymore</span>
00282 std::map<NLMISC::CSheetId, bool> sheetToRemove;
00283 <span class="keywordflow">for</span> (<span class="keyword">typename</span> std::map<NLMISC::CSheetId, T>::iterator it = container.begin(); it != container.end(); it++)
00284 {
00285 sheetToRemove.insert (std::make_pair((*it).first, <span class="keyword">true</span>));
00286 }
00287
00288 <span class="comment">// check if we need to create a new .pitems or just read it</span>
00289 <a class="code" href="a04558.html#a11">uint32</a> packedFiledate = <a class="code" href="a02524.html#NLMISC_1_1CFilee9">NLMISC::CFile::getFileModificationDate</a>(packedFilenamePath);
00290
00291 <span class="keywordtype">bool</span> containerChanged = <span class="keyword">false</span>;
00292
00293 <a class="code" href="a02559.html">NLGEORGES::UFormLoader</a> *formLoader = NULL;
00294
00295 std::vector<uint> NeededToRecompute;
00296
00297 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; k < filenames.size(); k++)
00298 {
00299 std::string p = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">NLMISC::CPath::lookup</a> (filenames[k], <span class="keyword">false</span>, <span class="keyword">false</span>);
00300 <span class="keywordflow">if</span> (p.empty()) <span class="keywordflow">continue</span>;
00301 <a class="code" href="a04558.html#a11">uint32</a> d = <a class="code" href="a02524.html#NLMISC_1_1CFilee9">NLMISC::CFile::getFileModificationDate</a>(p);
00302
00303 <span class="comment">// no need to remove this sheet</span>
00304 sheetToRemove[sheetIds[k]] = <span class="keyword">false</span>;
00305
00306 <span class="keywordflow">if</span>( d > packedFiledate || container.find (sheetIds[k]) == container.end())
00307 {
00308 NeededToRecompute.push_back(k);
00309 }
00310 <span class="keywordflow">else</span>
00311 {
00312 <span class="comment">// check the date of each parent</span>
00313 <a class="code" href="a04199.html#a6">nlassert</a>(dependencies.find(sheetIds[k]) != dependencies.end());
00314 std::vector<uint32> &depends = dependencies[sheetIds[k]];
00315
00316 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<depends.size(); ++i)
00317 {
00318 <span class="keywordflow">if</span> (dependencyDates[depends[i]] > packedFiledate)
00319 {
00320 <a class="code" href="a04199.html#a0">nldebug</a>(<span class="stringliteral">"Dependancy on %s for %s not up to date !"</span>,
00321 dictionnary[depends[i]].c_str(), sheetIds[k].<a class="code" href="a05378.html#a244">toString</a>().c_str());
00322 NeededToRecompute.push_back(k);
00323 <span class="keywordflow">break</span>;
00324 }
00325 }
00326 }
00327 }
00328
00329 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"%d sheets checked, %d need to be recomputed"</span>, filenames.size(), NeededToRecompute.size());
00330
00331 <a class="code" href="a05378.html#a242">NLMISC::TTime</a> last = <a class="code" href="a02142.html#NLMISC_1_1CTimee0">NLMISC::CTime::getLocalTime</a> ();
00332 <a class="code" href="a05378.html#a242">NLMISC::TTime</a> start = <a class="code" href="a02142.html#NLMISC_1_1CTimee0">NLMISC::CTime::getLocalTime</a> ();
00333
00334 <a class="code" href="a03408.html">NLMISC::CSmartPtr<NLGEORGES::UForm></a> form;
00335 std::vector<NLMISC::CSmartPtr<NLGEORGES::UForm> > cacheFormList;
00336
00337 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> j = 0; j < NeededToRecompute.size(); j++)
00338 {
00339 <span class="keywordflow">if</span>(<a class="code" href="a02142.html#NLMISC_1_1CTimee0">NLMISC::CTime::getLocalTime</a> () > last + 5000)
00340 {
00341 last = <a class="code" href="a02142.html#NLMISC_1_1CTimee0">NLMISC::CTime::getLocalTime</a> ();
00342 <span class="keywordflow">if</span>(j>0)
00343 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"%.0f%% completed (%d/%d), %d seconds remaining"</span>, (<span class="keywordtype">float</span>)j*100.0/NeededToRecompute.size(),j,NeededToRecompute.size(), (NeededToRecompute.size()-j)*(last-start)/j/1000);
00344 }
00345
00346 <span class="comment">// create the georges loader if necessary</span>
00347 <span class="keywordflow">if</span> (formLoader == NULL)
00348 {
00349 NLMISC::WarningLog->addNegativeFilter(<span class="stringliteral">"CFormLoader: Can't open the form file"</span>);
00350 formLoader = <a class="code" href="a02559.html#NLGEORGES_1_1UFormLoadere0">NLGEORGES::UFormLoader::createLoader</a> ();
00351 }
00352
00353 <span class="comment">// cache used to retain information (to optimize time).</span>
00354 <span class="keywordflow">if</span> (form)
00355 cacheFormList.push_back (form);
00356
00357 <span class="comment">// Load the form with given sheet id</span>
00358 form = formLoader-><a class="code" href="a02559.html#NLGEORGES_1_1UFormLoadera0">loadForm</a> (sheetIds[NeededToRecompute[j]].<a class="code" href="a05378.html#a244">toString</a>().c_str ());
00359 <span class="keywordflow">if</span> (form)
00360 {
00361 <span class="comment">// build the dependency data</span>
00362 {
00363 std::vector<uint32> depends;
00364 std::set<std::string> dependFiles;
00365 form->getDependencies (dependFiles);
00366 <a class="code" href="a04199.html#a6">nlassert</a>(dependFiles.find(sheetIds[NeededToRecompute[j]].toString()) != dependFiles.end());
00367 <span class="comment">// remove the sheet itself from the container</span>
00368 dependFiles.erase(sheetIds[NeededToRecompute[j]].<a class="code" href="a05378.html#a244">toString</a>());
00369
00370 std::set<std::string>::iterator first(dependFiles.begin()), last(dependFiles.end());
00371 <span class="keywordflow">for</span> (; first != last; ++first)
00372 {
00373 <span class="keyword">const</span> std::string <a class="code" href="a05377.html#a2">filename</a> = <a class="code" href="a02524.html#NLMISC_1_1CFilee10">NLMISC::CFile::getFilename</a>(*first);
00374 std::map<std::string,uint>::iterator findDicIt=dictionnaryIndex.find(filename);
00375
00376 <span class="keywordflow">if</span> (findDicIt!=dictionnaryIndex.end())
00377 {
00378 depends.push_back(findDicIt->second);
00379 <span class="keywordflow">continue</span>;
00380 }
00381
00382 std::string p = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">NLMISC::CPath::lookup</a> (*first, <span class="keyword">false</span>, <span class="keyword">false</span>);
00383 <span class="keywordflow">if</span> (!p.empty())
00384 {
00385 <span class="comment">// uint32 date = NLMISC::CFile::getFileModificationDate(p);</span>
00386
00387 <a class="code" href="a04558.html#a15">uint</a> dicIndex;
00388 <span class="comment">// std::string filename = NLMISC::CFile::getFilename(p);</span>
00389
00390 <span class="comment">// if (dictionnaryIndex.find(filename) == dictionnaryIndex.end())</span>
00391 <span class="comment">// {</span>
00392 <span class="comment">// add a new dictionnary entry</span>
00393 dicIndex = dictionnary.size();
00394 dictionnaryIndex.insert(std::make_pair(filename, dictionnary.size()));
00395 dictionnary.push_back(filename);
00396 <span class="comment">// }</span>
00397 <span class="comment">// else</span>
00398 <span class="comment">// {</span>
00399 <span class="comment">// dicIndex = dictionnaryIndex.find(filename)->second;</span>
00400 <span class="comment">// }</span>
00401
00402 <span class="comment">// add the dependecy index</span>
00403 depends.push_back(dicIndex);
00404 }
00405 }
00406 <span class="comment">// store the dependency list with the sheet ID</span>
00407 dependencies[sheetIds[NeededToRecompute[j]]] = depends;
00408 }
00409
00410 <span class="comment">// add the new creature, it could be already loaded by the packed sheets but will be overwrite with the new one</span>
00411 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::map<NLMISC::CSheetId, T>::iterator TType1;
00412 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::pair<TType1, bool> TType2;
00413 TType2 <a class="code" href="a04223.html#a643">res</a> = container.insert(std::make_pair(sheetIds[NeededToRecompute[j]],T()));
00414
00415 (*<a class="code" href="a04223.html#a643">res</a>.first).second.readGeorges (form, sheetIds[NeededToRecompute[j]]);
00416 containerChanged = <span class="keyword">true</span>;
00417 }
00418 }
00419
00420 <span class="keywordflow">if</span>(NeededToRecompute.size() > 0)
00421 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"%d seconds to recompute %d sheets"</span>, (<a class="code" href="a04558.html#a11">uint32</a>)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size());
00422
00423 <span class="comment">// free the georges loader if necessary</span>
00424 <span class="keywordflow">if</span> (formLoader != NULL)
00425 {
00426 <a class="code" href="a02559.html#NLGEORGES_1_1UFormLoadere1">NLGEORGES::UFormLoader::releaseLoader</a> (formLoader);
00427 NLMISC::WarningLog->removeFilter (<span class="stringliteral">"CFormLoader: Can't open the form file"</span>);
00428 }
00429
00430 <span class="comment">// we have now to remove sheet that are in the container and not exist anymore in the sheet directories</span>
00431 <span class="keywordflow">for</span> (std::map<NLMISC::CSheetId, bool>::iterator it2 = sheetToRemove.begin(); it2 != sheetToRemove.end(); it2++)
00432 {
00433 <span class="keywordflow">if</span>((*it2).second)
00434 {
00435 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"the sheet '%s' is not in the directory, remove it from container"</span>, (*it2).first.toString().c_str());
00436 container.find((*it2).first)->second.removed();
00437 container.erase((*it2).first);
00438 containerChanged = <span class="keyword">true</span>;
00439 dependencies.erase((*it2).first);
00440 }
00441 }
00442
00443 <span class="comment">// now, save the new container in the packedfile</span>
00444 <span class="keywordflow">try</span>
00445 {
00446 <span class="keywordflow">if</span>(containerChanged)
00447 {
00448 <a class="code" href="a03011.html">NLMISC::COFile</a> ofile;
00449 ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea9">open</a>(packedFilenamePath);
00450
00451 <span class="comment">// write the header.</span>
00452 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_0">serialCheck</a>(PACKED_SHEET_HEADER);
00453 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_0">serialCheck</a>(PACKED_SHEET_VERSION);
00454 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_8">serialVersion</a>(PACKED_SHEET_VERSION_COMPATIBLE);
00455
00456 <span class="comment">// Write a dummy block size for now</span>
00457 <a class="code" href="a04558.html#a10">sint32</a> posBlockSize= ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea4">getPos</a>();
00458 <a class="code" href="a04558.html#a11">uint32</a> dependBlockSize= 0;
00459 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(dependBlockSize);
00460
00461 <span class="comment">// write the dictionnary</span>
00462 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(dictionnary);
00463
00464 <span class="comment">// write the dependencies data</span>
00465 <a class="code" href="a04558.html#a11">uint32</a> depSize = dependencies.size();
00466 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(depSize);
00467 std::map<NLMISC::CSheetId, std::vector<uint32> >::iterator first(dependencies.begin()), last(dependencies.end());
00468 <span class="keywordflow">for</span> (; first != last; ++first)
00469 {
00470 <a class="code" href="a03384.html">NLMISC::CSheetId</a> si = first->first;
00471 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(si);
00472 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(first->second);
00473 }
00474
00475 <span class="comment">// Then get the dicionary + dependencies size, and write it back to posBlockSize</span>
00476 <a class="code" href="a04558.html#a10">sint32</a> endBlockSize= ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea4">getPos</a>();
00477 dependBlockSize= (endBlockSize - posBlockSize) - 4;
00478 ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea10">seek</a>(posBlockSize, NLMISC::IStream::begin);
00479 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(dependBlockSize);
00480 ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea10">seek</a>(endBlockSize, NLMISC::IStream::begin);
00481
00482 <span class="comment">// write the sheet data</span>
00483 <a class="code" href="a04558.html#a11">uint32</a> nbEntries = sheetIds.size();
00484 <a class="code" href="a04558.html#a11">uint32</a> ver = T::getVersion ();
00485 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a> (nbEntries);
00486 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a> (ver);
00487 ofile.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(container);
00488 ofile.<a class="code" href="a03011.html#NLMISC_1_1COFilea0">close</a> ();
00489 }
00490 }
00491 <span class="keywordflow">catch</span> (<a class="code" href="a02482.html">NLMISC::Exception</a> &e)
00492 {
00493 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"loadForm(): Exception during saving the packed file, it will be recreated next launch (%s)"</span>, e.what());
00494 }
00495
00496 <span class="comment">// housekeeping</span>
00497 sheetIds.clear ();
00498 filenames.clear ();
00499 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="a3" doxytag="load_form.h::loadForm" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" colspan="4">
template<class T> </td>
</tr>
<tr>
<td class="md" nowrap valign="top"> void loadForm </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const std::string & </td>
<td class="mdname" nowrap> <em>sheetFilter</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const std::string & </td>
<td class="mdname" nowrap> <em>packedFilename</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>std::map< <a class="el" href="a03384.html">NLMISC::CSheetId</a>, T > & </td>
<td class="mdname" nowrap> <em>container</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>updatePackedSheet</em> = true, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>errorIfPackedSheetNotGood</em> = true</td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
This function is used to load values from georges sheet in a quick way. <dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign=top><em>sheetFilter</em> </td><td>a string to filter the sheet (ie: ".item") </td></tr>
<tr><td valign=top><em>packedFilename</em> </td><td>the name of the file that this function will generate (extension must be "packed_sheets") </td></tr>
<tr><td valign=top><em>container</em> </td><td>the map that will be filled by this function </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a05926.html#l00132">132</a> of file <a class="el" href="a05926.html">load_form.h</a>.
<p>
References <a class="el" href="a05926.html#l00522">loadForm()</a>.
<p>
<div class="fragment"><pre>00133 {
00134 std::vector<std::string> vs;
00135 vs.push_back(sheetFilter);
00136 <a class="code" href="a04503.html#a6">loadForm</a>(vs, packedFilename, container, updatePackedSheet, errorIfPackedSheetNotGood);
00137 }
</pre></div> </td>
</tr>
</table>
<hr><h2>Variable Documentation</h2>
<a class="anchor" name="a0" doxytag="load_form.h::PACKED_SHEET_HEADER" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> const <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a04503.html#a0">PACKED_SHEET_HEADER</a> = 'PKSH'
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Dictionnaley entry for dependency information.
<p>
This function is used to load values from georges sheet in a quick way. The first time it loads the sheet and parse it with the readGeorges function provided by the user to read the value he wants. It'll generate a packed file that contains this values (using serialCont). The next launch, the function will only load the packed file and if some sheet have changed, it'll automatically regenerate the packed file.<p>
To use the <a class="el" href="a04503.html#a3">loadForm()</a>, you first have to create a class that will contains values for one sheet. This class must also implements 2 functions (readGeorges() and serial()) and 1 static functions (getVersion())<p>
Extension file name for the packedFilename must be ".packed_sheets"<p>
Classical use (copy/paste this in your code):<p>
For each sheet in the packed sheet, an instance of this class is created and stored into an stl container. This class must be default and copy constructable. class CContainerEntry { public: CContainerEntry () : WalkSpeed(1.3f), RunSpeed(6.0f) {}<p>
float WalkSpeed, RunSpeed;<p>
load the values using the george sheet void readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const <a class="el" href="a03384.html">NLMISC::CSheetId</a> &sheetId) { the form was found so read the true values from George form->getRootNode ().getValueByName (WalkSpeed, "Basics.MovementSpeeds.WalkSpeed"); form->getRootNode ().getValueByName (RunSpeed, "Basics.MovementSpeeds.RunSpeed"); }<p>
load/save the values using the serial system void serial (<a class="el" href="a02270.html">NLMISC::IStream</a> &s) { s.serial (WalkSpeed, RunSpeed); }<p>
Event to implement any action when the sheet is no longeur existent. This method is call when a sheet have been read from the packed sheet and the associated sheet file no more exist in the directories. void removed() { any action that is needed if the sheet no more exist. }<p>
return the version of this class, increments this value when the content hof this class changed static uint getVersion () { return 1; } };<p>
this structure is fill by the <a class="el" href="a04503.html#a3">loadForm()</a> function and will contain all you need std::map<NLMISC::CSheetId,CContainerEntry> Container;<p>
void init () { load the values using the george sheet or packed file and fill the container loadForm(".creature", "test.packed_sheets", Container); }<p>
Now you can access the Container (using the CSheedId) to know the WalkSpeed and RunSpeed of all creatures.
<p>
Definition at line <a class="el" href="a05926.html#l00120">120</a> of file <a class="el" href="a05926.html">load_form.h</a>.
<p>
Referenced by <a class="el" href="a05926.html#l00145">loadForm()</a>. </td>
</tr>
</table>
<a class="anchor" name="a1" doxytag="load_form.h::PACKED_SHEET_VERSION" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> const <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a04503.html#a1">PACKED_SHEET_VERSION</a> = 5
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05926.html#l00121">121</a> of file <a class="el" href="a05926.html">load_form.h</a>.
<p>
Referenced by <a class="el" href="a05926.html#l00145">loadForm()</a>. </td>
</tr>
</table>
<a class="anchor" name="a2" doxytag="load_form.h::PACKED_SHEET_VERSION_COMPATIBLE" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> const <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a04503.html#a2">PACKED_SHEET_VERSION_COMPATIBLE</a> = 0
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05926.html#l00123">123</a> of file <a class="el" href="a05926.html">load_form.h</a>.
<p>
Referenced by <a class="el" href="a05926.html#l00145">loadForm()</a>. </td>
</tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:42:53 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.6 </small></address>
</body>
</html>
|