source: Sophya/trunk/SophyaProg/Tests/tstsegdb.cc@ 2659

Last change on this file since 2659 was 2659, checked in by ansari, 20 years ago

Ajout programme test des PPF wrappers des vecteurs de STL (tstppfwrapstl.cc ) des classes SegmentedDataBlock (tstsegdb.cc) et modifications mineurs ds ttimestamp.cc - Reza 7 Avril 2005

File size: 3.6 KB
RevLine 
[2659]1#include "sopnamsp.h"
2#include "machdefs.h"
3#include <stdio.h>
4#include <stdlib.h>
5#include "math.h"
6#include <iostream>
7#include <string>
8
9#include <typeinfo>
10#include "timing.h"
11#include "histinit.h"
12#include "pexceptions.h"
13#include "segdatablock.h"
14#include "fiosegdb.h"
15#include "swsegdb.h"
16#include "ppfswapper.h"
17#include "ppfwrapstlv.h"
18
19/* Programme test des classes SegDataBlock<T> et son PPF writer */
20/* SwSegDataBlock<T> avec le swapper PPF */
21/* SOPHYA - R. Ansari (LAL) - Avril 2005 */
22
23int main(int narg, char* arg[])
24{
25 cout << " ---- Programme tstsegdb.cc ----- \n"
26 << " Test classe SegDataBlock<T> et SwSegDataBlock<T> " << endl;
27 int rc = 0;
28 try {
29 SophyaInit();
30
31 InitTim();
32 cout << "1/ Test SegDataBlock Creation,remplissage, impression (segi, ssegi, sgds" << endl;
33 SegDataBlock<int> segi;
34 segi.Extend();
35 cout << segi;
36
37 SegDataBlock<int> ssegi(segi);
38 segi = 432;
39 ssegi.Extend();
40 ssegi.Print(cout, 4, " , ");
41 SegDataBlock<string> sgds(5,3);
42 cout << sgds;
43 sgds[2] = "bonjour"; sgds[5] = "AAAA";
44 sgds[8] = "BbbBBbb";
45 sgds.Print(cout, 4, " ; ");
46
47 {
48 cout << "2/ Ecriture segi sgds et ssegi dans segdb.ppf " << endl;
49 POutPersist so("segdb.ppf");
50 so << segi << sgds << ssegi;
51 }
52 {
53 cout << "3/ Lecture depuis segdb.ppf et print " << endl;
54 SegDataBlock<int> rsd1, rsd2;
55 SegDataBlock<string> rsds;
56 PInPersist si("segdb.ppf");
57 si >> rsd1 >> rsds >> rsd2;
58 rsds.Print(cout, 4, " ; ");
59 cout << "4/ On modifie certains elements de rsd1 et on verifie le partage de reference en lecture" << endl;
60 for(int jj=0; jj<rsd1.Size(); jj += 9)
61 rsd1[jj] = 999;
62 rsd1.Print(cout, 4, " , ");
63 rsd2.Print(cout, 4, " , ");
64 }
65 cout << "5/ Test SwSegDataBlock<T> creation/remplissage " << endl;
66 int SWSEGSZ = 4;
67 {
68 cout << " Creation PPFDataSwapper<float> swout(so) avec swseg.ppf " << endl;
69 POutPersist so("swseg.ppf");
70 PPFDataSwapper<float> swout(so);
71 SwSegDataBlock<float> swsd(swout, SWSEGSZ, 3);
72 float * fp = swsd.GetSegment(0);
73 fp[0] = 6.54321; fp[1] = 65.4321; fp[2] = 654.321; fp[3] = 6543.21;
74 fp = swsd.GetSegment(1);
75 fp[0] = 2.56789; fp[1] = 25.6789; fp[2] = 256.789; fp[3] = 2567.89;
76 fp = swsd.GetSegment(2);
77 fp[0] = 12.567; fp[1] = 225.67; fp[2] = 3256.7; fp[3] = 42567.;
78 vector<int_8> tags = swsd.GetSwapPosTagTable();
79 so << tags;
80 }
81 {
82 cout << "6/ Creation PPFDataSwapper<float> avec lecture depuis swseg.ppf " << endl;
83 PInPersist si("swseg.ppf");
84 PPFDataSwapper<float> swin(si);
85 vector<int_8> tags;
86 si >> tags;
87 SwSegDataBlock<float> swsd(swin, tags, SWSEGSZ);
88 cout <<"7/ Recopie ds SegDataBlock<float> depuis SwSegDataBlock<float> et print" << endl;
89 SegDataBlock<float> segf,segf2;
90 segf = swsd;
91 segf.Print(cout, 4, " ");
92 segf2 = swsd;
93 segf2.Print(cout, 4, " ");
94 }
95
96 }
97 catch (PThrowable & exc) {
98 cerr << " tstsegdb.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
99 << " - Msg= " << exc.Msg() << endl;
100 rc = 99;
101 }
102 catch (std::exception & e) {
103 cerr << " tstsegdb.cc: Catched std::xception "
104 << " - what()= " << e.what() << endl;
105 rc = 98;
106 }
107 catch (...) {
108 cerr << " tstsegdb.cc: some other exception (...) was caught ! " << endl;
109 rc = 97;
110 }
111 PrtTim("End tstsegdb " );
112 cout << " ---- Programme tstsegdb.cc - FIN (Rc=" << rc << ") --- " << endl;
113 return rc;
114}
Note: See TracBrowser for help on using the repository browser.