Commit f0246ede authored by Ken Leiter (Civ's avatar Ken Leiter (Civ

ENH: Initial Commit

parents
project(Xdmf2)
cmake_minimum_required(VERSION 2.6)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(BUILD_SHARED_LIBS true)
find_package(Boost REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
message(${Boost_INCLUDE_DIRS})
endif(Boost_FOUND)
find_package(PythonLibs REQUIRED)
if(PYTHONLIBS_FOUND)
include_directories(${PYTHON_INCLUDE_DIRS})
endif(PYTHONLIBS_FOUND)
set(XdmfSources
XdmfGeometry
XdmfGrid
XdmfObject
XdmfTopology
)
add_library(Xdmf ${XdmfSources})
add_library(_Xdmf MODULE XdmfPython)
set_target_properties(_Xdmf PROPERTIES PREFIX "")
target_link_libraries(_Xdmf Xdmf)
configure_file(Xdmf.py Xdmf.py COPYONLY)
add_executable(XdmfTest test.cpp)
target_link_libraries(XdmfTest Xdmf)
/*
XdmfPython.cpp:
swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
*/
%include std_string.i
%include std_vector.i
namespace boost {
template<class T> class shared_ptr
{
public:
T * operator-> () const;
};
}
%template(XdmfGeometryPtr) boost::shared_ptr<XdmfGeometry>;
%template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>;
%template(XdmfObjPtr) boost::shared_ptr<XdmfObject>;
%template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>;
%module Xdmf
%{
#include <XdmfGeometry.hpp>
#include <XdmfGrid.hpp>
#include <XdmfObject.hpp>
#include <XdmfTopology.hpp>
%}
%include XdmfObject.hpp
%include XdmfGeometry.hpp
%include XdmfGrid.hpp
%include XdmfTopology.hpp
/*
XdmfPython.cpp:
swig -v -c++ -make_default -python -shadow -I/share/kleiter/boost-1.41.0-install/include -o XdmfPython.cpp Xdmf.i
*/
%include std_string.i
%include std_vector.i
namespace boost {
template<class T> class shared_ptr
{
public:
T * operator-> () const;
};
}
%template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>;
%module Xdmf
%{
#include <XdmfGeometry.hpp>
#include <XdmfGrid.hpp>
#include <XdmfObject.hpp>
#include <XdmfTopology.hpp>
%}
%include XdmfObject.hpp
%include XdmfGeometry.hpp
%include XdmfGrid.hpp
%include XdmfObject.hpp
%include XdmfTopology.hpp
This diff is collapsed.
/*
* XdmfAttribute.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFATTRIBUTE_HPP_
#define XDMFATTRIBUTE_HPP_
#include "XdmfObject.hpp"
class XdmfAttribute : public XdmfObject {
XdmfNewMacro(XdmfAttribute);
};
#endif /* XDMFATTRIBUTE_HPP_ */
/*
* XdmfGrid.cpp
*
* Created on: Jan 29, 2010
* Author: kleiter
*/
#include "XdmfGeometry.hpp"
XdmfGeometry::XdmfGeometry()
{
std::cout << "Created Geometry " << this << std::endl;
}
XdmfGeometry::~XdmfGeometry()
{
std::cout << "Deleted Geometry " << this << std::endl;
}
std::string XdmfGeometry::printSelf() const
{
return "XdmfGeometry";
}
/*
* XdmfGeometry.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFGEOMETRY_HPP_
#define XDMFGEOMETRY_HPP_
#include "XdmfObject.hpp"
class XdmfGeometry : public XdmfObject {
public:
XdmfNewMacro(XdmfGeometry);
virtual std::string printSelf() const;
protected:
XdmfGeometry();
virtual ~XdmfGeometry();
private:
class Delete
{
public:
void operator()(XdmfGeometry * p) { delete p; }
};
XdmfGeometry(const XdmfGeometry&); // Not implemented.
void operator=(const XdmfGeometry&); // Not implemented.
};
#endif /* XDMFGEOMETRY_HPP_ */
/*
* XdmfGrid.cpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#include "XdmfGrid.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
XdmfGrid::XdmfGrid()
{
std::cout << "Created Grid " << this << std::endl;
mGeometry = XdmfGeometry::New();
mTopology = XdmfTopology::New();
}
XdmfGrid::~XdmfGrid()
{
std::cout << "Deleted Grid " << this << std::endl;
}
std::string XdmfGrid::printSelf() const
{
return "XdmfGrid containing a " + mGeometry->printSelf() + " and a " + mTopology->printSelf();
}
// Kenneth Leiter
// Xdmf Smart Pointer Test
#ifndef XDMFGRID_HPP_
#define XDMFGRID_HPP_
// Forward Declarations
class XdmfAttribute;
class XdmfAttributeVector;
class XdmfGeometry;
class XdmfTopology;
// Includes
#include "XdmfObject.hpp"
#include <vector>
class XdmfGrid : public XdmfObject {
public:
XdmfNewMacro(XdmfGrid);
// Get the XdmfGeometry for this grid
XdmfGetValueMacro(Geometry, boost::shared_ptr<XdmfGeometry>);
// Set the XdmfGeometry for this grid
XdmfSetValueMacro(Geometry, boost::shared_ptr<XdmfGeometry>);
// Get the XdmfTopology for this grid
XdmfGetValueMacro(Topology, boost::shared_ptr<XdmfTopology>);
// Set the XdmfTopology for this grid
XdmfSetValueMacro(Topology, boost::shared_ptr<XdmfTopology>);
virtual std::string printSelf() const;
protected:
XdmfGrid();
virtual ~XdmfGrid();
private:
XdmfGrid(const XdmfGrid&); // Not implemented.
void operator=(const XdmfGrid&); // Not implemented.
boost::shared_ptr<XdmfGeometry> mGeometry;
boost::shared_ptr<XdmfTopology> mTopology;
std::vector<boost::shared_ptr<XdmfAttribute> > mAttributes;
};
#endif /* XDMFGRID_HPP_ */
/*
* XdmfObject.cpp
*
* Created on: Feb 1, 2010
* Author: kleiter
*/
#include "XdmfObject.hpp"
XdmfObject::XdmfObject()
{
}
XdmfObject::~XdmfObject()
{
}
std::string XdmfObject::printSelf() const
{
return "XdmfObject";
}
std::ostream& operator<<(std::ostream& out, const XdmfObject& ob)
{
out << ob.printSelf();
return out;
}
/*
* XdmfObject.hpp
*
* Created on: Feb 1, 2010
* Author: kleiter
*/
#ifndef XDMFOBJECT_HPP_
#define XDMFOBJECT_HPP_
#include "boost/shared_ptr.hpp"
#include <iostream>
#include <ostream>
#define XdmfNewMacro(type) \
template <typename T> friend void boost::checked_delete(T * x); \
static boost::shared_ptr<type> New() \
{ \
boost::shared_ptr<type> p(new type()); \
return p; \
}
#define XdmfGetValueMacro(var,type) \
type get##var () \
{ \
return ( this->m##var ); \
}
#define XdmfSetValueMacro(var,type) \
void set##var (type _arg) \
{ \
this->m##var = _arg; \
}
class XdmfObject {
public:
XdmfNewMacro(XdmfObject);
virtual std::string printSelf() const;
protected:
XdmfObject();
virtual ~XdmfObject();
};
std::ostream& operator<<(std::ostream& out, const XdmfObject& ob);
#endif /* XDMFOBJECT_HPP_ */
This diff is collapsed.
/*
* XdmfGrid.cpp
*
* Created on: Jan 29, 2010
* Author: kleiter
*/
#include "XdmfTopology.hpp"
XdmfTopology::XdmfTopology()
{
std::cout << "Created Topology " << this << std::endl;
}
XdmfTopology::~XdmfTopology()
{
std::cout << "Deleted Topology " << this << std::endl;
}
std::string XdmfTopology::printSelf() const
{
return "XdmfTopology";
}
/*
* XdmfTopology.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFTOPOLOGY_HPP_
#define XDMFTOPOLOGY_HPP_
#include "XdmfObject.hpp"
class XdmfTopology : public XdmfObject {
public:
XdmfNewMacro(XdmfTopology);
virtual std::string printSelf() const;
protected:
XdmfTopology();
virtual ~XdmfTopology();
private:
XdmfTopology(const XdmfTopology&); // Not implemented.
void operator=(const XdmfTopology&); // Not implemented.
};
#endif /* XDMFTOPOLOGY_HPP_ */
/*
* test.cc
*
* Created on: Jan 29, 2010
* Author: kleiter
*/
#include "XdmfGrid.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
#include <iostream>
int main(int argc, char* argv[])
{
boost::shared_ptr<XdmfGrid> grid = XdmfGrid::New();
std::cout << *grid << std::endl;
boost::shared_ptr<XdmfObject> obj = XdmfGrid::New();
std::cout << *obj << std::endl;
boost::shared_ptr<XdmfTopology> top = XdmfTopology::New();
std::cout << *top << std::endl;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment