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

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

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

revision 1934 by jfenwick, Fri Oct 24 05:54:08 2008 UTC revision 1935 by jfenwick, Mon Oct 27 06:06:39 2008 UTC
# Line 827  DataLazy::intoString(ostringstream& oss) Line 827  DataLazy::intoString(ostringstream& oss)
827    }    }
828  }  }
829    
 // Note that in this case, deepCopy does not make copies of the leaves.  
 // Hopefully copy on write (or whatever we end up using) will take care of this.  
830  DataAbstract*  DataAbstract*
831  DataLazy::deepCopy()  DataLazy::deepCopy()
832  {  {
833    if (m_op==IDENTITY)    switch (getOpgroup(m_op))
834    {    {
835      return new DataLazy(m_left);    // we don't need to copy the child here    case G_IDENTITY:  return new DataLazy(m_id->deepCopy()->getPtr());
836      case G_UNARY: return new DataLazy(m_left->deepCopy()->getPtr(),m_op);
837      case G_BINARY:    return new DataLazy(m_left->deepCopy()->getPtr(),m_right->deepCopy()->getPtr(),m_op);
838      default:
839        throw DataException("Programmer error - do not know how to deepcopy operator "+opToString(m_op)+".");
840    }    }
   return new DataLazy(m_left->deepCopy()->getPtr(),m_right->deepCopy()->getPtr(),m_op);  
841  }  }
842    
843    
# Line 853  DataLazy::getSlice(const DataTypes::Regi Line 854  DataLazy::getSlice(const DataTypes::Regi
854    throw DataException("getSlice - not implemented for Lazy objects.");    throw DataException("getSlice - not implemented for Lazy objects.");
855  }  }
856    
857    
858    // To do this we need to rely on our child nodes
859    DataTypes::ValueType::size_type
860    DataLazy::getPointOffset(int sampleNo,
861                     int dataPointNo)
862    {
863      if (m_op==IDENTITY)
864      {
865        return m_id->getPointOffset(sampleNo,dataPointNo);
866      }
867      if (m_readytype!='E')
868      {
869        collapse();
870        return m_id->getPointOffset(sampleNo,dataPointNo);
871      }
872      // at this point we do not have an identity node and the expression will be Expanded
873      // so we only need to know which child to ask
874      if (m_left->m_readytype=='E')
875      {
876        return m_left->getPointOffset(sampleNo,dataPointNo);
877      }
878      else
879      {
880        return m_right->getPointOffset(sampleNo,dataPointNo);
881      }
882    }
883    
884    // To do this we need to rely on our child nodes
885  DataTypes::ValueType::size_type  DataTypes::ValueType::size_type
886  DataLazy::getPointOffset(int sampleNo,  DataLazy::getPointOffset(int sampleNo,
887                   int dataPointNo) const                   int dataPointNo) const
888  {  {
889    throw DataException("getPointOffset - not implemented for Lazy objects - yet.");    if (m_op==IDENTITY)
890      {
891        return m_id->getPointOffset(sampleNo,dataPointNo);
892      }
893      if (m_readytype=='E')
894      {
895        // at this point we do not have an identity node and the expression will be Expanded
896        // so we only need to know which child to ask
897        if (m_left->m_readytype=='E')
898        {
899        return m_left->getPointOffset(sampleNo,dataPointNo);
900        }
901        else
902        {
903        return m_right->getPointOffset(sampleNo,dataPointNo);
904        }
905      }
906      if (m_readytype=='C')
907      {
908        return m_left->getPointOffset(sampleNo,dataPointNo); // which child doesn't matter
909      }
910      throw DataException("Programmer error - getPointOffset on lazy data may require collapsing (but this object is marked const).");
911  }  }
912    
913  // It would seem that DataTagged will need to be treated differently since even after setting all tags  // It would seem that DataTagged will need to be treated differently since even after setting all tags

Legend:
Removed from v.1934  
changed lines
  Added in v.1935

  ViewVC Help
Powered by ViewVC 1.1.26