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