Commit 696ae389 authored by lealv's avatar lealv
Browse files

UPDATED : remove wizard-old from camitk repository

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1967 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 871b6ff0
This diff is collapsed.
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2014 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef ACTIONGENERATOR_H
#define ACTIONGENERATOR_H
#if defined(_WIN32) && !defined(__MINGW32__) // MSVC only
#pragma warning( disable : 4290 )
#endif // MSVC only
// include from STD
#include <set>
// includes from Qt
#include <QMap>
#include <QDir>
#include <QPair>
#include <QString>
#include <QFileInfo>
#include <QTextStream>
// coreschema
#include <Parameters.hxx>
#include <Action.hxx>
class ActionGenerator {
public :
static bool generateActionFiles(QString xmlFileName, QString devDirectoryName, QString * elementClassName = NULL);
protected:
ActionGenerator(QString xmlFilename, QString devDirectoryName);
virtual void setXmlFileName(QString xmlFileName) throw (QString);
virtual void setDevDirectoryName(QString devDirectoryName) throw (QString);
virtual void createElement() throw (QString);
virtual void generateActionFiles() throw (QString);
virtual void writeHFile() throw (QString);
virtual void writeCFile() throw (QString);
virtual void writeImplementationFile() throw (QString);
/** XML DOM Element create by CodeSynthesis
* This action contains all of the informations of the xml file
*/
std::auto_ptr<coreschema::Action> theAction;
/// Where to find the XML description of the Action
QFileInfo xmlFileName;
/// Where to store the produced files
QDir devDirectoryName;
/// Name of the created Action class
/// redundant information already contained in theAction, for practicle purpose.
QString className;
/// Does the action have parameters stored as properties ?
bool hasParameters;
/** List containing all parameters of the action stored as properties of theAction
* For practical reasons, this map contains for each parameter:
* - key: the name of the parameter
* - value: a QPair of element:
* - first: the type of the parameter
* - second: the default value of the parameter
* (if non exists in the XML file, a default one is given)
*/
QMap<QString, QPair<QString, QString> > parameters;
/// Set of additional files to include
std::set<QString> additionalIncludes;
private:
bool isItkFilter;
};
#endif
# TODO NICOLAS Update the Qt XML dependencies
# use the application extension macro
camitk_application( DISABLED
NEEDS_XSD
NEEDS_XERCESC
NEEDS_QT_MODULES
NEEDS_CEP_LIBRARIES coreschema
ADDITIONAL_SOURCES CommandLineOptions.cxx CommandLineOptions.hxx CommandLineOptions.ixx
CEP_NAME SDK
DESCRIPTION "The wizard allows you to simply create extensions to CamiTK"
)
if(APPLICATION_WIZARD)
# build-time FindCamiTK.cmake install
# check directory
if (NOT EXISTS ${CAMITK_BUILD_CMAKE_DIR})
add_custom_command( TARGET application-wizard
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_BUILD_CMAKE_DIR}
COMMENT "Creating build-time group include dir ${CAMITK_BUILD_CMAKE_DIR}"
VERBATIM
)
endif()
# copy after build, only if there was a change
add_custom_command( TARGET application-wizard
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../cmake/modules/FindCamiTK.cmake ${CAMITK_BUILD_CMAKE_DIR}/
COMMENT "Installing build-time FindCamiTK.cmake"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
endif()
# Recursively update the shiboken path variable containing the CamiTK SDK tree structure
set(SHIBOKEN_CAMITK_SDK_PATH ${SHIBOKEN_CAMITK_SDK_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
\ No newline at end of file
// Code Synthesis CLI configuration
// see http://codesynthesis.com/projects/cli
//
// cli must be run everytime this file is modified:
// cli CommandLineOptions.cli
//
// to update the manpage:
// cli --stdout --man-prologue manpage-prologue.1.in --man-epilogue manpage-epilogue.1.in --generate-man CommandLineOptions.cli > camitk-wizard.1.in
include <string>;
class options {
bool --help | -h {"Print usage information and exit."};
bool --version | -v {"Print CamiTK version message and exit"};
std::string --file | -f {"<file>",
"input CamiTK CoreSchema XML document describing the extension to generate (need cepDir option)"};
bool --skel | -s {"Generate an empty CEP (needs cepDir option)"};
std::string --cepDir | -c {"<dir>",
"CamiTK Extenion Project directory to use"};
};
\ No newline at end of file
// This code was generated by CLI, a command line interface
// compiler for C++.
//
#include "CommandLineOptions.hxx"
#include <map>
#include <set>
#include <string>
#include <vector>
#include <ostream>
#include <sstream>
namespace cli
{
// unknown_option
//
unknown_option::
~unknown_option () throw ()
{
}
void unknown_option::
print (std::ostream& os) const
{
os << "unknown option '" << option () << "'";
}
const char* unknown_option::
what () const throw ()
{
return "unknown option";
}
// unknown_argument
//
unknown_argument::
~unknown_argument () throw ()
{
}
void unknown_argument::
print (std::ostream& os) const
{
os << "unknown argument '" << argument () << "'";
}
const char* unknown_argument::
what () const throw ()
{
return "unknown argument";
}
// missing_value
//
missing_value::
~missing_value () throw ()
{
}
void missing_value::
print (std::ostream& os) const
{
os << "missing value for option '" << option () << "'";
}
const char* missing_value::
what () const throw ()
{
return "missing option value";
}
// invalid_value
//
invalid_value::
~invalid_value () throw ()
{
}
void invalid_value::
print (std::ostream& os) const
{
os << "invalid value '" << value () << "' for option '"
<< option () << "'";
}
const char* invalid_value::
what () const throw ()
{
return "invalid option value";
}
// eos_reached
//
void eos_reached::
print (std::ostream& os) const
{
os << what ();
}
const char* eos_reached::
what () const throw ()
{
return "end of argument stream reached";
}
// scanner
//
scanner::
~scanner ()
{
}
// argv_scanner
//
bool argv_scanner::
more ()
{
return i_ < argc_;
}
const char* argv_scanner::
peek ()
{
if (i_ < argc_)
return argv_[i_];
else
throw eos_reached ();
}
const char* argv_scanner::
next ()
{
if (i_ < argc_)
{
const char* r (argv_[i_]);
if (erase_)
{
for (int i (i_ + 1); i < argc_; ++i)
argv_[i - 1] = argv_[i];
--argc_;
argv_[argc_] = 0;
}
else
++i_;
return r;
}
else
throw eos_reached ();
}
void argv_scanner::
skip ()
{
if (i_ < argc_)
++i_;
else
throw eos_reached ();
}
template <typename X>
struct parser
{
static void
parse (X& x, scanner& s)
{
const char* o (s.next ());
if (s.more ())
{
const char* v (s.next ());
std::istringstream is (v);
if (!(is >> x && is.eof ()))
throw invalid_value (o, v);
}
else
throw missing_value (o);
}
};
template <>
struct parser<bool>
{
static void
parse (bool& x, scanner& s)
{
s.next ();
x = true;
}
};
template <>
struct parser<std::string>
{
static void
parse (std::string& x, scanner& s)
{
const char* o (s.next ());
if (s.more ())
x = s.next ();
else
throw missing_value (o);
}
};
template <typename X>
struct parser<std::vector<X> >
{
static void
parse (std::vector<X>& c, scanner& s)
{
X x;
parser<X>::parse (x, s);
c.push_back (x);
}
};
template <typename X>
struct parser<std::set<X> >
{
static void
parse (std::set<X>& c, scanner& s)
{
X x;
parser<X>::parse (x, s);
c.insert (x);
}
};
template <typename K, typename V>
struct parser<std::map<K, V> >
{
static void
parse (std::map<K, V>& m, scanner& s)
{
const char* o (s.next ());
if (s.more ())
{
std::string ov (s.next ());
std::string::size_type p = ov.find ('=');
if (p == std::string::npos)
{
K k = K ();
if (!ov.empty ())
{
std::istringstream ks (ov);
if (!(ks >> k && ks.eof ()))
throw invalid_value (o, ov);
}
m[k] = V ();
}
else
{
K k = K ();
V v = V ();
std::string kstr (ov, 0, p);
std::string vstr (ov, p + 1);
if (!kstr.empty ())
{
std::istringstream ks (kstr);
if (!(ks >> k && ks.eof ()))
throw invalid_value (o, ov);
}
if (!vstr.empty ())
{
std::istringstream vs (vstr);
if (!(vs >> v && vs.eof ()))
throw invalid_value (o, ov);
}
m[k] = v;
}
}
else
throw missing_value (o);
}
};
template <typename X, typename T, T X::*P>
void
thunk (X& x, scanner& s)
{
parser<T>::parse (x.*P, s);
}
}
#include <map>
#include <cstring>
// options
//
options::
options (int& argc,
char** argv,
bool erase,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
: help_ (),
version_ (),
file_ (),
skel_ (),
cepDir_ ()
{
::cli::argv_scanner s (argc, argv, erase);
_parse (s, opt, arg);
}
options::
options (int start,
int& argc,
char** argv,
bool erase,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
: help_ (),
version_ (),
file_ (),
skel_ (),
cepDir_ ()
{
::cli::argv_scanner s (start, argc, argv, erase);
_parse (s, opt, arg);
}
options::
options (int& argc,
char** argv,
int& end,
bool erase,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
: help_ (),
version_ (),
file_ (),
skel_ (),
cepDir_ ()
{
::cli::argv_scanner s (argc, argv, erase);
_parse (s, opt, arg);
end = s.end ();
}
options::
options (int start,
int& argc,
char** argv,
int& end,
bool erase,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
: help_ (),
version_ (),
file_ (),
skel_ (),
cepDir_ ()
{
::cli::argv_scanner s (start, argc, argv, erase);
_parse (s, opt, arg);
end = s.end ();
}
options::
options (::cli::scanner& s,
::cli::unknown_mode opt,
::cli::unknown_mode arg)
: help_ (),
version_ (),
file_ (),
skel_ (),
cepDir_ ()
{
_parse (s, opt, arg);
}
void options::
print_usage (::std::ostream& os)
{
os << "--help|-h Print usage information and exit." << ::std::endl;
os << "--version|-v Print CamiTK version message and exit" << ::std::endl;
os << "--file|-f <file> input CamiTK CoreSchema XML document describing the extension" << ::std::endl
<< " to generate (need cepDir option)" << ::std::endl;
os << "--skel|-s Generate an empty CEP (needs cepDir option)" << ::std::endl;
os << "--cepDir|-c <dir> CamiTK Extenion Project directory to use" << ::std::endl;
}
typedef
std::map<std::string, void (*) (options&, ::cli::scanner&)>
_cli_options_map;
static _cli_options_map _cli_options_map_;
struct _cli_options_map_init
{
_cli_options_map_init ()
{
_cli_options_map_["--help"] =
&::cli::thunk< options, bool, &options::help_ >;
_cli_options_map_["-h"] =
&::cli::thunk< options, bool, &options::help_ >;
_cli_options_map_["--version"] =
&::cli::thunk< options, bool, &options::version_ >;
_cli_options_map_["-v"] =
&::cli::thunk< options, bool, &options::version_ >;
_cli_options_map_["--file"] =
&::cli::thunk< options, std::string, &options::file_ >;
_cli_options_map_["-f"] =
&::cli::thunk< options, std::string, &options::file_ >;
_cli_options_map_["--skel"] =
&::cli::thunk< options, bool, &options::skel_ >;
_cli_options_map_["-s"] =
&::cli::thunk< options, bool, &options::skel_ >;
_cli_options_map_["--cepDir"] =
&::cli::thunk< options, std::string, &options::cepDir_ >;
_cli_options_map_["-c"] =
&::cli::thunk< options, std::string, &options::cepDir_ >;
}
} _cli_options_map_init_;
void options::
_parse (::cli::scanner& s,
::cli::unknown_mode opt_mode,
::cli::unknown_mode arg_mode)
{
bool opt = true;