Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/kernel.git] / src / DSC / DSC_User / Datastream / Calcium / test_DataIdContainer.cxx
1 //  Copyright (C) 2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //
21 //
22 //  File   : test_DataIdContainer.cxx
23 //  Author : Eric Fayolle (EDF)
24 //  Module : KERNEL
25 // Modified by : $LastChangedBy$
26 // Date        : $LastChangedDate: 2007-03-01 15:07:46 +0100 (jeu, 01 mar 2007) $
27 // Id          : $Id$
28
29 #include "CalciumCouplingPolicy.hxx"
30
31 #include "CalciumProvidesPort.hxx"
32 #include "CalciumException.hxx"
33
34 using namespace CalciumTypes;
35
36 class TEST1 : public CalciumCouplingPolicy {
37 public:
38   int ret;
39   TEST1() {
40
41     ret=0;
42   
43     CORBA::Long time=1,tag=1;
44     typedef CalciumCouplingPolicy::DataIdContainer DataIdContainer;  
45     typedef CalciumCouplingPolicy::DataId          DataId;
46     
47     DataId          dataId(time,tag);   //potentiellement avec un troisième paramètre
48     try {
49       DataIdContainer dataIds(dataId,*this);   
50
51       DataIdContainer::iterator dataIdIt = dataIds.begin();
52       
53       if (!dataIds.empty())
54         for (;dataIdIt != dataIds.end();++dataIdIt) {
55           std::cout << "(*dataIdIt) must be equal to given dataId parameter : " << *dataIdIt;
56           std::cout << " == " << dataId << " : " << (ret = (*dataIdIt == dataId)) << std::endl;
57         }
58     } catch(const CalciumException & ex) {
59       ret=1;
60       std::cout << ex.what() << std::endl;
61     }
62
63   }
64 };
65
66 class TEST2 : public CalciumCouplingPolicy {
67     
68 public:
69   int ret;
70   TEST2() {
71
72     //  Doit filtrer le mode de dépendance temporel car le mode est 
73     //  défini itératif
74     ret=0;
75
76     CORBA::Long time=1,tag=1;
77     typedef CalciumCouplingPolicy::DataIdContainer DataIdContainer;  
78     typedef CalciumCouplingPolicy::DataId          DataId;
79     
80     DataId          dataId(time,tag);   //potentiellement avec un troisième paramètre
81     setDependencyType(ITERATION_DEPENDENCY);
82     DataIdContainer dataIds(dataId,*this);   
83
84
85     DataIdContainer::iterator dataIdIt = dataIds.begin();
86
87     if (!dataIds.empty())
88       for (;dataIdIt != dataIds.end();++dataIdIt) {
89         std::cout << "(*dataIdIt) must be equal to given dataId parameter : " << *dataIdIt ;
90         std::cout << " == " << DataId(0,tag) << " : " << (ret = (*dataIdIt == DataId(0,tag))) << std::endl;
91
92       }
93   }
94 };
95  
96
97 class TEST3 : public CalciumCouplingPolicy {
98 public:
99   int ret;
100
101   TEST3() {
102
103     //  Doit filtrer le mode de dépendance temporel car le mode est 
104     //  défini itératif
105     ret=0;
106
107     CORBA::Long time=1,tag=1;
108     typedef CalciumCouplingPolicy::DataIdContainer DataIdContainer;  
109     typedef CalciumCouplingPolicy::DataId          DataId;
110     
111     DataId          dataId(time,tag);   //potentiellement avec un troisième paramètre
112     setDependencyType(TIME_DEPENDENCY);
113     DataIdContainer dataIds(dataId,*this);   
114
115
116     DataIdContainer::iterator dataIdIt = dataIds.begin();
117
118     if (!dataIds.empty())
119       for (;dataIdIt != dataIds.end();++dataIdIt) {
120         std::cout << "(*dataIdIt) must be equal to given dataId parameter : " << *dataIdIt ;
121         std::cout << " == " << DataId(time,0) << " : " << (ret = (*dataIdIt == DataId(time,0))) << std::endl;
122
123       }
124   }
125 };
126  
127 int main() {
128   TEST1 test1;
129   TEST2 test2;
130   TEST3 test3;
131   return !test1.ret+!test2.ret+!test3.ret;
132 };
133