Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 7c318b71 authored by Florian Vichot's avatar Florian Vichot
Browse files

Subtree merged IPF

parents 7f532d20 afee44e8
No related branches found
No related tags found
No related merge requests found
Showing with 865 additions and 0 deletions
project(IPF)
cmake_minimum_required(VERSION 2.6)
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
# warnings. Copied from ITK CMakeLists.
IF(WIN32)
IF(NOT BORLAND)
IF(NOT CYGWIN)
IF(NOT MINGW)
ADD_DEFINITIONS(
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
-D_CRT_IS_WCTYPE_NO_DEPRECATE
-D_CRT_MANAGED_FP_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
-D_CRT_VCCLRIT_NO_DEPRECATE
-D_SCL_SECURE_NO_DEPRECATE
)
ENDIF(NOT MINGW)
ENDIF(NOT CYGWIN)
ENDIF(NOT BORLAND)
ENDIF(WIN32)
#
# Define EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH
#
SET(EXECUTABLE_OUTPUT_PATH
${CMAKE_BINARY_DIR}/bin
CACHE PATH "Single output directory for building all executables."
)
SET(LIBRARY_OUTPUT_PATH
${CMAKE_BINARY_DIR}/lib
CACHE PATH "Single output directory for building all libraries."
)
# -------------------------------------------------------------------------------------
# Setup installation settings
# -------------------------------------------------------------------------------------
set(${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT 0 CACHE BOOL "Do not install development")
set(${PROJECT_NAME}_INSTALL_NO_RUNTIME 0 CACHE BOOL "Do not install runtime")
set(${PROJECT_NAME}_INSTALL_NO_LIBRARIES)
if(${PROJECT_NAME}_BUILD_SHARED_LIBS)
if(${PROJECT_NAME}_INSTALL_NO_RUNTIME AND ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
set(${PROJECT_NAME}_INSTALL_NO_LIBRARIES 1)
endif(${PROJECT_NAME}_INSTALL_NO_RUNTIME AND ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
else(${PROJECT_NAME}_BUILD_SHARED_LIBS)
if(${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
set(${PROJECT_NAME}_INSTALL_NO_LIBRARIES 1)
else(${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
set(${PROJECT_NAME}_INSTALL_NO_LIBRARIES 0)
endif(${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
endif(${PROJECT_NAME}_BUILD_SHARED_LIBS)
mark_as_advanced(${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT
${PROJECT_NAME}_INSTALL_NO_RUNTIME
)
set(IPF_REQUIRED_C_FLAGS)
set(IPF_REQUIRED_CXX_FLAGS)
include(${IPF_SOURCE_DIR}/ipfIncludeDirectories.cmake)
include_directories(
${IPF_INCLUDE_DIRS_SOURCE_TREE}
)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
# set IPF_DIR so it can be used by subprojects
SET(IPF_DIR "${PROJECT_BINARY_DIR}" CACHE INTERNAL "IPF_DIR variable to be used by subprojects")
set(LIBRARY_STYLE)
if (ITK_BUILD_SHARED)
set (LIBRARY_STYLE "SHARED")
else (ITK_BUILD_SHARED)
set (LIBRARY_STYLE "STATIC")
endif (ITK_BUILD_SHARED)
add_library(ITKProgramFactory ${LIBRARY_STYLE}
itkCommandObjectBase.cxx
itkCommandObjectFactory.cxx
)
target_link_libraries(ITKProgramFactory
${ITK_LIBRARIES}
)
add_executable(programFactoryTest
itkHelloWorldCommand.cxx
itkHelloWorldCommandFactory.cxx
programFactoryTest.cxx
)
target_link_libraries(programFactoryTest
ITKProgramFactory
)
if (NOT ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
file(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
file(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx")
install(FILES ${__files1} ${__files2}
DESTINATION include
COMPONENT Development
)
endif (NOT ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
if (NOT ${PROJECT_NAME}_INSTALL_NO_LIBRARIES)
install(TARGETS ITKProgramFactory
DESTINATION lib
COMPONENT RuntimeLibraries
)
endif (NOT ${PROJECT_NAME}_INSTALL_NO_LIBRARIES)
# if (NOT ${PROJECT_NAME}_INSTALL_NO_RUNTIME)
# install(TARGETS programFactoryTest
# DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
# COMPONENT RuntimeLibraries
# )
# endif (NOT ${PROJECT_NAME}_INSTALL_NO_RUNTIME)
#-----------------------------------------------------------------------------
# Help other projects use IPF.
CONFIGURE_FILE(${IPF_SOURCE_DIR}/UseIPF.cmake.in
${IPF_BINARY_DIR}/UseIPF.cmake COPYONLY IMMEDIATE)
# Save the compiler settings so another project can import them.
SET(IPF_BUILD_SETTINGS_FILE ${IPF_BINARY_DIR}/IPFBuildSettings.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake)
CMAKE_EXPORT_BUILD_SETTINGS(${IPF_BUILD_SETTINGS_FILE})
# Create the IPFConfig.cmake file containing the IPF configuration.
INCLUDE (${IPF_SOURCE_DIR}/ipfGenerateIPFConfig.cmake)
if (NOT ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
INSTALL(FILES
${IPF_BINARY_DIR}/IPFBuildSettings.cmake
${IPF_BINARY_DIR}/UseIPF.cmake
${IPF_BINARY_DIR}/Utilities/IPFConfig.cmake
DESTINATION lib
)
endif (NOT ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
# Copyright (c) 2010, INRIA Saclay Île-de-France, Parietal Research Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list
# * of conditions and the following disclaimer in the documentation and/or other
# * materials provided with the distribution.
# * Neither the name of the INRIA Saclay Île-de-France, Parietal Research Team nor the
# names of its contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#-----------------------------------------------------------------------------
#
# IPFConfig.cmake - IPF CMake configuration file for external projects.
#
# This file is configured by IPF and used by the UseIPF.cmake module
# to load IPF's settings for an external project.
# The IPF source tree.
SET(IPF_SOURCE_DIR "@IPF_SOURCE_DIR@")
# The IPF include file directories.
SET(IPF_INCLUDE_DIRS "@IPF_INCLUDE_DIRS_CONFIG@")
# The IPF library directories.
SET(IPF_LIBRARY_DIRS "@IPF_LIBRARY_DIRS_CONFIG@")
# The C and C++ flags added by IPF to the cmake-configured flags.
SET(IPF_REQUIRED_C_FLAGS "@IPF_REQUIRED_C_FLAGS@")
SET(IPF_REQUIRED_CXX_FLAGS "@IPF_REQUIRED_CXX_FLAGS@")
# The location of the UseIPF.cmake file.
SET(IPF_USE_FILE "@IPF_USE_FILE@")
# The build settings file.
SET(IPF_BUILD_SETTINGS_FILE "@IPF_BUILD_SETTINGS_FILE@")
# Some libraries variables useful to keep.
SET(ITK_DIR "@ITK_DIR@")
#
# This file sets up include directories, link directories, and
# compiler settings for a project to use IPF. It should not be
# included directly, but rather through the IPF_USE_FILE setting
# obtained from IPFConfig.cmake.
#
# Load the compiler settings used for IPF.
IF(IPF_BUILD_SETTINGS_FILE)
INCLUDE(${CMAKE_ROOT}/Modules/CMakeImportBuildSettings.cmake)
CMAKE_IMPORT_BUILD_SETTINGS(${IPF_BUILD_SETTINGS_FILE})
ENDIF(IPF_BUILD_SETTINGS_FILE)
# Add compiler flags needed to use IPF.
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${IPF_REQUIRED_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${IPF_REQUIRED_CXX_FLAGS}")
# Add include directories needed to use IPF.
INCLUDE_DIRECTORIES(${IPF_INCLUDE_DIRS})
# Add link directories needed to use IPF.
LINK_DIRECTORIES(${IPF_LIBRARY_DIRS})
#-----------------------------------------------------------------------------
# Settings specific to the build tree.
# The install-only section is empty for the build tree.
SET(IPF_CONFIG_INSTALL_ONLY)
# The "use" file.
SET(IPF_USE_FILE ${IPF_BINARY_DIR}/UseIPF.cmake)
# The build settings file.
SET(IPF_BUILD_SETTINGS_FILE ${IPF_BINARY_DIR}/IPFBuildSettings.cmake)
# Library directory.
SET(IPF_LIBRARY_DIRS_CONFIG ${LIBRARY_OUTPUT_PATH})
# Runtime library directory.
SET(IPF_RUNTIME_LIBRARY_DIRS_CONFIG ${LIBRARY_OUTPUT_PATH})
# Determine the include directories needed.
SET(IPF_INCLUDE_DIRS_CONFIG
${IPF_INCLUDE_DIRS_BUILD_TREE}
${IPF_INCLUDE_DIRS_SYSTEM}
)
#-----------------------------------------------------------------------------
# Configure IPFConfig.cmake for the build tree.
CONFIGURE_FILE(${IPF_SOURCE_DIR}/IPFConfig.cmake.in
${IPF_BINARY_DIR}/IPFConfig.cmake @ONLY IMMEDIATE)
#-----------------------------------------------------------------------------
# Settings specific to the install tree.
# The "use" file.
SET(IPF_USE_FILE ${CMAKE_INSTALL_PREFIX}/lib/UseIPF.cmake)
# The build settings file.
SET(IPF_BUILD_SETTINGS_FILE ${CMAKE_INSTALL_PREFIX}/lib/IPFBuildSettings.cmake)
# Include directories.
SET(IPF_INCLUDE_DIRS_CONFIG
${CMAKE_INSTALL_PREFIX}/include
${IPF_INCLUDE_DIRS_SYSTEM}
)
# Link directories.
IF(CYGWIN AND BUILD_SHARED_LIBS)
# In Cygwin programs directly link to the .dll files.
SET(IPF_LIBRARY_DIRS_CONFIG ${CMAKE_INSTALL_PREFIX}/bin/)
ELSE(CYGWIN AND BUILD_SHARED_LIBS)
SET(IPF_LIBRARY_DIRS_CONFIG ${CMAKE_INSTALL_PREFIX}/lib/)
ENDIF(CYGWIN AND BUILD_SHARED_LIBS)
# Runtime directories.
IF(WIN32)
SET(IPF_RUNTIME_LIBRARY_DIRS_CONFIG ${CMAKE_INSTALL_PREFIX}/bin/)
ELSE(WIN32)
SET(IPF_RUNTIME_LIBRARY_DIRS_CONFIG ${CMAKE_INSTALL_PREFIX}/lib/)
ENDIF(WIN32)
#-----------------------------------------------------------------------------
# Configure IPFConfig.cmake for the install tree.
CONFIGURE_FILE(${IPF_SOURCE_DIR}/IPFConfig.cmake.in
${IPF_BINARY_DIR}/Utilities/IPFConfig.cmake @ONLY IMMEDIATE)
#-----------------------------------------------------------------------------
# Include directories for other projects installed on the system.
SET(IPF_INCLUDE_DIRS_SYSTEM "")
# These directories are always needed.
SET(IPF_INCLUDE_DIRS_BUILD_TREE
${IPF_SOURCE_DIR}
)
#-----------------------------------------------------------------------------
# Include directories from the install tree.
SET(IPF_INSTALL_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/include/")
SET(IPF_INCLUDE_DIRS_INSTALL_TREE
${IPF_INSTALL_INCLUDE_PATH}
)
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkCommandObjectBase.h"
namespace itk
{
CommandObjectBase::CommandObjectBase()
{}
CommandObjectBase::~CommandObjectBase()
{}
const char *CommandObjectBase::GetShortDescription (void) const
{
return m_ShortDescription.c_str();
}
const char *CommandObjectBase::GetLongDescription (void) const
{
return m_LongDescription.c_str();
}
}
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _itk_CommandObjectBase_h_
#define _itk_CommandObjectBase_h_
#include "itkProcessObject.h"
/**
*/
namespace itk
{
class CommandObjectBase : public ProcessObject
{
public:
typedef CommandObjectBase Self;
typedef ProcessObject Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
itkTypeMacro (CommandObjectBase, ProcessObject);
virtual const char *GetCommandName (void) = 0;
virtual const char *GetShortDescription (void) const;
virtual const char *GetLongDescription (void) const;
virtual int Execute (int nargs, const char *args[]) = 0;
protected:
CommandObjectBase();
~CommandObjectBase();
std::string m_ShortDescription;
std::string m_LongDescription;
private:
CommandObjectBase (const Self&);
void operator=(const Self&);
};
} // end of namespace
#endif
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkCommandObjectFactory.h"
#include "itkMutexLock.h"
#include "itkMutexLockHolder.h"
#include <algorithm>
#include <string.h>
namespace itk
{
CommandObjectBase::Pointer
CommandObjectFactory::CreateCommandObject(const char* name)
{
std::list<CommandObjectBase::Pointer> possibleCommandObject;
std::list<LightObject::Pointer> allobjects =
ObjectFactoryBase::CreateAllInstance("itkCommandObjectBase");
for(std::list<LightObject::Pointer>::iterator i = allobjects.begin();
i != allobjects.end(); ++i)
{
CommandObjectBase* command = dynamic_cast<CommandObjectBase*>(i->GetPointer());
if(command)
{
possibleCommandObject.push_back(command);
}
else
{
std::cerr << "Error CommandObject factory did not return an CommandObjectBase: "
<< (*i)->GetNameOfClass()
<< std::endl;
}
}
for(std::list<CommandObjectBase::Pointer>::iterator k = possibleCommandObject.begin();
k != possibleCommandObject.end(); ++k)
{
if( strcmp((*k)->GetCommandName(), name)==0 )
return *k;
}
return 0;
}
void CommandObjectFactory::PrintHelp(std::ostream &os, Indent indent)
{
std::list<LightObject::Pointer> allobjects =
ObjectFactoryBase::CreateAllInstance("itkCommandObjectBase");
std::vector<std::string> commandNames;
for(std::list<LightObject::Pointer>::iterator i = allobjects.begin();
i != allobjects.end(); ++i)
{
CommandObjectBase* command = dynamic_cast<CommandObjectBase*>(i->GetPointer());
if(command)
{
commandNames.push_back ( command->GetCommandName() );
}
}
std::sort (commandNames.begin(), commandNames.end());
for (unsigned int i=0; i<commandNames.size(); i++)
{
os << indent << "\t " << commandNames[i] << std::endl;
/*
<< "...";
os << indent << command->GetShortDescription() << "\n";
os << "\n";
*/
}
}
} // end namespace itk
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkCommandObjectFactory_h
#define __itkCommandObjectFactory_h
#include "itkObject.h"
#include "itkCommandObjectBase.h"
namespace itk
{
class CommandObjectFactory : public Object
{
public:
/** Standard class typedefs. */
typedef CommandObjectFactory Self;
typedef Object Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Class Methods used to interface with the registered factories */
/** Run-time type information (and related methods). */
itkTypeMacro(CommandObjectFactory, Object);
/** Convenient typedefs. */
typedef ::itk::CommandObjectBase::Pointer CommandObjectBasePointer;
/** Create the appropriate CommandObject. */
static CommandObjectBasePointer CreateCommandObject(const char* name);
/** Print help messages of all registered commands */
static void PrintHelp(std::ostream &os, Indent indent);
protected:
CommandObjectFactory();
~CommandObjectFactory();
private:
CommandObjectFactory(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
} // end namespace itk
#endif
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkHelloWorldCommand.h"
namespace itk
{
HelloWorldCommand::HelloWorldCommand()
{}
HelloWorldCommand::~HelloWorldCommand()
{}
const char *HelloWorldCommand::GetCommandName()
{
return "HelloWorld";
}
const char *HelloWorldCommand::GetShortDescription() const
{
return "This is a short description";
}
const char *HelloWorldCommand::GetLongDescription() const
{
return "This is a long description";
}
int HelloWorldCommand::Execute (int nargs, const char *args[])
{
std::cout << "Hello World!" << std::endl;
return EXIT_SUCCESS;
}
}
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _itk_HelloWorldCommand_h_
#define _itk_HelloWorldCommand_h_
#include "itkCommandObjectBase.h"
/**
*/
namespace itk
{
class HelloWorldCommand : public CommandObjectBase
{
public:
typedef HelloWorldCommand Self;
typedef CommandObjectBase Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
itkNewMacro (HelloWorldCommand);
itkTypeMacro (HelloWorldCommand, CommandObjectBase);
virtual const char *GetCommandName (void);
virtual const char *GetShortDescription (void) const;
virtual const char *GetLongDescription (void) const;
virtual int Execute (int nargs, const char *args[]);
protected:
HelloWorldCommand();
~HelloWorldCommand();
private:
HelloWorldCommand (const Self&);
void operator=(const Self&);
};
} // end of namespace
#endif
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkHelloWorldCommandFactory.h"
#include "itkCreateObjectFunction.h"
#include "itkHelloWorldCommand.h"
#include "itkVersion.h"
namespace itk
{
HelloWorldCommandFactory::HelloWorldCommandFactory()
{
this->RegisterOverride("itkCommandObjectBase",
"itkHelloWorldCommand",
"Hello World Command",
1,
CreateObjectFunction<HelloWorldCommand>::New());
}
HelloWorldCommandFactory::~HelloWorldCommandFactory()
{
}
const char*
HelloWorldCommandFactory::GetITKSourceVersion(void) const
{
return ITK_SOURCE_VERSION;
}
const char*
HelloWorldCommandFactory::GetDescription(void) const
{
return "Pouet pouet pouet";
}
} // end namespace itk
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _itk_HelloWorldCommandFactory_h_
#define _itk_HelloWorldCommandFactory_h_
#include "itkObjectFactoryBase.h"
namespace itk
{
class HelloWorldCommandFactory : public ObjectFactoryBase
{
public:
typedef HelloWorldCommandFactory Self;
typedef ObjectFactoryBase Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Class methods used to interface with the registered factories. */
virtual const char* GetITKSourceVersion(void) const;
virtual const char* GetDescription(void) const;
/** Method for class instantiation. */
itkFactorylessNewMacro(Self);
static HelloWorldCommandFactory* FactoryNew() { return new HelloWorldCommandFactory;}
/** Run-time type information (and related methods). */
itkTypeMacro(HelloWorldCommandFactory, ObjectFactoryBase);
/** Register one factory of this type */
static void RegisterOneFactory(void)
{
HelloWorldCommandFactory::Pointer HWFactory = HelloWorldCommandFactory::New();
ObjectFactoryBase::RegisterFactory( HWFactory );
}
protected:
HelloWorldCommandFactory();
~HelloWorldCommandFactory();
private:
HelloWorldCommandFactory(const Self&);
void operator=(const Self&);
};
}
#endif
/*=========================================================================
Program: ITK Program Factory
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) INRIA Saclay Île-de-France, Parietal Research Team. All rights reserved.
See CodeCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkHelloWorldCommandFactory.h"
#include "itkCommandObjectFactory.h"
int main (int narg, char *args[])
{
itk::HelloWorldCommandFactory::RegisterOneFactory();
if (narg<2) {
itk::CommandObjectFactory::PrintHelp( std::cout, 0 );
return EXIT_FAILURE;
}
const char *programName = args[1];
itk::CommandObjectBase::Pointer prog = itk::CommandObjectFactory::CreateCommandObject( programName );
int returnValue = EXIT_SUCCESS;
if( !prog.IsNull() )
{
std::cout << prog->GetCommandName() << std::endl;
std::cout << prog->GetShortDescription() << std::endl;
std::cout << prog->GetLongDescription() << std::endl;
std::cout << "Executing...\n";
returnValue = prog->Execute(narg, (const char**)args);
std::cout << "Done." << std::endl;
}
else {
std::cout << "Prog is null" << std::endl;
}
return returnValue;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment