Commit cf9dcca4 authored by florent's avatar florent

Bindings python for dynamic_grapĥ.

parents
Authors:
#
# Copyright
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(PROJECT_NAME dynamic-graph-python)
project(${PROJECT_NAME})
SET(PROJECT_VERSION 1.0)
SET(CMAKE_VERBOSE_MAKEFILE true)
IF(WIN32)
SET(LIBDIR_KW "/LIBPATH:")
SET(LIBINCL_KW "")
SET(LIB_EXT ".lib")
ENDIF(WIN32)
IF(UNIX)
SET(LIBDIR_KW "-L")
SET(LIBINCL_KW "-l")
SET(LIB_EXT "")
ENDIF(UNIX)
#
# Look for dependencies
#
# Load Pkgconfig macros
INCLUDE(FindPkgConfig)
SET(PACKAGE_REQUIREMENTS "")
#
# Dependency to package dynamic-graph
#
SET(DYNAMIC_GRAPH_FOUND 0)
SET(DYNAMIC_GRAPH_REQUIRED "dynamic-graph >= 1.0")
PKG_CHECK_MODULES(DYNAMIC_GRAPH REQUIRED ${DYNAMIC_GRAPH_REQUIRED})
EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS --variable=docdir dynamic-graph
OUTPUT_VARIABLE DYNAMIC_GRAPH_DOCDIR)
MESSAGE(STATUS "pkg-config: ${PKG_CONFIG_EXECUTABLE}")
MESSAGE(STATUS "DYNAMIC_GRAPH_DOCDIR=${DYNAMIC_GRAPH_DOCDIR}")
SET(DYNAMIC_GRAPH_FOUND 1)
IF(NOT ${DYNAMIC_GRAPH_FOUND})
MESSAGE(FATAL_ERROR "Check that package dynamic-graph is installed in a directory pointed out by PKG_CONFIG_PATH.")
ENDIF(NOT ${DYNAMIC_GRAPH_FOUND})
IF(PACKAGE_REQUIREMENTS STREQUAL "")
SET(PACKAGE_REQUIREMENTS ${DYNAMIC_GRAPH_REQUIRED})
ELSE(PACKAGE_REQUIREMENTS STREQUAL "")
SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${DYNAMIC_GRAPH_REQUIRED}")
ENDIF(PACKAGE_REQUIREMENTS STREQUAL "")
#
# pkg-config file
#
SET(install_pkg_prefix "\${prefix}")
SET(install_pkg_exec_prefix "\${exec_prefix}")
SET(install_pkg_libdir "\${libdir}")
SET(install_pkg_datarootdir "\${datarootdir}")
SET(install_pkg_include_dir "\${includedir}")
# Install the file in the appropriate place.
SET(install_libdir_pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION ${install_libdir_pkgconfig}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
ADD_SUBDIRECTORY(src)
#
# Documentation produced by doxygen
#
INCLUDE(FindDoxygen)
IF(DOXYGEN_FOUND)
add_subdirectory(doc)
ENDIF(DOXYGEN_FOUND)
#
# Copyright (c)
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Write in this file the modifications you commit.
#
# Copyright
#
Installation instructions for library dynamic-graph-python
----------------------------------------------
It is recommended to create a specific directory to install this package.
mkdir build
cd build
cmake [Options] ..
make
make install
Options:
-DCMAKE_INSTALL_PREFIX=...
specifies the directory where to install the package.
-DCMAKE_BUILD_TYPE=[none|debug|release|relwithdebinfo|MinSizeRel]
specifies to type of compilation (release, debug, ...)
Write in this file the news related to package dynamic-graph-python.
See INSTALL for installation instruction.
echo ""
echo "This package is installed through cmake. Please read INSTALL for instructions."
echo ""
#
# Copyright
#
# Configure package.dox file
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/package.dox.cmake
${CMAKE_CURRENT_BINARY_DIR}/package.dox
)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
COMMAND ${DOXYGEN_EXECUTABLE} \"${CMAKE_CURRENT_BINARY_DIR}/package.dox\"
)
ADD_CUSTOM_TARGET(documentation ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
#
# Install html documentation
#
# html files
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME})
# doxytag
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.doxytag
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}/html)
# pictures
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pictures
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}/html)
/**
\mainpage
\section intro_dynamic-graph-python Introduction
This package implements ...
*/
<br><br>
<hr>
<center>
<img src="./pictures/footer.jpg" Height=100>
<br>dynamic-graph-python library documentation</br>
</center>
<hr>
</center>
</body>
</head>
<HTML>
<HEAD>
<TITLE>dynamic-graph-python library documentation</TITLE>
<LINK HREF="package.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY>
body {
font-family: 'Lucida Grande','Lucida Sans Unicode',Verdana,Sans-Serif;
color: #5D5D5D;
}
dl {
border: 1.5px #82b6d7 solid;
width: 97%;
padding: 5px;
color: #330077;
}
code {
color: #3C9A35;
}
td.md {
color: #0066CC;
}
h1 {
padding-top: 50px;
padding: 0px;
font-family: 'Lucida Grande','Lucida Sans Unicode',Verdana,Sans-Serif;
font-variant: small-caps;
color:#0066CC;
text-align: center;
}
h2,h3,hr {
magin-top: 15px;
padding: 0px;
font-family: 'Lucida Grande','Lucida Sans Unicode',Verdana,Sans-Serif;
font-variant: small-caps;
color:#0066CC;
}
h4 {
color: #3C9A35;
}
a:link {
font-weight: bold;
text-decoration: none;
color:#0066CC
}
a:hover, a:active {
text-decoration: underline;
color: #3C9A35;
}
a:visited {
font-weight: bold;
color: #3C9A35;
text-decoration: none;
}
DIV.memitem
{
spacing: 10px;
width:100%;
background:#FFFFFF;
font-size:100%;
line-height:normal;
border-width: 1px;
border-style: solid;
border-color: #808080;
-moz-border-radius: 8px 8px 8px 8px;
}
DIV.memproto
{
width:100%;
background:#F0F0F0;
font-size:100%;
line-height:normal;
border-width: 1px;
border-style: solid;
border-color: #808080;
-moz-border-radius: 8px 8px 8px 8px;
}
DIV.memdoc
{
padding: 10px;
width:100%;
font-size:100%;
line-height:normal;
}
DIV.tabs
{
float : left;
width : 100%;
background : url("tab_b.gif") repeat-x bottom;
margin-bottom : 4px;
}
DIV.tabs UL
{
margin : 0px;
padding-left : 10px;
list-style : none;
}
DIV.tabs LI, DIV.tabs FORM
{
display : inline;
margin : 0px;
padding : 0px;
}
DIV.tabs FORM
{
float : right;
}
DIV.tabs A
{
float : left;
background : url("tab_r.gif") no-repeat right top;
border-bottom : 1px solid #84B0C7;
font-size : x-small;
font-weight : bold;
text-decoration : none;
}
DIV.tabs A:hover
{
background-position: 100% -150px;
}
DIV.tabs A:link, DIV.tabs A:visited,
DIV.tabs A:active, DIV.tabs A:hover
{
color: #1A419D;
}
DIV.tabs SPAN
{
float : left;
display : block;
background : url("tab_l.gif") no-repeat left top;
padding : 5px 9px;
white-space : nowrap;
}
DIV.tabs INPUT
{
float : right;
display : inline;
font-size : 1em;
}
DIV.tabs TD
{
font-size : x-small;
font-weight : bold;
text-decoration : none;
}
DIV.tabs SPAN {float : none;}
DIV.tabs A:hover SPAN
{
background-position: 0% -150px;
}
DIV.tabs LI#current A
{
background-position: 100% -150px;
border-width : 0px;
}
DIV.tabs LI#current SPAN
{
background-position: 0% -150px;
padding-bottom : 6px;
}
DIV.nav
{
background : none;
border : none;
border-bottom : 1px solid #84B0C7;
}
DIV.groupHeader
{
padding-top: 30px;
padding-bottom: 20px;
background : none;
border : none;
border-bottom : 1px solid #84B0C7;
font-family: 'Lucida Grande','Lucida Sans Unicode',Verdana,Sans-Serif;
font-variant: small-caps;
font-size: 14pt;
color:#0066CC;
}
.directory p
{
margin: 0px;
white-space: nowrap;
font-family: 'Lucida Grande','Lucida Sans Unicode',Verdana,Sans-Serif;
font-size: 10pt;
font-weight: normal;
}
.directory h3
{
font-family: 'Lucida Grande','Lucida Sans Unicode',Verdana,Sans-Serif;
margin: 0px;
margin-top: 1em;
padding-bottom: 20px;
font-size: 12pt;
font-variant: small-caps;
text-align: center;
}
.directory a:visited {
font-weight: bold;
text-decoration: none;
color:#0066CC
}
This diff is collapsed.
Copy in this directory the image you wish to use in the footer of the documentation or edit file dynamic-graph-python/doc/footer.html and
remove this file.
prefix=${CMAKE_INSTALL_PREFIX}
exec_prefix=${install_pkg_prefix}
libdir=${install_pkg_exec_prefix}/lib
includedir=${install_pkg_prefix}/include
datarootdir=${install_pkg_prefix}/share
docdir=${install_pkg_datarootdir}/doc/${PROJECT_NAME}
Name: ${PROJECT_NAME}
Description:
Version: ${PROJECT_VERSION}
Requires: ${PACKAGE_REQUIREMENTS}
Libs:
Cflags: -I${install_pkg_include_dir} ${${PROJECT_NAME}_CXXFLAGS}
#
# Copyright 2010 CNRS
#
# Author: Florent Lamiraux
#
#
# Python
#
INCLUDE(FindPythonLibs)
IF (NOT ${PYTHONLIBS_FOUND} STREQUAL TRUE)
MESSAGE(FATAL_ERROR "Python has not been found.")
ENDIF (NOT ${PYTHONLIBS_FOUND} STREQUAL TRUE)
INCLUDE(FindPythonInterp)
IF (NOT ${PYTHONINTERP_FOUND} STREQUAL TRUE)
MESSAGE(FATAL_ERROR "Python executable has not been found.")
ENDIF (NOT ${PYTHONINTERP_FOUND} STREQUAL TRUE)
# provide path to library libdynamic-graph.so
LINK_DIRECTORIES(${DYNAMIC_GRAPH_LIBRARY_DIRS})
#
#
# Python bindings
#
#
SET(PYTHON_MODULE wrap)
ADD_LIBRARY(${PYTHON_MODULE}
MODULE
dynamic-graph-py.cc)
# Remove prefix lib
SET_TARGET_PROPERTIES(${PYTHON_MODULE}
PROPERTIES PREFIX "")
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
#
# Installation
#
EXEC_PROGRAM(${PYTHON_EXECUTABLE} ARGS "-c \"from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='')\""
OUTPUT_VARIABLE PYTHON_SITELIB)
MESSAGE(STATUS "PYTHON_SITELIB=${PYTHON_SITELIB}")
SET(PYTHON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/dynamic_graph)
INSTALL(TARGETS ${PYTHON_MODULE}
DESTINATION
${PYTHON_INSTALL_DIR})
SET (PYTHON_SOURCES
dynamic_graph/__init__.py
)
SET (PYTHON_SOURCES_FULLPATH "")
FOREACH (SOURCE ${PYTHON_SOURCES})
SET(PYTHON_SOURCES_FULLPATH
${PYTHON_SOURCES_FULLPATH}
${CMAKE_SOURCE_DIR}/src/${SOURCE}
)
ENDFOREACH (SOURCE)
INSTALL(FILES ${PYTHON_SOURCES_FULLPATH}
DESTINATION ${PYTHON_INSTALL_DIR})
/*
* Copyright 2010 (C) CNRS
* Author: Florent Lamiraux
*/
#include <Python.h>
#include <iostream>
#include <string>
static PyObject*
loadPlugin(PyObject* self, PyObject* args)
{
char* plugin = NULL;
char* path = NULL;
if (!PyArg_ParseTuple(args,"ss", &plugin, &path))
return NULL;
std::cout << "loadPlugin " << std::string(plugin) << " "
<< std::string(path) << std::endl;
return Py_BuildValue("");
}
static PyObject*
plug(PyObject* self, PyObject* args)
{
char* out = NULL;
char* in = NULL;
if (!PyArg_ParseTuple(args,"ss", &out, &in))
return NULL;
std::cout << "plug " << std::string(out) << " "
<< std::string(in) << std::endl;
return Py_BuildValue("");
}
/**
\brief List of python functions
*/
static PyMethodDef sotTutorialMethods[] = {
{"loadPlugin", loadPlugin, METH_VARARGS,
"load a plugin into the dynamic-graph"},
{"plug", plug, METH_VARARGS,
"plug an output signal into an input signal"},
{NULL, NULL, 0, NULL} /* Sentinel */
};
PyMODINIT_FUNC
initwrap(void)
{
PyObject *m;
m = Py_InitModule("wrap", sotTutorialMethods);
if (m == NULL)
return;
}
"""
Copyright (c) 2010 CNRS
Author: Florent Lamiraux
"""
import wrap
#
# Copyright
#
SET(EXECUTABLE_NAME test${PROJECT_NAME})
ADD_DEFINITIONS(-DDEBUG=2)
# provide path to library libdynamic-graph.so
LINK_DIRECTORIES(${DYNAMIC_GRAPH_LIBRARY_DIRS})
ADD_EXECUTABLE(${EXECUTABLE_NAME}
main.cc
dynamic-graph-python-test.cc)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
LINK_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/src)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
dynamic-graph-python)
# Add dynamic-graph compilation flags and link to library libdynamic-graph.so
ADD_DEFINITIONS(${DYNAMIC_GRAPH_CFLAGS})
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${DYNAMIC_GRAPH_LIBRARIES})
/*
* Copyright
*/
#include <iostream>
#include "dynamic-graph-python-test.hh"
GraphTest::GraphTest()
{
std::cout << "Constructor of unitTesting object of class Graph." << std::endl;
}
/*
* Copyright
*/
#ifndef DYNAMIC_GRAPH_PYTHON_HH
#define DYNAMIC_GRAPH_PYTHON_HH
#include "dynamic-graph-python/dynamic-graph-python.hh"
/**
\brief UnitTesting class of class Graph
*/
class GraphTest
{
public:
/**
\brief Constructor
*/
GraphTest();
private:
dynamic::Graph graph_;
};
#endif
/*
* Copyright
*/
#include "dynamic-graph-python-test.hh"
int main (int argc, char** argv)
{
GraphTest testGraph();
}
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