/[escript]/trunk/escript/src/Data.cpp
ViewVC logotype

Diff of /trunk/escript/src/Data.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 782 by bcumming, Tue Jul 18 00:47:47 2006 UTC revision 783 by gross, Tue Jul 18 01:32:50 2006 UTC
# Line 51  Data::Data() Line 51  Data::Data()
51    DataAbstract* temp=new DataEmpty();    DataAbstract* temp=new DataEmpty();
52    shared_ptr<DataAbstract> temp_data(temp);    shared_ptr<DataAbstract> temp_data(temp);
53    m_data=temp_data;    m_data=temp_data;
54      m_protected=false;
55  #if defined DOPROF  #if defined DOPROF
56    // create entry in global profiling table for this object    // create entry in global profiling table for this object
57    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 68  Data::Data(double value, Line 69  Data::Data(double value,
69    }    }
70    DataArray temp(dataPointShape,value);    DataArray temp(dataPointShape,value);
71    initialise(temp.getView(),what,expanded);    initialise(temp.getView(),what,expanded);
72      m_protected=false;
73  #if defined DOPROF  #if defined DOPROF
74    // create entry in global profiling table for this object    // create entry in global profiling table for this object
75    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 82  Data::Data(double value, Line 84  Data::Data(double value,
84    DataArray temp(dataPointShape,value);    DataArray temp(dataPointShape,value);
85    pair<int,int> dataShape=what.getDataShape();    pair<int,int> dataShape=what.getDataShape();
86    initialise(temp.getView(),what,expanded);    initialise(temp.getView(),what,expanded);
87      m_protected=false;
88  #if defined DOPROF  #if defined DOPROF
89    // create entry in global profiling table for this object    // create entry in global profiling table for this object
90    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 91  Data::Data(double value, Line 94  Data::Data(double value,
94  Data::Data(const Data& inData)  Data::Data(const Data& inData)
95  {  {
96    m_data=inData.m_data;    m_data=inData.m_data;
97      m_protected=inData.isProtected();
98  #if defined DOPROF  #if defined DOPROF
99    // create entry in global profiling table for this object    // create entry in global profiling table for this object
100    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 105  Data::Data(const Data& inData, Line 109  Data::Data(const Data& inData,
109    DataAbstract* tmp = inData.m_data->getSlice(region);    DataAbstract* tmp = inData.m_data->getSlice(region);
110    shared_ptr<DataAbstract> temp_data(tmp);    shared_ptr<DataAbstract> temp_data(tmp);
111    m_data=temp_data;    m_data=temp_data;
112      m_protected=false;
113  #if defined DOPROF  #if defined DOPROF
114    // create entry in global profiling table for this object    // create entry in global profiling table for this object
115    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 137  Data::Data(const Data& inData, Line 142  Data::Data(const Data& inData,
142      }      }
143      m_data=tmp.m_data;      m_data=tmp.m_data;
144    }    }
145      m_protected=false;
146  }  }
147    
148  Data::Data(const DataTagged::TagListType& tagKeys,  Data::Data(const DataTagged::TagListType& tagKeys,
# Line 148  Data::Data(const DataTagged::TagListType Line 154  Data::Data(const DataTagged::TagListType
154    DataAbstract* temp=new DataTagged(tagKeys,values,defaultValue,what);    DataAbstract* temp=new DataTagged(tagKeys,values,defaultValue,what);
155    shared_ptr<DataAbstract> temp_data(temp);    shared_ptr<DataAbstract> temp_data(temp);
156    m_data=temp_data;    m_data=temp_data;
157      m_protected=false;
158    if (expanded) {    if (expanded) {
159      expand();      expand();
160    }    }
# Line 162  Data::Data(const numeric::array& value, Line 169  Data::Data(const numeric::array& value,
169             bool expanded)             bool expanded)
170  {  {
171    initialise(value,what,expanded);    initialise(value,what,expanded);
172      m_protected=false;
173  #if defined DOPROF  #if defined DOPROF
174    // create entry in global profiling table for this object    // create entry in global profiling table for this object
175    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 173  Data::Data(const DataArrayView& value, Line 181  Data::Data(const DataArrayView& value,
181             bool expanded)             bool expanded)
182  {  {
183    initialise(value,what,expanded);    initialise(value,what,expanded);
184      m_protected=false;
185  #if defined DOPROF  #if defined DOPROF
186    // create entry in global profiling table for this object    // create entry in global profiling table for this object
187    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 185  Data::Data(const object& value, Line 194  Data::Data(const object& value,
194  {  {
195    numeric::array asNumArray(value);    numeric::array asNumArray(value);
196    initialise(asNumArray,what,expanded);    initialise(asNumArray,what,expanded);
197      m_protected=false;
198  #if defined DOPROF  #if defined DOPROF
199    // create entry in global profiling table for this object    // create entry in global profiling table for this object
200    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 209  Data::Data(const object& value, Line 219  Data::Data(const object& value,
219      // Create a DataConstant with the same sample shape as other      // Create a DataConstant with the same sample shape as other
220      initialise(temp.getView(),other.getFunctionSpace(),false);      initialise(temp.getView(),other.getFunctionSpace(),false);
221    }    }
222      m_protected=false;
223  #if defined DOPROF  #if defined DOPROF
224    // create entry in global profiling table for this object    // create entry in global profiling table for this object
225    profData = dataProfTable.newData();    profData = dataProfTable.newData();
# Line 356  Data::isConstant() const Line 367  Data::isConstant() const
367  }  }
368    
369  void  void
370    Data::setProtection()
371    {
372       m_protected=true;
373    }
374    
375    bool
376    Data::isProtected() const
377    {
378       return m_protected;
379    }
380    
381    
382    
383    void
384  Data::expand()  Data::expand()
385  {  {
386    if (isConstant()) {    if (isConstant()) {
# Line 525  Data::getDataPointShape() const Line 550  Data::getDataPointShape() const
550  void  void
551  Data::fillFromNumArray(const boost::python::numeric::array num_array)  Data::fillFromNumArray(const boost::python::numeric::array num_array)
552  {  {
553      if (isProtected()) {
554            throw DataException("Error - attempt to update protected Data object.");
555      }
556    //    //
557    // check rank    // check rank
558    if (num_array.getrank()<getDataPointRank())    if (num_array.getrank()<getDataPointRank())
# Line 1510  Data::saveVTK(std::string fileName) cons Line 1538  Data::saveVTK(std::string fileName) cons
1538  Data&  Data&
1539  Data::operator+=(const Data& right)  Data::operator+=(const Data& right)
1540  {  {
1541      if (isProtected()) {
1542            throw DataException("Error - attempt to update protected Data object.");
1543      }
1544  #if defined DOPROF  #if defined DOPROF
1545    profData->binary++;    profData->binary++;
1546  #endif  #endif
# Line 1520  Data::operator+=(const Data& right) Line 1551  Data::operator+=(const Data& right)
1551  Data&  Data&
1552  Data::operator+=(const boost::python::object& right)  Data::operator+=(const boost::python::object& right)
1553  {  {
1554      if (isProtected()) {
1555            throw DataException("Error - attempt to update protected Data object.");
1556      }
1557  #if defined DOPROF  #if defined DOPROF
1558    profData->binary++;    profData->binary++;
1559  #endif  #endif
# Line 1530  Data::operator+=(const boost::python::ob Line 1564  Data::operator+=(const boost::python::ob
1564  Data&  Data&
1565  Data::operator-=(const Data& right)  Data::operator-=(const Data& right)
1566  {  {
1567      if (isProtected()) {
1568            throw DataException("Error - attempt to update protected Data object.");
1569      }
1570  #if defined DOPROF  #if defined DOPROF
1571    profData->binary++;    profData->binary++;
1572  #endif  #endif
# Line 1540  Data::operator-=(const Data& right) Line 1577  Data::operator-=(const Data& right)
1577  Data&  Data&
1578  Data::operator-=(const boost::python::object& right)  Data::operator-=(const boost::python::object& right)
1579  {  {
1580      if (isProtected()) {
1581            throw DataException("Error - attempt to update protected Data object.");
1582      }
1583  #if defined DOPROF  #if defined DOPROF
1584    profData->binary++;    profData->binary++;
1585  #endif  #endif
# Line 1550  Data::operator-=(const boost::python::ob Line 1590  Data::operator-=(const boost::python::ob
1590  Data&  Data&
1591  Data::operator*=(const Data& right)  Data::operator*=(const Data& right)
1592  {  {
1593      if (isProtected()) {
1594            throw DataException("Error - attempt to update protected Data object.");
1595      }
1596  #if defined DOPROF  #if defined DOPROF
1597    profData->binary++;    profData->binary++;
1598  #endif  #endif
# Line 1560  Data::operator*=(const Data& right) Line 1603  Data::operator*=(const Data& right)
1603  Data&  Data&
1604  Data::operator*=(const boost::python::object& right)  Data::operator*=(const boost::python::object& right)
1605  {  {
1606      if (isProtected()) {
1607            throw DataException("Error - attempt to update protected Data object.");
1608      }
1609  #if defined DOPROF  #if defined DOPROF
1610    profData->binary++;    profData->binary++;
1611  #endif  #endif
# Line 1570  Data::operator*=(const boost::python::ob Line 1616  Data::operator*=(const boost::python::ob
1616  Data&  Data&
1617  Data::operator/=(const Data& right)  Data::operator/=(const Data& right)
1618  {  {
1619      if (isProtected()) {
1620            throw DataException("Error - attempt to update protected Data object.");
1621      }
1622  #if defined DOPROF  #if defined DOPROF
1623    profData->binary++;    profData->binary++;
1624  #endif  #endif
# Line 1580  Data::operator/=(const Data& right) Line 1629  Data::operator/=(const Data& right)
1629  Data&  Data&
1630  Data::operator/=(const boost::python::object& right)  Data::operator/=(const boost::python::object& right)
1631  {  {
1632      if (isProtected()) {
1633            throw DataException("Error - attempt to update protected Data object.");
1634      }
1635  #if defined DOPROF  #if defined DOPROF
1636    profData->binary++;    profData->binary++;
1637  #endif  #endif
# Line 1590  Data::operator/=(const boost::python::ob Line 1642  Data::operator/=(const boost::python::ob
1642  Data  Data
1643  Data::rpowO(const boost::python::object& left) const  Data::rpowO(const boost::python::object& left) const
1644  {  {
1645      if (isProtected()) {
1646            throw DataException("Error - attempt to update protected Data object.");
1647      }
1648  #if defined DOPROF  #if defined DOPROF
1649    profData->binary++;    profData->binary++;
1650  #endif  #endif
# Line 1897  void Line 1952  void
1952  Data::setSlice(const Data& value,  Data::setSlice(const Data& value,
1953                 const DataArrayView::RegionType& region)                 const DataArrayView::RegionType& region)
1954  {  {
1955      if (isProtected()) {
1956            throw DataException("Error - attempt to update protected Data object.");
1957      }
1958  #if defined DOPROF  #if defined DOPROF
1959    profData->slicing++;    profData->slicing++;
1960  #endif  #endif
# Line 1940  void Line 1998  void
1998  Data::setTaggedValue(int tagKey,  Data::setTaggedValue(int tagKey,
1999                       const boost::python::object& value)                       const boost::python::object& value)
2000  {  {
2001      if (isProtected()) {
2002            throw DataException("Error - attempt to update protected Data object.");
2003      }
2004    //    //
2005    // Ensure underlying data object is of type DataTagged    // Ensure underlying data object is of type DataTagged
2006    tag();    tag();
# Line 1963  void Line 2024  void
2024  Data::setTaggedValueFromCPP(int tagKey,  Data::setTaggedValueFromCPP(int tagKey,
2025                              const DataArrayView& value)                              const DataArrayView& value)
2026  {  {
2027      if (isProtected()) {
2028            throw DataException("Error - attempt to update protected Data object.");
2029      }
2030    //    //
2031    // Ensure underlying data object is of type DataTagged    // Ensure underlying data object is of type DataTagged
2032    tag();    tag();
# Line 1990  void Line 2054  void
2054  Data::setRefValue(int ref,  Data::setRefValue(int ref,
2055                    const boost::python::numeric::array& value)                    const boost::python::numeric::array& value)
2056  {  {
2057      if (isProtected()) {
2058            throw DataException("Error - attempt to update protected Data object.");
2059      }
2060    //    //
2061    // Construct DataArray from boost::python::object input value    // Construct DataArray from boost::python::object input value
2062    DataArray valueDataArray(value);    DataArray valueDataArray(value);

Legend:
Removed from v.782  
changed lines
  Added in v.783

  ViewVC Help
Powered by ViewVC 1.1.26