Dear Jaroslav
after goggling a lot I found a nice example that I converted to fix the 
MPI_Comunicator problem

Here there is the code adjusted from 
http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4031/

there are just two files Comm.h and Comexample.cc

#define FILL_COMM(RNAME,LNAME)        \
  MPI_Comm RNAME##comm = MPI_LNAME;\

#include "mpi.h"



#define READ_ONLY 1
#define WRITE_ONLY 2
#define READ_WRITE 3

template <typename Container, typename ValueType, int nPropType>
class property
{
public:
property()
{
  m_cObject = NULL;
  Set = NULL;
  Get = NULL;
}
//-- This to set a pointer to the class that contain the
//   property --
void
 setContainer(Container* cObject)
{
  m_cObject = cObject;
}
//-- Set the set member function that will change the value --
void setter(void (Container::*pSet)(ValueType value))
{
  if((nPropType == WRITE_ONLY) || (nPropType == READ_WRITE))
    Set = pSet;
  else
    Set = NULL;
}
//-- Set the get member function that will retrieve the value --
void getter(ValueType (Container::*pGet)())
{
  if((nPropType == READ_ONLY) || (nPropType == READ_WRITE))
    Get = pGet;
  else
    Get = NULL;
}
//-- Overload the '=' sign to set the value using the set
//   member --
ValueType operator =(const ValueType& value)
{
  assert(m_cObject != NULL);
  assert(Set != NULL);
  (m_cObject->*Set)(value);
  return value;
}
//-- To make possible to cast the property
 class to the
//   internal type --
operator ValueType()
{
  assert(m_cObject != NULL);
  assert(Get != NULL);
  return (m_cObject->*Get)();
}
private:
  Container* m_cObject;  //-- Pointer to the module that
                         //   contains the property --
  void (Container::*Set)(ValueType value);
                         //-- Pointer to set member function --
  ValueType (Container::*Get)();
                         //-- Pointer to get member function --
};


class
 PropTest
{
public:
  PropTest()
  {
    Comm.setContainer(this);
    Comm.setter(&PropTest::setComm);
    Comm.getter(&PropTest::getComm);
  }
  MPI_Comm getComm()
  {
    return m_nComm;
  }
  void setComm(MPI_Comm nComm)
  {
    m_nComm = nComm;
  }
  property<PropTest,MPI_Comm,READ_WRITE> Comm;


private:
  MPI_Comm m_nComm;
};


And the DLD function
#include <octave/oct.h>
#include "Comm.h"
DEFUN_DLD(CommExample,args,,"A simple example using a C++ class holding 
Comunicator as property")
{
    
// Example setting
 PropTest SetTest;
 SetTest.Comm = MPI_COMM_WORLD;
// Example getting
 MPI_Comm ex_comm;
 ex_comm = SetTest.Comm;
// the problem is how could SetTest
 comunicate with GNU Octave ?
}

I think the situation here is simpler because we have a simple class holding 
all pieces of info and perhaps the pointers to this class are easier to 
handle.. and more universal among different MPI implementations ...
What do you think ?
Thanks a lot in advance for all your patience and help.
Bests
Riccardo






      
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to