[pooma-dev] [PATCH] C++ correctness fixes

Jeffrey Oldham oldham at codesourcery.com
Mon Jul 1 22:26:57 UTC 2002


On Thu, Jun 27, 2002 at 01:41:54PM +0200, Richard Guenther wrote:
> Hi!
> 
> The attached patch provides some fixes for C++ correctness to either
> avoid warnings or, in case of ContextMapper.h, fix the destructor being
> not virtual.
> 
> All of these were catched by gcc3.1, pooma r2 now compiles without
> warnings [apart from using <*.h> rather than <*> includes].
> 
> Richard.
> 
> Btw. is it considered good practice to post patches to this mailinglist?
> I have (after some cleanup) more stuff pending, like introducing HDF5
> I/O classes and activation of CoordinateSystem support (much like the one
> from pooma-2.3.0). For my own development I set up a bitkeeper repository
> to mirror the CVS one, but its not pullable from outside our institute.

Thanks for the submission.  I read it, approved it, and committed it.

Yes, it is appropriate to send patches to the mailing list.  The patch
process is:

1) Create a patch.

2) Check the patch by compiling the POOMA library and, if appropriate,
POOMA test cases.  For example, if changing a Field feature, run all
the src/Field/tests/ tests.

3) Create a ChangeLog entry associated with the patch.  (See the
attached file.)  Be sure to list how the patch was tested.

4) Send to either the pooma-dev email list or to an individual for
comments and possible approval.

5) Commit the patch.  Be sure to note who approved the patch.

6) Send the committed patch to the pooma-dev email list.

FWIW, I'm used to reading the output of 'cvs diff' using this ~/.cvsrc:

    update -d -P
    diff -c -p -N
    cvs -z6

I'm glad you are using POOMA.

Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
2002Jul01  Richard Guenther <richard.guenther at uni-tuebingen.de>
	(Jeffrey D. Oldham (oldham at codesourcery.com) typed this ChangeLog.)

	* Field/NearestNeighbors.h (NearestNeighborClass::operator()):
	Add 'typename'.
	(NearestNeighborClass::nearestNeighbors): Likewise.
	* Field/DiffOps/FieldShiftEngine.h (FieldShiftSimple::make):
	Likewise.
	* Field/FieldEngine/FieldEngine.h (FieldEngine::FieldEngine):
	Reorder constructor initializers to reflect member declaration
	order.
	* Partition/ContextMapper.h (ContextMapper::~ContextMapper):
	New virtual destructor for class with virtual functions.

	Tested using g++ 3.0.3 on sequential Linux by compiling Pooma library.
	Approved by Jeffrey D. Oldham.
-------------- next part --------------
Index: src/Field/NearestNeighbors.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Field/NearestNeighbors.h,v
retrieving revision 1.2
diff -c -p -r1.2 NearestNeighbors.h
*** src/Field/NearestNeighbors.h	2001/10/06 00:39:19	1.2
--- src/Field/NearestNeighbors.h	2002/07/01 22:11:47
*************** public:
*** 129,135 ****
  
      // Determine nearest neighbors for each output value.
  
!     for (Answer_t::size_type outputIndex = 0;
  	 outputIndex < outputCentering.size();
  	 ++outputIndex)
        answer[outputIndex] = nearestNeighbors(inputPositions,
--- 129,135 ----
  
      // Determine nearest neighbors for each output value.
  
!     for (typename Answer_t::size_type outputIndex = 0;
  	 outputIndex < outputCentering.size();
  	 ++outputIndex)
        answer[outputIndex] = nearestNeighbors(inputPositions,
*************** public:
*** 173,179 ****
  
      // Determine nearest neighbors for each field offset.
  
!     for (FieldOffsetList_t::size_type folIndex = 0;
  	 folIndex < outputCentering.size();
  	 ++folIndex) {
        PInsist(fieldOffsetList[folIndex].subFieldNumber() < outputCentering.size(),
--- 173,179 ----
  
      // Determine nearest neighbors for each field offset.
  
!     for (typename FieldOffsetList_t::size_type folIndex = 0;
  	 folIndex < outputCentering.size();
  	 ++folIndex) {
        PInsist(fieldOffsetList[folIndex].subFieldNumber() < outputCentering.size(),
*************** private:
*** 238,244 ****
  
      FieldOffset_vt answerHolder;
      if (IntraCellOnly) {
!       for (MinimumSet::size_type minIndex = 0;
  	   minIndex < minimumSet.size();
  	   ++minIndex)
  	answerHolder.push_back(FieldOffset_t(Loc<Dim>(0),
--- 238,244 ----
  
      FieldOffset_vt answerHolder;
      if (IntraCellOnly) {
!       for (typename MinimumSet::size_type minIndex = 0;
  	   minIndex < minimumSet.size();
  	   ++minIndex)
  	answerHolder.push_back(FieldOffset_t(Loc<Dim>(0),
*************** private:
*** 246,252 ****
      }
      else {
        FieldOffset_vt partialAnswer;
!       for (MinimumSet::size_type minIndex = 0;
  	   minIndex < minimumSet.size();
  	   ++minIndex)
  	{
--- 246,252 ----
      }
      else {
        FieldOffset_vt partialAnswer;
!       for (typename MinimumSet::size_type minIndex = 0;
  	   minIndex < minimumSet.size();
  	   ++minIndex)
  	{
Index: src/Field/DiffOps/FieldShiftEngine.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Field/DiffOps/FieldShiftEngine.h,v
retrieving revision 1.1
diff -c -p -r1.1 FieldShiftEngine.h
*** src/Field/DiffOps/FieldShiftEngine.h	2001/08/30 01:15:09	1.1
--- src/Field/DiffOps/FieldShiftEngine.h	2002/07/01 22:11:48
*************** struct FieldShiftSimple
*** 435,441 ****
  	      const std::vector<FieldOffset<outputDim> > &vs1,
                const Centering<outputDim> &centering)
    {
!     typedef std::vector<FieldOffset<outputDim> >::size_type size_type;
  
      // Create a model field with the new centering.
  
--- 435,441 ----
  	      const std::vector<FieldOffset<outputDim> > &vs1,
                const Centering<outputDim> &centering)
    {
!     typedef typename std::vector<FieldOffset<outputDim> >::size_type size_type;
  
      // Create a model field with the new centering.
  
Index: src/Field/FieldEngine/FieldEngine.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Field/FieldEngine/FieldEngine.h,v
retrieving revision 1.2
diff -c -p -r1.2 FieldEngine.h
*** src/Field/FieldEngine/FieldEngine.h	2001/10/04 22:06:54	1.2
--- src/Field/FieldEngine/FieldEngine.h	2002/07/01 22:11:48
*************** public:
*** 182,189 ****
    
    FieldEngine(const This_t &model)
      : num_materials_m(model.num_materials_m),
-       stride_m(model.stride_m),
        centering_m(model.centering_m),
        data_m(model.data_m),
        physicalCellDomain_m(model.physicalCellDomain_m),
        guards_m(model.guards_m),
--- 182,189 ----
    
    FieldEngine(const This_t &model)
      : num_materials_m(model.num_materials_m),
        centering_m(model.centering_m),
+       stride_m(model.stride_m),
        data_m(model.data_m),
        physicalCellDomain_m(model.physicalCellDomain_m),
        guards_m(model.guards_m),
*************** public:
*** 244,251 ****
    FieldEngine(const FieldEngine<Mesh, T2, EngineTag2> &model,
                const Domain_t &d)
      : num_materials_m(model.numMaterials()),
-       stride_m(model.centeringSize()),
        centering_m(model.centering()),
        guards_m(0),
        mesh_m(model.mesh(),
               inputDomainToVertexDomain(d))
--- 244,251 ----
    FieldEngine(const FieldEngine<Mesh, T2, EngineTag2> &model,
                const Domain_t &d)
      : num_materials_m(model.numMaterials()),
        centering_m(model.centering()),
+       stride_m(model.centeringSize()),
        guards_m(0),
        mesh_m(model.mesh(),
               inputDomainToVertexDomain(d))
*************** public:
*** 282,289 ****
    FieldEngine(const FieldEngine<Mesh2, T2, EngineTag2> &model,
                const Domain &d)
      : num_materials_m(model.numMaterials()),
-       stride_m(model.centeringSize()),
        centering_m(model.centering()),
        guards_m(0)
    {
      addSubFields();
--- 282,289 ----
    FieldEngine(const FieldEngine<Mesh2, T2, EngineTag2> &model,
                const Domain &d)
      : num_materials_m(model.numMaterials()),
        centering_m(model.centering()),
+       stride_m(model.centeringSize()),
        guards_m(0)
    {
      addSubFields();
*************** public:
*** 304,311 ****
    FieldEngine(const FieldEngine<Mesh, T2, EngineTag2> &model,
                const INode<Dim> &i)
      : num_materials_m(model.numMaterials()),
-       stride_m(model.centeringSize()),
        centering_m(model.centering()),
        guards_m(0),
        mesh_m(model.mesh(),
               inputDomainToVertexDomain(i.domain())) // FIXME: should hand INode to mesh?
--- 304,311 ----
    FieldEngine(const FieldEngine<Mesh, T2, EngineTag2> &model,
                const INode<Dim> &i)
      : num_materials_m(model.numMaterials()),
        centering_m(model.centering()),
+       stride_m(model.centeringSize()),
        guards_m(0),
        mesh_m(model.mesh(),
               inputDomainToVertexDomain(i.domain())) // FIXME: should hand INode to mesh?
*************** public:
*** 342,349 ****
    FieldEngine(const FieldEngine<Mesh2, T2, EngineTag2> &model,
                const EngineView<Tag> &ev)
      : num_materials_m(model.numMaterials()),
-       stride_m(model.centeringSize()),
        centering_m(model.centering()),
        physicalCellDomain_m(model.physicalCellDomain()),
        guards_m(model.guardLayers()),
        mesh_m(model.mesh())
--- 342,349 ----
    FieldEngine(const FieldEngine<Mesh2, T2, EngineTag2> &model,
                const EngineView<Tag> &ev)
      : num_materials_m(model.numMaterials()),
        centering_m(model.centering()),
+       stride_m(model.centeringSize()),
        physicalCellDomain_m(model.physicalCellDomain()),
        guards_m(model.guardLayers()),
        mesh_m(model.mesh())
*************** public:
*** 366,373 ****
    FieldEngine(const FieldEngine<Mesh, T, EngineTag2> &model,
                const FieldEnginePatch<Dim> &p)
      : num_materials_m(model.numMaterials()),
-       stride_m(model.centeringSize()),
        centering_m(model.centering()),
        guards_m(model.guardLayers()),
        mesh_m(model.mesh()) // FIXME: should take a view of the mesh???
    {
--- 366,373 ----
    FieldEngine(const FieldEngine<Mesh, T, EngineTag2> &model,
                const FieldEnginePatch<Dim> &p)
      : num_materials_m(model.numMaterials()),
        centering_m(model.centering()),
+       stride_m(model.centeringSize()),
        guards_m(model.guardLayers()),
        mesh_m(model.mesh()) // FIXME: should take a view of the mesh???
    {
*************** public:
*** 384,391 ****
    FieldEngine(const FieldEngine<Mesh2, T2, EngineTag2> &model, 
                const ComponentWrapper<Components> &cw)
      : num_materials_m(model.numMaterials()),
-       stride_m(model.centeringSize()),
        centering_m(model.centering()),
        physicalCellDomain_m(model.physicalCellDomain()),
        guards_m(model.guardLayers()),
        mesh_m(model.mesh())
--- 384,391 ----
    FieldEngine(const FieldEngine<Mesh2, T2, EngineTag2> &model, 
                const ComponentWrapper<Components> &cw)
      : num_materials_m(model.numMaterials()),
        centering_m(model.centering()),
+       stride_m(model.centeringSize()),
        physicalCellDomain_m(model.physicalCellDomain()),
        guards_m(model.guardLayers()),
        mesh_m(model.mesh())
*************** public:
*** 405,412 ****
    FieldEngine(const This_t &model, 
                const Pooma::DontCopyRelations &d)
      : num_materials_m(model.numMaterials()),
-       stride_m(model.centeringSize()),
        centering_m(model.centering()),
        physicalCellDomain_m(model.physicalCellDomain_m),
        guards_m(model.guardLayers()),
        mesh_m(model.mesh())
--- 405,412 ----
    FieldEngine(const This_t &model, 
                const Pooma::DontCopyRelations &d)
      : num_materials_m(model.numMaterials()),
        centering_m(model.centering()),
+       stride_m(model.centeringSize()),
        physicalCellDomain_m(model.physicalCellDomain_m),
        guards_m(model.guardLayers()),
        mesh_m(model.mesh())
Index: src/Partition/ContextMapper.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Partition/ContextMapper.h,v
retrieving revision 1.20
diff -c -p -r1.20 ContextMapper.h
*** src/Partition/ContextMapper.h	2000/12/29 02:47:37	1.20
--- src/Partition/ContextMapper.h	2002/07/01 22:11:48
*************** public:
*** 80,85 ****
--- 80,87 ----
  
    ContextMapper(){};
  
+   virtual ~ContextMapper(){};
+ 
    virtual void map(const List_t & templist) const = 0;
  
    


More information about the pooma-dev mailing list