2 Commits

61 changed files with 830 additions and 5392 deletions

View File

@@ -82,7 +82,7 @@ ENDMACRO(uLib_add_target)
# TESTS and LIBRARIES must be defined # TESTS and LIBRARIES must be defined
macro(uLib_add_tests name) macro(uLib_add_tests name)
foreach(tn ${TESTS}) foreach(tn ${TESTS})
add_executable(${tn} EXCLUDE_FROM_ALL ${tn}.cpp) add_executable(${tn} ${tn}.cpp)
add_test(NAME ${tn} COMMAND ${tn}) add_test(NAME ${tn} COMMAND ${tn})
target_link_libraries(${tn} ${LIBRARIES}) target_link_libraries(${tn} ${LIBRARIES})

View File

@@ -76,6 +76,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_WARNING_OPTION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -UULIB_SERIALIZATION_ON -Wno-cpp") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -UULIB_SERIALIZATION_ON -Wno-cpp")
# CTEST framework # CTEST framework
include(CTest)
enable_testing() enable_testing()
@@ -85,7 +86,7 @@ set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON) set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF) set(Boost_USE_STATIC_RUNTIME OFF)
message(STATUS "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}") message(STATUS "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}")
find_package(Boost 1.45.0 COMPONENTS program_options REQUIRED) find_package(Boost 1.45.0 COMPONENTS program_options serialization unit_test_framework REQUIRED)
include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS})
find_package(Eigen3 CONFIG REQUIRED) find_package(Eigen3 CONFIG REQUIRED)

View File

@@ -23,14 +23,12 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#ifndef U_CORE_ARCHIVES_H #ifndef U_CORE_ARCHIVES_H
#define U_CORE_ARCHIVES_H #define U_CORE_ARCHIVES_H
#include <boost/archive/detail/basic_pointer_iserializer.hpp> #include <boost/archive/detail/basic_pointer_iserializer.hpp>
#include <boost/archive/detail/basic_pointer_oserializer.hpp> #include <boost/archive/detail/basic_pointer_oserializer.hpp>
#include <iostream>
#include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_oarchive.hpp>
@@ -40,25 +38,20 @@
#include <boost/archive/detail/register_archive.hpp> #include <boost/archive/detail/register_archive.hpp>
#include <boost/archive/polymorphic_iarchive.hpp>
#include <boost/archive/polymorphic_oarchive.hpp>
#include <boost/archive/detail/polymorphic_iarchive_route.hpp> #include <boost/archive/detail/polymorphic_iarchive_route.hpp>
#include <boost/archive/detail/polymorphic_oarchive_route.hpp> #include <boost/archive/detail/polymorphic_oarchive_route.hpp>
#include <boost/archive/polymorphic_iarchive.hpp>
#include <boost/archive/polymorphic_oarchive.hpp>
#include <boost/archive/polymorphic_text_oarchive.hpp> #include <boost/archive/polymorphic_text_oarchive.hpp>
#include "StringReader.h" #include "StringReader.h"
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// FWD DECLARATIONS OF ARCHIVES // // FWD DECLARATIONS OF ARCHIVES //
namespace uLib { namespace uLib {
namespace Archive { namespace Archive {
@@ -68,40 +61,36 @@ class text_iarchive;
class text_oarchive; class text_oarchive;
class log_archive; class log_archive;
} // namespace Archive
} } // namespace uLib
}
namespace boost { namespace boost {
namespace archive { namespace archive {
namespace detail { namespace detail {
template<class ArchiveImplementation> class polymorphic_oarchive_route; template <class ArchiveImplementation> class polymorphic_oarchive_route;
template<class ArchiveImplementation> class polymorphic_iarchive_route; template <class ArchiveImplementation> class polymorphic_iarchive_route;
} } // namespace detail
} } // namespace archive
} } // namespace boost
namespace boost { namespace boost {
namespace serialization { namespace serialization {
template <typename T> struct hrp; template <typename T> struct hrp;
} }
} } // namespace boost
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// ARCHIVES REGISTRATION // // ARCHIVES REGISTRATION //
namespace uLib { namespace uLib {
namespace Archive { namespace Archive {
namespace detail { namespace detail {
struct adl_tag {}; struct adl_tag {};
} } // namespace detail
} } // namespace Archive
} } // namespace uLib
namespace boost { namespace boost {
namespace archive { namespace archive {
@@ -110,34 +99,36 @@ namespace detail {
// in overload resolution with the functions declared by // in overload resolution with the functions declared by
// BOOST_SERIALIZATION_REGISTER_ARCHIVE, below. // BOOST_SERIALIZATION_REGISTER_ARCHIVE, below.
template <class Serializable> template <class Serializable>
void instantiate_ptr_serialization(Serializable*, int, uLib::Archive::detail::adl_tag ) {} void instantiate_ptr_serialization(Serializable *, int,
} uLib::Archive::detail::adl_tag) {}
} } // namespace detail
} } // namespace archive
} // namespace boost
// The function declaration generated by this macro never actually // The function declaration generated by this macro never actually
// gets called, but its return type gets instantiated, and that's // gets called, but its return type gets instantiated, and that's
// enough to cause registration of serialization functions between // enough to cause registration of serialization functions between
// Archive and any exported Serializable type. See also: // Archive and any exported Serializable type. See also:
// boost/serialization/export.hpp // boost/serialization/export.hpp
# define ULIB_SERIALIZATION_REGISTER_ARCHIVE(_Archive) \ #define ULIB_SERIALIZATION_REGISTER_ARCHIVE(_Archive) \
namespace boost { namespace archive { namespace detail { \ namespace boost { \
namespace archive { \
namespace detail { \
\ \
template <class Serializable> \ template <class Serializable> \
BOOST_DEDUCED_TYPENAME _ptr_serialization_support<_Archive, Serializable>::type \ BOOST_DEDUCED_TYPENAME \
instantiate_ptr_serialization( Serializable*, _Archive*, uLib::Archive::detail::adl_tag ); }}} _ptr_serialization_support<_Archive, Serializable>::type \
instantiate_ptr_serialization(Serializable *, _Archive *, \
uLib::Archive::detail::adl_tag); \
} \
} \
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// ARCHIVES IO INTERFACES // // ARCHIVES IO INTERFACES //
namespace boost { namespace boost {
namespace archive { namespace archive {
namespace detail { namespace detail {
@@ -145,11 +136,10 @@ namespace detail {
/** /**
* Custom implementation of boost interface_iarchive to add new operators * Custom implementation of boost interface_iarchive to add new operators
*/ */
template<class Archive> template <class Archive> class uLib_interface_iarchive {
class uLib_interface_iarchive
{
protected: protected:
uLib_interface_iarchive(){}; uLib_interface_iarchive() {};
public: public:
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
// archive public interface // archive public interface
@@ -157,54 +147,40 @@ public:
typedef mpl::bool_<false> is_saving; typedef mpl::bool_<false> is_saving;
// return a pointer to the most derived class // return a pointer to the most derived class
Archive * This(){ Archive *This() { return static_cast<Archive *>(this); }
return static_cast<Archive *>(this);
}
template<class T> template <class T>
const basic_pointer_iserializer * const basic_pointer_iserializer *register_type(T * = NULL) {
register_type(T * = NULL){ const basic_pointer_iserializer &bpis = boost::serialization::singleton<
const basic_pointer_iserializer & bpis = pointer_iserializer<Archive, T>>::get_const_instance();
boost::serialization::singleton<
pointer_iserializer<Archive, T>
>::get_const_instance();
this->This()->register_basic_serializer(bpis.get_basic_serializer()); this->This()->register_basic_serializer(bpis.get_basic_serializer());
return & bpis; return &bpis;
} }
template<class T> template <class T> Archive &operator>>(T &t) {
Archive & operator>>(T & t){ this->This()->load_override(t);
this->This()->load_override(t, 0); return *this->This();
return * this->This();
} }
// the & operator // the & operator
template<class T> template <class T> Archive &operator&(T &t) { return *(this->This()) >> t; }
Archive & operator&(T & t){
return *(this->This()) >> t;
}
// the == operator // the == operator
template <class T> template <class T> Archive &operator==(T &t) { return this->operator&(t); }
Archive & operator == (T & t) {
return this->operator &(t);
}
// the != operator for human readable access // the != operator for human readable access
template <class T> template <class T> Archive &operator!=(T &t) {
Archive & operator != (T & t) {
std::cerr << std::flush << "cauch string: " << t << "\n"; // REMOVE THIS ! std::cerr << std::flush << "cauch string: " << t << "\n"; // REMOVE THIS !
return * this->This(); return *this->This();
} }
}; };
/** /**
* Custom implementation of boost interface_oarchive to add new operators * Custom implementation of boost interface_oarchive to add new operators
*/ */
template <class Archive> template <class Archive> class uLib_interface_oarchive {
class uLib_interface_oarchive {
protected: protected:
uLib_interface_oarchive(){}; uLib_interface_oarchive() {};
public: public:
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
// archive public interface // archive public interface
@@ -212,109 +188,82 @@ public:
typedef mpl::bool_<true> is_saving; typedef mpl::bool_<true> is_saving;
// return a pointer to the most derived class // return a pointer to the most derived class
Archive * This(){ Archive *This() { return static_cast<Archive *>(this); }
return static_cast<Archive *>(this);
}
template<class T> template <class T>
const basic_pointer_oserializer * const basic_pointer_oserializer *register_type(const T * = NULL) {
register_type(const T * = NULL){ const basic_pointer_oserializer &bpos = boost::serialization::singleton<
const basic_pointer_oserializer & bpos = pointer_oserializer<Archive, T>>::get_const_instance();
boost::serialization::singleton<
pointer_oserializer<Archive, T>
>::get_const_instance();
this->This()->register_basic_serializer(bpos.get_basic_serializer()); this->This()->register_basic_serializer(bpos.get_basic_serializer());
return & bpos; return &bpos;
} }
template<class T> template <class T> Archive &operator<<(T &t) {
Archive & operator<<(T & t){
// to get access you must redefine save_override by typing // to get access you must redefine save_override by typing
// "using save_override" in archive impl // "using save_override" in archive impl
this->This()->save_override(t, 0); this->This()->save_override(t);
return * this->This(); return *this->This();
} }
// the & operator // the & operator
template<class T> template <class T> Archive &operator&(T &t) {
Archive & operator&(T & t){ #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING return *this->This() << const_cast<const T &>(t);
return * this->This() << const_cast<const T &>(t); #else
#else return *this->This() << t;
return * this->This() << t; #endif
#endif
} }
// the == operator // the == operator
template <class T> template <class T> Archive &operator==(T &t) { return this->operator&(t); }
Archive & operator == (T & t) {
return this->operator &(t);
}
// the != operator for human readable access // the != operator for human readable access
template <class T> template <class T> Archive &operator!=(T &t) {
Archive & operator != (T & t) {
std::cerr << std::flush << "cauch string: " << t << "\n"; // REMOVE THIS ! std::cerr << std::flush << "cauch string: " << t << "\n"; // REMOVE THIS !
return * this->This(); return *this->This();
} }
}; };
// DECLARE INTERFACE SPECIALIZATIONS /////////////////////////////////////////// // DECLARE INTERFACE SPECIALIZATIONS ///////////////////////////////////////////
// With this declarations all uLib archive Implementation will use their own // With this declarations all uLib archive Implementation will use their own
// extended interface // // extended interface //
template <> template <>
class interface_iarchive <uLib::Archive::xml_iarchive> : public class interface_iarchive<uLib::Archive::xml_iarchive>
uLib_interface_iarchive <uLib::Archive::xml_iarchive> {}; : public uLib_interface_iarchive<uLib::Archive::xml_iarchive> {};
template <> template <>
class interface_oarchive <uLib::Archive::xml_oarchive> : public class interface_oarchive<uLib::Archive::xml_oarchive>
uLib_interface_oarchive <uLib::Archive::xml_oarchive> {}; : public uLib_interface_oarchive<uLib::Archive::xml_oarchive> {};
template <> template <>
class interface_iarchive <uLib::Archive::text_iarchive> : public class interface_iarchive<uLib::Archive::text_iarchive>
uLib_interface_iarchive <uLib::Archive::text_iarchive> {}; : public uLib_interface_iarchive<uLib::Archive::text_iarchive> {};
template <> template <>
class interface_oarchive <uLib::Archive::text_oarchive> : public class interface_oarchive<uLib::Archive::text_oarchive>
uLib_interface_oarchive <uLib::Archive::text_oarchive> {}; : public uLib_interface_oarchive<uLib::Archive::text_oarchive> {};
template <> template <>
class interface_oarchive <uLib::Archive::log_archive> : public class interface_oarchive<uLib::Archive::log_archive>
uLib_interface_oarchive <uLib::Archive::log_archive> {}; : public uLib_interface_oarchive<uLib::Archive::log_archive> {};
//// Veritical repetition macro // FINIRE !!!!!!!!!!!!!!!!!!!!!!!!! //// Veritical repetition macro // FINIRE !!!!!!!!!!!!!!!!!!!!!!!!!
//#define _DECL_INTERFACE_ARCHIVE_V(vz,vn,vdata) \ // #define _DECL_INTERFACE_ARCHIVE_V(vz,vn,vdata) \
// template <class TypeSeq> \ // template <class TypeSeq> \
// struct inherit_nofold<TypeSeq,BOOST_PP_INC(vn)> : \ // struct inherit_nofold<TypeSeq,BOOST_PP_INC(vn)> : \
// BOOST_PP_REPEAT(BOOST_PP_INC(vn),_INERIT_NOFOLD_H,~) \ // BOOST_PP_REPEAT(BOOST_PP_INC(vn),_INERIT_NOFOLD_H,~) \
// {}; // {};
//// Multiple size declaration // //// Multiple size declaration //
//BOOST_PP_REPEAT(ULIB_CFG_MPL_INERIT_NOFOLD_MAXSIZE,_INERIT_NOFOLD_V,~) // BOOST_PP_REPEAT(ULIB_CFG_MPL_INERIT_NOFOLD_MAXSIZE,_INERIT_NOFOLD_V,~)
//#undef _INERIT_NOFOLD_H
//#undef _INERIT_NOFOLD_V
} // detail
} // archive
} // boost
// #undef _INERIT_NOFOLD_H
// #undef _INERIT_NOFOLD_V
} // namespace detail
} // namespace archive
} // namespace boost
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -330,14 +279,14 @@ class interface_oarchive <uLib::Archive::log_archive> : public
namespace boost { namespace boost {
namespace archive { namespace archive {
//template<class Archive> // template<class Archive>
//inline void load_const_override(Archive & ar, const char *t ){ // inline void load_const_override(Archive & ar, const char *t ){
// typedef typename mpl::identity<detail::load_non_pointer_type<Archive> >::type typex; // typedef typename mpl::identity<detail::load_non_pointer_type<Archive>
// typex::invoke(ar, t); // >::type typex; typex::invoke(ar, t);
//} // }
//template<class Archive, class T> // template<class Archive, class T>
//inline void load(Archive & ar, T &t){ // inline void load(Archive & ar, T &t){
// // if this assertion trips. It means we're trying to load a // // if this assertion trips. It means we're trying to load a
// // const object with a compiler that doesn't have correct // // const object with a compiler that doesn't have correct
// // funtion template ordering. On other compilers, this is // // funtion template ordering. On other compilers, this is
@@ -358,47 +307,38 @@ namespace archive {
// > // >
// >::type typex; // >::type typex;
// typex::invoke(ar, t); // typex::invoke(ar, t);
//} // }
}
}
} // namespace archive
} // namespace boost
namespace uLib { namespace uLib {
namespace Archive { namespace Archive {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// POLYMORPHIC // // POLYMORPHIC //
// class polymorphic_iarchive :
//class polymorphic_iarchive :
// public boost::archive::polymorphic_iarchive { // public boost::archive::polymorphic_iarchive {
//public: // public:
// void load_override(const char *t, BOOST_PFTO int) // void load_override(const char *t, BOOST_PFTO int)
// { // {
// boost::archive::load_const_override(* this->This(), const_cast<char*>(t)); // boost::archive::load_const_override(* this->This(),
// const_cast<char*>(t));
// } // }
//}; //};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// XML // // XML //
class xml_iarchive : class xml_iarchive : public boost::archive::xml_iarchive_impl<xml_iarchive> {
public boost::archive::xml_iarchive_impl<xml_iarchive>
{
typedef xml_iarchive Archive; typedef xml_iarchive Archive;
typedef boost::archive::xml_iarchive_impl<Archive> base; typedef boost::archive::xml_iarchive_impl<Archive> base;
@@ -406,75 +346,63 @@ class xml_iarchive :
friend class boost::archive::detail::interface_iarchive<Archive>; friend class boost::archive::detail::interface_iarchive<Archive>;
friend class boost::archive::basic_xml_iarchive<Archive>; friend class boost::archive::basic_xml_iarchive<Archive>;
friend class boost::archive::load_access; friend class boost::archive::load_access;
public: public:
xml_iarchive(std::istream & is, unsigned int flags = 0) : xml_iarchive(std::istream &is, unsigned int flags = 0)
xml_iarchive_impl<xml_iarchive>(is, flags) : xml_iarchive_impl<xml_iarchive>(is, flags) {}
{}
using basic_xml_iarchive::load_override; using basic_xml_iarchive::load_override;
// Anything not an attribute should be a name value pair as nvp or hrp // Anything not an attribute should be a name value pair as nvp or hrp
typedef boost::archive::detail::common_iarchive<Archive> detail_common_iarchive; typedef boost::archive::detail::common_iarchive<Archive>
template<class T> detail_common_iarchive;
template <class T>
void load_override( void load_override(
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const const
#endif #endif
boost::serialization::hrp< T > & t, boost::serialization::hrp<T> &t) {
int v
){
this->This()->load_start(t.name()); this->This()->load_start(t.name());
this->detail_common_iarchive::load_override(t.value(), 0); this->detail_common_iarchive::load_override(t.value());
// t.stov(); // t.stov();
this->This()->load_end(t.name()); this->This()->load_end(t.name());
} }
// class_name_type can't be handled here as it depends upon the // class_name_type can't be handled here as it depends upon the
// char type used by the stream. So require the derived implementation. // char type used by the stream. So require the derived implementation.
// derived in this case is xml_iarchive_impl or base .. // derived in this case is xml_iarchive_impl or base ..
using base::load_override; using base::load_override;
void load_override(const char *str, int v) { void load_override(const char *str) {
// StringReader sr(basic_text_iprimitive::is); // StringReader sr(basic_text_iprimitive::is);
// sr >> str; // sr >> str;
} }
~xml_iarchive(){}; ~xml_iarchive() {};
}; };
//typedef boost::archive::detail::polymorphic_iarchive_route< // typedef boost::archive::detail::polymorphic_iarchive_route<
//boost::archive::xml_iarchive_impl<xml_iarchive> // boost::archive::xml_iarchive_impl<xml_iarchive>
//> polymorphic_xml_iarchive; //> polymorphic_xml_iarchive;
template <class ArchiveImpl> template <class ArchiveImpl>
struct polymorphic_iarchive_route : struct polymorphic_iarchive_route
boost::archive::detail::polymorphic_iarchive_route<ArchiveImpl> : boost::archive::detail::polymorphic_iarchive_route<ArchiveImpl> {
{ virtual void load(const char *t) { ArchiveImpl::load(t); }
virtual void load(const char * t){
ArchiveImpl::load(t);
}
}; };
class polymorphic_xml_iarchive
class polymorphic_xml_iarchive : : public polymorphic_iarchive_route<
public polymorphic_iarchive_route< boost::archive::xml_iarchive_impl<xml_iarchive> > boost::archive::xml_iarchive_impl<xml_iarchive>> {
{
// give serialization implementation access to this class // give serialization implementation access to this class
// friend class boost::archive::detail::interface_iarchive<Archive>; // friend class boost::archive::detail::interface_iarchive<Archive>;
// friend class boost::archive::basic_xml_iarchive<Archive>; // friend class boost::archive::basic_xml_iarchive<Archive>;
// friend class boost::archive::load_access; // friend class boost::archive::load_access;
public: public:
virtual void load_override(const char *str, int v) { virtual void load_override(const char *str) { ; }
;
}
}; };
class xml_oarchive : public boost::archive::xml_oarchive_impl<xml_oarchive> {
class xml_oarchive :
public boost::archive::xml_oarchive_impl<xml_oarchive>
{
typedef xml_oarchive Archive; typedef xml_oarchive Archive;
typedef boost::archive::xml_oarchive_impl<Archive> base; typedef boost::archive::xml_oarchive_impl<Archive> base;
@@ -482,10 +410,10 @@ class xml_oarchive :
friend class boost::archive::detail::interface_oarchive<Archive>; friend class boost::archive::detail::interface_oarchive<Archive>;
friend class boost::archive::basic_xml_oarchive<Archive>; friend class boost::archive::basic_xml_oarchive<Archive>;
friend class boost::archive::save_access; friend class boost::archive::save_access;
public: public:
xml_oarchive(std::ostream & os, unsigned int flags = 0) : xml_oarchive(std::ostream &os, unsigned int flags = 0)
boost::archive::xml_oarchive_impl<xml_oarchive>(os, flags) : boost::archive::xml_oarchive_impl<xml_oarchive>(os, flags) {}
{}
// example of implementing save_override for const char* // // example of implementing save_override for const char* //
// void save_override(const char *t, int) { // void save_override(const char *t, int) {
@@ -495,31 +423,30 @@ public:
using basic_xml_oarchive::save_override; using basic_xml_oarchive::save_override;
// special treatment for name-value pairs. // special treatment for name-value pairs.
typedef boost::archive::detail::common_oarchive<Archive> detail_common_oarchive; typedef boost::archive::detail::common_oarchive<Archive>
template<class T> detail_common_oarchive;
template <class T>
void save_override( void save_override(
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const const
#endif #endif
::boost::serialization::hrp< T > & t, ::boost::serialization::hrp<T> &t) {
int v
){
this->This()->save_start(t.name()); this->This()->save_start(t.name());
// t.vtos(); // t.vtos();
// this->detail_common_oarchive::save_override(t.const_value(), 0); // this->detail_common_oarchive::save_override(t.const_value());
this->This()->save_end(t.name()); this->This()->save_end(t.name());
} }
void save_override(const char *str, int v) { void save_override(const char *str) {
// Do not save any human decoration string // // Do not save any human decoration string //
// basic_text_oprimitive::save(str); // basic_text_oprimitive::save(str);
} }
~xml_oarchive(){} ~xml_oarchive() {}
}; };
//typedef boost::archive::detail::polymorphic_oarchive_route< // typedef boost::archive::detail::polymorphic_oarchive_route<
//boost::archive::xml_oarchive_impl<xml_oarchive> // boost::archive::xml_oarchive_impl<xml_oarchive>
//> polymorphic_xml_oarchive; //> polymorphic_xml_oarchive;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -527,9 +454,7 @@ public:
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// TEXT // // TEXT //
class text_iarchive : class text_iarchive : public boost::archive::text_iarchive_impl<text_iarchive> {
public boost::archive::text_iarchive_impl<text_iarchive>
{
typedef text_iarchive Archive; typedef text_iarchive Archive;
typedef boost::archive::text_iarchive_impl<Archive> base; typedef boost::archive::text_iarchive_impl<Archive> base;
@@ -537,21 +462,21 @@ class text_iarchive :
friend class boost::archive::detail::interface_iarchive<Archive>; friend class boost::archive::detail::interface_iarchive<Archive>;
friend class boost::archive::basic_text_iarchive<Archive>; friend class boost::archive::basic_text_iarchive<Archive>;
friend class boost::archive::load_access; friend class boost::archive::load_access;
public: public:
text_iarchive(std::istream & is, unsigned int flags = 0) : text_iarchive(std::istream &is, unsigned int flags = 0)
text_iarchive_impl<Archive>(is, flags) : text_iarchive_impl<Archive>(is, flags) {}
{}
using basic_text_iarchive::load_override; using basic_text_iarchive::load_override;
void load_override(boost::archive::object_id_type & t, int) {} void load_override(boost::archive::object_id_type &t) {}
// class_name_type can't be handled here as it depends upon the // class_name_type can't be handled here as it depends upon the
// char type used by the stream. So require the derived implementation. // char type used by the stream. So require the derived implementation.
// derived in this case is xml_iarchive_impl or base .. // derived in this case is xml_iarchive_impl or base ..
using base::load_override; using base::load_override;
void load_override(const char *str, int v) { void load_override(const char *str) {
StringReader sr(basic_text_iprimitive::is); StringReader sr(basic_text_iprimitive::is);
sr >> str; sr >> str;
} }
@@ -561,15 +486,11 @@ public:
typedef text_iarchive naked_text_iarchive; typedef text_iarchive naked_text_iarchive;
//typedef boost::archive::detail::polymorphic_iarchive_route< // typedef boost::archive::detail::polymorphic_iarchive_route<
//naked_text_iarchive // naked_text_iarchive
//> polymorphic_text_iarchive; //> polymorphic_text_iarchive;
class text_oarchive : public boost::archive::text_oarchive_impl<text_oarchive> {
class text_oarchive :
public boost::archive::text_oarchive_impl<text_oarchive>
{
typedef text_oarchive Archive; typedef text_oarchive Archive;
typedef boost::archive::text_oarchive_impl<Archive> base; typedef boost::archive::text_oarchive_impl<Archive> base;
@@ -577,33 +498,28 @@ class text_oarchive :
friend class boost::archive::detail::interface_oarchive<Archive>; friend class boost::archive::detail::interface_oarchive<Archive>;
friend class boost::archive::basic_text_oarchive<Archive>; friend class boost::archive::basic_text_oarchive<Archive>;
friend class boost::archive::save_access; friend class boost::archive::save_access;
public: public:
text_oarchive(std::ostream & os, unsigned int flags = 0) : text_oarchive(std::ostream &os, unsigned int flags = 0)
boost::archive::text_oarchive_impl<Archive>(os, flags) : boost::archive::text_oarchive_impl<Archive>(os, flags) {}
{}
using basic_text_oarchive::save_override; using basic_text_oarchive::save_override;
void save_override(const char *str, int v) { void save_override(const char *str) { basic_text_oprimitive::save(str); }
basic_text_oprimitive::save(str);
}
~text_oarchive(){} ~text_oarchive() {}
}; };
//typedef boost::archive::detail::polymorphic_oarchive_route< // typedef boost::archive::detail::polymorphic_oarchive_route<
//boost::archive::text_oarchive_impl<text_oarchive> // boost::archive::text_oarchive_impl<text_oarchive>
//> polymorphic_text_oarchive; //> polymorphic_text_oarchive;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// SIMPLE HUMAN READABLE TEXT // // SIMPLE HUMAN READABLE TEXT //
class hrt_iarchive : class hrt_iarchive : public boost::archive::text_iarchive_impl<hrt_iarchive> {
public boost::archive::text_iarchive_impl<hrt_iarchive>
{
typedef hrt_iarchive Archive; typedef hrt_iarchive Archive;
typedef boost::archive::text_iarchive_impl<Archive> base; typedef boost::archive::text_iarchive_impl<Archive> base;
@@ -611,29 +527,29 @@ class hrt_iarchive :
friend class boost::archive::detail::interface_iarchive<Archive>; friend class boost::archive::detail::interface_iarchive<Archive>;
friend class boost::archive::basic_text_iarchive<Archive>; friend class boost::archive::basic_text_iarchive<Archive>;
friend class boost::archive::load_access; friend class boost::archive::load_access;
public: public:
hrt_iarchive(std::istream & is, unsigned int flags = 0) : hrt_iarchive(std::istream &is, unsigned int flags = 0)
base(is, flags | boost::archive::no_header ) : base(is, flags | boost::archive::no_header) {}
{}
using basic_text_iarchive::load_override; using basic_text_iarchive::load_override;
// hide all archive props // // hide all archive props //
void load_override( boost::archive::object_id_type & t, int) {} void load_override(boost::archive::object_id_type &t) {}
void load_override( boost::archive::object_reference_type & t, int) {} void load_override(boost::archive::object_reference_type &t) {}
void load_override( boost::archive::version_type & t, int) {} void load_override(boost::archive::version_type &t) {}
void load_override( boost::archive::class_id_type & t, int) {} void load_override(boost::archive::class_id_type &t) {}
void load_override( boost::archive::class_id_optional_type & t, int) {} void load_override(boost::archive::class_id_optional_type &t) {}
void load_override( boost::archive::class_id_reference_type & t, int){} void load_override(boost::archive::class_id_reference_type &t) {}
void load_override( boost::archive::class_name_type & t, int) {} void load_override(boost::archive::class_name_type &t) {}
void load_override( boost::archive::tracking_type & t, int) {} void load_override(boost::archive::tracking_type &t) {}
// class_name_type can't be handled here as it depends upon the // class_name_type can't be handled here as it depends upon the
// char type used by the stream. So require the derived implementation. // char type used by the stream. So require the derived implementation.
// derived in this case is xml_iarchive_impl or base .. // derived in this case is xml_iarchive_impl or base ..
using base::load_override; using base::load_override;
void load_override(const char *str, int v) { void load_override(const char *str) {
StringReader sr(basic_text_iprimitive::is); StringReader sr(basic_text_iprimitive::is);
sr >> str; sr >> str;
} }
@@ -641,10 +557,7 @@ public:
~hrt_iarchive() {}; ~hrt_iarchive() {};
}; };
class hrt_oarchive : public boost::archive::text_oarchive_impl<hrt_oarchive> {
class hrt_oarchive :
public boost::archive::text_oarchive_impl<hrt_oarchive>
{
typedef hrt_oarchive Archive; typedef hrt_oarchive Archive;
typedef boost::archive::text_oarchive_impl<Archive> base; typedef boost::archive::text_oarchive_impl<Archive> base;
@@ -652,32 +565,26 @@ class hrt_oarchive :
friend class boost::archive::detail::interface_oarchive<Archive>; friend class boost::archive::detail::interface_oarchive<Archive>;
friend class boost::archive::basic_text_oarchive<Archive>; friend class boost::archive::basic_text_oarchive<Archive>;
friend class boost::archive::save_access; friend class boost::archive::save_access;
public:
hrt_oarchive(std::ostream & os, unsigned int flags = 0) : public:
base(os, flags | boost::archive::no_header ) hrt_oarchive(std::ostream &os, unsigned int flags = 0)
{} : base(os, flags | boost::archive::no_header) {}
using basic_text_oarchive::save_override; using basic_text_oarchive::save_override;
void save_override(const boost::archive::object_id_type & t, int) {} void save_override(const boost::archive::object_id_type &t) {}
void save_override(const boost::archive::object_reference_type & t, int) {} void save_override(const boost::archive::object_reference_type &t) {}
void save_override(const boost::archive::version_type & t, int) {} void save_override(const boost::archive::version_type &t) {}
void save_override(const boost::archive::class_id_type & t, int) {} void save_override(const boost::archive::class_id_type &t) {}
void save_override(const boost::archive::class_id_optional_type & t, int) {} void save_override(const boost::archive::class_id_optional_type &t) {}
void save_override(const boost::archive::class_id_reference_type & t, int){} void save_override(const boost::archive::class_id_reference_type &t) {}
void save_override(const boost::archive::class_name_type & t, int) {} void save_override(const boost::archive::class_name_type &t) {}
void save_override(const boost::archive::tracking_type & t, int) {} void save_override(const boost::archive::tracking_type &t) {}
void save_override(const char *str, int v) {
basic_text_oprimitive::save(str);
}
~hrt_oarchive(){}
};
void save_override(const char *str) { basic_text_oprimitive::save(str); }
~hrt_oarchive() {}
};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -690,8 +597,7 @@ class hrt_oarchive :
// any serializable class. Intended to be useful as a debugging aid. // any serializable class. Intended to be useful as a debugging aid.
class log_archive : class log_archive :
/* protected ? */ /* protected ? */
public boost::archive::xml_oarchive_impl<log_archive> public boost::archive::xml_oarchive_impl<log_archive> {
{
typedef boost::archive::xml_oarchive_impl<log_archive> base; typedef boost::archive::xml_oarchive_impl<log_archive> base;
typedef log_archive Archive; typedef log_archive Archive;
// give serialization implementation access to this clas // give serialization implementation access to this clas
@@ -700,66 +606,52 @@ class log_archive :
friend class boost::archive::save_access; friend class boost::archive::save_access;
public: public:
void save_override(const char *str) {
void save_override(const char *str, int v) {
// Do not save any human decoration string // // Do not save any human decoration string //
// basic_text_oprimitive::save(str); // basic_text_oprimitive::save(str);
} }
template<class T> template <class T> void save_override(T &t) {
void save_override(T & t, BOOST_PFTO int){ base::save_override(boost::serialization::make_nvp(NULL, t));
base::save_override(boost::serialization::make_nvp(NULL, t), 0);
} }
// activate this if you want to trap non nvp objects // // activate this if you want to trap non nvp objects //
// template<class T> // template<class T>
// void save_override(T & t, BOOST_PFTO int) // void save_override(T & t)
// { // {
// BOOST_MPL_ASSERT((boost::serialization::is_wrapper< T >)); // BOOST_MPL_ASSERT((boost::serialization::is_wrapper< T >));
// // this->detail_common_oarchive::save_override(t, 0); // // this->detail_common_oarchive::save_override(t);
// } // }
template<class T> template <class T> void save_override(const boost::serialization::nvp<T> &t) {
void save_override(const boost::serialization::nvp<T> & t, int){ base::save_override(t);
base::save_override(t, 0);
} }
// specific overrides for attributes - not name value pairs so we // specific overrides for attributes - not name value pairs so we
// want to trap them before the above "fall through" // want to trap them before the above "fall through"
// since we don't want to see these in the output - make them no-ops. // since we don't want to see these in the output - make them no-ops.
void save_override(const boost::archive::object_id_type & t, int) {} void save_override(const boost::archive::object_id_type &t) {}
void save_override(const boost::archive::object_reference_type & t, int) {} void save_override(const boost::archive::object_reference_type &t) {}
void save_override(const boost::archive::version_type & t, int) {} void save_override(const boost::archive::version_type &t) {}
void save_override(const boost::archive::class_id_type & t, int) {} void save_override(const boost::archive::class_id_type &t) {}
void save_override(const boost::archive::class_id_optional_type & t, int) {} void save_override(const boost::archive::class_id_optional_type &t) {}
void save_override(const boost::archive::class_id_reference_type & t, int){} void save_override(const boost::archive::class_id_reference_type &t) {}
void save_override(const boost::archive::class_name_type & t, int) {} void save_override(const boost::archive::class_name_type &t) {}
void save_override(const boost::archive::tracking_type & t, int) {} void save_override(const boost::archive::tracking_type &t) {}
public: public:
log_archive(std::ostream & os, unsigned int flags = 0) : log_archive(std::ostream &os, unsigned int flags = 0)
boost::archive::xml_oarchive_impl<log_archive>( : boost::archive::xml_oarchive_impl<log_archive>(
os, os, flags | boost::archive::no_header) {}
flags | boost::archive::no_header
)
{}
}; };
//typedef boost::archive::detail::polymorphic_oarchive_route< // typedef boost::archive::detail::polymorphic_oarchive_route<
//boost::archive::xml_oarchive_impl<log_archive> // boost::archive::xml_oarchive_impl<log_archive>
//> polymorphic_log_archive; //> polymorphic_log_archive;
} // namespace Archive
} // namespace uLib
} // Archive
} // uLib
ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::xml_iarchive) ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::xml_iarchive)
ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::xml_oarchive) ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::xml_oarchive)
@@ -769,13 +661,10 @@ ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::hrt_iarchive)
ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::hrt_oarchive) ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::hrt_oarchive)
ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::log_archive) ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::log_archive)
//ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_xml_iarchive) // ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_xml_iarchive)
//ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_xml_oarchive) // ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_xml_oarchive)
//ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_text_iarchive) // ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_text_iarchive)
//ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_text_oarchive) // ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_text_oarchive)
//ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_log_archive) // ULIB_SERIALIZATION_REGISTER_ARCHIVE(uLib::Archive::polymorphic_log_archive)
#endif // U_CORE_ARCHIVES_H #endif // U_CORE_ARCHIVES_H

View File

@@ -1,10 +1,9 @@
set(HEADERS Options.h set(HEADERS Archives.h Array.h Collection.h Debug.h Export.h Function.h Macros.h Mpl.h Object.h Options.h Serializable.h Signal.h Singleton.h SmartPointer.h StaticInterface.h StringReader.h Types.h Uuid.h Vector.h)
StaticInterface.h)
set(SOURCES Options.cpp) set(SOURCES Archives.cpp Debug.cpp Object.cpp Options.cpp Serializable.cpp Signal.cpp Uuid.cpp)
set(LIBRARIES ${Boost_PROGRAM_OPTIONS_LIBRARY}) set(LIBRARIES Boost::program_options)
set(libname ${PACKAGE_LIBPREFIX}Core) set(libname ${PACKAGE_LIBPREFIX}Core)
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE) set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
@@ -23,5 +22,7 @@ install(TARGETS ${libname}
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Core) install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Core)
if(BUILD_TESTING)
include(uLibTargetMacros)
add_subdirectory(testing)
endif()

View File

@@ -23,95 +23,85 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#ifndef U_CORE_EXPORT_H #ifndef U_CORE_EXPORT_H
#define U_CORE_EXPORT_H #define U_CORE_EXPORT_H
#include <utility>
#include <cstddef> // NULL #include <cstddef> // NULL
#include <iostream> #include <iostream>
#include <utility>
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/preprocessor/stringize.hpp> #include <boost/preprocessor/stringize.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_polymorphic.hpp> #include <boost/type_traits/is_polymorphic.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/and.hpp> #include <boost/mpl/and.hpp>
#include <boost/mpl/not.hpp> #include <boost/mpl/assert.hpp>
#include <boost/mpl/bool.hpp> #include <boost/mpl/bool.hpp>
#include <boost/mpl/not.hpp>
#include <boost/serialization/extended_type_info.hpp> // for guid_defined only
#include <boost/serialization/static_warning.hpp>
#include <boost/serialization/assume_abstract.hpp> #include <boost/serialization/assume_abstract.hpp>
#include <boost/serialization/extended_type_info.hpp> // for guid_defined only
#include <boost/serialization/force_include.hpp> #include <boost/serialization/force_include.hpp>
#include <boost/serialization/singleton.hpp> #include <boost/serialization/singleton.hpp>
#include <boost/serialization/static_warning.hpp>
#include <boost/archive/detail/register_archive.hpp> #include <boost/archive/detail/register_archive.hpp>
#include "Core/Archives.h" #include "Core/Archives.h"
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
namespace uLib { namespace uLib {
namespace Archive { namespace Archive {
namespace detail { namespace detail {
namespace extra_detail { namespace extra_detail {
template<class T> template <class T> struct guid_initializer {
struct guid_initializer void export_guid(boost::mpl::false_) const {
{
void export_guid(mpl::false_) const {
// generates the statically-initialized objects whose constructors // generates the statically-initialized objects whose constructors
// register the information allowing serialization of T objects // register the information allowing serialization of T objects
// through pointers to their base classes. // through pointers to their base classes.
boost::archive::detail:: boost::archive::detail::instantiate_ptr_serialization(
instantiate_ptr_serialization((T*)0, 0, (T *)0, 0, uLib::Archive::detail::adl_tag());
uLib::Archive::detail::adl_tag());
} }
void export_guid(mpl::true_) const { void export_guid(boost::mpl::true_) const {}
} guid_initializer const &export_guid() const {
guid_initializer const & export_guid() const { BOOST_STATIC_WARNING(boost::is_polymorphic<T>::value);
BOOST_STATIC_WARNING(boost::is_polymorphic< T >::value);
// note: exporting an abstract base class will have no effect // note: exporting an abstract base class will have no effect
// and cannot be used to instantitiate serialization code // and cannot be used to instantitiate serialization code
// (one might be using this in a DLL to instantiate code) // (one might be using this in a DLL to instantiate code)
//BOOST_STATIC_WARNING(! boost::serialization::is_abstract< T >::value); // BOOST_STATIC_WARNING(! boost::serialization::is_abstract< T >::value);
export_guid(boost::serialization::is_abstract< T >()); export_guid(boost::serialization::is_abstract<T>());
return *this; return *this;
} }
}; };
template<typename T> template <typename T> struct init_guid;
struct init_guid;
} // anonymous } // namespace extra_detail
} // namespace detail } // namespace detail
} // namespace Archive } // namespace Archive
} // namespace uLib } // namespace uLib
#define ULIB_CLASS_EXPORT_IMPLEMENT(T) \ #define ULIB_CLASS_EXPORT_IMPLEMENT(T) \
namespace uLib { \ namespace uLib { \
namespace Archive { \ namespace Archive { \
namespace detail { \ namespace detail { \
namespace extra_detail { \ namespace extra_detail { \
template<> \ template <> struct init_guid<T> { \
struct init_guid< T > { \ static guid_initializer<T> const &g; \
static guid_initializer< T > const & g; \
}; \ }; \
guid_initializer< T > const & init_guid< T >::g = \ guid_initializer<T> const &init_guid<T>::g = \
::boost::serialization::singleton< \ ::boost::serialization::singleton< \
guid_initializer< T > \ guid_initializer<T>>::get_mutable_instance() \
>::get_mutable_instance().export_guid(); \ .export_guid(); \
}}}} \ } \
/**/ } \
} \
} \
/**/
#endif // EXPORT_H #endif // EXPORT_H

View File

@@ -110,11 +110,13 @@ bool Object::addSignalImpl(SignalBase *sig, GenericMFPtr fptr,
const char *name) { const char *name) {
ObjectPrivate::Signal s = {fptr, std::string(name), sig}; ObjectPrivate::Signal s = {fptr, std::string(name), sig};
d->sigv.push_back(s); d->sigv.push_back(s);
return true;
} }
bool Object::addSlotImpl(GenericMFPtr fptr, const char *name) { bool Object::addSlotImpl(GenericMFPtr fptr, const char *name) {
ObjectPrivate::Slot s = {fptr, std::string(name)}; ObjectPrivate::Slot s = {fptr, std::string(name)};
d->slov.push_back(s); d->slov.push_back(s);
return true;
} }
SignalBase *Object::findSignalImpl(const GenericMFPtr &fptr) const { SignalBase *Object::findSignalImpl(const GenericMFPtr &fptr) const {

View File

@@ -107,6 +107,7 @@ public:
// if(sig && slo) // if(sig && slo)
// return Object::connect(sig,slo->operator ()(),receiver); // return Object::connect(sig,slo->operator ()(),receiver);
// else return false; // else return false;
return false;
} }
// Qt5 style connector // // Qt5 style connector //
@@ -119,11 +120,13 @@ public:
typename FunctionPointer<Func2>::SignalSignature> typename FunctionPointer<Func2>::SignalSignature>
SigT; SigT;
ConnectSignal(sigb, slof, receiver); ConnectSignal(sigb, slof, receiver);
return true;
} }
template <typename FuncT> template <typename FuncT>
static inline bool connect(SignalBase *sigb, FuncT slof, Object *receiver) { static inline bool connect(SignalBase *sigb, FuncT slof, Object *receiver) {
ConnectSignal(sigb, slof, receiver); ConnectSignal(sigb, slof, receiver);
return true;
} }
template <typename FuncT> template <typename FuncT>
@@ -139,7 +142,7 @@ public:
} }
template <typename FuncT> inline bool addSlot(FuncT fun, const char *name) { template <typename FuncT> inline bool addSlot(FuncT fun, const char *name) {
this->addSlotImpl(GenericMFPtr(fun), name); return this->addSlotImpl(GenericMFPtr(fun), name);
} }
template <typename FuncT> template <typename FuncT>

View File

@@ -23,21 +23,19 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#ifndef U_CORE_SIGNAL_H #ifndef U_CORE_SIGNAL_H
#define U_CORE_SIGNAL_H #define U_CORE_SIGNAL_H
#include <boost/typeof/typeof.hpp> #include <boost/typeof/typeof.hpp>
#include <boost/signals2/signal.hpp> #include <boost/signals2/signal.hpp>
#include <boost/signals2/slot.hpp>
#include <boost/signals2/signal_type.hpp> #include <boost/signals2/signal_type.hpp>
#include <boost/signals2/slot.hpp>
#include "Function.h" #include "Function.h"
#include <boost/bind/bind.hpp>
using namespace boost::placeholders;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -51,8 +49,8 @@
#define SLOT(a) BOOST_STRINGIZE(a) #define SLOT(a) BOOST_STRINGIZE(a)
#define SIGNAL(a) BOOST_STRINGIZE(a) #define SIGNAL(a) BOOST_STRINGIZE(a)
#define _ULIB_DETAIL_SIGNAL_EMIT(_name,...) \ #define _ULIB_DETAIL_SIGNAL_EMIT(_name, ...) \
static BOOST_AUTO(sig,this->findOrAddSignal(&_name)); \ static BOOST_AUTO(sig, this->findOrAddSignal(&_name)); \
sig->operator()(__VA_ARGS__); sig->operator()(__VA_ARGS__);
/** /**
@@ -66,103 +64,105 @@
* // cast automatico // * // cast automatico //
* static BOOST_AUTO(sig,this->findOrAddSignal(&Ob1::V0)); * static BOOST_AUTO(sig,this->findOrAddSignal(&Ob1::V0));
* sig->operator()(); * sig->operator()();
*/ */
#define ULIB_SIGNAL_EMIT(_name,...) _ULIB_DETAIL_SIGNAL_EMIT(_name,__VA_ARGS__) #define ULIB_SIGNAL_EMIT(_name, ...) \
_ULIB_DETAIL_SIGNAL_EMIT(_name, __VA_ARGS__)
namespace uLib { namespace uLib {
// A boost::signal wrapper structure /////////////////////////////////////////// // A boost::signal wrapper structure ///////////////////////////////////////////
// TODO ... // TODO ...
typedef boost::signals2::signal_base SignalBase; typedef boost::signals2::signal_base SignalBase;
template <typename T> template <typename T> struct Signal {
struct Signal {
typedef boost::signals2::signal<T> type; typedef boost::signals2::signal<T> type;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
namespace detail { namespace detail {
template <typename FuncT, int arity> struct ConnectSignal {};
template <typename FuncT, int arity> template <typename FuncT> struct ConnectSignal<FuncT, 0> {
struct ConnectSignal {}; static void connect(SignalBase *sigb, FuncT slof,
typename FunctionPointer<FuncT>::Object *receiver) {
template <typename FuncT> typedef
struct ConnectSignal< FuncT, 0 > { typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
static void connect(SignalBase *sigb, FuncT slof, typename FunctionPointer<FuncT>::Object *receiver) { SigT;
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT; reinterpret_cast<SigT *>(sigb)->connect(slof);
reinterpret_cast<SigT*>(sigb)->connect(slof);
} }
}; };
template <typename FuncT> template <typename FuncT> struct ConnectSignal<FuncT, 1> {
struct ConnectSignal< FuncT, 1 > { static void connect(SignalBase *sigb, FuncT slof,
static void connect(SignalBase *sigb, FuncT slof, typename FunctionPointer<FuncT>::Object *receiver) { typename FunctionPointer<FuncT>::Object *receiver) {
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT; typedef
reinterpret_cast<SigT*>(sigb)->connect(boost::bind(slof,receiver)); typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
SigT;
reinterpret_cast<SigT *>(sigb)->connect(boost::bind(slof, receiver));
} }
}; };
template <typename FuncT> template <typename FuncT> struct ConnectSignal<FuncT, 2> {
struct ConnectSignal< FuncT, 2 > { static void connect(SignalBase *sigb, FuncT slof,
static void connect(SignalBase *sigb, FuncT slof, typename FunctionPointer<FuncT>::Object *receiver) { typename FunctionPointer<FuncT>::Object *receiver) {
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT; typedef
reinterpret_cast<SigT*>(sigb)->connect(boost::bind(slof,receiver,_1)); typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
SigT;
reinterpret_cast<SigT *>(sigb)->connect(boost::bind(slof, receiver, _1));
} }
}; };
template <typename FuncT> template <typename FuncT> struct ConnectSignal<FuncT, 3> {
struct ConnectSignal< FuncT, 3 > { static void connect(SignalBase *sigb, FuncT slof,
static void connect(SignalBase *sigb, FuncT slof, typename FunctionPointer<FuncT>::Object *receiver) { typename FunctionPointer<FuncT>::Object *receiver) {
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT; typedef
reinterpret_cast<SigT*>(sigb)->connect(boost::bind(slof,receiver,_1,_2)); typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
SigT;
reinterpret_cast<SigT *>(sigb)->connect(
boost::bind(slof, receiver, _1, _2));
} }
}; };
template <typename FuncT> template <typename FuncT> struct ConnectSignal<FuncT, 4> {
struct ConnectSignal< FuncT, 4 > { static void connect(SignalBase *sigb, FuncT slof,
static void connect(SignalBase *sigb, FuncT slof, typename FunctionPointer<FuncT>::Object *receiver) { typename FunctionPointer<FuncT>::Object *receiver) {
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT; typedef
reinterpret_cast<SigT*>(sigb)->connect(boost::bind(slof,receiver,_1,_2,_3)); typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
SigT;
reinterpret_cast<SigT *>(sigb)->connect(
boost::bind(slof, receiver, _1, _2, _3));
} }
}; };
template <typename FuncT> template <typename FuncT> struct ConnectSignal<FuncT, 5> {
struct ConnectSignal< FuncT, 5 > { static void connect(SignalBase *sigb, FuncT slof,
static void connect(SignalBase *sigb, FuncT slof, typename FunctionPointer<FuncT>::Object *receiver) { typename FunctionPointer<FuncT>::Object *receiver) {
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT; typedef
reinterpret_cast<SigT*>(sigb)->connect(boost::bind(slof,receiver,_1,_2,_3,_4)); typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
SigT;
reinterpret_cast<SigT *>(sigb)->connect(
boost::bind(slof, receiver, _1, _2, _3, _4));
} }
}; };
} // namespace detail
} // detail template <typename FuncT> SignalBase *NewSignal(FuncT f) {
template <typename FuncT>
SignalBase *NewSignal(FuncT f) {
// seems to work wow ! // seems to work wow !
return new Signal<void()>::type; return new Signal<void()>::type;
} }
template <typename FuncT> template <typename FuncT>
void ConnectSignal(SignalBase *sigb, FuncT slof, typename FunctionPointer<FuncT>::Object *receiver) void ConnectSignal(SignalBase *sigb, FuncT slof,
{ typename FunctionPointer<FuncT>::Object *receiver) {
detail::ConnectSignal< FuncT, FunctionPointer<FuncT>::arity >::connect(sigb,slof,receiver); detail::ConnectSignal<FuncT, FunctionPointer<FuncT>::arity>::connect(
sigb, slof, receiver);
} }
} // namespace uLib
} // uLib
#endif // SIGNAL_H #endif // SIGNAL_H

View File

@@ -24,9 +24,8 @@ set( TESTS
set(LIBRARIES set(LIBRARIES
${PACKAGE_LIBPREFIX}Core ${PACKAGE_LIBPREFIX}Core
${PACKAGE_LIBPREFIX}Math ${PACKAGE_LIBPREFIX}Math
${Boost_SERIALIZATION_LIBRARY} Boost::serialization
${Boost_SIGNALS_LIBRARY} Boost::program_options
${Boost_PROGRAM_OPTIONS_LIBRARY}
${ROOT_LIBRARIES} ${ROOT_LIBRARIES}
) )
uLib_add_tests(${uLib-module}) uLib_add_tests(Core)

View File

@@ -23,13 +23,10 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#include <iostream>
#include <fstream> #include <fstream>
#include <typeinfo> #include <iostream>
#include <string> #include <string>
#include <typeinfo>
#include "Core/Object.h" #include "Core/Object.h"
@@ -37,78 +34,43 @@
using namespace uLib; using namespace uLib;
struct A : Object { struct A : Object {
uLibTypeMacro(A,Object) uLibTypeMacro(A, Object) A() : numa(5552368) {}
A() : numa(5552368) {}
int numa; int numa;
}; };
ULIB_SERIALIZABLE_OBJECT(A) ULIB_SERIALIZABLE_OBJECT(A)
ULIB_SERIALIZE_OBJECT(A,Object) { ULIB_SERIALIZE_OBJECT(A, Object) { ar &AR(numa); }
ar & AR(numa);
}
struct B : virtual Object { struct B : virtual Object {
uLibTypeMacro(B,Object) uLibTypeMacro(B, Object) B() : numb(5552369) {}
B() : numb(5552369) {}
int numb; int numb;
}; };
ULIB_SERIALIZABLE_OBJECT(B) ULIB_SERIALIZABLE_OBJECT(B)
ULIB_SERIALIZE_OBJECT(B,Object) { ar & AR(numb); } ULIB_SERIALIZE_OBJECT(B, Object) { ar &AR(numb); }
struct C : B { struct C : B {
uLibTypeMacro(C,B) uLibTypeMacro(C, B) C() : numc(5552370) {}
C() : numc(5552370) {}
int numc; int numc;
}; };
ULIB_SERIALIZABLE_OBJECT(C) ULIB_SERIALIZABLE_OBJECT(C)
ULIB_SERIALIZE_OBJECT(C,B) { ar & AR(numc); } ULIB_SERIALIZE_OBJECT(C, B) { ar &AR(numc); }
struct D : A,B { struct D : A, B {
uLibTypeMacro(D,A,B) uLibTypeMacro(D, A, B)
D() : numd(5552371) {} D()
: numd(5552371) {}
int numd; int numd;
}; };
ULIB_SERIALIZABLE_OBJECT(D) ULIB_SERIALIZABLE_OBJECT(D)
ULIB_SERIALIZE_OBJECT(D,A,B) { ar & AR(numd); } ULIB_SERIALIZE_OBJECT(D, A, B) { ar &AR(numd); }
int main() {
A o;
main() {
A o; o.init_properties();
Archive::xml_oarchive(std::cout) << NVP(o); Archive::xml_oarchive(std::cout) << NVP(o);
} }

View File

@@ -23,20 +23,16 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#include <iostream>
#include <fstream> #include <fstream>
#include <iostream>
#include "Core/Object.h"
#include "Core/Archives.h" #include "Core/Archives.h"
#include "Core/Object.h"
#include "testing-prototype.h" #include "testing-prototype.h"
using namespace uLib; using namespace uLib;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -45,49 +41,41 @@ using namespace uLib;
struct V3f { struct V3f {
float x,y,z; float x, y, z;
V3f() V3f() { x = y = z = 0; }
{ x = y = z =0; }
V3f(float x, float y, float z) : V3f(float x, float y, float z) : x(x), y(y), z(z) {}
x(x), y(y), z(z) {}
template <class Archive> template <class Archive> void serialize(Archive &ar, unsigned int v) {
void serialize (Archive &ar,unsigned int v) { ar & "<" & NVP(x) & NVP(y) & NVP(z) & ">";
ar
& "<" & NVP(x) & NVP(y) & NVP(z) & ">";
} }
}; };
ULIB_CLASS_EXPORT_KEY(V3f); ULIB_CLASS_EXPORT_KEY(V3f);
ULIB_CLASS_EXPORT_IMPLEMENT(V3f); ULIB_CLASS_EXPORT_IMPLEMENT(V3f);
inline std::ostream &operator<<(std::ostream &o, const V3f &v) {
inline std::ostream &
operator <<(std::ostream &o, const V3f &v) {
Archive::hrt_oarchive(o) << v; Archive::hrt_oarchive(o) << v;
return o; return o;
} }
inline std::istream & inline std::istream &operator>>(std::istream &is, V3f &v) {
operator >>(std::istream &is, V3f &v) {
Archive::hrt_iarchive(is) >> v; Archive::hrt_iarchive(is) >> v;
return is; return is;
} }
int test_V3f() { int test_V3f() {
// testing human readble archive with simple serializable structure // // testing human readble archive with simple serializable structure //
V3f v1(1,2,3),v2,v3,v4; V3f v1(1, 2, 3), v2, v3, v4;
std::cout << "v --> " << v1 << "\n"; std::cout << "v --> " << v1 << "\n";
std::stringstream ss; ss << v1; std::stringstream ss;
ss << v1;
std::cout << "ss.v --> " << ss.str() << "\n"; std::cout << "ss.v --> " << ss.str() << "\n";
Archive::hrt_iarchive ar(ss); ar >> v2; Archive::hrt_iarchive ar(ss);
ar >> v2;
std::cout << "v2 --> " << v2 << "\n"; std::cout << "v2 --> " << v2 << "\n";
std::stringstream("<2 3 4>") >> v3; std::stringstream("<2 3 4>") >> v3;
@@ -98,10 +86,6 @@ int test_V3f() {
return (1); return (1);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -109,70 +93,56 @@ int test_V3f() {
// OBJECT SERIALIZATION // // OBJECT SERIALIZATION //
class A : public virtual Object { class A : public virtual Object {
uLibTypeMacro(A,Object) uLibTypeMacro(A, Object) ULIB_SERIALIZE_ACCESS public : A() : m_a(5552368) {}
ULIB_SERIALIZE_ACCESS
public:
A() : m_a(5552368) {}
properties() { void init_properties();
std::string p_a; std::string p_a;
};
uLibRefMacro (a,int); uLibRefMacro(a, int);
private: private:
int m_a; int m_a;
}; };
void A::init_properties() { void A::init_properties() { p_a = "A property string"; }
$_init();
$$.p_a = "A property string";
}
ULIB_SERIALIZABLE_OBJECT(A) ULIB_SERIALIZABLE_OBJECT(A)
ULIB_SERIALIZE_OBJECT(A,Object) { ULIB_SERIALIZE_OBJECT(A, Object) {
ar ar & "Object A : " & "--> m_a = " & AR(m_a) & "\n" & "Object A properties: " &
& "Object A : " "---> p_a = " & AR(p_a) & "\n";
& "--> m_a = " & AR(m_a)
& "\n";
} }
ULIB_SERIALIZE_OBJECT_PROPS(A) {
ar
& "Object A properties: "
& "---> p_a = " & AR(p_a) & "\n";
}
int testing_xml_class() { int testing_xml_class() {
A a; a.init_properties(); A a;
a.init_properties();
{ {
std::ofstream file("test.xml"); std::ofstream file("test.xml");
Archive::xml_oarchive(file) << NVP(a); Archive::xml_oarchive(file) << NVP(a);
} }
a.a() = 0; a.a() = 0;
a.$$.p_a = "zero string"; a.p_a = "zero string";
{ {
std::ifstream file("test.xml"); std::ifstream file("test.xml");
Archive::xml_iarchive(file) >> NVP(a); Archive::xml_iarchive(file) >> NVP(a);
} }
Archive::xml_oarchive(std::cout) << NVP(a); Archive::xml_oarchive(std::cout) << NVP(a);
return ( a.a() == 5552368 && a.$$.p_a == "A property string" ); return (a.a() == 5552368 && a.p_a == "A property string");
} }
int testing_hrt_class() { int testing_hrt_class() {
A a; a.init_properties(); A a;
a.init_properties();
{ {
std::ofstream file("test.xml"); std::ofstream file("test.xml");
Archive::hrt_oarchive(file) << NVP(a); Archive::hrt_oarchive(file) << NVP(a);
} }
a.a() = 0; a.a() = 0;
a.$$.p_a = "zero string"; a.p_a = "zero string";
{ {
// ERRORE FIX ! // ERRORE FIX !
// std::ifstream file("test.xml"); // std::ifstream file("test.xml");
@@ -180,33 +150,15 @@ int testing_hrt_class() {
} }
Archive::hrt_oarchive(std::cout) << NVP(a); Archive::hrt_oarchive(std::cout) << NVP(a);
return ( a.a() == 5552368 && a.$$.p_a == "A property string" ); return (a.a() == 5552368 && a.p_a == "A property string");
} }
int main() { int main() {
BEGIN_TESTING(Serialize Test); BEGIN_TESTING(Serialize Test);
TEST1( test_V3f() ); TEST1(test_V3f());
TEST1( testing_xml_class() ); TEST1(testing_xml_class());
// testing_hrt_class(); ///// << ERRORE in HRT with properties // testing_hrt_class(); ///// << ERRORE in HRT with properties
END_TESTING; END_TESTING;
} }

View File

@@ -23,16 +23,11 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#include <iostream> #include <iostream>
#include "testing-prototype.h" #include "testing-prototype.h"
#include <Core/StaticInterface.h> #include <Core/StaticInterface.h>
namespace uLib { namespace uLib {
//// INTERFACE TO COMPLEX CLASS ///// //// INTERFACE TO COMPLEX CLASS /////
@@ -40,73 +35,61 @@ namespace uLib {
namespace Interface { namespace Interface {
struct Test { struct Test {
MAKE_TRAITS MAKE_TRAITS
template<class Self> void check_structural() { template <class Self> void check_structural() {
uLibCheckFunction(Self,test,bool,int,float); uLibCheckFunction(Self, test, bool, int, float);
uLibCheckMember(Self,testmemb,int); uLibCheckMember(Self, testmemb, int);
} }
}; };
} } // namespace Interface
struct Test { struct Test {
bool test(int i, float f){} bool test(int i, float f) { return true; }
int testmemb; int testmemb;
}; };
//// INTERFAC TO SIMPLE CLASS /////////// //// INTERFAC TO SIMPLE CLASS ///////////
namespace Interface { namespace Interface {
struct Simple { struct Simple {
MAKE_TRAITS MAKE_TRAITS
template<class Self> void check_structural() { template <class Self> void check_structural() {
uLibCheckMember(Self,memb1,int); uLibCheckMember(Self, memb1, int);
uLibCheckMember(Self,memb2,float); uLibCheckMember(Self, memb2, float);
} }
}; };
} } // namespace Interface
struct Simple { struct Simple {
int memb1; int memb1;
float memb2; float memb2;
}; };
///////////////////////// /////////////////////////
template <class T> template <class T> class UseTest {
class UseTest {
public: public:
UseTest() { UseTest() {
Interface::IsA<T,Interface::Test>(); Interface::IsA<T, Interface::Test>();
T t; T t;
int i; float f; int i;
t.test(i,f); float f;
t.test(i, f);
} }
}; };
template <class T> template <class T> class UseSimple {
class UseSimple {
public: public:
UseSimple() { UseSimple() { Interface::IsA<T, Interface::Simple>(); }
Interface::IsA<T,Interface::Simple>();
}
}; };
} // namespace uLib
int main() {
}
int main()
{
BEGIN_TESTING(Static Interface); BEGIN_TESTING(Static Interface);
uLib::UseTest<uLib::Test> u; uLib::UseTest<uLib::Test> u;
uLib::UseSimple<uLib::Simple> s; uLib::UseSimple<uLib::Simple> s;
END_TESTING; END_TESTING;
} }

View File

@@ -5,3 +5,8 @@ set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Detectors PARENT_SCOPE)
install(FILES ${HEADERS} install(FILES ${HEADERS}
DESTINATION ${INSTALL_INC_DIR}/Detectors) DESTINATION ${INSTALL_INC_DIR}/Detectors)
if(BUILD_TESTING)
include(uLibTargetMacros)
add_subdirectory(testing)
endif()

View File

@@ -1,18 +1,15 @@
# TESTS # TESTS
set( TESTS set( TESTS
GDMLSolidTest # GDMLSolidTest
HierarchicalEncodingTest HierarchicalEncodingTest
) )
#set(LIBRARIES set(LIBRARIES
# ${PACKAGE_LIBPREFIX}Core ${PACKAGE_LIBPREFIX}Core
# ${PACKAGE_LIBPREFIX}Math ${PACKAGE_LIBPREFIX}Math
# ${PACKAGE_LIBPREFIX}Detectors Boost::serialization
# ${Boost_SERIALIZATION_LIBRARY} Boost::program_options
# ${Boost_SIGNALS_LIBRARY} Eigen3::Eigen
# ${Boost_PROGRAM_OPTIONS_LIBRARY} ${ROOT_LIBRARIES}
# ${Eigen_LIBRARY} )
# ${Geant4_LIBRARIES} uLib_add_tests(Detectors)
# ${ROOT_LIBRARIES}
#)
uLib_add_tests(${uLib-module})

View File

@@ -1,35 +0,0 @@
# SUBDIRS = .
include $(top_srcdir)/Common.am
DISTSOURCES = vtkviewport.cpp main.cpp
DISTHEADERS_MOC =
DISTHEADERS_NO_MOC =
FORMS = vtkviewport.ui
FORMHEADERS = $(FORMS:.ui=.h)
MOC_CC = $(FORMS:.ui=.moc.cpp) $(DISTHEADERS_MOC:.h=.moc.cpp)
bin_PROGRAMS = QTVtkViewport
BUILT_SOURCES = $(FORMHEADERS) $(MOC_CC)
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = $(FORMS)
QTVtkViewport_SOURCES = $(DISTSOURCES) $(DISTHEADERS_MOC) $(DISTHEADERS_NO_MOC)
nodist_QTVtkViewport_SOURCES = $(MOC_CC)
QTVtkViewport_LDADD = $(top_srcdir)/libmutom.la
.ui.h: $(FORMS)
$(UIC) -o ui_$@ $<
.ui.hpp: $(FORMS_HPP)
$(UIC) -o $@ $<
.h.moc.cpp:
$(MOC) -o $@ $<
SUFFIXES = .h .ui .moc.cpp

View File

@@ -1,18 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2012-08-30T18:59:53
#
#-------------------------------------------------
QT += core gui
TARGET = QVTKViewport2
TEMPLATE = app
SOURCES += main.cpp\
vtkviewport.cpp
HEADERS += vtkviewport.h
FORMS += vtkviewport.ui

View File

@@ -1,453 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.4.1, 2012-09-03T09:43:56. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QString" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">System</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">1</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.7.4 for GCC (Qt SDK) Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/andrea/devel/MuonTomography/mutom/uLib/trunk/src/Gui/Qt/QVTKViewport2</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">3</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.7.4 for GCC (Qt SDK) Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/andrea/devel/MuonTomography/mutom/uLib/trunk/src/Gui/Qt/QVTKViewport2</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">3</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.7.0 in PATH (System) Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/andrea/devel/MuonTomography/mutom/uLib/trunk/src/Gui/Qt/QVTKViewport2</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">4</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.7.0 in PATH (System) Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/andrea/devel/MuonTomography/mutom/uLib/trunk/src/Gui/Qt/QVTKViewport2</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">4</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.4">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.7.0 (System) Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/andrea/devel/MuonTomography/mutom/uLib/trunk/src/Gui/Qt/QVTKViewport2</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">5</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.5">
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.gdb</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.7.0 (System) Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/andrea/devel/MuonTomography/mutom/uLib/trunk/src/Gui/Qt/QVTKViewport2</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">5</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">6</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Project.UseGlobal">true</value>
<value type="bool" key="Analyzer.Project.UseGlobal">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">false</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">false</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
</valuelist>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">QVTKViewport2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">QVTKViewport2.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
<value type="QString">{f8bb0047-7f6e-45df-9cc8-e746abebf883}</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">10</value>
</data>
</qtcreator>

View File

@@ -1,38 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#include <QtGui/QApplication>
#include "vtkviewport.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
VtkViewport w;
w.show();
return a.exec();
}

View File

@@ -1,41 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#include "vtkviewport.h"
#include "ui_vtkviewport.h"
VtkViewport::VtkViewport(QWidget *parent) :
QWidget(parent),
ui(new Ui::VtkViewport)
{
ui->setupUi(this);
}
VtkViewport::~VtkViewport()
{
delete ui;
}

View File

@@ -1,49 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef VTKVIEWPORT_H
#define VTKVIEWPORT_H
#include <QWidget>
namespace Ui {
class VtkViewport;
}
class VtkViewport : public QWidget
{
Q_OBJECT
public:
explicit VtkViewport(QWidget *parent = 0);
~VtkViewport();
private:
Ui::VtkViewport *ui;
};
#endif // VTKVIEWPORT_H

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VtkViewport</class>
<widget class="QWidget" name="VtkViewport">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>580</width>
<height>536</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>140</x>
<y>170</y>
<width>161</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Hello World !</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -54,7 +54,8 @@ install(TARGETS ${libname}
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Math) install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Math)
# TESTING if(BUILD_TESTING)
# include(uLibTargetMacros) include(uLibTargetMacros)
# add_subdirectory(testing) add_subdirectory(testing)
endif()

View File

@@ -23,18 +23,16 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#include "Math/Accumulator.h" #include "Math/Accumulator.h"
#include "testing-prototype.h" #include "testing-prototype.h"
#include <TRandom.h> #include <TRandom.h>
#include <iostream>
#include <vector>
// #include <boost/accumulators/framework/accumulator_set.hpp>
//#include <boost/accumulators/framework/accumulator_set.hpp> // #include <boost/accumulators/statistics/count.hpp>
//#include <boost/accumulators/statistics/count.hpp> // #include <boost/accumulators/accumulators.hpp>
//#include <boost/accumulators/accumulators.hpp>
using namespace uLib; using namespace uLib;
@@ -42,68 +40,72 @@ int test_ABTrim() {
Accumulator_ABTrim<float> acc; Accumulator_ABTrim<float> acc;
acc.SetABTrim(1,1); acc.SetABTrim(1, 1);
std::vector<float> v; std::vector<float> v;
for(float tmpf : {1,5,5,5,300}) v.push_back(tmpf); for (float tmpf : {1, 5, 5, 5, 300})
//v << 1,5,5,5,300; v.push_back(tmpf);
// v << 1,5,5,5,300;
for(std::vector<float>::iterator itr=v.begin(); itr<v.end(); itr++) for (std::vector<float>::iterator itr = v.begin(); itr < v.end(); itr++)
acc += *itr; acc += *itr;
// TODO missing operator << // TODO missing operator <<
//std::cout << "Accumulating Trim(1,1) vector: " // std::cout << "Accumulating Trim(1,1) vector: "
// << v << " ... out = " << acc() << "\n"; // << v << " ... out = " << acc() << "\n";
return( acc() == 15.0 ); return (acc() == 15.0);
} }
int test_Mean() { int test_Mean() {
Accumulator_Mean<float> mean; Accumulator_Mean<float> mean;
TRandom rnd; TRandom rnd;
const int c = 10000000; const int c = 10000000;
std::vector<float> v; std::vector<float> v;
v.reserve(c); v.reserve(c);
for(int i=0;i<c;++i) v.push_back( rnd.Gaus(2000,5) ); for (int i = 0; i < c; ++i)
v.push_back(rnd.Gaus(2000, 5));
float m = 0; float m = 0;
for(int i=0;i<c;++i) m += v[i]; for (int i = 0; i < c; ++i)
m += v[i];
m /= c; m /= c;
std::cout << "simple mean: " << m << "\n"; std::cout << "simple mean: " << m << "\n";
for(int i=0;i<c;++i) mean(v[i]); for (int i = 0; i < c; ++i)
mean(v[i]);
std::cout << "mean pass: " << mean() << "\n"; std::cout << "mean pass: " << mean() << "\n";
mean.AddPass(); mean.AddPass();
for(int i=0;i<c;++i) mean(v[i]); for (int i = 0; i < c; ++i)
mean(v[i]);
std::cout << "mean pass: " << mean() << "\n"; std::cout << "mean pass: " << mean() << "\n";
mean.AddPass(); mean.AddPass();
for(int i=0;i<c;++i) mean(v[i]); for (int i = 0; i < c; ++i)
mean(v[i]);
std::cout << "mean pass: " << mean() << "\n"; std::cout << "mean pass: " << mean() << "\n";
mean.AddPass(); mean.AddPass();
for(int i=0;i<c;++i) mean(v[i]); for (int i = 0; i < c; ++i)
mean(v[i]);
std::cout << "mean pass: " << mean() << "\n"; std::cout << "mean pass: " << mean() << "\n";
mean.AddPass(); mean.AddPass();
for(int i=0;i<c;++i) mean(v[i]); for (int i = 0; i < c; ++i)
mean(v[i]);
std::cout << "mean pass: " << mean() << "\n"; std::cout << "mean pass: " << mean() << "\n";
mean.AddPass(); mean.AddPass();
for(int i=0;i<c;++i) mean(v[i]); for (int i = 0; i < c; ++i)
mean(v[i]);
std::cout << "mean pass: " << mean() << "\n"; std::cout << "mean pass: " << mean() << "\n";
mean.AddPass(); mean.AddPass();
for(int i=0;i<c;++i) mean(v[i]); for (int i = 0; i < c; ++i)
mean(v[i]);
std::cout << "mean pass: " << mean() << "\n"; std::cout << "mean pass: " << mean() << "\n";
return 1;
} }
int main(void) { int main(void) {
BEGIN_TESTING(Accumulator); BEGIN_TESTING(Accumulator);
//TEST1( test_ABTrim() ); // TEST1( test_ABTrim() );
test_Mean(); test_Mean();
END_TESTING; END_TESTING;

View File

@@ -17,6 +17,8 @@ set(TESTS
set(LIBRARIES set(LIBRARIES
${PACKAGE_LIBPREFIX}Core ${PACKAGE_LIBPREFIX}Core
${PACKAGE_LIBPREFIX}Math ${PACKAGE_LIBPREFIX}Math
Boost::serialization
Eigen3::Eigen
) )
uLib_add_tests(Math) uLib_add_tests(Math)

View File

@@ -23,28 +23,23 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#include "testing-prototype.h" #include "testing-prototype.h"
#include "Math/TriangleMesh.h" #include "Math/TriangleMesh.h"
#include <iostream>
using namespace uLib; using namespace uLib;
int main() int main() {
{
BEGIN_TESTING(Triangle Mesh); BEGIN_TESTING(Triangle Mesh);
TriangleMesh mesh; TriangleMesh mesh;
mesh.AddPoint(Vector3f(0,0,0)); mesh.AddPoint(Vector3f(0, 0, 0));
mesh.AddPoint(Vector3f(0,1,0)); mesh.AddPoint(Vector3f(0, 1, 0));
mesh.AddPoint(Vector3f(1,0,0)); mesh.AddPoint(Vector3f(1, 0, 0));
mesh.AddTriangle(Vector3i(0,1,2));
mesh.AddTriangle(Vector3i(0, 1, 2));
mesh.PrintSelf(std::cout); mesh.PrintSelf(std::cout);

View File

@@ -23,129 +23,114 @@
//////////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////////*/
#include "Math/StructuredGrid.h"
#include "Math/VoxRaytracer.h" #include "Math/VoxRaytracer.h"
#include "Math/StructuredGrid.h"
#include "testing-prototype.h" #include "testing-prototype.h"
#include <iostream>
using namespace uLib; using namespace uLib;
int Vector4f0(Vector4f c) {
int Vector4f0(Vector4f c)
{
c(3) = 0; c(3) = 0;
if ( fabs(c(0)) < 0.001 && fabs(c(1)) < 0.001 && fabs(c(2)) < 0.001 ) if (fabs(c(0)) < 0.001 && fabs(c(1)) < 0.001 && fabs(c(2)) < 0.001)
return 0; return 0;
else else
return 1; return 1;
} }
//bool Comapare(const &t1, const T2 &t2) // bool Comapare(const &t1, const T2 &t2)
//{ //{
// int out = 0; // int out = 0;
// out += t1.vox_id != t2.vox_id; // out += t1.vox_id != t2.vox_id;
// out += (fabs(t1.L) - fabs(t2.L)) > 0.001; // out += (fabs(t1.L) - fabs(t2.L)) > 0.001;
// return out == 0; // return out == 0;
//} // }
typedef VoxRaytracer Raytracer; typedef VoxRaytracer Raytracer;
int main() int main() {
{
BEGIN_TESTING(Math VoxRaytracer); BEGIN_TESTING(Math VoxRaytracer);
StructuredGrid img(Vector3i(2,2,2)); StructuredGrid img(Vector3i(2, 2, 2));
img.SetSpacing(Vector3f(2,2,2)); img.SetSpacing(Vector3f(2, 2, 2));
img.SetPosition(Vector3f(-2,0,-2)); img.SetPosition(Vector3f(-2, 0, -2));
{ {
HLine3f line; HLine3f line;
line.origin << 0.1, 4.1, 0.1, 1; line.origin << 0.1, 4.1, 0.1, 1;
line.direction << 0.1, -0.1, 0.1,0; line.direction << 0.1, -0.1, 0.1, 0;
Raytracer rt(img); Raytracer rt(img);
HPoint3f pt; HPoint3f pt;
TEST1( rt.GetEntryPoint(line,pt) ); TEST1(rt.GetEntryPoint(line, pt));
TEST0( Vector4f0( pt - HPoint3f(0.2,4,0.2) ) ); TEST0(Vector4f0(pt - HPoint3f(0.2, 4, 0.2)));
} }
{ {
HLine3f line; HLine3f line;
line.origin << 4,0,4, 1; line.origin << 4, 0, 4, 1;
line.direction << -0.1, 0.1, -0.1, 0; line.direction << -0.1, 0.1, -0.1, 0;
Raytracer rt(img); Raytracer rt(img);
HPoint3f pt; HPoint3f pt;
TEST1( rt.GetEntryPoint(line,pt) ); TEST1(rt.GetEntryPoint(line, pt));
TEST0( Vector4f0( pt - HPoint3f(2,2,2) ) ); TEST0(Vector4f0(pt - HPoint3f(2, 2, 2)));
} }
{ // Test a point inside image // { // Test a point inside image //
StructuredGrid img(Vector3i(4,4,4)); StructuredGrid img(Vector3i(4, 4, 4));
img.SetSpacing(Vector3f(2,2,2)); img.SetSpacing(Vector3f(2, 2, 2));
img.SetPosition(Vector3f(-4,-4,-4)); img.SetPosition(Vector3f(-4, -4, -4));
Raytracer ray(img); Raytracer ray(img);
HPoint3f pt; HPoint3f pt;
HLine3f line; HLine3f line;
line.origin = HPoint3f(-3,-3,-3); line.origin = HPoint3f(-3, -3, -3);
// line.direction = HVector3f(1,1,1); // // line.direction = HVector3f(1,1,1); //
TEST1( ray.GetEntryPoint(line,pt) ); TEST1(ray.GetEntryPoint(line, pt));
TEST1( pt == HPoint3f(-3,-3,-3) ); TEST1(pt == HPoint3f(-3, -3, -3));
Raytracer::RayData rdata = ray.TraceBetweenPoints(HPoint3f(-3,-3,-3), HPoint3f(3,3,3)); Raytracer::RayData rdata =
for(const Raytracer::RayData::Element &el : rdata.Data()) ray.TraceBetweenPoints(HPoint3f(-3, -3, -3), HPoint3f(3, 3, 3));
{ for (const Raytracer::RayData::Element &el : rdata.Data()) {
std::cout << " " << el.vox_id << " , " << el.L << "\n"; std::cout << " " << el.vox_id << " , " << el.L << "\n";
} }
} }
{ {
HPoint3f pt1(1,-0.5,1); HPoint3f pt1(1, -0.5, 1);
HPoint3f pt2(1,4.5,1); HPoint3f pt2(1, 4.5, 1);
Raytracer rt(img); Raytracer rt(img);
Raytracer::RayData ray = rt.TraceBetweenPoints(pt1,pt2); Raytracer::RayData ray = rt.TraceBetweenPoints(pt1, pt2);
TEST1( ray.Data().size() == 2 ); TEST1(ray.Data().size() == 2);
TEST1( ray.Data().at(0).vox_id == 6 ); TEST1(ray.Data().at(0).vox_id == 6);
TEST1( ray.Data().at(1).vox_id == 7 ); TEST1(ray.Data().at(1).vox_id == 7);
ray.PrintSelf(std::cout); ray.PrintSelf(std::cout);
} }
{ {
HPoint3f pt1(5,1,1); HPoint3f pt1(5, 1, 1);
HPoint3f pt2(-3,1,1); HPoint3f pt2(-3, 1, 1);
Raytracer rt(img); Raytracer rt(img);
Raytracer::RayData ray = rt.TraceBetweenPoints(pt1,pt2); Raytracer::RayData ray = rt.TraceBetweenPoints(pt1, pt2);
TEST1( ray.Data().size() == 2 ); TEST1(ray.Data().size() == 2);
TEST1( ray.Data().at(0).vox_id == 6 ); TEST1(ray.Data().at(0).vox_id == 6);
TEST1( ray.Data().at(1).vox_id == 4 ); TEST1(ray.Data().at(1).vox_id == 4);
ray.PrintSelf(std::cout); ray.PrintSelf(std::cout);
} }
{ {
HPoint3f pt1(1,1,1); HPoint3f pt1(1, 1, 1);
HPoint3f pt2(-1,3,-1); HPoint3f pt2(-1, 3, -1);
Raytracer rt(img); Raytracer rt(img);
Raytracer::RayData ray = rt.TraceBetweenPoints(pt1,pt2); Raytracer::RayData ray = rt.TraceBetweenPoints(pt1, pt2);
TEST1( ray.Data().size() == 4 ); TEST1(ray.Data().size() == 4);
TEST1( ray.Data().at(0).vox_id == 6 ); TEST1(ray.Data().at(0).vox_id == 6);
TEST1( ray.Data().at(1).vox_id == 4 ); TEST1(ray.Data().at(1).vox_id == 4);
TEST1( ray.Data().at(2).vox_id == 5 ); TEST1(ray.Data().at(2).vox_id == 5);
TEST1( ray.Data().at(3).vox_id == 1 ); TEST1(ray.Data().at(3).vox_id == 1);
ray.PrintSelf(std::cout); ray.PrintSelf(std::cout);
} }
END_TESTING END_TESTING
} }

View File

@@ -62,4 +62,7 @@ install(TARGETS ${libname}
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Root) install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Root)
if(BUILD_TESTING)
include(uLibTargetMacros)
add_subdirectory(testing)
endif()

View File

@@ -8,9 +8,8 @@ set(LIBRARIES
${PACKAGE_LIBPREFIX}Core ${PACKAGE_LIBPREFIX}Core
${PACKAGE_LIBPREFIX}Math ${PACKAGE_LIBPREFIX}Math
${PACKAGE_LIBPREFIX}Root ${PACKAGE_LIBPREFIX}Root
${Boost_SERIALIZATION_LIBRARY} Boost::serialization
${Boost_SIGNALS_LIBRARY} Boost::program_options
${Boost_PROGRAM_OPTIONS_LIBRARY}
${ROOT_LIBRARIES} ${ROOT_LIBRARIES}
) )
uLib_add_tests(${uLib-module}) uLib_add_tests(Root)

View File

@@ -36,3 +36,7 @@ install(TARGETS ${libname}
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Vtk) install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR}/Vtk)
if(BUILD_TESTING)
include(uLibTargetMacros)
add_subdirectory(testing)
endif()

View File

@@ -14,5 +14,5 @@ set(LIBRARIES
${PACKAGE_LIBPREFIX}Vtk ${PACKAGE_LIBPREFIX}Vtk
) )
include(${VTK_USE_FILE}) # include(${VTK_USE_FILE})
uLib_add_tests(${uLib-module}) uLib_add_tests(Vtk)

View File

@@ -1,12 +0,0 @@
set(HEADERS
ltktypes.h
ltkmacros.h
ltkdebug.h
)
SET(SOURCES)
set(LIBRARIES)
uLib_add_shared_library(${uLib-module})

View File

@@ -1,111 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef DENSEMATRIX_H
#define DENSEMATRIX_H
#include "templates.h"
#include "Vector.h"
BEGIN_NAMESPACE(ltk)
/* ////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////// MATRIX ////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
C_BEGIN_DECLS
#define LTK_MATRIX_DECLARE_FUNC(Type,ltkType,Class_name,csize,rsize) \
inline Type ltkType##_##Class_name##_get(ltkType m, \
unsigned int c, \
unsigned int r) \
{ \
assert(c + r * csize < csize * rsize); \
return *((ltkType)m + c + r * csize); \
} \
inline void ltkType##_##Class_name##_set(ltkType m, \
unsigned int c, \
unsigned int r, \
Type t) \
{ \
assert (c + r * csize < csize * rsize); \
*((ltkType)m + c + r * csize) = t; \
}
#define LTK_MATRIX_DECLARE(Type,Type_name,csize,rsize) \
typedef Type * Type_name; \
LTK_SIMPLE_ALLOC_FUNC(Type, Type_name,ltk_matrix,csize * rsize) \
LTK_MATRIX_DECLARE_FUNC(Type,Type_name,ltk_matrix,csize,rsize)
C_END_DECLS
#ifdef __cplusplus
template <typename T, unsigned int csize, unsigned int rsize> class ltkDenseMatrix
: public ltkAbstractBuffer< T, csize * rsize >
{
protected:
typedef ltkDenseMatrix<T, csize, rsize> ThisClass;
typedef ltkAbstractBuffer<T, csize * rsize> BaseClass;
public:
ltkDenseMatrix() {}
~ltkDenseMatrix() { }
inline T* getBuffer() {
return (T*)m_buffer;
}
inline const T* getBuffer() const {
return (const T*)m_buffer;
}
ThisClass & operator =(const ThisClass &src) {
if (this != &src) {
CType_ltk_matrix_copy(m_buffer, (const CType) src.getBuffer());
}
}
typedef struct BaseClass::CommaInit CommaInit;
inline CommaInit operator = (T scalar) {
return this->operator <<(scalar);
}
private:
LTK_MATRIX_DECLARE(T,CType, csize, rsize);
T m_buffer [csize * rsize];
};
#endif // __cplusplus
END_NAMESPACE
#endif // DENSEMATRIX_H

View File

@@ -1,6 +0,0 @@
include $(top_srcdir)/Common.am
library_includedir = $(includedir)/libmutom-${PACKAGE_VERSION}/ltk
library_include_HEADERS = ltktypes.h \
ltkmacros.h \
ltkdebug.h

View File

@@ -1,18 +0,0 @@
#include "Object.h"
static const struct _ltkObjectClass {
size_t class_size;
void (* constructor)(struct _Object *);
void (* destructor) (struct _Object *);
int (* GetElement) (struct _Object *);
} _ObjectClassInstance;
const struct _ltkObjectClass *ltkObjectClass = &_ObjectClassInstance;
ltkPointer Object_new(struct _ObjectClass klass)
{
struct _Object *ob = (struct _Object)malloc(klass->class_size);
klass->constructor(ob);
return ob;
}

View File

@@ -1,78 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef OBJECT_H
#define OBJECT_H
#include <stdlib.h> // for std allocator //
#include <string.h> // for memcpy //
#include <assert.h>
#include "templates.h"
BEGIN_NAMESPACE(ltk)
C_BEGIN_DECLS
struct _ltkObject
{
int element;
};
struct _ltkObjectClass {
size_t class_size;
void (* constructor)(struct _ltkObject *);
void (* destructor) (struct _ltkObject *);
int (* GetElement) (struct _ltkObject *);
};
struct _ltkObject *ltk_object_new()
{
return NULL;
}
C_END_DECLS
#ifdef __cplusplus
class Object
{
struct _ltkObject *d;
typedef struct _ltkObject ObjectType;
public:
Object() : d(new ObjectType()) { d->element = 5552368; }
int GetElement() { return d->element; }
};
#endif
END_NAMESPACE
#endif //OBJECT_H

View File

@@ -1,195 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
/*
* File: denseVector.h
* Author: andrea
*
* Created on July 6, 2012, 3:41 PM
*/
#ifndef VECTOR_H
#define VECTOR_H
#include <stdlib.h> // for std allocator //
#include <string.h> // for memcpy //
#include <assert.h>
#include "templates.h"
BEGIN_NAMESPACE(ltk)
/* ////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////// VECTOR ///////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
C_BEGIN_DECLS
#define LTK_VECTOR_DECLARE(Type,Type_name,size) \
typedef Type *Type_name; \
LTK_SIMPLE_ALLOC_FUNC(Type,Type_name,ltk_vector,size) \
inline unsigned int Type_name##_ltk_vector_size() { return size; } \
inline Type Type_name##_ltk_vector_get(Type_name vector, unsigned int i) \
{ return *(vector+i); } \
inline void Type_name##_ltk_vector_set(Type_name vector, unsigned int i, \
Type data) { *(vector+i) = data; }
C_END_DECLS
#ifdef __cplusplus
template <typename T, unsigned int size> class ltkVector
: public ltkAbstractBuffer< T, size >
{
T m_vector [size];
protected:
typedef ltkVector<T, size> ThisClass;
typedef ltkAbstractBuffer<T, size> BaseClass;
public:
ltkVector() {}
ltkVector(const ltkVector<T, size> &copy) {
CType_ltk_vector_copy(m_vector, (const CType) copy.getBuffer());
}
virtual ~ltkVector() { }
inline unsigned int getSize() const {
return size;
}
inline T* getBuffer() {
return (T*)m_vector;
}
inline const T* getBuffer() const {
return (const T*)m_vector;
}
ThisClass & operator =(const ThisClass &src) {
if (this != &src) {
CType_ltk_vector_copy(m_vector, (const CType) src.getBuffer());
}
}
typedef struct BaseClass::CommaInit CommaInit;
inline CommaInit operator = (T scalar) {
return this->operator <<(scalar);
}
// MATH //
inline bool operator ==(const ThisClass &in) {
int test = 0;
for (int i = 0; i < size; ++i) test += this->at(i) != in(i);
return test == 0;
}
inline bool operator !=(const ThisClass &in) {
return !this->operator ==(in);
}
inline void operator +=(const ThisClass &in) {
for (int i = 0; i < size; ++i) this->at(i) += in(i);
}
inline void operator -=(const ThisClass &in) {
for (int i = 0; i < size; ++i) this->at(i) -= in(i);
}
inline void operator *=(const ThisClass &in) {
for (int i = 0; i < size; ++i) this->at(i) *= in(i);
}
inline void operator /=(const ThisClass &in) {
for (int i = 0; i < size; ++i) this->at(i) /= in(i);
}
inline void operator +=(const T t) {
for (int i = 0; i < size; ++i) this->at(i) += t;
}
inline void operator -=(const T t) {
for (int i = 0; i < size; ++i) this->at(i) -= t;
}
inline void operator *=(const T t) {
for (int i = 0; i < size; ++i) this->at(i) *= t;
}
inline void operator /=(const T t) {
for (int i = 0; i < size; ++i) this->at(i) /= t;
}
inline ThisClass & operator + (const ThisClass &in) {
ThisClass *out = new ThisClass();
for (int i = 0; i < size; ++i) out->at(i) = this->at(i) + in(i);
return *out;
}
inline ThisClass & operator - (const ThisClass &in) {
ThisClass *out = new ThisClass();
for (int i = 0; i < size; ++i) out->at(i) = this->at(i) - in(i);
return *out;
}
// fix with constructor and product null element ------------- //
inline T operator * (const ThisClass &in) {
T out = 0;
for (int i = 0; i < size; ++i) out += this->at(i) * in(i);
return out;
}
inline T operator / (const ThisClass &in) {
T out = 0;
for (int i = 0; i < size; ++i) out += this->at(i) / in(i);
return out;
}
// ------------------------------------------------------------- //
inline ThisClass & operator +(const T t) {
ThisClass *out = new ThisClass();
for (int i = 0; i < size; ++i) out->at(i) = this->at(i) + t;
return *out;
}
inline ThisClass & operator -(const T t) {
ThisClass *out = new ThisClass();
for (int i = 0; i < size; ++i) out->at(i) = this->at(i) - t;
return *out;
}
inline ThisClass & operator *(const T t) {
ThisClass *out = new ThisClass();
for (int i = 0; i < size; ++i) out->at(i) = this->at(i) * t;
return *out;
}
inline ThisClass & operator /(const T t) {
ThisClass *out = new ThisClass();
for (int i = 0; i < size; ++i) out->at(i) = this->at(i) / t;
return *out;
}
private:
LTK_VECTOR_DECLARE(T,CType, size)
};
#endif // __cplusplus
END_NAMESPACE // ltk
#endif /* DENSEVECTOR_H */

View File

@@ -1,43 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
/*
* File: comma_init.h
* Author: andrea
*
* Created on May 24, 2012, 3:12 PM
*/
#ifndef CONTAINER_H
#define CONTAINER_H
#include <assert.h>
#endif /* CONTAINER_H */

View File

@@ -1,32 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#include "templates.h"
#include "Vector.h"
#include "DenseMatrix.h"

View File

@@ -1,339 +0,0 @@
//#include <linux/config.h>
#include <linux/version.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <linux/ioctl.h>
#ifdef MODVERSIONS
# include <linux/modversions.h>
#endif
#include <asm/io.h>
#include <asm/system.h>
#include <asm/uaccess.h>
/* methods of the character device */
static int ltkb_open(struct inode *inode, struct file *filp);
static int ltkb_release(struct inode *inode, struct file *filp);
static int ltkb_mmap(struct file *filp, struct vm_area_struct *vma);
static ssize_t ltkb_read(struct file *filp,
char __user *buffer,
size_t count,
loff_t *offp);
static ssize_t ltkb_write(struct file *filp,
const char __user *buffer,
size_t count,
loff_t *offp);
// internal data
// length of the two memory areas
#define NPAGES 16
// pointer to the vmalloc'd area - alway page aligned
static int *vmalloc_area;
// pointer to the kmalloc'd area, rounded up to a page boundary
static int *kmalloc_area;
// original pointer for kmalloc'd area as returned by kmalloc
static void *kmalloc_ptr;
#define BUF_LEN 80
static int Device_Open = 0;
static char Message[BUF_LEN];
/*
* How far did the process reading the message get?
* Useful if the message is larger than the size of the
* buffer we get to fill in device_read.
*/
static char *Message_Ptr;
struct ltkb_dev {
struct cdev cdev; // device structure
struct semaphore semaphore; // lock semaphore for race control
char *message; // message passing from/to user
unsigned int size; // size of data stored
unsigned int acl_key; // user access control
};
struct ltkb_dev *_ltkb_devices; // devices array //
/////// OPEN AND RELEASE ///////////////////////////////////////////////////////
static int ltkb_open(struct inode *inode, struct file *filp)
{
// insert cdev data in dev structure and file->private_data //
struct ltkb_dev *dev;
dev = container_of (inode->i_cdev, struct ltkb_dev, cdev);
// this shares dev for all methods //
filp->private_data = dev;
pr_debug("ltk bridge opened");
return 0;
}
/* character device last close method */
static int ltkb_release(struct inode *inode, struct file *filp)
{
pr_debug("ltk bridge released");
return 0;
}
// -------------------------------------------------------------------------- //
// kmalloc instancer //
int ltkb_kmem(struct file *filp, struct vm_area_struct *vma)
{
int ret;
long length = vma->vm_end - vma->vm_start;
/* check length - do not allow larger mappings than the number of
pages allocated */
if (length > NPAGES * PAGE_SIZE)
return -EIO;
/* map the whole physically contiguous area in one piece */
if ((ret = remap_pfn_range(vma,
vma->vm_start,
virt_to_phys((void *)kmalloc_area) >> PAGE_SHIFT,
length,
vma->vm_page_prot)) < 0) {
return ret;
}
return 0;
}
// vmalloc instancer //
int ltkb_vmem(struct file *filp, struct vm_area_struct *vma)
{
int ret;
long length = vma->vm_end - vma->vm_start;
unsigned long start = vma->vm_start;
char *vmalloc_area_ptr = (char *)vmalloc_area;
unsigned long pfn;
/* check length - do not allow larger mappings than the number of
pages allocated */
if (length > NPAGES * PAGE_SIZE)
return -EIO;
/* loop over all pages, map it page individually */
while (length > 0) {
pfn = vmalloc_to_pfn(vmalloc_area_ptr);
if ((ret = remap_pfn_range(vma, start, pfn, PAGE_SIZE,
PAGE_SHARED)) < 0) {
return ret;
}
start += PAGE_SIZE;
vmalloc_area_ptr += PAGE_SIZE;
length -= PAGE_SIZE;
}
return 0;
}
// mmap function //
static int ltkb_mmap(struct file *filp, struct vm_area_struct *vma)
{
/* at offset 0 we map the vmalloc'd area */
if (vma->vm_pgoff == 0) {
return ltkb_vmem(filp, vma);
}
/* at offset NPAGES we map the kmalloc'd area */
if (vma->vm_pgoff == NPAGES) {
return ltkb_kmem(filp, vma);
}
/* at any other offset we return an error */
return -EIO;
}
////////////// CHAR DEVICE READ/WRITE /////////////////////////////////////////
static ssize_t ltkb_read(struct file *filp, /* see include/linux/fs.h */
char __user *buffer, /* buffer to fill with data */
size_t length, /* length of the buffer */
loff_t * offset)
{
#ifdef _DEBUG
printk(KERN_INFO "device_read(%p,%s,%d)", filp, buffer, (int)length);
#endif
return 0;
}
static ssize_t ltkb_write(struct file *filp,
const char __user *buffer,
size_t length,
loff_t * offset)
{
#ifdef _DEBUG
printk(KERN_INFO "device_write(%p,%s,%d)", filp, buffer, (int)length);
#endif
return 0;
}
// ------------------------------------------------------------------------- //
#define LTKB_IOC_HEADER 'b'
#define LTKB_IOC_RESET _IO(LTKB_IOC_HEADER, 0)
#define LTKB_IOC_PING _IOWR(LTKB_IOC_HEADER, 1, char)
#define LTKB_IOC_MAXNR 1
////////////// IOCTL ///////////////////////////////////////////////////////////
int ltkb_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
char c = 0;
int retval = 0;
/*
* extract the type and number bitfields, and don't decode
* wrong cmds: return ENOTTY (inappropriate ioctl) before access_ok()
*/
if (_IOC_TYPE(cmd) != LTKB_IOC_HEADER) return -ENOTTY;
if (_IOC_NR(cmd) > LTKB_IOC_MAXNR) return -ENOTTY;
// TODO user access control //
switch(cmd) {
case LTKB_IOC_RESET:
if(!capable(CAP_SYS_ADMIN))
return -EPERM;
// TODO free all memory mapping//
break;
case LTKB_IOC_PING:
retval = __get_user(c,(char __user *)arg);
c++;
retval = __put_user(c,(char __user *)arg);
break;
default:
return -ENOTTY;
}
return retval;
}
// ------------------------------------------------------------------------- //
#ifndef LTKB_MAJOR
#define LTKB_MAJOR 0
#endif
#ifndef LTKB_NR_DEVS
#define LTKB_NR_DEVS 4
#endif
#ifndef LTKB_DEVICE_NAME
#define LTKB_DEVICE_NAME "ltkb"
#endif
/* the file operations, i.e. all character device methods */
static struct file_operations ltkb_fops = {
.open = ltkb_open,
.release = ltkb_release,
.read = ltkb_read,
.write = ltkb_write,
.ioctl = ltkb_ioctl,
.mmap = ltkb_mmap,
.owner = THIS_MODULE,
};
static int _ltkb_major_number = LTKB_MAJOR;
// Module init function ////////////////////////////////////////////////////////
static int __init ltkb_init(void)
{
int i,ret = 0;
dev_t dev = 0;
// REGISTER DEVICE //
if(_ltkb_major_number)
{
dev = MKDEV(_ltkb_major_number,0);
ret = register_chrdev_region(dev, LTKB_NR_DEVS, LTKB_DEVICE_NAME);
}
else {
ret = alloc_chrdev_region(&dev, 0, LTKB_NR_DEVS, LTKB_DEVICE_NAME );
_ltkb_major_number = MAJOR(dev);
}
if (ret < 0) {
printk(KERN_WARNING "could not allocate major number %d for ltkb\n",
_ltkb_major_number);
return ret;
}
// ALLOCATE DEVICES //
_ltkb_devices = kmalloc( LTKB_NR_DEVS * sizeof(struct ltkb_dev), GFP_KERNEL );
if(!_ltkb_devices) {
printk(KERN_ERR "error allocating device structure in memory");
return -ENOMEM;
}
memset(_ltkb_devices, 0, LTKB_NR_DEVS * sizeof(struct ltkb_dev));
// SETUP DEVICES //
for (i = 0 ; i < LTKB_NR_DEVS ; i++ )
{
struct ltkb_dev *dev = &_ltkb_devices[i];
int devno = MKDEV(_ltkb_major_number, i);
cdev_init (&dev->cdev, &ltkb_fops);
dev->cdev.owner = THIS_MODULE;
dev->cdev.ops = &ltkb_fops;
ret = cdev_add(&dev->cdev,devno,1);
if(ret) printk(KERN_NOTICE "Error %d adding ltkb%d device", ret, i);
init_MUTEX(&dev->semaphore);
}
printk( KERN_NOTICE "ltk bridge module loaded");
return ret;
}
// module release //
static void __exit ltkb_exit(void)
{
// remove the character deivce //
int i;
dev_t devno = MKDEV(_ltkb_major_number,0);
if(_ltkb_devices)
{
for(i=0;i<LTKB_NR_DEVS;i++)
cdev_del(&_ltkb_devices[i].cdev);
kfree(_ltkb_devices);
}
unregister_chrdev_region(devno,LTKB_NR_DEVS);
printk( KERN_NOTICE "ltk bridge module unloaded");
}
// ------------------------------------------------------------------------ //
//////////////////// Main Module Init ///////////////////
//
module_init(ltkb_init); //
module_exit(ltkb_exit); //
//
MODULE_DESCRIPTION("ltk bridge memory dispatcher"); //
MODULE_AUTHOR("andrea"); //
MODULE_LICENSE("Not licenced yet"); //
//
/////////////////////////////////////////////////////////

View File

@@ -1,40 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#define LTKB_IOC_HEADER 'b'
#define LTKB_IOC_RESET _IO(LTKB_IOC_HEADER, 0)
#define LTKB_IOC_PING _IOWR(LTKB_IOC_HEADER, 1, char)
#define LTKB_IOC_MAXNR 1
int main(void)
{
int fd;
if ((fd=open("ltkb0", O_RDWR|O_SYNC))<0)
{
perror("open");
exit(-1);
}
char buffer[200] = "hello";
write(fd, (void *)&buffer, 6);
char c = 'a';
printf("%c ",c);
ioctl(fd, LTKB_IOC_PING, &c);
printf("%c ",c);
ioctl(fd, LTKB_IOC_PING, &c);
printf("%c\n",c);
close(fd);
return(0);
}

View File

@@ -1,21 +0,0 @@
#!/bin/sh
module="ltkb"
device="ltkb"
mode="664"
/sbin/insmod ./$module.ko $* || exit 1
rm -f ./${device}[0-3]
major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
mknod ./${device}0 c $major 0
mknod ./${device}1 c $major 1
mknod ./${device}2 c $major 2
mknod ./${device}3 c $major 3
group="mutom"
grep -q '^mutom:' /etc/group || group="adm"
chgrp $group ./${device}[0-3]
chmod $mode ./${device}[0-3]

View File

@@ -1,4 +0,0 @@
#include "ltkdebug.h"

View File

@@ -1,105 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef LTKDEBUG_H
#define LTKDEBUG_H
#include "ltkmacros.h"
#include "ltktypes.h"
//! Provide a string for current function, non-concatenatable
#if defined (__GNUC__) || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 19901L)
# define __func_to_string__ ((const char*) (__func__))
#else
# define __func_to_string__ ((const char*) ("???"))
#endif
//! Provide a string for current function in pretty format, non-concatenatable
#if defined (__GNUC__)
# define __pfunc_to_string__ ((const char*) (__PRETTY_FUNCTION__))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 19901L
# define __pfunc_to_string__ ((const char*) (__func__))
#else
# define __pfunc_to_string__ ((const char*) ("???"))
#endif
////////////////////////////////////////////////////////////////////////////////
//// Pragma Messages for debug allerts during compilation /////////////////////
////////////////////////////////////////////////////////////////////////////////
#ifdef PRAGMA_MESSAGES
#define DEBUG_DO_PRAGMA(x) _Pragma (#x)
#else
#define DEBUG_DO_PRAGMA(x) ;
#endif
#define TODO(x) DEBUG_DO_PRAGMA(message ("\n\n [TODO] >> " #x " <<\n"))
#define OPTIMIZE(x) DEBUG_DO_PRAGMA(message ("\n\n [OPTIMIZE] > " #x " <\n"))
#define DUMP(x) DEBUG_DO_PRAGMA(message ("\n\n [DUMP] > " #x " <\n"))
// ------------------------------------------------------------------------ //
C_BEGIN_DECLS
typedef enum
{
LOG_FLAG_ACTIVE = 1 << 0,
LOG_FLAG_FATAL = 1 << 1,
LOG_LEVEL_ERROR = 1 << 2,
LOG_LEVEL_CRITICAL = 1 << 3,
LOG_LEVEL_WARNING = 1 << 4,
LOG_LEVEL_MESSAGE = 1 << 5,
LOG_LEVEL_INFO = 1 << 6,
LOG_LEVEL_DEBUG = 1 << 7,
LOG_LEVEL_ANNOING = 1 << 8,
LOG_LEVEL_PARANOID = 1 << 9
} LogLevelFlags;
void debug_log(
void *handler,
LogLevelFlags flags,
const char *function_name,
const char *message,
...);
C_END_DECLS
#endif // LTKDEBUG_H

View File

@@ -1,61 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
/*
* File: macros.h
* Author: andrea
*
* Created on May 23, 2012, 9:01 AM
*/
#ifndef LTK_MACROS_H
#define LTK_MACROS_H
// C code in headers, while including them from C++
#ifdef __cplusplus
# define C_BEGIN_DECLS extern "C" {
# define C_END_DECLS }
#define BEGIN_NAMESPACE(name) namespace name {
#define END_NAMESPACE }
#else
# define C_BEGIN_DECLS
# define C_END_DECLS
#define BEGIN_NAMESPACE(name)
#define END_NAMESPACE
#endif
#endif /* MACROS_H */

View File

@@ -1,127 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef LTK_TYPE_H
#define LTK_TYPE_H
#include <assert.h>
#include <sys/types.h>
//#include "templates.h"
#include "ltkmacros.h"
#ifdef __cplusplus
# define LTK_TYPECAST(T, Type) static_cast< T >(Type)
#else
# define LTK_TYPECAST(T, Type) ((T)(Type))
#endif
BEGIN_NAMESPACE(ltk)
C_BEGIN_DECLS
/* ////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////// TYPE DEFINITIONS ////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
typedef void * Pointer_t;
typedef id_t Id_t;
typedef size_t Size_t;
#ifndef LTK_DOUBLE_PRECISION
typedef float Real_t;
#else
typedef double Real_t;
#endif
#define LTK_SIGNED_CHAR_MIN LTK_TYPECAST(signed char, 0x80)
#define LTK_SIGNED_CHAR_MAX LTK_TYPECAST(signed char, 0x7f)
#define LTK_UNSIGNED_CHAR_MIN LTK_TYPECAST(unsigned char, 0u)
#define LTK_UNSIGNED_CHAR_MAX LTK_TYPECAST(unsigned char, 0xffu)
#define LTK_SHORT_MIN LTK_TYPECAST(short, 0x8000)
#define LTK_SHORT_MAX LTK_TYPECAST(short, 0x7fff)
#define LTK_UNSIGNED_SHORT_MIN LTK_TYPECAST(unsigned short, 0u)
#define LTK_UNSIGNED_SHORT_MAX LTK_TYPECAST(unsigned short, 0xffffu)
#define LTK_INT_MIN LTK_TYPECAST(int, ~(~0u >> 1))
#define LTK_INT_MAX LTK_TYPECAST(int, ~0u >> 1)
#define LTK_INT8_MIN LTK_TYPECAST(int8_t, 0x80)
#define LTK_INT8_MAX LTK_TYPECAST(int8_t, 0x7f)
#define LTK_INT16_MIN LTK_TYPECAST(int16_t, 0x8000u)
#define LTK_INT16_MAX LTK_TYPECAST(int16_t, 0x7fffu)
#define LTK_UNSIGNED_INT16_MIN LTK_TYPECAST(int16_t, 0u)
#define LTK_UNSIGNED_INT16_MAX LTK_TYPECAST(unsigned int16_t, 0xffffu)
#define LTK_INT32_MIN LTK_TYPECAST(int32_t, 0x80000000u)
#define LTK_INT32_MAX LTK_TYPECAST(int32_t, 0x7fffffffu)
#define LTK_UNSIGNED_INT32_MIN LTK_TYPECAST(unsigned int32_t, 0u)
#define LTK_UNSIGNED_INT32_MAX LTK_TYPECAST(unsigned int32_t, 0xffffffffu)
#define LTK_INT64_MIN LTK_TYPECAST(int64_t, 0x8000000000000000u)
#define LTK_INT64_MAX LTK_TYPECAST(int64_t, 0x7fffffffffffffffu)
#define LTK_UNSIGNED_INT8_MIN LTK_TYPECAST(int8_t, 0u)
#define LTK_UNSIGNED_INT8_MAX LTK_TYPECAST(int8_t, 0xffu)
#define LTK_UNSIGNED_INT64_MIN LTK_TYPECAST(unsigned int64_t, 0u)
#define LTK_UNSIGNED_INT64_MAX LTK_TYPECAST(unsigned int64_t, \
0xffffffffffffffffu)
#define LTK_UNSIGNED_INT_MIN LTK_TYPECAST(unsigned int, 0)
#define LTK_UNSIGNED_INT_MAX LTK_TYPECAST(unsigned int, ~0u)
#define LTK_LONG_MIN LTK_TYPECAST(long, ~(~0ul >> 1))
#define LTK_LONG_MAX LTK_TYPECAST(long, ~0ul >> 1)
#define LTK_UNSIGNED_LONG_MIN LTK_TYPECAST(unsigned long, 0ul)
#define LTK_UNSIGNED_LONG_MAX LTK_TYPECAST(unsigned long, ~0ul)
#define LTK_FLOAT_MIN LTK_TYPECAST(float, -1.0e+38f)
#define LTK_FLOAT_MAX LTK_TYPECAST(float, 1.0e+38f)
#define LTK_DOUBLE_MIN LTK_TYPECAST(double, -1.0e+299)
#define LTK_DOUBLE_MAX LTK_TYPECAST(double, 1.0e+299)
C_END_DECLS
END_NAMESPACE
#endif //TYPE_H

View File

@@ -1,72 +0,0 @@
#include "DenseMatrix.h"
#include "Vector.h"
#include "Object.h"
#include "vectormath/simd/instrset.h"
/* LTK_VECTOR_DECLARE(int,LtkInt4,4) */
/* LTK_MATRIX_DECLARE(int,LtkInt2x2,2,2) */
/* LTK_MATRIX_DECLARE(int,LtkInt4x1,4,1) */
/* LTK_MATRIX_DECLARE(int,LtkInt4x4,4,4) */
int test(int a) { return 0; }
int main(void)
{
// testing dense matrix //
/****************************************************/
/* LtkInt2x2 a; */
/* LtkInt4x1 b; */
/* LtkInt4x4 c; */
/* LtkInt4 v, w; */
/* */
/* v = LtkInt4_ltk_vector_new (); */
/* w = LtkInt4_ltk_vector_new (); */
/* */
/* int i; */
/* for (i = 0; i < LtkInt4_ltk_vector_size (); ++i) */
/* { */
/* LtkInt4_ltk_vector_set (v, i, 0); */
/* LtkInt4_ltk_vector_set (w, i, 3); */
/* } */
/* */
/* printf ("v = "); */
/* for (i = 0; i < 4; ++i) */
/* printf ("%d ", LtkInt4_ltk_vector_get (v, i)); */
/* printf ("\n"); */
/* */
/* printf ("w = "); */
/* for (i = 0; i < 4; ++i) */
/* printf ("%d ", LtkInt4_ltk_vector_get (w, i)); */
/* printf ("\n"); */
/****************************************************/
// testing intrinsics //
printf("INSTRUCTION SET -> %d\n",INSTRSET);
__m128 aligned_float = _mm_setzero_ps();
float *p = &aligned_float;
printf("%f,%f,%f,%f\n",p[0],p[1],p[2],p[3]);
// adder //
__m128 a_1,a_2;
a_1 = _mm_set_ps(3,3,3,3);
a_2 = _mm_set_ps(1,2,3,4);
aligned_float = _mm_add_ps(a_1,a_2);
p = &aligned_float; printf("%f,%f,%f,%f\n",p[0],p[1],p[2],p[3]);
// testing Objects //
//LTK_MATRIX_DECLARE(TypeName, type, r, c);
// Object *ob = New(ObjectClass);
// int el = ObjectClass->GetElement(ob);
return 0;
}

View File

@@ -1,92 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "templates.h"
LtkList ltk_list_new()
{
LtkList list = malloc(sizeof(struct _template_list));
list->size = 0;
list->start = NULL;
list->end = NULL;
return list;
}
void ltk_list_nodepush(LtkList list,LtkListNode node)
{
if(list == NULL) return;
node->next = list->start;
list->start = node;
if(list->end == NULL) list->end = node;
list->size++;
}
LtkListNode ltk_list_get_start(LtkList list)
{
if (list==NULL || list->start==NULL) return NULL;
return list->start;
}
LtkListNode ltk_list_get_end(LtkList list)
{
if (list==NULL || list->end==NULL) return NULL;
return list->end;
}
void ltk_list_remove(LtkList list,LtkListNode node)
{
if (list == NULL || list->start==NULL) return;
struct _template_list_node *node_tofree,*prev;
node_tofree=list->start;
while (node_tofree != node) {
if(node_tofree->next == NULL) return;
prev = node_tofree;
node_tofree = node_tofree->next;
}
if(node_tofree == list->start) list->start = node_tofree->next;
else prev->next = node_tofree->next;
free(node_tofree);
}
void ltk_list_pop_start(LtkList list)
{
if (list==NULL || list->start==NULL) return;
struct _template_list_node *nodetofree;
nodetofree=list->start;
list->start = list->start->next;
free(nodetofree);
}
void ltk_list_pop_end(LtkList list)
{
if (list==NULL || list->end==NULL) return;
struct _template_list_node *iter;
iter=list->start;
if(iter==list->end) {
free(iter);
list->start = list->end = NULL;
}
else {
while(iter->next!=list->end) iter=iter->next;
free(iter->next);
iter->next = NULL;
list->end = iter;
}
list->size--;
}
int ltk_list_get_size(LtkList list)
{
if(list==NULL) return 0;
return list->size;
}
LtkListIterator ltk_list_iterator_new(LtkList list)
{
if(list==NULL || list->start == NULL) return NULL;
return (LtkListIterator)list->start;
}

View File

@@ -1,303 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2012 Andrea Rigoni Garola <andrea.rigoni@pd.infn.it>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or (at
* your option) any later version.
*
* This program 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef TEMPLATES_H
#define TEMPLATES_H
#include <stdlib.h> // for std allocator //
#include <string.h> // for memcpy //
#include <assert.h>
#include "ltkmacros.h" // default environment //
#include "container.h" // TODO !!! //
#include <stdio.h>
/* ////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////// ALLOC FUNCTIONS ///////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
C_BEGIN_DECLS
//inline ltkPointer ltk_malloc(unsigned int size) { return malloc(size); }
//inline void ltk_free (ltkPointer ptr) { free(ptr); }
#define LTK_SIMPLE_ALLOC_FUNC(Type, ltkType, Class_name, size) \
inline ltkType ltkType##_##Class_name##_new() \
{ \
return LTK_TYPECAST(ltkType, malloc(sizeof(Type) * size)); \
} \
inline void ltkType##_##Class_name##_delete(ltkType t) \
{ free(t); } \
inline void ltkType##_##Class_name##_copy(ltkType dst, const ltkType src) \
{ memcpy((ltkPointer)dst, (ltkPointer)src, sizeof(Type) * size ); }
C_END_DECLS
/* ////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////// ABSTRACT C BUFFER /////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
C_BEGIN_DECLS
#define LTK_ABSTRACT_BUFFER_DECLARE_FUNC(Type,ltkType,Class_name,size) \
inline int ltkType##_##Class_name##_size() { return size; } \
inline Type ltkType##_##Class_name##_get(ltkType v, unsigned int c) \
{ assert(c < size); return *((ltkType)m + c); } \
inline void ltkType##_##Class_name##_set(ltkType v, Type t, unsigned int c) \
{ assert(c < size); *((ltkType)m + c) = t; }
// FINIRE !!! //
C_END_DECLS
#ifdef __cplusplus
template <typename T, unsigned int size> class ltkAbstractBuffer
{
typedef ltkAbstractBuffer<T, size> ThisClass;
protected:
typedef T ContentType;
virtual T* getBuffer() = 0;
virtual const T* getBuffer() const = 0;
struct CommaInit
{
inline explicit CommaInit(ltkAbstractBuffer<T, size> *container,float s)
: container(container) {
this->index = 0;
this->container->getBuffer()[0] = s;
}
inline CommaInit & operator, (float s) {
this->index++;
assert(index < size);
this->container->getBuffer()[this->index] = s;
return *this;
}
ltkAbstractBuffer<T, size> *container;
unsigned int index;
};
public:
inline CommaInit operator =(T scalar) {
return CommaInit(this, scalar);
}
inline CommaInit operator <<(T scalar) {
return CommaInit(this, scalar);
}
inline T& at(const unsigned int i) {
return *(this->getBuffer() + i);
}
inline T & operator[](unsigned int i) {
return *(this->getBuffer() + i);
}
inline const T & operator[](unsigned int i) const {
return *(this->getBuffer() + i);
}
inline T & operator()(unsigned int i) {
return *(this->getBuffer() + i);
}
inline const T & operator()(unsigned int i) const {
return *(this->getBuffer() + i);
}
};
#endif // __cplusplus
/* ////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////// ARRAY /////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
// COMING SOON //
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// DO NOT USE ANYTHING AFTER THIS LINE ... EXPERIMENTAL //////////////////
/* ////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////// CIRCULAR BUFFER ///////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/* CIRCULAR BUFFER */
struct _ltk_template_buffer {
void *pos;
void *head;
};
#define LTK_BUFFER_DECLARE(Type, Type_name, size, overlap) \
typedef struct _ltk_template_buffer *Type_name; \
inline Type_name Type_name##_ltk_buffer_new() \
{ Type_name out = (Type_name)ltk_malloc \
(sizeof(Type) * (size + overlap) + 2); \
out->head = (void *)out + 2 + overlap * sizeof(Type); \
out->pos = out->head; \
return out; } \
inline void Type_name##_ltk_buffer_free(Type_name buffer) { ltk_free(buffer); }\
// TO BE CONTINUED.... //
///// LtkPTree ////////
struct _LtkPTreeNode
{
struct _LtkPTreeNode *parent;
};
typedef struct _LtkPTreeNode *LtkPtree;
/*
one way list template usable as FIFO or LIFO by macros
Element must be a pointer to a real allocated object.
*/
// this acts as dummy node, never really instanciated //
struct _template_list_node {
struct _template_list_node *next;
};
typedef struct _template_list_node *LtkListNode;
#define LTK_LIST_HEADER LtkListNode ltk_list_node_next;
struct _template_list {
int size;
struct _template_list_node *start;
struct _template_list_node *end;
};
typedef struct _template_list *LtkList;
typedef struct _template_list_node *LtkListIterator;
LtkList ltk_list_new();
void ltk_list_nodepush(LtkList list,LtkListNode node);
LtkListNode ltk_list_get_start(LtkList list);
LtkListNode ltk_list_get_end(LtkList list);
void ltk_list_remove(LtkList list,LtkListNode node);
void ltk_list_pop_start(LtkList list);
void ltk_list_pop_end(LtkList list);
#define LTK_LIST_DECLARE(Type,Type_name) \
static LtkList (* Type_name##_list_new)(void) = ltk_list_new;\
void (* Type_name##_list_nodepush)(LtkList list, Type *node) = (void (*)(LtkList, Type *))ltk_list_nodepush; \
Type * (* Type_name##_list_get_start)(LtkList list) = (Type *(*)(LtkList))ltk_list_get_start; \
Type * (* Type_name##_list_get_end)(LtkList list) = (Type *(*)(LtkList))ltk_list_get_end; \
void (* Type_name##_list_remove)(LtkList list, Type *node) = (void (*)(LtkList, Type *))ltk_list_remove; \
void (* Type_name##_list_pop_start)(LtkList list) = (void (*)(LtkList))ltk_list_pop_start; \
void (* Type_name##_list_pop_end)(LtkList list) = (void (*)(LtkList))ltk_list_pop_end;
#define LTK_LIST_DECLARE_KEYACCESS(Type,Type_name,KeyType,key_member_name,key_function) \
Type * Type_name##_list_key_lookup(LtkList list, KeyType key) { \
LtkListIterator iter = ltk_list_iterator_new(list); \
while(iter) { \
if (key_function( ((Type *)iter)->key_member_name, key )) \
return (Type *)iter; \
iter = iter->next; } \
return NULL; } \
\
void Type_name##_list_key_remove(LtkList list, KeyType key) { \
LtkListNode node = (LtkListNode)Type_name##_list_key_lookup(list,key); \
if(node) ltk_list_remove(list,node); } \
LtkListIterator ltk_list_iterator_new(LtkList list);
#endif // TEMPLATES_H

View File

@@ -1,117 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
/*
* File: test_comma.h
* Author: andrea
*
* Created on May 24, 2012, 4:47 PM
*/
#ifndef TEST_COMMA_H
#define TEST_COMMA_H
#include <assert.h>
struct Vector3
{
union
{
struct { float x, y, z; };
float data[3];
};
struct CommaAssign;
CommaAssign operator=(float _x)
{
x = _x;
return CommaAssign(this,1);
}
struct CommaAssign
{
Vector3 *vec3;
int index;
explicit CommaAssign(Vector3 *vec3, int index) : vec3(vec3) {
this->index = index;
}
CommaAssign operator, (float f) {
vec3->data[index] = f;
return CommaAssign(vec3, index + 1);
}
};
};
struct Container
{
union
{
struct { float x, y, z; };
float data[3];
};
inline float *getBuffer() {
return this->data;
}
template <typename T, unsigned int size> class CommaAssign
{
private:
T *container;
int index;
public:
inline explicit CommaAssign(T *container, float s) : container(container) {
this->index = 0;
this->container->getBuffer()[0] = s;
}
inline CommaAssign& operator, (float s) {
this->index++;
assert(index < size);
this->container->getBuffer()[this->index] = s;
return *this;
}
};
CommaAssign<Container, 3> operator=(float s) {
return CommaAssign<Container, 3 > (this, s);
}
};
#endif /* TEST_COMMA_H */

View File

@@ -1,37 +0,0 @@
include $(top_srcdir)/Common.am
#AM_DEFAULT_SOURCE_EXT = .cpp
TESTS = LtkDebugTest \
LtkFunctionToStringTest
LDADD = ../../../libmutom-0.1.la
check_PROGRAMS = $(TESTS)
####################################################
# Hybrid c/c++ Ltk Specific tests #
####################################################
check_PROGRAMS += Vector-test
Vector_test_SOURCES = Vector.c
TESTS += Vector-test
check_PROGRAMS += Vector-test-cc
Vector_test_cc_SOURCES = Vector-cc.cpp
TESTS += Vector-test-cc
check_PROGRAMS += Object-test
Object_test_SOURCES = Object.c
TESTS += Object-test
check_PROGRAMS += Object-test-cc
Object_test_cc_SOURCES = Object-cc.cpp
TESTS += Object-test-cc
####################################################
AM_COLOR_TESTS = always

View File

@@ -1,40 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#include "testing-prototype.h"
#include "../Object.h"
using namespace ltk;
int main() {
BEGIN_TESTING(Object - cc);
Object ob;
TEST1( ob.GetElement() == 5552368 );
END_TESTING;
}

View File

@@ -1,11 +0,0 @@
#include "testing-prototype.h"
#include "../Object.h"
int main() {
BEGIN_TESTING(Object);
struct _Object *ob = Object_new(ObjectClass);
END_TESTING;
}

View File

@@ -1,79 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#include "testing-prototype.h"
#include "../Vector.h"
using namespace ltk;
int main() {
BEGIN_TESTING(Vector - cc);
typedef ltkVector<int, 4 > ltkInt4;
ltkInt4 v, w;
v = 1, 2, 3, 4;
w = v;
printf("v -> %d,%d,%d,%d\n", v[0], *(v.getBuffer() + 1), v.at(2), v(3));
// test assign operator
TEST1(v == w);
TEST0(v != w);
// test accessors
TEST1(v[0] == 1);
TEST1(*(v.getBuffer() + 1) == 2);
TEST1(v.at(2) == 3);
TEST1(v(3) == 4);
// setter
w << 1, 4, 9, 16;
TEST1(w[0] == 1);
TEST1(w[1] == 4);
TEST1(w[2] == 9);
TEST1(w[3] == 16);
// math operators
v *= v;
w = 1, 4, 9, 16;
TEST1(v == w);
v /= v;
w = 1, 1, 1, 1;
TEST1(v == w);
v += v;
w = 2, 2, 2, 2;
TEST1(v == w);
v << 1, 1, -1, 1;
w << -1, 1, 1, 1;
TEST0(v * w);
TEST0(v / w);
END_TESTING;
}

View File

@@ -1,14 +0,0 @@
#include <stdio.h>
#include "testing-prototype.h"
#include "../Vector.h"
LTK_VECTOR_DECLARE (float, uFloat4, 4)
int main()
{
BEGIN_TESTING (Vector);
uFloat4 f = uFloat4_ltk_vector_new ();
END_TESTING;
}

View File

@@ -1,37 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#include <stdio.h>
#define BEGIN_TESTING(name) \
static int _fail = 0; \
printf("..:: Testing " #name " ::..\n");
#define TEST1(val) _fail += (val)==0
#define TEST0(val) _fail += (val)!=0
#define END_TESTING return _fail;

View File

@@ -67,9 +67,8 @@ if(ULIB_FOUND)
############################################################################ ############################################################################
# MANUAL INLCLUDE EXTERNAL DEPENDENCIES # MANUAL INLCLUDE EXTERNAL DEPENDENCIES
# ${Boost_SERIALIZATION_LIBRARY} # Boost::serialization
# ${Boost_SIGNALS_LIBRARY} # Boost::program_options
# ${Boost_PROGRAM_OPTIONS_LIBRARY}
# ${Geant4_LIBRARIES} # ${Geant4_LIBRARIES}
# ${ROOT_LIBRARIES} # ${ROOT_LIBRARIES}
# ${VTK_LIBRARIES} # all VTK libs # ${VTK_LIBRARIES} # all VTK libs

View File

@@ -1,24 +0,0 @@
# Makefile example -- scanner and parser.
#
CXX = g++ -D_DEBUG
LEX = flex
YACC = bison -y -t
YFLAGS = -d
objects = parse.o scan.o
moc: $(objects)
$(CXX) -o $@ $(objects) -lfl
parse.o: parse.y
# parse.h: parse.c
# mv -f y.tab.h parse.h
scan.o: scan.l
clean:
rm -f *.o parse.tab.c parse.tab.h

View File

@@ -1,92 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef MOC_ACTION_H
#define MOC_ACTION_H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#ifndef NDEBUG
#define DEBUG( ... ) { printf(" /*["); printf( __VA_ARGS__ ); printf("]*/ "); }
#else
#define DEBUG( ... ) ;
#endif
#define CONCAT( dest , ... ) string_append(dest, __VA_ARGS__, NULL)
char * string_append(char *first, ... ) {
va_list ap;
va_start (ap, first); /* Initialize the argument list. */
char *str_in = first;
char *str = malloc(sizeof(char) * strlen(str_in));
strcat(str,str_in);
str_in = va_arg (ap,char *);
while (str_in) {
char *tmp = malloc(sizeof(char) * (strlen(str)+strlen(str_in)) );
memcpy(tmp,str,strlen(str));
memcpy(tmp+strlen(str),str_in,strlen(str_in));
free(str);
str = tmp;
str_in = va_arg (ap,char *);
}
return str;
}
// ACTIONS //
#define SIMPLE_DECLARATION simple_declaration_action
static int simple_declaration_action(const char *type, const char *ids);
// move to implementation .. //
static int simple_declaration_action(const char *type, const char *ids) {
DEBUG("simple_declaration -> type:\"%s\" decl:\"%s\" ",type,ids);
return 0;
}
#endif // MOC_ACTION_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,51 +0,0 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
typedef int TestInt;
class DerivedObject {
public:
ULIB_OBJECT_PARAMETERS(test)
{
Bubu *a;
};
};
int main() {
ULIB_OBJECT_PARAMETERS(prova) {
int a,b;
char *c;
};
return 0;
}

View File

@@ -1,252 +0,0 @@
%option stack
%{
/* preamble */
#include <ctype.h>
#include <stdio.h>
#include "y.tab.h"
#define PRINT(str) { printf("%s",str); }
#define ENSTATE(st) { yy_push_state(YY_START); BEGIN(st); /*printf("ST[%i]",YY_START);*/ }
#define EXSTATE { BEGIN(yy_top_state()); yy_pop_state(); /*printf("ST[%i]",YY_START);*/ }
#define SCANTEXT { fill_sval(); }
#define MATCH(name) { ECHO; SCANTEXT; return name; }
int lineno;
int moc_level = 0;
static int yywrap(void);
static void skip_until_eol(void);
static void skip_comment(void);
static int check_identifier(const char *);
static int fill_sval();
%}
blank [\t\f\v\r ]+
anyunch <*>.
intsuffix ([uU][lL]?)|([lL][uU]?)
fracconst ([0-9]*\.[0-9]+)|([0-9]+\.)
exppart [eE][-+]?[0-9]+
floatsuffix [fFlL]
chartext ([^'])|(\\.)
stringtext ([^"])|(\\.)
digit [0-9]
hex [0-9A-Fa-f]
letter [A-Z_a-z]
simple_escape_sequence (\\\'|\\\"|\\\?|\\\\|\\a|\\b|\\f|\\n|\\r|\\t|\\v)
octal_escape_sequence (\\[0-7]|\\[0-7][0-7]|\\[0-7][0-7][0-7])
hexadecimal_escape_sequence (\\x{hex}+)
escape_sequence ({simple_escape_sequence}|{octal_escape_sequence}|{hexadecimal_escape_sequence})
universal_character_name (\\u{hex}{hex}{hex}{hex}|\\U{hex}{hex}{hex}{hex}{hex}{hex}{hex}{hex})
non_digit ({letter}|{universal_character_name})
identifier ({non_digit}({non_digit}|{digit})*)
begin_comment "/*"
end_comment "*/"
begin_inline_comment "//"
end_inline_comment "\n"
%s moc
%x cmt
%x inlcmt
%%
"\n" { ++lineno; ECHO; }
{blank} ECHO;
{begin_comment} { ENSTATE(cmt); ECHO; }
<cmt>{end_comment} { EXSTATE; ECHO; }
{begin_inline_comment} { ENSTATE(inlcmt); ECHO; }
<inlcmt>{end_inline_comment} { EXSTATE; ECHO; }
property { ECHO; ENSTATE(moc); return MOC_PROPERTY; }
ULIB_OBJECT_PARAMETERS { ECHO; ENSTATE(moc); return MOC_OBJECT_PARAMETERS; }
<moc>{
"{" { moc_level++; MATCH('{'); }
"}" { if(!--moc_level)EXSTATE; MATCH('}'); }
"<%" { MATCH('{'); }
"%>" { MATCH('}'); }
"[" { MATCH('['); }
"<:" { MATCH('['); }
"]" { MATCH(']'); }
":>" { MATCH(']'); }
"(" { MATCH('('); }
")" { MATCH(')'); }
";" { MATCH(';'); }
"::" { MATCH(COLONCOLON); }
":" { MATCH(':'); }
"..." { MATCH(ELLIPSIS); }
"?" { MATCH('?'); }
"." { MATCH('.'); }
".*" { MATCH(DOTSTAR); }
"+" { MATCH('+'); }
"-" { MATCH('-'); }
"*" { MATCH('*'); }
"/" { MATCH('/'); }
"%" { MATCH('%'); }
"^" { MATCH('^'); }
"xor" { MATCH('^'); }
"&" { MATCH('&'); }
"bitand" { MATCH('&'); }
"|" { MATCH('|'); }
"bitor" { MATCH('|'); }
"~" { MATCH('~'); }
"compl" { MATCH('~'); }
"!" { MATCH('!'); }
"not" { MATCH('!'); }
"=" { MATCH('='); }
"<" { MATCH('<'); }
">" { MATCH('>'); }
"+=" { MATCH(ADDEQ); }
"-=" { MATCH(SUBEQ); }
"*=" { MATCH(MULEQ); }
"/=" { MATCH(DIVEQ); }
"%=" { MATCH(MODEQ); }
"^=" { MATCH(XOREQ); }
"xor_eq" { MATCH(XOREQ); }
"&=" { MATCH(ANDEQ); }
"and_eq" { MATCH(ANDEQ); }
"|=" { MATCH(OREQ); }
"or_eq" { MATCH(OREQ); }
"<<" { MATCH(SL); }
">>" { MATCH(SR); }
"<<=" { MATCH(SLEQ); }
">>=" { MATCH(SREQ); }
"==" { MATCH(EQ); }
"!=" { MATCH(NOTEQ); }
"not_eq" { MATCH(NOTEQ); }
"<=" { MATCH(LTEQ); }
">=" { MATCH(GTEQ); }
"&&" { MATCH(ANDAND); }
"and" { MATCH(ANDAND); }
"||" { MATCH(OROR); }
"or" { MATCH(OROR); }
"++" { MATCH(PLUSPLUS); }
"--" { MATCH(MINUSMINUS); }
"," { MATCH(','); }
"->*" { MATCH(ARROWSTAR); }
"->" { MATCH(ARROW); }
"asm" { MATCH(ASM); }
"auto" { MATCH(AUTO); }
"bool" { MATCH(BOOL); }
"break" { MATCH(BREAK); }
"case" { MATCH(CASE); }
"catch" { MATCH(CATCH); }
"char" { MATCH(CHAR); }
"class" { MATCH(CLASS); }
"const" { MATCH(CONST); }
"const_cast" { MATCH(CONST_CAST); }
"continue" { MATCH(CONTINUE); }
"default" { MATCH(DEFAULT); }
"delete" { MATCH(DELETE); }
"do" { MATCH(DO); }
"double" { MATCH(DOUBLE); }
"dynamic_cast" { MATCH(DYNAMIC_CAST); }
"else" { MATCH(ELSE); }
"enum" { MATCH(ENUM); }
"explicit" { MATCH(EXPLICIT); }
"export" { MATCH(EXPORT); }
"extern" { MATCH(EXTERN); }
"false" { MATCH(FALSE); }
"float" { MATCH(FLOAT); }
"for" { MATCH(FOR); }
"friend" { MATCH(FRIEND); }
"goto" { MATCH(GOTO); }
"if" { MATCH(IF); }
"inline" { MATCH(INLINE); }
"int" { MATCH(INT); }
"long" { MATCH(LONG); }
"mutable" { MATCH(MUTABLE); }
"namespace" { MATCH(NAMESPACE); }
"new" { MATCH(NEW); }
"operator" { MATCH(OPERATOR); }
"private" { MATCH(PRIVATE); }
"protected" { MATCH(PROTECTED); }
"public" { MATCH(PUBLIC); }
"register" { MATCH(REGISTER); }
"reinterpret_cast" { MATCH(REINTERPRET_CAST); }
"return" { MATCH(RETURN); }
"short" { MATCH(SHORT); }
"signed" { MATCH(SIGNED); }
"sizeof" { MATCH(SIZEOF); }
"static" { MATCH(STATIC); }
"static_cast" { MATCH(STATIC_CAST); }
"struct" { MATCH(STRUCT); }
"switch" { MATCH(SWITCH); }
"template" { MATCH(TEMPLATE); }
"this" { MATCH(THIS); }
"throw" { MATCH(THROW); }
"true" { MATCH(TRUE); }
"try" { MATCH(TRY); }
"typedef" { MATCH(TYPEDEF); }
"typeid" { MATCH(TYPEID); }
"typename" { MATCH(TYPENAME); }
"union" { MATCH(UNION); }
"unsigned" { MATCH(UNSIGNED); }
"using" { MATCH(USING); }
"virtual" { MATCH(VIRTUAL); }
"void" { MATCH(VOID); }
"volatile" { MATCH(VOLATILE); }
"wchar_t" { MATCH(WCHAR_T); }
"while" { MATCH(WHILE); }
[a-zA-Z_][a-zA-Z_0-9]* { ECHO; return check_identifier(yytext); }
"0"[xX][0-9a-fA-F]+{intsuffix}? { ECHO; return INTEGER; }
"0"[0-7]+{intsuffix}? { ECHO; return INTEGER; }
[0-9]+{intsuffix}? { ECHO; return INTEGER; }
{fracconst}{exppart}?{floatsuffix}? { ECHO; return FLOATING; }
[0-9]+{exppart}{floatsuffix}? { ECHO; return FLOATING; }
"'"{chartext}*"'" { ECHO; return CHARACTER; }
"L'"{chartext}*"'" { ECHO; return CHARACTER; }
"\""{stringtext}*"\"" { ECHO; return STRING; }
"L\""{stringtext}*"\"" { ECHO; return STRING; }
}
%%
static int yywrap(void)
{
return 1;
}
static int fill_sval() {
int len = strlen(yytext);
if(len) {
yylval.sval = malloc(len);
strncpy(yylval.sval, yytext, len);
}
else {
yylval.sval = strdup("");
}
return len;
}
static int check_identifier(const char *s)
{
/*
switch (s[0]) {
case 'D': return TYPEDEF_NAME;
case 'N': return NAMESPACE_NAME;
case 'C': return CLASS_NAME;
case 'E': return ENUM_NAME;
case 'T': return TEMPLATE_NAME;
}
*/
yylval.sval = malloc(strlen(yytext));
strncpy(yylval.sval, yytext, strlen(yytext));
return IDENTIFIER;
}