summaryrefslogtreecommitdiff
path: root/src/MDataStd/MDataStd_NamedDataRetrievalDriver.cxx
blob: 875f1b11982340a8dfabf9f729cbc805ef990aa8 (plain)
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
// File:	MDataStd_NamedDataRetrievalDriver.cxx
// Created:	Wed Jun 27 18:37:45 2007
// Author:	Sergey ZARITCHNY
//		<szy@friendox>
// Copyright:   Open CASCADE SA 2007

#include <MDataStd_NamedDataRetrievalDriver.ixx>
#include <PDataStd_NamedData.hxx>
#include <TDataStd_NamedData.hxx>
#include <MDataStd.hxx>
#include <CDM_MessageDriver.hxx>
#include <PCollection_HExtendedString.hxx>
#include <TColStd_DataMapOfStringInteger.hxx>
#include <TDataStd_DataMapOfStringReal.hxx>
#include <TDataStd_DataMapOfStringByte.hxx>
#include <TDataStd_DataMapOfStringString.hxx>
#include <TDataStd_DataMapOfStringHArray1OfInteger.hxx>
#include <TDataStd_DataMapOfStringHArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <PColStd_HArray1OfInteger.hxx>
#include <PColStd_HArray1OfReal.hxx>

//=======================================================================
//function : MDataStd_NamedDataRetrievalDriver
//purpose  : 
//=======================================================================
MDataStd_NamedDataRetrievalDriver::MDataStd_NamedDataRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
{

}

//=======================================================================
//function : VersionNumber
//purpose  : 
//=======================================================================
Standard_Integer MDataStd_NamedDataRetrievalDriver::VersionNumber() const
{ 
  return 0; 
}

//=======================================================================
//function : SourceType
//purpose  : 
//=======================================================================
Handle(Standard_Type) MDataStd_NamedDataRetrievalDriver::SourceType() const
{
  static Handle(Standard_Type) sourceType = STANDARD_TYPE(PDataStd_NamedData);
  return sourceType;
}

//=======================================================================
//function : NewEmpty
//purpose  : 
//=======================================================================
Handle(TDF_Attribute) MDataStd_NamedDataRetrievalDriver::NewEmpty () const 
{
  return new TDataStd_NamedData();
}

//=======================================================================
//function : Paste
//purpose  : 
//=======================================================================
void MDataStd_NamedDataRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,
						   const Handle(TDF_Attribute)& Target,
						   const Handle(MDF_RRelocationTable)& ) const
{
  Handle(PDataStd_NamedData) S = Handle(PDataStd_NamedData)::DownCast (Source);
  Handle(TDataStd_NamedData) T = Handle(TDataStd_NamedData)::DownCast (Target);
  if(S.IsNull() || T.IsNull()) return;
  Standard_Integer i;
#ifdef MDTV_DEB
  cout << "Start: " <<S->LowerI() << " " <<S->UpperI()<<"\t"<<S->LowerR() << " " <<S->UpperR();
  cout << "\t"<<S->LowerS() << " " <<S->UpperS()<< "\t"<<S->LowerB() << " " <<S->UpperB();
  cout << "\t"<<S->LowerAI() << " " <<S->UpperAI()<<"\t"<<S->LowerAR() << " " <<S->UpperAR()<<endl;
#endif
  if(S->HasIntegers()) {
    TColStd_DataMapOfStringInteger aMap;
    for(i=S->LowerI();i<=S->UpperI();i++) {
      Handle(PCollection_HExtendedString) aPKey;
      Standard_Integer aValue = S->IntDataItemValue(i, aPKey);
      const TCollection_ExtendedString& aKey = aPKey->Convert();
      aMap.Bind(aKey, aValue);
    }
    T->ChangeIntegers(aMap);
    }

  if(S->HasReals()) {
    TDataStd_DataMapOfStringReal aMap;
    for(i=S->LowerR();i<=S->UpperR();i++) {
      Handle(PCollection_HExtendedString) aPKey;
      Standard_Real aValue = S->RealDataItemValue(i, aPKey);
      const TCollection_ExtendedString& aKey = aPKey->Convert();
      aMap.Bind(aKey, aValue);
    }
    T->ChangeReals(aMap);
  }
  if(S->HasStrings()) {
    TDataStd_DataMapOfStringString aMap;
    for(i=S->LowerS();i<=S->UpperS();i++) {
      Handle(PCollection_HExtendedString) aPKey;
      const Handle(PCollection_HExtendedString)& aPValue = S->StrDataItemValue(i, aPKey);
      const TCollection_ExtendedString& aKey = aPKey->Convert();
      const TCollection_ExtendedString& aValue = aPValue->Convert();
      aMap.Bind(aKey, aValue);
    }
    T->ChangeStrings(aMap);
  }
  if(S->HasBytes()) {
    TDataStd_DataMapOfStringByte aMap;
    for(i=S->LowerB();i<=S->UpperB();i++) {
      Handle(PCollection_HExtendedString) aPKey;
      Standard_Byte aValue = S->ByteDataItemValue(i, aPKey);
      const TCollection_ExtendedString& aKey = aPKey->Convert();
      aMap.Bind(aKey, aValue);
    }
    T->ChangeBytes(aMap);
  }
  if(S->HasArraysOfIntegers()) {
    TDataStd_DataMapOfStringHArray1OfInteger aMap;
    for(i=S->LowerAI();i<=S->UpperAI();i++) {
      Handle(PCollection_HExtendedString) aPKey;
      Handle(PColStd_HArray1OfInteger) aPValue = S->ArrIntDataItemValue(i, aPKey);
      const TCollection_ExtendedString& aKey = aPKey->Convert();
      Handle(TColStd_HArray1OfInteger) anAr;
      if (aPValue.IsNull()) continue;
      Standard_Integer lower = aPValue->Lower(), upper = aPValue->Upper();
      anAr = new TColStd_HArray1OfInteger(lower, upper);
      for (Standard_Integer j = lower; j <= upper; j++)
	anAr->SetValue(j, aPValue->Value(j));
      aMap.Bind(aKey, anAr);
    }
    T->ChangeArraysOfIntegers(aMap);
  }
  if(S->HasArraysOfReals()) {
    TDataStd_DataMapOfStringHArray1OfReal aMap;
    for(i=S->LowerAR();i<=S->UpperAR();i++) {
      Handle(PCollection_HExtendedString) aPKey;
      Handle(PColStd_HArray1OfReal) aPValue = S->ArrRealDataItemValue(i, aPKey);
      const TCollection_ExtendedString& aKey = aPKey->Convert();
      Handle(TColStd_HArray1OfReal) anAr;
      if (aPValue.IsNull()) continue;
      Standard_Integer lower = aPValue->Lower(), upper = aPValue->Upper();
      anAr = new TColStd_HArray1OfReal(lower, upper);
      for (Standard_Integer j = lower; j <= upper; j++)
	anAr->SetValue(j, aPValue->Value(j));
      aMap.Bind(aKey, anAr);
    }
    T->ChangeArraysOfReals(aMap);
  }
}