* Firstly, we need to create a directory for our module under modules directory. Copy folder //dummy// and name it //imagemagick//
* We can use the module with name DummyModule, but for any real module, we probably want to give some beeter name. So the next few steps are optional, but recommended:
* Rename DummyModule.cpp to ImageMagickSource.cpp and DummyModule.h to ImageMagickSource.h
* Change DummyModule.h in #include in ImageMagickSource.cpp to ImageMagickSource.h
* Rename the class: change all occurences of DummyModule class to ImageMagickSource
* We're gonna use ImageMagick library, specifically it's C++ bindings called **Magick++**. CMake know about this packafe, so it's easy to add test for in. We add following line into CMakeLists.txt in modules directory:
find_package(ImageMagick COMPONENTS Magick++)
* If we found ImageMagick, we can tell cmake to compile our module. So we add subdirectory imagemagic, if the test was successfull:
IF(${ImageMagick_Magick++_FOUND})
add_subdirectory(imagemagick)
ENDIF()
* Now we have to edit CMakeLists.txt in imagemagick directory: change SET(MODULE dummy) to SET(MODULE imagemagick_source) and filenames in SET(SRC.... to ImageMagickSource.*
* And lastly, we add the library to CMakeLists.txt in imagemagick directory: add following line for imagemagick includes:
include_directories(${ImageMagick_Magick++_INCLUDE_DIR})
and change linking to this:
target_link_libraries(${MODULE} ${LIBNAME} ${ImageMagick_Magick++_LIBRARY})
* Now the module should compile under new name and link with libMagick++.so
* So we can finally move to the code. Let's change the header file like this:
#ifndef DUMMYMODULE_H_
#define DUMMYMODULE_H_
#include "yuri/io/BasicIOThread.h"
namespace yuri {
namespace imagemagick_module {
using yuri::log::Log;
using yuri::config::Parameter;
using yuri::config::Parameters;
using yuri::io::pThreadBase;
class ImageMagickSource: public yuri::io::BasicIOThread
{
public:
IO_THREAD_GENERATOR_DECLARATION
static shared_ptr configure();
virtual ~ImageMagickSource();
private:
ImageMagickSource(Log &log_,pThreadBase parent,Parameters ¶meters);
virtual bool step();
virtual bool set_param(Parameter& param);
};
} /* namespace dummy_module */
} /* namespace yuri */
The only difference between this and the DummyModule.h is (except for the name) that we removed the attribute **dummy_name**.
Not for the cpp file:
#include "ImageMagickSource.h"
#include "yuri/config/RegisteredClass.h"
#include "Magick++.h"
#include