andrea-dev #1
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
build/
|
build/
|
||||||
|
.cache/
|
||||||
|
|||||||
8
.vscode/settings.json
vendored
Normal file
8
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"clangd.fallbackFlags": [
|
||||||
|
"-I${workspaceFolder}/src",
|
||||||
|
"-I/home/share/micromamba/envs/mutom/include",
|
||||||
|
"-I/home/rigoni/.conan2/p/eigen5481853932f72/p/include/eigen3"
|
||||||
|
],
|
||||||
|
"clangd.semanticHighlighting.enable": true
|
||||||
|
}
|
||||||
@@ -73,7 +73,7 @@ set(CMAKE_VERBOSE_MAKEFILE FALSE
|
|||||||
CACHE STRING "Verbose compile output switch")
|
CACHE STRING "Verbose compile output switch")
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_WARNING_OPTION}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_WARNING_OPTION}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -UULIB_SERIALIZATION_ON")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -UULIB_SERIALIZATION_ON -Wno-cpp")
|
||||||
|
|
||||||
# CTEST framework
|
# CTEST framework
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|||||||
36
build.log
Normal file
36
build.log
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
make: Entering directory '/home/rigoni/devel/cmt/ulib/build'
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/VoxImage.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/TriangleMesh.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Core/CMakeFiles/mutomCore.dir/Options.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/Dense.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/StructuredGrid.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/VoxRaytracer.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/StructuredData.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/Structured2DGrid.cpp.o
|
||||||
|
[ 30%] Building CXX object src/Math/CMakeFiles/mutomMath.dir/Structured4DGrid.cpp.o
|
||||||
|
[ 33%] Linking CXX shared library libmutomCore.so
|
||||||
|
[ 33%] Built target mutomCore
|
||||||
|
[ 36%] Linking CXX shared library libmutomMath.so
|
||||||
|
[ 36%] Built target mutomMath
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkContainerBox.cpp.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/uLibVtkInterface.cxx.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkStructuredGrid.cpp.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkMuonScatter.cxx.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/uLibVtkViewer.cpp.o
|
||||||
|
[ 63%] Generating mutomRootDict.cxx, libmutomRootDict_rdict.pcm, libmutomRootDict.rootmap
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkVoxImage.cpp.o
|
||||||
|
[ 63%] Building CXX object src/Vtk/CMakeFiles/mutomVtk.dir/vtkVoxRaytracerRepresentation.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorSkinHit.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorHit.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorMCTrack.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorInfo.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/RootMuonScatter.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorPrimaryVertex.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/muCastorMuDetDIGI.cpp.o
|
||||||
|
[ 90%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/SkinDetectorWriter.cpp.o
|
||||||
|
[ 93%] Building CXX object src/Root/CMakeFiles/mutomRoot.dir/mutomRootDict.cxx.o
|
||||||
|
[ 96%] Linking CXX shared library libmutomVtk.so
|
||||||
|
[ 96%] Built target mutomVtk
|
||||||
|
[100%] Linking CXX shared library libmutomRoot.so
|
||||||
|
[100%] Built target mutomRoot
|
||||||
|
make: Leaving directory '/home/rigoni/devel/cmt/ulib/build'
|
||||||
@@ -14,7 +14,6 @@ library_include_HEADERS = \
|
|||||||
Macros.h \
|
Macros.h \
|
||||||
Mpl.h \
|
Mpl.h \
|
||||||
Object.h \
|
Object.h \
|
||||||
ObjectProps.h \
|
|
||||||
Options.h \
|
Options.h \
|
||||||
Serializable.h \
|
Serializable.h \
|
||||||
Signal.h \
|
Signal.h \
|
||||||
|
|||||||
@@ -23,38 +23,29 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
#include "boost/archive/polymorphic_xml_oarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_xml_iarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_text_oarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_text_iarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_binary_oarchive.hpp"
|
|
||||||
#include "boost/archive/polymorphic_binary_iarchive.hpp"
|
#include "boost/archive/polymorphic_binary_iarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_binary_oarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_text_iarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_text_oarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_xml_iarchive.hpp"
|
||||||
|
#include "boost/archive/polymorphic_xml_oarchive.hpp"
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
const char *Version::PackageName = PACKAGE_NAME;
|
const char *Version::PackageName = PACKAGE_NAME;
|
||||||
const char *Version::VersionNumber = PACKAGE_VERSION;
|
const char *Version::VersionNumber = PACKAGE_VERSION;
|
||||||
const char *Version::Release = "x"; // SVN_REVISION;
|
const char *Version::Release = "x"; // SVN_REVISION;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Object Private //
|
// Object Private //
|
||||||
|
|
||||||
class ObjectPrivate {
|
class ObjectPrivate {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Signal {
|
struct Signal {
|
||||||
GenericMFPtr sigptr;
|
GenericMFPtr sigptr;
|
||||||
std::string sigstr;
|
std::string sigstr;
|
||||||
@@ -66,135 +57,92 @@ public:
|
|||||||
std::string slostr;
|
std::string slostr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Vector<Signal> sigv;
|
Vector<Signal> sigv;
|
||||||
Vector<Slot> slov;
|
Vector<Slot> slov;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// OBJECT IMPLEMENTATION
|
// OBJECT IMPLEMENTATION
|
||||||
|
|
||||||
|
Object::Object() : d(new ObjectPrivate) {}
|
||||||
|
|
||||||
|
Object::Object(const Object ©) : d(new ObjectPrivate(*copy.d)) {}
|
||||||
|
|
||||||
Object::Object() :
|
Object::~Object() { delete d; }
|
||||||
d(new ObjectPrivate)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Object::Object(const Object ©) :
|
void Object::DeepCopy(const Object ©) {
|
||||||
ObjectPropable(copy),
|
|
||||||
d(new ObjectPrivate(*copy.d))
|
|
||||||
{}
|
|
||||||
|
|
||||||
Object::~Object() {
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::DeepCopy(const Object ©)
|
|
||||||
{
|
|
||||||
// should lock to be tread safe //
|
// should lock to be tread safe //
|
||||||
memcpy(d, copy.d, sizeof(ObjectPrivate));
|
memcpy(d, copy.d, sizeof(ObjectPrivate));
|
||||||
// ERROR! does not copy parameters ... <<<< FIXXXXX
|
// ERROR! does not copy parameters ... <<<< FIXXXXX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::SaveXml(std::ostream &os, Object &ob) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Object::SaveXml(std::ostream &os, Object &ob)
|
|
||||||
{
|
|
||||||
Archive::xml_oarchive ar(os);
|
Archive::xml_oarchive ar(os);
|
||||||
ar << boost::serialization::make_nvp("Object", ob);
|
ar << boost::serialization::make_nvp("Object", ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::LoadXml(std::istream &is, Object &ob)
|
void Object::LoadXml(std::istream &is, Object &ob) {
|
||||||
{
|
|
||||||
Archive::xml_iarchive ar(is);
|
Archive::xml_iarchive ar(is);
|
||||||
ar >> boost::serialization::make_nvp("Object", ob);
|
ar >> boost::serialization::make_nvp("Object", ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FINIRE
|
// FINIRE
|
||||||
void Object::SaveConfig(std::ostream &os, int version)
|
void Object::SaveConfig(std::ostream &os, int version) {
|
||||||
{
|
|
||||||
Archive::xml_oarchive ar(os);
|
Archive::xml_oarchive ar(os);
|
||||||
ObjectPropable::serialize(ar,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::LoadConfig(std::istream &is, int version)
|
void Object::LoadConfig(std::istream &is, int version) {
|
||||||
{
|
|
||||||
if(!props()) this->init_properties();
|
|
||||||
Archive::xml_iarchive ar(is);
|
Archive::xml_iarchive ar(is);
|
||||||
ObjectPropable::serialize(ar,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::PrintSelf(std::ostream &o) const {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Object::PrintSelf(std::ostream &o) const
|
|
||||||
{
|
|
||||||
o << "OBJECT signals: ------------------\n";
|
o << "OBJECT signals: ------------------\n";
|
||||||
Vector<ObjectPrivate::Signal>::Iterator itr;
|
Vector<ObjectPrivate::Signal>::Iterator itr;
|
||||||
for(itr = d->sigv.begin(); itr<d->sigv.end(); itr++)
|
for (itr = d->sigv.begin(); itr < d->sigv.end(); itr++) {
|
||||||
{
|
|
||||||
o << " signal:[ " << itr->sigstr << " ]\n";
|
o << " signal:[ " << itr->sigstr << " ]\n";
|
||||||
}
|
}
|
||||||
o << "--------------------------------------\n\n";
|
o << "--------------------------------------\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Object::addSignalImpl(SignalBase *sig, GenericMFPtr fptr,
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalBase *Object::findSignalImpl(const GenericMFPtr &fptr) const
|
SignalBase *Object::findSignalImpl(const GenericMFPtr &fptr) const {
|
||||||
{
|
for (int i = 0; i < d->sigv.size(); ++i) {
|
||||||
for(int i=0; i<d->sigv.size(); ++i)
|
|
||||||
{
|
|
||||||
if (d->sigv[i].sigptr == fptr)
|
if (d->sigv[i].sigptr == fptr)
|
||||||
return d->sigv[i].signal;
|
return d->sigv[i].signal;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalBase *Object::findSignalImpl(const char *name) const
|
SignalBase *Object::findSignalImpl(const char *name) const {
|
||||||
{
|
|
||||||
std::string in(name);
|
std::string in(name);
|
||||||
for(int i=0; i<d->sigv.size(); ++i)
|
for (int i = 0; i < d->sigv.size(); ++i) {
|
||||||
{
|
|
||||||
if (d->sigv[i].sigstr == in)
|
if (d->sigv[i].sigstr == in)
|
||||||
return d->sigv[i].signal;
|
return d->sigv[i].signal;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericMFPtr *Object::findSlotImpl(const char *name) const
|
GenericMFPtr *Object::findSlotImpl(const char *name) const {
|
||||||
{
|
|
||||||
std::string in(name);
|
std::string in(name);
|
||||||
for(int i=0; i<d->slov.size(); ++i)
|
for (int i = 0; i < d->slov.size(); ++i) {
|
||||||
{
|
|
||||||
if (d->slov[i].slostr == in)
|
if (d->slov[i].slostr == in)
|
||||||
return &d->slov[i].sloptr;
|
return &d->slov[i].sloptr;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// std::ostream &
|
// std::ostream &
|
||||||
// operator << (std::ostream &os, uLib::Object &ob)
|
// operator << (std::ostream &os, uLib::Object &ob)
|
||||||
// {
|
// {
|
||||||
@@ -218,10 +166,4 @@ GenericMFPtr *Object::findSlotImpl(const char *name) const
|
|||||||
// return is;
|
// return is;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_CORE_OBJECT_H
|
#ifndef U_CORE_OBJECT_H
|
||||||
#define U_CORE_OBJECT_H
|
#define U_CORE_OBJECT_H
|
||||||
|
|
||||||
@@ -33,28 +31,25 @@
|
|||||||
// WARNING: COPILE ERROR if this goes after mpl/vector //
|
// WARNING: COPILE ERROR if this goes after mpl/vector //
|
||||||
// #include "Core/Vector.h"
|
// #include "Core/Vector.h"
|
||||||
|
|
||||||
#include "Core/Types.h"
|
|
||||||
#include "Core/Debug.h"
|
#include "Core/Debug.h"
|
||||||
|
#include "Core/Types.h"
|
||||||
|
|
||||||
#include "Core/Function.h"
|
#include "Core/Function.h"
|
||||||
#include "Core/Signal.h"
|
#include "Core/Signal.h"
|
||||||
|
|
||||||
#include "Core/Mpl.h"
|
#include "Core/Mpl.h"
|
||||||
#include "Core/Serializable.h"
|
#include "Core/Serializable.h"
|
||||||
#include "Core/ObjectProps.h"
|
|
||||||
#include "Core/Uuid.h"
|
#include "Core/Uuid.h"
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace archive {
|
namespace archive {
|
||||||
class polymorphic_iarchive;
|
class polymorphic_iarchive;
|
||||||
class polymorphic_oarchive;
|
class polymorphic_oarchive;
|
||||||
} // archive
|
} // namespace archive
|
||||||
} // boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
class Version {
|
class Version {
|
||||||
public:
|
public:
|
||||||
static const char *PackageName;
|
static const char *PackageName;
|
||||||
@@ -62,23 +57,14 @@ public:
|
|||||||
static const char *Release;
|
static const char *Release;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//// OBJECT ////////////////////////////////////////////////////////////////////
|
//// OBJECT ////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Object class is the object base implementation for uLib Framework.
|
* @brief Object class is the object base implementation for uLib Framework.
|
||||||
*/
|
*/
|
||||||
class Object : public ObjectPropable
|
class Object {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// std::string name;
|
// std::string name;
|
||||||
@@ -94,14 +80,13 @@ public:
|
|||||||
// FIXX !!!
|
// FIXX !!!
|
||||||
virtual void DeepCopy(const Object ©);
|
virtual void DeepCopy(const Object ©);
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// SERIALIZATION //
|
// SERIALIZATION //
|
||||||
|
|
||||||
template <class ArchiveT> void serialize(ArchiveT &ar, const unsigned int version) {
|
template <class ArchiveT>
|
||||||
ObjectPropable::serialize(ar,version);
|
void serialize(ArchiveT &ar, const unsigned int version) {}
|
||||||
}
|
template <class ArchiveT>
|
||||||
template <class ArchiveT> void save_override(ArchiveT &ar,const unsigned int version) {}
|
void save_override(ArchiveT &ar, const unsigned int version) {}
|
||||||
|
|
||||||
void SaveConfig(std::ostream &os, int version = 0);
|
void SaveConfig(std::ostream &os, int version = 0);
|
||||||
void LoadConfig(std::istream &is, int version = 0);
|
void LoadConfig(std::istream &is, int version = 0);
|
||||||
@@ -109,13 +94,12 @@ public:
|
|||||||
static void SaveXml(std::ostream &os, Object &ob);
|
static void SaveXml(std::ostream &os, Object &ob);
|
||||||
static void LoadXml(std::istream &is, Object &ob);
|
static void LoadXml(std::istream &is, Object &ob);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// SIGNALS //
|
// SIGNALS //
|
||||||
|
|
||||||
// Qt4 style connector //
|
// Qt4 style connector //
|
||||||
static bool connect(const Object *ob1, const char *signal_name, const Object *receiver, const char *slot_name) {
|
static bool connect(const Object *ob1, const char *signal_name,
|
||||||
|
const Object *receiver, const char *slot_name) {
|
||||||
// // NOT WORKING YET //
|
// // NOT WORKING YET //
|
||||||
// 1) find slot pointer from name
|
// 1) find slot pointer from name
|
||||||
// SignalBase *sig = ob1->findSignal(signal_name);
|
// SignalBase *sig = ob1->findSignal(signal_name);
|
||||||
@@ -127,11 +111,13 @@ public:
|
|||||||
|
|
||||||
// Qt5 style connector //
|
// Qt5 style connector //
|
||||||
template <typename Func1, typename Func2>
|
template <typename Func1, typename Func2>
|
||||||
static bool connect( typename FunctionPointer<Func1>::Object *sender, Func1 sigf,
|
static bool
|
||||||
typename FunctionPointer<Func2>::Object *receiver, Func2 slof)
|
connect(typename FunctionPointer<Func1>::Object *sender, Func1 sigf,
|
||||||
{
|
typename FunctionPointer<Func2>::Object *receiver, Func2 slof) {
|
||||||
SignalBase *sigb = sender->findOrAddSignal(sigf);
|
SignalBase *sigb = sender->findOrAddSignal(sigf);
|
||||||
typedef boost::signals2::signal<typename FunctionPointer<Func2>::SignalSignature> SigT;
|
typedef boost::signals2::signal<
|
||||||
|
typename FunctionPointer<Func2>::SignalSignature>
|
||||||
|
SigT;
|
||||||
ConnectSignal(sigb, slof, receiver);
|
ConnectSignal(sigb, slof, receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,34 +126,39 @@ public:
|
|||||||
ConnectSignal(sigb, slof, receiver);
|
ConnectSignal(sigb, slof, receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename FuncT>
|
template <typename FuncT>
|
||||||
inline typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
inline
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
||||||
addSignal(FuncT fun, const char *name) {
|
addSignal(FuncT fun, const char *name) {
|
||||||
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT;
|
typedef
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
|
||||||
|
SigT;
|
||||||
SignalBase *sig = NewSignal(fun);
|
SignalBase *sig = NewSignal(fun);
|
||||||
addSignalImpl(sig, fun, name);
|
addSignalImpl(sig, fun, name);
|
||||||
return (SigT *)sig;
|
return (SigT *)sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename FuncT>
|
template <typename FuncT> inline bool addSlot(FuncT fun, const char *name) {
|
||||||
inline bool addSlot(FuncT fun, const char *name) {
|
|
||||||
this->addSlotImpl(GenericMFPtr(fun), name);
|
this->addSlotImpl(GenericMFPtr(fun), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FuncT>
|
template <typename FuncT>
|
||||||
inline typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
inline
|
||||||
findSignal(FuncT fptr)
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
||||||
{
|
findSignal(FuncT fptr) {
|
||||||
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT;
|
typedef
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
|
||||||
|
SigT;
|
||||||
return (SigT *)findSignalImpl(GenericMFPtr(fptr));
|
return (SigT *)findSignalImpl(GenericMFPtr(fptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FuncT>
|
template <typename FuncT>
|
||||||
inline typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
inline
|
||||||
findOrAddSignal(FuncT fptr)
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type *
|
||||||
{
|
findOrAddSignal(FuncT fptr) {
|
||||||
typedef typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type SigT;
|
typedef
|
||||||
|
typename Signal<typename FunctionPointer<FuncT>::SignalSignature>::type
|
||||||
|
SigT;
|
||||||
SignalBase *sig = findSignalImpl(GenericMFPtr(fptr));
|
SignalBase *sig = findSignalImpl(GenericMFPtr(fptr));
|
||||||
if (!sig) {
|
if (!sig) {
|
||||||
sig = NewSignal(fptr);
|
sig = NewSignal(fptr);
|
||||||
@@ -176,25 +167,20 @@ public:
|
|||||||
return (SigT *)sig;
|
return (SigT *)sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline SignalBase *findSignal(const char *name) const {
|
||||||
inline SignalBase *
|
|
||||||
findSignal(const char *name) const
|
|
||||||
{
|
|
||||||
return findSignalImpl(name);
|
return findSignalImpl(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline GenericMFPtr *
|
inline GenericMFPtr *findSlot(const char *name) const {
|
||||||
findSlot(const char *name) const
|
|
||||||
{
|
|
||||||
return findSlotImpl(name);
|
return findSlotImpl(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintSelf(std::ostream &o) const;
|
void PrintSelf(std::ostream &o) const;
|
||||||
|
|
||||||
inline const Object& operator = (const Object ©)
|
inline const Object &operator=(const Object ©) {
|
||||||
{ this->DeepCopy(copy); return *this; }
|
this->DeepCopy(copy);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool addSignalImpl(SignalBase *sig, GenericMFPtr fptr, const char *name);
|
bool addSignalImpl(SignalBase *sig, GenericMFPtr fptr, const char *name);
|
||||||
@@ -208,9 +194,7 @@ private:
|
|||||||
class ObjectPrivate *d;
|
class ObjectPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -218,5 +202,4 @@ private:
|
|||||||
// std::ostream & operator << (std::ostream &os, uLib::Object *ob);
|
// std::ostream & operator << (std::ostream &os, uLib::Object *ob);
|
||||||
// std::istream & operator >> (std::istream &is, uLib::Object &ob);
|
// std::istream & operator >> (std::istream &is, uLib::Object &ob);
|
||||||
|
|
||||||
|
|
||||||
#endif // U_OBJECT_H
|
#endif // U_OBJECT_H
|
||||||
|
|||||||
@@ -1,278 +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 U_OBJECTPROPS_H
|
|
||||||
#define U_OBJECTPROPS_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
|
||||||
|
|
||||||
#include <Core/Mpl.h>
|
|
||||||
#include <Core/Types.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// MACROS //
|
|
||||||
|
|
||||||
|
|
||||||
#define ULIB_props() \
|
|
||||||
public: struct ObjectProps; \
|
|
||||||
virtual void init_properties(); \
|
|
||||||
inline struct ObjectProps &p() { /* static const unsigned int offset = props_offset(this); */ \
|
|
||||||
/* NON FUNZIA! return * (struct ObjectProps *)(reinterpret_cast<char*>(props())+offset); */ \
|
|
||||||
return *props()->ptr<ObjectProps>(); } \
|
|
||||||
typedef uLib::mpl::bool_<true>::type propable_trait; \
|
|
||||||
public: struct DLL_PUBLIC ObjectProps
|
|
||||||
|
|
||||||
#define properties() ULIB_props()
|
|
||||||
|
|
||||||
#define default(vlaue)
|
|
||||||
|
|
||||||
#define $$ p()
|
|
||||||
|
|
||||||
#define $(_name) props_ref<_name>()
|
|
||||||
|
|
||||||
#define $_init() \
|
|
||||||
if(props(this)) return; \
|
|
||||||
props_new(this); \
|
|
||||||
uLib::detail::ObjectProps::initializer::init_object_baselist(this);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
namespace serialization {
|
|
||||||
class access;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
struct ObjectProps {
|
|
||||||
|
|
||||||
/** Define a trait has_member to find if an Object is Propable*/
|
|
||||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(propable_trait)
|
|
||||||
|
|
||||||
/** IsA ProbapleObject Implementation Template */
|
|
||||||
template <class T>
|
|
||||||
struct IsA : has_propable_trait<T> {};
|
|
||||||
|
|
||||||
/** Lambda to get Props member type */
|
|
||||||
template <class T>
|
|
||||||
struct props_type {
|
|
||||||
typedef typename T::ObjectProps type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct get_props {
|
|
||||||
|
|
||||||
/** CFList has result but this method check for has BaseList */
|
|
||||||
typedef typename detail::TypeIntrospection::child_first<T>::type CFTypeList;
|
|
||||||
|
|
||||||
/** Filter List items that have not Propable feature */
|
|
||||||
typedef typename mpl::filter_view< CFTypeList, IsA<mpl::_> >::type FilteredCFTypeList;
|
|
||||||
|
|
||||||
/** Get Props from each Parent in Seq */
|
|
||||||
typedef typename mpl::transform_view< FilteredCFTypeList, props_type<mpl::_> >::type type;
|
|
||||||
|
|
||||||
|
|
||||||
// qui sotto ho un problema che ho temporaneamente tamponato //
|
|
||||||
// ovvero ho usato child_first_impl per ottenere la lista delle basi //
|
|
||||||
// vorrei farlo facendo un pop_back ma non va forse perche il tipo //
|
|
||||||
// non e' corretto. //
|
|
||||||
|
|
||||||
/** Get Parent list from CFTypeList */
|
|
||||||
typedef typename detail::TypeIntrospection::child_first_impl<T>::Childs CFBaseList;
|
|
||||||
|
|
||||||
/** Filter Parents that have not Propable feature */
|
|
||||||
typedef typename mpl::filter_view< CFBaseList, IsA<mpl::_> >::type FilteredCFBaseList;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: convert to pp const value,
|
|
||||||
// (non so se sia possibile con il dinamic casting intanto funziona cosi' )
|
|
||||||
template <typename T1, typename T2>
|
|
||||||
static unsigned int measure_offset(T1 base, T2 derived) {
|
|
||||||
return reinterpret_cast<char*>(derived) - reinterpret_cast<char*>(base);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct initializer {
|
|
||||||
|
|
||||||
template <class _ObjectT>
|
|
||||||
struct lambda_init_object {
|
|
||||||
_ObjectT *o;
|
|
||||||
lambda_init_object(_ObjectT *o) : o(o) {}
|
|
||||||
template<class T> void operator()(T) {
|
|
||||||
o->T::init_properties();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This calls the internal init_properties() virtual function for each
|
|
||||||
* object parent defined in BaseList only if it is propable
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
static void init_object_baselist(T *o) {
|
|
||||||
typedef typename uLib::detail::ObjectProps::get_props<T>::FilteredCFBaseList CFBaseList;
|
|
||||||
mpl::for_each<CFBaseList>(lambda_init_object<T>(o));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This calls the internal init_properties() virtual function only if
|
|
||||||
* object is propable ( implementation if not propable )
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
static
|
|
||||||
typename boost::enable_if<mpl::not_<IsA<T> >,void>::type
|
|
||||||
init_object(T *o) {
|
|
||||||
; // do nothing //
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This calls the internal init_properties() virtual function only if
|
|
||||||
* object is propable ( implementation if propable )
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
static
|
|
||||||
typename boost::enable_if<IsA<T>,void>::type
|
|
||||||
init_object(T *o) {
|
|
||||||
o->init_properties();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class ThisClass, class Archive>
|
|
||||||
struct serialize_baselist {
|
|
||||||
ThisClass & m_object;
|
|
||||||
Archive & m_ar;
|
|
||||||
serialize_baselist(ThisClass &o, Archive &ar) : m_object(o), m_ar(ar) {}
|
|
||||||
template <class T> void operator()(T &o) {
|
|
||||||
// T is taken fron get_props<BaseList>::FilteredPList types to get
|
|
||||||
// type_info_name that is the type name defined by Type macro
|
|
||||||
typedef typename props_type<T>::type PType;
|
|
||||||
std::string name(TypeIntrospection::access<T>::type_info::name);
|
|
||||||
boost::algorithm::replace_all(name,"::","_");
|
|
||||||
m_ar & boost::serialization::make_nvp(
|
|
||||||
name.c_str() ,
|
|
||||||
boost::serialization::base_object<PType>(m_object));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct ObjectPropsBase {
|
|
||||||
virtual ~ObjectPropsBase() {}
|
|
||||||
virtual ObjectPropsBase *copy() = 0;
|
|
||||||
|
|
||||||
template <class T> inline T *ptr() { return dynamic_cast<T*>(this); }
|
|
||||||
|
|
||||||
template<class ArchiveT> void serialize(ArchiveT &ar, const unsigned int version) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct ObjectPropsImpl :
|
|
||||||
ObjectPropsBase,
|
|
||||||
ULIB_MPL_INHERIT_NOFOLD_SEQ(typename uLib::detail::ObjectProps::get_props<T>::type)
|
|
||||||
{
|
|
||||||
typedef ObjectPropsImpl<T> ThisClass;
|
|
||||||
typedef typename uLib::detail::ObjectProps::get_props<T>::type CFList;
|
|
||||||
typedef typename uLib::detail::ObjectProps::get_props<T>::FilteredCFTypeList FilteredCFTypeList;
|
|
||||||
ObjectPropsBase *copy() { return new ThisClass(*this); }
|
|
||||||
|
|
||||||
template<class ArchiveT> void serialize(ArchiveT &ar, const unsigned int version) {
|
|
||||||
boost::serialization::void_cast_register<ThisClass,ObjectPropsBase>();
|
|
||||||
mpl::for_each<FilteredCFTypeList>(detail::ObjectProps::serialize_baselist<ThisClass,ArchiveT>(*this,ar));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectPropable {
|
|
||||||
|
|
||||||
ObjectPropsBase *m_props;
|
|
||||||
friend class uLib::detail::ObjectProps;
|
|
||||||
friend class boost::serialization::access;
|
|
||||||
public:
|
|
||||||
ObjectPropable() : m_props(NULL) {}
|
|
||||||
ObjectPropable(const ObjectPropable &c) { if(c.m_props) m_props = c.m_props->copy(); else m_props = NULL; }
|
|
||||||
~ObjectPropable() { if(m_props) delete m_props; }
|
|
||||||
|
|
||||||
|
|
||||||
template <class T> inline typename T::ObjectProps& props_ref() const { if(m_props) return *m_props->ptr<typename T::ObjectProps>(); else exit(1); }
|
|
||||||
template <class T> inline typename T::ObjectProps* props(T *ptr = NULL) const { if(m_props) return m_props->ptr<typename T::ObjectProps>(); else return NULL; }
|
|
||||||
protected:
|
|
||||||
ObjectPropsBase *props() const { return m_props; }
|
|
||||||
template <class T> inline void props_new(T* ptr = NULL) { if(!m_props) m_props = new ObjectPropsImpl<T>; }
|
|
||||||
|
|
||||||
/** NOT working dynamic cache casting */
|
|
||||||
template <class T> inline unsigned int props_offset(T *ptr) const
|
|
||||||
{ if(m_props) return detail::ObjectProps::measure_offset(m_props,m_props->ptr<T>()); else return -1; }
|
|
||||||
|
|
||||||
|
|
||||||
template<class ArchiveT> void serialize(ArchiveT &ar, const unsigned int version) {
|
|
||||||
if(m_props) ar & boost::serialization::make_nvp("properties",m_props);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* ObjectPropable is not directly propable itself to prevent Basclass
|
|
||||||
* duplication in inherit_nofold. And for the same reason ANY VIRTUAL BASE
|
|
||||||
* SHOULD NOT BE PROPABLE
|
|
||||||
*/
|
|
||||||
virtual void init_properties() {}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // U_OBJECTPROPS_H
|
|
||||||
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_SERIALIZABLE_H
|
#ifndef U_SERIALIZABLE_H
|
||||||
#define U_SERIALIZABLE_H
|
#define U_SERIALIZABLE_H
|
||||||
|
|
||||||
@@ -38,9 +36,6 @@ TODO:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <boost/serialization/access.hpp>
|
#include <boost/serialization/access.hpp>
|
||||||
#include <boost/serialization/export.hpp>
|
#include <boost/serialization/export.hpp>
|
||||||
|
|
||||||
@@ -55,19 +50,15 @@ TODO:
|
|||||||
// #include "boost/archive/polymorphic_iarchive.hpp"
|
// #include "boost/archive/polymorphic_iarchive.hpp"
|
||||||
// #include "boost/archive/polymorphic_oarchive.hpp"
|
// #include "boost/archive/polymorphic_oarchive.hpp"
|
||||||
|
|
||||||
#include <boost/preprocessor/comma_if.hpp>
|
|
||||||
#include <boost/preprocessor/repeat.hpp>
|
|
||||||
#include <boost/preprocessor/inc.hpp>
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
#include <boost/preprocessor/comma_if.hpp>
|
||||||
|
#include <boost/preprocessor/inc.hpp>
|
||||||
|
#include <boost/preprocessor/repeat.hpp>
|
||||||
#include <boost/preprocessor/tuple/to_seq.hpp>
|
#include <boost/preprocessor/tuple/to_seq.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include "Core/Mpl.h"
|
|
||||||
#include "Core/ObjectProps.h"
|
|
||||||
#include "Core/Archives.h"
|
#include "Core/Archives.h"
|
||||||
#include "Core/Export.h"
|
#include "Core/Export.h"
|
||||||
|
#include "Core/Mpl.h"
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -80,25 +71,17 @@ namespace serialization {
|
|||||||
// ACCESS 2 //
|
// ACCESS 2 //
|
||||||
template <class T> struct access2 {};
|
template <class T> struct access2 {};
|
||||||
|
|
||||||
|
|
||||||
// NON FUNZIONA ... SISTEMARE !!!! // ------------------------------------------
|
// NON FUNZIONA ... SISTEMARE !!!! // ------------------------------------------
|
||||||
template<class T>
|
template <class T> class hrp : public wrapper_traits<const hrp<T>> {
|
||||||
class hrp :
|
|
||||||
public wrapper_traits<const hrp< T > >
|
|
||||||
{
|
|
||||||
const char *m_name;
|
const char *m_name;
|
||||||
T *m_value;
|
T *m_value;
|
||||||
std::string *m_str;
|
std::string *m_str;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit hrp(const char * name_, T &t) :
|
explicit hrp(const char *name_, T &t)
|
||||||
m_str(new std::string),
|
: m_str(new std::string), m_name(name_), m_value(&t) {}
|
||||||
m_name(name_), m_value(&t) {}
|
|
||||||
|
|
||||||
const char * name() const {
|
|
||||||
return this->m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const char *name() const { return this->m_name; }
|
||||||
|
|
||||||
template <class Archivex>
|
template <class Archivex>
|
||||||
void save(Archivex &ar, const unsigned int /* file_version */) const {
|
void save(Archivex &ar, const unsigned int /* file_version */) const {
|
||||||
@@ -116,7 +99,6 @@ public:
|
|||||||
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline
|
inline
|
||||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||||
@@ -126,17 +108,10 @@ hrp< T > make_hrp(const char * name, T & t){
|
|||||||
return hrp<T>(name, t);
|
return hrp<T>(name, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HRP(name) \
|
#define HRP(name) boost::serialization::make_hrp(BOOST_PP_STRINGIZE(name), name)
|
||||||
boost::serialization::make_hrp(BOOST_PP_STRINGIZE(name), name)
|
|
||||||
|
|
||||||
|
|
||||||
} // serialization
|
|
||||||
} // boost
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace serialization
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -151,8 +126,6 @@ hrp< T > make_hrp(const char * name, T & t){
|
|||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define _AR_OP(r, data, elem) data &BOOST_SERIALIZATION_BASE_OBJECT_NVP(elem);
|
#define _AR_OP(r, data, elem) data &BOOST_SERIALIZATION_BASE_OBJECT_NVP(elem);
|
||||||
|
|
||||||
#define NVP(data) BOOST_SERIALIZATION_NVP(data)
|
#define NVP(data) BOOST_SERIALIZATION_NVP(data)
|
||||||
@@ -167,22 +140,25 @@ namespace uLib {
|
|||||||
|
|
||||||
#ifdef ULIB_CFG_INTRUSIVE_SERIALIZATION_OBJECT
|
#ifdef ULIB_CFG_INTRUSIVE_SERIALIZATION_OBJECT
|
||||||
#define ULIB_SERIALIZABLE_OBJECT _ULIB_DETAIL_INTRUSIVE_SERIALIZABLE_OBJECT
|
#define ULIB_SERIALIZABLE_OBJECT _ULIB_DETAIL_INTRUSIVE_SERIALIZABLE_OBJECT
|
||||||
# define ULIB_SERIALIZE_OBJECT(_Ob,...) _ULIB_DETAIL_INTRUSIVE_SERIALIZE_OBJECT(_Ob,__VA_ARGS__)
|
#define ULIB_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
|
_ULIB_DETAIL_INTRUSIVE_SERIALIZE_OBJECT(_Ob, __VA_ARGS__)
|
||||||
#define _AR_(_name) _ULIB_DETAIL_INTRUSIVE_AR_(_name)
|
#define _AR_(_name) _ULIB_DETAIL_INTRUSIVE_AR_(_name)
|
||||||
#else
|
#else
|
||||||
# define ULIB_SERIALIZABLE(_Ob) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE(_Ob) \
|
#define ULIB_SERIALIZABLE(_Ob) \
|
||||||
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE(_Ob) \
|
||||||
ULIB_CLASS_EXPORT_KEY(_Ob)
|
ULIB_CLASS_EXPORT_KEY(_Ob)
|
||||||
#define ULIB_SERIALIZE(_Ob, ...) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE(_Ob)
|
#define ULIB_SERIALIZE(_Ob, ...) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE(_Ob)
|
||||||
# define ULIB_SERIALIZE_DERIVED(_Ob,...) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_DERIVED(_Ob,__VA_ARGS__)
|
#define ULIB_SERIALIZE_DERIVED(_Ob, ...) \
|
||||||
# define ULIB_SERIALIZABLE_OBJECT(_Ob) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE_OBJECT(_Ob) \
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_DERIVED(_Ob, __VA_ARGS__)
|
||||||
|
#define ULIB_SERIALIZABLE_OBJECT(_Ob) \
|
||||||
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE_OBJECT(_Ob) \
|
||||||
ULIB_CLASS_EXPORT_OBJECT_KEY(_Ob)
|
ULIB_CLASS_EXPORT_OBJECT_KEY(_Ob)
|
||||||
# define ULIB_SERIALIZE_OBJECT(_Ob,...) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob,__VA_ARGS__)
|
#define ULIB_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
# define ULIB_SERIALIZE_OBJECT_PROPS(_Ob) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_PROPS(_Ob)
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob, __VA_ARGS__)
|
||||||
#define AR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
#define AR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
||||||
#define HR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
#define HR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define ULIB_SERIALIZE_ACCESS \
|
#define ULIB_SERIALIZE_ACCESS \
|
||||||
friend class boost::serialization::access; \
|
friend class boost::serialization::access; \
|
||||||
template <class T> friend class boost::serialization::access2;
|
template <class T> friend class boost::serialization::access2;
|
||||||
@@ -191,26 +167,25 @@ namespace uLib {
|
|||||||
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass)
|
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass)
|
||||||
|
|
||||||
#define ULIB_CLASS_EXPORT_OBJECT_KEY(_FullNamespaceClass) \
|
#define ULIB_CLASS_EXPORT_OBJECT_KEY(_FullNamespaceClass) \
|
||||||
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass) \
|
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass)
|
||||||
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass::ObjectProps) \
|
|
||||||
BOOST_CLASS_EXPORT_KEY(uLib::ObjectPropsImpl<_FullNamespaceClass>)
|
|
||||||
|
|
||||||
|
|
||||||
#define _SERIALIZE_IMPL_SEQ \
|
#define _SERIALIZE_IMPL_SEQ \
|
||||||
(uLib::Archive::text_iarchive) \
|
(uLib::Archive::text_iarchive)(uLib::Archive::text_oarchive)( \
|
||||||
(uLib::Archive::text_oarchive) \
|
uLib::Archive:: \
|
||||||
(uLib::Archive::hrt_iarchive) \
|
hrt_iarchive)(uLib::Archive:: \
|
||||||
(uLib::Archive::hrt_oarchive) \
|
hrt_oarchive)(uLib::Archive:: \
|
||||||
(uLib::Archive::xml_iarchive) \
|
xml_iarchive)(uLib::Archive:: \
|
||||||
(uLib::Archive::xml_oarchive) \
|
xml_oarchive)(uLib::Archive:: \
|
||||||
(uLib::Archive::log_archive)
|
log_archive)
|
||||||
|
|
||||||
|
|
||||||
/** Solving virtual class check problem */
|
/** Solving virtual class check problem */
|
||||||
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(_Base,_Derived) namespace boost{ template<> struct is_virtual_base_of<_Base,_Derived>: public boost::mpl::true_ {}; }
|
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(_Base, _Derived) \
|
||||||
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP(r,data,elem) _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(elem,data)
|
namespace boost { \
|
||||||
|
template <> \
|
||||||
|
struct is_virtual_base_of<_Base, _Derived> : public boost::mpl::true_ {}; \
|
||||||
|
}
|
||||||
|
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP(r, data, elem) \
|
||||||
|
_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(elem, data)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -225,33 +200,52 @@ namespace uLib {
|
|||||||
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC(Class, Archive) \
|
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC(Class, Archive) \
|
||||||
template void Class::serialize(Archive &ar, const unsigned int);
|
template void Class::serialize(Archive &ar, const unsigned int);
|
||||||
|
|
||||||
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC_OP(r,data,elem) _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC(data,elem);
|
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC_OP(r, data, elem) \
|
||||||
|
_ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC(data, elem);
|
||||||
|
|
||||||
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZABLE_OBJECT \
|
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZABLE_OBJECT \
|
||||||
typedef boost::mpl::bool_<true> serializable; \
|
typedef boost::mpl::bool_<true> serializable; \
|
||||||
typedef boost::mpl::remove_if< TypeList, IsUnSerializable >::type SerilizableTypeList; \
|
typedef boost::mpl::remove_if<TypeList, IsUnSerializable>::type \
|
||||||
void PrintSerializableListId() { boost::mpl::for_each<SerilizableTypeList>(PrintTypeId()); } \
|
SerilizableTypeList; \
|
||||||
template <class ArchiveT> void serialize(ArchiveT &ar,const unsigned int version); \
|
void PrintSerializableListId() { \
|
||||||
template <class ArchiveT> void serialize_parents(ArchiveT &ar,const unsigned int version); \
|
boost::mpl::for_each<SerilizableTypeList>(PrintTypeId()); \
|
||||||
template <class ArchiveT> void save_override(ArchiveT &ar,const unsigned int version);
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, const unsigned int version); \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, const unsigned int version); \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void save_override(ArchiveT &ar, const unsigned int version);
|
||||||
|
|
||||||
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_OBJECT(_Ob, ...) \
|
#define _ULIB_DETAIL_INTRUSIVE_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
template <class ArchiveT> void _Ob::serialize(ArchiveT &ar, const unsigned int version) { \
|
template <class ArchiveT> \
|
||||||
boost::serialization::void_cast_register<_Ob,_Ob::BaseClass>(static_cast<_Ob *>(NULL),static_cast<_Ob::BaseClass *>(NULL)); \
|
void _Ob::serialize(ArchiveT &ar, const unsigned int version) { \
|
||||||
|
boost::serialization::void_cast_register<_Ob, _Ob::BaseClass>( \
|
||||||
|
static_cast<_Ob *>(NULL), static_cast<_Ob::BaseClass *>(NULL)); \
|
||||||
_Ob::serialize_parents(ar, version); \
|
_Ob::serialize_parents(ar, version); \
|
||||||
_Ob::save_override(ar,version); }\
|
_Ob::save_override(ar, version); \
|
||||||
template <class ArchiveT> void _Ob::serialize_parents(ArchiveT &ar, const unsigned int v) { \
|
} \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_AR_OP,ar,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); } \
|
template <class ArchiveT> \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC_OP,_Ob,_SERIALIZE_IMPL_SEQ)\
|
void _Ob::serialize_parents(ArchiveT &ar, const unsigned int v) { \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP,_Ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
BOOST_PP_SEQ_FOR_EACH(_AR_OP, ar, BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
||||||
|
} \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_INTRUSIVE_SERIALIZE_FUNC_OP, _Ob, \
|
||||||
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP, _Ob, \
|
||||||
|
BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
||||||
namespace boost { \
|
namespace boost { \
|
||||||
namespace serialization { \
|
namespace serialization { \
|
||||||
template<class ArchiveT> inline void load_construct_data(ArchiveT & ar, _Ob *o, const unsigned int file_version) \
|
template <class ArchiveT> \
|
||||||
{ ::new(o)_Ob(); o->init_parameters(); } }}\
|
inline void load_construct_data(ArchiveT &ar, _Ob *o, \
|
||||||
template <class ArchiveT> void _Ob::save_override(ArchiveT &ar, const unsigned int version)
|
const unsigned int file_version) { \
|
||||||
|
::new (o) _Ob(); \
|
||||||
|
o->init_parameters(); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void _Ob::save_override(ArchiveT &ar, const unsigned int version)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -261,96 +255,134 @@ namespace uLib {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// UNINTRUSIVE SERIALIZATION
|
// UNINTRUSIVE SERIALIZATION
|
||||||
|
|
||||||
#define _UNAR_OP(r,data,elem) ar&boost::serialization::make_nvp(BOOST_PP_STRINGIZE(elem),boost::serialization::base_object<elem>(ob));
|
#define _UNAR_OP(r, data, elem) \
|
||||||
|
ar &boost::serialization::make_nvp( \
|
||||||
|
BOOST_PP_STRINGIZE(elem), boost::serialization::base_object<elem>(ob));
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC(Class, Archive) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC(Class, Archive) \
|
||||||
template void boost::serialization::serialize(Archive &ar, Class &ob, const unsigned int i);
|
template void boost::serialization::serialize(Archive &ar, Class &ob, \
|
||||||
|
const unsigned int i);
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP(r,data,elem) _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC(data,elem)
|
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP(r, data, elem) \
|
||||||
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC(data, elem)
|
||||||
|
|
||||||
// NOTE: becouse of BOOST_PP_VARIADIC_SIZE issue of some boost macro has two
|
// NOTE: becouse of BOOST_PP_VARIADIC_SIZE issue of some boost macro has two
|
||||||
// different implementation
|
// different implementation
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE(_Ob) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE(_Ob) \
|
||||||
namespace boost { namespace serialization { \
|
namespace boost { \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
namespace serialization { \
|
||||||
template <class ArchiveT> void serialize_parents (ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
template <class ArchiveT> \
|
||||||
template <> struct access2< _Ob > { template <class ArchiveT> static void save_override (ArchiveT &ar, _Ob &ob, const unsigned int version); }; }}
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
||||||
|
template <> struct access2<_Ob> { \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
static void save_override(ArchiveT &ar, _Ob &ob, \
|
||||||
|
const unsigned int version); \
|
||||||
|
}; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE(_Ob) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE(_Ob) \
|
||||||
namespace boost { namespace serialization { \
|
namespace boost { \
|
||||||
template <class ArchiveT> void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) {} \
|
namespace serialization { \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) {} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
||||||
serialize_parents(ar, ob, version); \
|
serialize_parents(ar, ob, version); \
|
||||||
access2< _Ob >::save_override(ar,ob,version); } }}\
|
access2<_Ob>::save_override(ar, ob, version); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP,_Ob,_SERIALIZE_IMPL_SEQ)\
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP, _Ob, \
|
||||||
template <class ArchiveT> void boost::serialization::access2< _Ob >::save_override(ArchiveT &ar, _Ob &ob, const unsigned int version)
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void boost::serialization::access2<_Ob>::save_override( \
|
||||||
|
ArchiveT &ar, _Ob &ob, const unsigned int version)
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_DERIVED(_Ob, ...) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_DERIVED(_Ob, ...) \
|
||||||
namespace boost { namespace serialization { \
|
namespace boost { \
|
||||||
template <class ArchiveT> void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
namespace serialization { \
|
||||||
BOOST_PP_IF(BOOST_PP_VARIADIC_SIZE((__VA_ARGS__)),BOOST_PP_SEQ_FOR_EACH(_UNAR_OP,ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__)));,) } \
|
template <class ArchiveT> \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
||||||
|
BOOST_PP_IF(BOOST_PP_VARIADIC_SIZE((__VA_ARGS__)), \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(_UNAR_OP, ob, \
|
||||||
|
BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
||||||
|
, ) \
|
||||||
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
||||||
serialize_parents(ar, ob, version); \
|
serialize_parents(ar, ob, version); \
|
||||||
access2< _Ob >::save_override (ar,ob,version); } }}\
|
access2<_Ob>::save_override(ar, ob, version); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP,_Ob,_SERIALIZE_IMPL_SEQ) \
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP, _Ob, \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP,_Ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
template <class ArchiveT> void boost::serialization::access2< _Ob >::save_override(ArchiveT &ar, _Ob &ob, const unsigned int version)
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP, _Ob, \
|
||||||
|
BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void boost::serialization::access2<_Ob>::save_override( \
|
||||||
|
ArchiveT &ar, _Ob &ob, const unsigned int version)
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE_OBJECT(_Ob) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZABLE_OBJECT(_Ob) \
|
||||||
namespace boost { namespace serialization { \
|
namespace boost { \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
namespace serialization { \
|
||||||
template <class ArchiveT> void serialize_parents (ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
template <class ArchiveT> \
|
||||||
template <> struct access2< _Ob > { template <class ArchiveT> static void save_override (ArchiveT &ar, _Ob &ob, const unsigned int version); }; \
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, class _Ob::ObjectProps &ob, const unsigned int version); \
|
template <class ArchiveT> \
|
||||||
template <class ArchiveT> void save_override (ArchiveT &ar, class _Ob::ObjectProps &ob, const unsigned int version); }}
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int version); \
|
||||||
|
template <> struct access2<_Ob> { \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
static void save_override(ArchiveT &ar, _Ob &ob, \
|
||||||
|
const unsigned int version); \
|
||||||
|
}; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob, ...) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
namespace boost { namespace serialization { \
|
namespace boost { \
|
||||||
template <class ArchiveT> void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
namespace serialization { \
|
||||||
/* PP serialize */ BOOST_PP_SEQ_FOR_EACH(_UNAR_OP,ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
template <class ArchiveT> \
|
||||||
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
||||||
|
/* PP serialize */ BOOST_PP_SEQ_FOR_EACH( \
|
||||||
|
_UNAR_OP, ob, BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
||||||
/* MPL serialize */ /*uLib::mpl::for_each<_Ob::BaseList>(uLib::detail::Serializable::serialize_baseobject<_Ob,ArchiveT>(ob,ar) );*/ } \
|
/* MPL serialize */ /*uLib::mpl::for_each<_Ob::BaseList>(uLib::detail::Serializable::serialize_baseobject<_Ob,ArchiveT>(ob,ar) );*/ } \
|
||||||
template<class ArchiveT> inline void load_construct_data(ArchiveT & ar, _Ob *ob, const unsigned int file_version) { \
|
template <class ArchiveT> \
|
||||||
::new(ob)_Ob(); uLib::detail::ObjectProps::initializer::init_object(ob); } \
|
inline void load_construct_data(ArchiveT &ar, _Ob *ob, \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
const unsigned int file_version) { \
|
||||||
void_cast_register<_Ob,_Ob::BaseClass>(static_cast<_Ob *>(NULL),static_cast<_Ob::BaseClass *>(NULL)); /*fix*/ \
|
::new (ob) _Ob(); \
|
||||||
|
} \
|
||||||
|
template <class ArchiveT> \
|
||||||
|
void serialize(ArchiveT &ar, _Ob &ob, const unsigned int version) { \
|
||||||
|
void_cast_register<_Ob, _Ob::BaseClass>( \
|
||||||
|
static_cast<_Ob *>(NULL), \
|
||||||
|
static_cast<_Ob::BaseClass *>(NULL)); /*fix*/ \
|
||||||
serialize_parents(ar, ob, version); \
|
serialize_parents(ar, ob, version); \
|
||||||
access2< _Ob >::save_override (ar,ob,version); } }}\
|
access2<_Ob>::save_override(ar, ob, version); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob) \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP,_Ob,BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE_OP, _Ob, \
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP,_Ob,_SERIALIZE_IMPL_SEQ)\
|
BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))) \
|
||||||
template <class ArchiveT> void boost::serialization::access2< _Ob >::save_override(ArchiveT &ar, _Ob &ob, const unsigned int version)
|
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP, _Ob, \
|
||||||
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_PROPS(_Ob) \
|
template <class ArchiveT> \
|
||||||
namespace boost { namespace serialization { \
|
void boost::serialization::access2<_Ob>::save_override( \
|
||||||
template <class ArchiveT> void serialize (ArchiveT &ar, _Ob::ObjectProps &ob, const unsigned int version) { \
|
ArchiveT &ar, _Ob &ob, const unsigned int version)
|
||||||
save_override (ar,ob,version); } }}\
|
|
||||||
BOOST_PP_SEQ_FOR_EACH(_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_FUNC_OP,_Ob::ObjectProps,_SERIALIZE_IMPL_SEQ)\
|
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(_Ob::ObjectProps) \
|
|
||||||
ULIB_CLASS_EXPORT_IMPLEMENT(uLib::ObjectPropsImpl<_Ob>) \
|
|
||||||
template <class ArchiveT> void boost::serialization::save_override(ArchiveT &ar, _Ob::ObjectProps &ob, const unsigned int version)
|
|
||||||
|
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_AR_(name) boost::serialization::make_nvp(BOOST_PP_STRINGIZE(name),ob.name)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_AR_(name) \
|
||||||
|
boost::serialization::make_nvp(BOOST_PP_STRINGIZE(name), ob.name)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
struct Serializable {
|
struct Serializable {
|
||||||
@@ -360,53 +392,34 @@ struct Serializable {
|
|||||||
* This only works if UNINTRUSIVE SERIALIZATION is applyed; in intrusive
|
* This only works if UNINTRUSIVE SERIALIZATION is applyed; in intrusive
|
||||||
* cases a has_serialize trait should be implemented
|
* cases a has_serialize trait should be implemented
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T> struct serializable_trait : mpl::bool_<false> {};
|
||||||
struct serializable_trait : mpl::bool_<false> {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IsA Serializable Implementation Template
|
* IsA Serializable Implementation Template
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T> struct IsA : serializable_trait<T> {};
|
||||||
struct IsA : serializable_trait<T> {};
|
|
||||||
|
|
||||||
template <class ThisClass, class Archive>
|
template <class ThisClass, class Archive> struct serialize_baseobject {
|
||||||
struct serialize_baseobject {
|
|
||||||
ThisClass &m_object;
|
ThisClass &m_object;
|
||||||
Archive &m_ar;
|
Archive &m_ar;
|
||||||
serialize_baseobject(ThisClass &o, Archive &ar) : m_object(o), m_ar(ar) {}
|
serialize_baseobject(ThisClass &o, Archive &ar) : m_object(o), m_ar(ar) {}
|
||||||
template <class T> void operator()(T &o) {
|
template <class T> void operator()(T &o) {
|
||||||
m_ar &boost::serialization::make_nvp(
|
m_ar &boost::serialization::make_nvp(
|
||||||
typeid(T).name() ,
|
typeid(T).name(), boost::serialization::base_object<T>(m_object));
|
||||||
boost::serialization::base_object<T>(m_object));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
} // detail
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Serializable {
|
struct Serializable {
|
||||||
friend class boost::serialization::access;
|
friend class boost::serialization::access;
|
||||||
template <class T> friend class boost::serialization::access2;
|
template <class T> friend class boost::serialization::access2;
|
||||||
virtual ~Serializable() {}
|
virtual ~Serializable() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // U_SERIALIZABLE_H
|
#endif // U_SERIALIZABLE_H
|
||||||
|
|||||||
127
src/Core/Types.h
127
src/Core/Types.h
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_CORE_TYPES_H
|
#ifndef U_CORE_TYPES_H
|
||||||
#define U_CORE_TYPES_H
|
#define U_CORE_TYPES_H
|
||||||
|
|
||||||
@@ -38,15 +36,8 @@
|
|||||||
#include "Core/Macros.h"
|
#include "Core/Macros.h"
|
||||||
#include "Core/Mpl.h"
|
#include "Core/Mpl.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@@ -72,23 +63,19 @@ struct TypeIntrospection {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** IsA Introspectable Object Implementation Template */
|
/** IsA Introspectable Object Implementation Template */
|
||||||
template <class T>
|
template <class T> struct IsIntrospectable : has_type_info<T> {};
|
||||||
struct IsIntrospectable : has_type_info<T> {};
|
|
||||||
|
|
||||||
template <typename T> struct access {
|
template <typename T> struct access {
|
||||||
typedef typename T::type_info type_info;
|
typedef typename T::type_info type_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> struct child_first_impl {
|
||||||
struct child_first_impl {
|
|
||||||
|
|
||||||
template <class T1, bool cond>
|
template <class T1, bool cond> struct lambda_CFList_f {
|
||||||
struct lambda_CFList_f {
|
|
||||||
typedef mpl::vector<T1> type;
|
typedef mpl::vector<T1> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T1>
|
template <class T1> struct lambda_CFList_f<T1, true> {
|
||||||
struct lambda_CFList_f<T1,true> {
|
|
||||||
// typedef typename T1::type_info::CFList type;
|
// typedef typename T1::type_info::CFList type;
|
||||||
typedef typename access<T1>::type_info::CFList type;
|
typedef typename access<T1>::type_info::CFList type;
|
||||||
};
|
};
|
||||||
@@ -97,39 +84,28 @@ struct TypeIntrospection {
|
|||||||
struct lambda_CFList : lambda_CFList_f<T1, has_type_info<T1>::value> {};
|
struct lambda_CFList : lambda_CFList_f<T1, has_type_info<T1>::value> {};
|
||||||
|
|
||||||
/** Transforms all Base Type into proper CFList */
|
/** Transforms all Base Type into proper CFList */
|
||||||
typedef typename mpl::transform_view < typename access<T>::type_info::BaseList
|
typedef
|
||||||
, lambda_CFList<mpl::_>
|
typename mpl::transform_view<typename access<T>::type_info::BaseList,
|
||||||
>::type CFListSeq;
|
lambda_CFList<mpl::_>>::type CFListSeq;
|
||||||
|
|
||||||
/** Folds each CFList into a new sequence */
|
/** Folds each CFList into a new sequence */
|
||||||
typedef typename mpl::fold< CFListSeq
|
typedef typename mpl::fold<
|
||||||
, mpl::vector<>
|
CFListSeq, mpl::vector<>,
|
||||||
, mpl::copy< mpl::_1
|
mpl::copy<mpl::_1, mpl::back_inserter<mpl::_2>>>::type Childs;
|
||||||
, mpl::back_inserter<mpl::_2>
|
|
||||||
>
|
|
||||||
>::type Childs;
|
|
||||||
|
|
||||||
/** Add This Class to final CFList sequence */
|
/** Add This Class to final CFList sequence */
|
||||||
typedef typename mpl::copy< Childs
|
typedef typename mpl::copy<Childs, mpl::back_inserter<mpl::vector<T>>>::type
|
||||||
, mpl::back_inserter< mpl::vector<T> >
|
type;
|
||||||
>::type type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests if T has a member called type_info then compile type CFList
|
* Tests if T has a member called type_info then compile type CFList
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct child_first : mpl::if_< has_type_info<T>
|
struct child_first
|
||||||
, child_first_impl<T>
|
: mpl::if_<has_type_info<T>, child_first_impl<T>, mpl::vector<>>::type {};
|
||||||
, mpl::vector<>
|
|
||||||
>::type {};
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -137,30 +113,19 @@ struct TypeIntrospection {
|
|||||||
|
|
||||||
// #define _REPETITION_V(vz,vn,vdata)
|
// #define _REPETITION_V(vz,vn,vdata)
|
||||||
|
|
||||||
|
|
||||||
// template < class TypeList >
|
// template < class TypeList >
|
||||||
// class TypeAdapterInputInterface {
|
// class TypeAdapterInputInterface {
|
||||||
// virtual ~TypeAdapterInputInterface() {}
|
// virtual ~TypeAdapterInputInterface() {}
|
||||||
// public:
|
// public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// virtual void operator()(int val) {}
|
// virtual void operator()(int val) {}
|
||||||
// virtual void operator()(std::string val) {}
|
// virtual void operator()(std::string val) {}
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // detail ////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
#define CONSTEXPR BOOST_CONSTEXPR
|
#define CONSTEXPR BOOST_CONSTEXPR
|
||||||
|
|
||||||
|
|
||||||
// typedef ltk::Real_t Real_t;
|
// typedef ltk::Real_t Real_t;
|
||||||
#ifndef LTK_DOUBLE_PRECISION
|
#ifndef LTK_DOUBLE_PRECISION
|
||||||
typedef float Real_t;
|
typedef float Real_t;
|
||||||
@@ -174,8 +139,6 @@ typedef id_t Id_t;
|
|||||||
typedef void *Pointer_t;
|
typedef void *Pointer_t;
|
||||||
typedef bool Bool_t; // Boolean (0=false, 1=true) (bool)
|
typedef bool Bool_t; // Boolean (0=false, 1=true) (bool)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--- bit manipulation ---------------------------------------------------------
|
//--- bit manipulation ---------------------------------------------------------
|
||||||
#ifndef BIT
|
#ifndef BIT
|
||||||
#define BIT(n) (1ULL << (n))
|
#define BIT(n) (1ULL << (n))
|
||||||
@@ -193,14 +156,11 @@ typedef bool Bool_t; //Boolean (0=false, 1=true) (bool)
|
|||||||
#define TESTBIT(n, i) ((Bool_t)(((n) & BIT(i)) != 0))
|
#define TESTBIT(n, i) ((Bool_t)(((n) & BIT(i)) != 0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TYPE INTROSPECTION FOR OBJECTS //
|
// TYPE INTROSPECTION FOR OBJECTS //
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define uLibTypeMacro(thisClass, ...) \
|
#define uLibTypeMacro(thisClass, ...) \
|
||||||
\
|
\
|
||||||
/* Friendship detail for accessing introspection */ \
|
/* Friendship detail for accessing introspection */ \
|
||||||
@@ -215,71 +175,38 @@ typedef bool Bool_t; //Boolean (0=false, 1=true) (bool)
|
|||||||
typedef thisClass ThisClass; \
|
typedef thisClass ThisClass; \
|
||||||
typedef uLib::mpl::vector<__VA_ARGS__, thisClass> TypeList; \
|
typedef uLib::mpl::vector<__VA_ARGS__, thisClass> TypeList; \
|
||||||
typedef uLib::mpl::vector<__VA_ARGS__> BaseList; \
|
typedef uLib::mpl::vector<__VA_ARGS__> BaseList; \
|
||||||
typedef uLib::detail::TypeIntrospection::child_first<ThisClass>::type CFList; \
|
typedef uLib::detail::TypeIntrospection::child_first<ThisClass>::type \
|
||||||
|
CFList; \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
typedef type_info::BaseClass BaseClass; \
|
typedef type_info::BaseClass BaseClass; \
|
||||||
virtual const char *type_name() const { return type_info::name; } \
|
virtual const char *type_name() const { return type_info::name; } \
|
||||||
/* Object Props fwd declaration*/ \
|
|
||||||
struct ObjectProps; \
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TypeList inheritance introspection
|
* TypeList inheritance introspection
|
||||||
*/
|
*/
|
||||||
struct TypeIntrospection {
|
struct TypeIntrospection {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct child_first : detail::TypeIntrospection::child_first<T> {};
|
struct child_first : detail::TypeIntrospection::child_first<T> {};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// SISTEMARE //
|
// SISTEMARE //
|
||||||
struct PrintTypeId {
|
struct PrintTypeId {
|
||||||
template <class T>
|
template <class T> void operator()(T) const {
|
||||||
void operator()(T) const
|
std::cout << typeid(T).name() << std::endl;
|
||||||
{ std::cout << typeid(T).name() << std::endl; }
|
}
|
||||||
|
|
||||||
template <typename SeqT>
|
template <typename SeqT> static void PrintMplSeq(SeqT *p = NULL) {
|
||||||
static void PrintMplSeq(SeqT *p = NULL) { boost::mpl::for_each<SeqT>(PrintTypeId()); }
|
boost::mpl::for_each<SeqT>(PrintTypeId());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Class>
|
template <typename Class> static void PrintType(Class *p = NULL) {
|
||||||
static void PrintType(Class *p = NULL) { std::cout << typeid(Class).name() << std::endl; }
|
std::cout << typeid(Class).name() << std::endl;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // uLib
|
|
||||||
|
|
||||||
#endif // U_CORE_TYPES_H
|
#endif // U_CORE_TYPES_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ set( TESTS
|
|||||||
SerializeTest
|
SerializeTest
|
||||||
SerializeDreadDiamondTest
|
SerializeDreadDiamondTest
|
||||||
DreadDiamondParameters
|
DreadDiamondParameters
|
||||||
ObjectPropableTest
|
|
||||||
UuidTest
|
UuidTest
|
||||||
TypeIntrospectionTraversal
|
TypeIntrospectionTraversal
|
||||||
OptionsTest
|
OptionsTest
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ TESTS = SmartPointerTest \
|
|||||||
SerializeTest \
|
SerializeTest \
|
||||||
SerializeDreadDiamondTest \
|
SerializeDreadDiamondTest \
|
||||||
DreadDiamondParameters \
|
DreadDiamondParameters \
|
||||||
ObjectPropableTest \
|
|
||||||
TypeIntrospectionTraversal \
|
TypeIntrospectionTraversal \
|
||||||
OptionsTest
|
OptionsTest
|
||||||
|
|
||||||
|
|||||||
@@ -1,237 +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 <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <typeinfo>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
#include "Core/Types.h"
|
|
||||||
#include "Core/Object.h"
|
|
||||||
#include "Core/ObjectProps.h"
|
|
||||||
#include "Core/StringReader.h"
|
|
||||||
#include "Math/Dense.h"
|
|
||||||
|
|
||||||
#include "boost/archive/text_oarchive.hpp"
|
|
||||||
#include "boost/archive/text_iarchive.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
#include "testing-prototype.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace uLib;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// STRUCTURES //
|
|
||||||
|
|
||||||
|
|
||||||
struct A : virtual Object {
|
|
||||||
|
|
||||||
uLibTypeMacro(A, Object)
|
|
||||||
|
|
||||||
properties() {
|
|
||||||
int p_a;
|
|
||||||
Vector3f p_3f;
|
|
||||||
};
|
|
||||||
|
|
||||||
int m_a;
|
|
||||||
};
|
|
||||||
|
|
||||||
void A::init_properties() {
|
|
||||||
$_init();
|
|
||||||
$$.p_a = 0;
|
|
||||||
$$.p_3f << 1,2,3;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(A)
|
|
||||||
ULIB_SERIALIZE_OBJECT(A, Object) { ar & AR(m_a); }
|
|
||||||
ULIB_SERIALIZE_OBJECT_PROPS(A) { ar & AR(p_a) & AR(p_3f); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct B : A {
|
|
||||||
uLibTypeMacro(B,A)
|
|
||||||
|
|
||||||
properties() {
|
|
||||||
std::string p;
|
|
||||||
};
|
|
||||||
|
|
||||||
B() : m_b(324) {}
|
|
||||||
|
|
||||||
int m_b;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void B::init_properties() {
|
|
||||||
$_init();
|
|
||||||
$$.p = "ciao";
|
|
||||||
}
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(B)
|
|
||||||
ULIB_SERIALIZE_OBJECT(B,A) { ar & AR(m_b); }
|
|
||||||
ULIB_SERIALIZE_OBJECT_PROPS(B) { ar & AR(p); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct C {
|
|
||||||
int m_c;
|
|
||||||
std::string m_str;
|
|
||||||
};
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(C)
|
|
||||||
ULIB_SERIALIZE(C) { ar & AR(m_c) & AR(m_str); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct D : virtual Object, B {
|
|
||||||
uLibTypeMacro(D,Object,B)
|
|
||||||
|
|
||||||
properties() {
|
|
||||||
C p_c;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
void D::init_properties() {
|
|
||||||
$_init();
|
|
||||||
$$.p_c.m_c = 1234;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(D)
|
|
||||||
ULIB_SERIALIZE_OBJECT(D,Object) {}
|
|
||||||
ULIB_SERIALIZE_OBJECT_PROPS(D) {
|
|
||||||
ar & AR(p_c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class E : public C, public D {
|
|
||||||
uLibTypeMacro(E,D,C)
|
|
||||||
public:
|
|
||||||
E() : m_Ea(5552368) {}
|
|
||||||
int m_Ea;
|
|
||||||
};
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(E)
|
|
||||||
ULIB_SERIALIZE_OBJECT(E,C,D) {
|
|
||||||
ar & AR(m_Ea);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TESTS //
|
|
||||||
|
|
||||||
|
|
||||||
int test_xml_direct() {
|
|
||||||
// TEST ARCHIVE SAVE AND LOAD direct //
|
|
||||||
E o; o.init_properties();
|
|
||||||
o.$$.p_c.m_str = "works";
|
|
||||||
{
|
|
||||||
std::ofstream file("test.xml");
|
|
||||||
Archive::xml_oarchive ar(file);
|
|
||||||
ar << NVP(o);
|
|
||||||
}
|
|
||||||
o.$$.p_c.m_str = "hola";
|
|
||||||
{
|
|
||||||
std::ifstream file("test.xml");
|
|
||||||
Archive::xml_iarchive ar(file);
|
|
||||||
ar >> NVP(o);
|
|
||||||
}
|
|
||||||
std::cout << o.$$.p_c.m_str << "\n";
|
|
||||||
return ( o.$$.p_c.m_str == "works" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int test_xml_pointer() {
|
|
||||||
// TEST ARCHIVE SAVE AND LOAD from pointer //
|
|
||||||
E *o = new E; o->init_properties();
|
|
||||||
o->$$.p_c.m_str = "works";
|
|
||||||
{
|
|
||||||
std::ofstream file("test.xml");
|
|
||||||
Archive::xml_oarchive ar(file);
|
|
||||||
ar << NVP(o);
|
|
||||||
}
|
|
||||||
o->$$.p_c.m_str = "hola";
|
|
||||||
{
|
|
||||||
std::ifstream file("test.xml");
|
|
||||||
Archive::xml_iarchive ar(file);
|
|
||||||
ar >> NVP(o);
|
|
||||||
}
|
|
||||||
std::cout << o->$$.p_c.m_str << "\n";
|
|
||||||
return ( o->$$.p_c.m_str == "works" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int test_xml_objsave() {
|
|
||||||
// TEST SELF SAVE
|
|
||||||
E o; o.init_properties();
|
|
||||||
o.$(B).p = "works";
|
|
||||||
{
|
|
||||||
std::ofstream file("test.xml");
|
|
||||||
Object::SaveXml(file,o);
|
|
||||||
}
|
|
||||||
o.$(B).p = "hola";
|
|
||||||
{
|
|
||||||
std::ifstream file("test.xml");
|
|
||||||
Object::LoadXml(file,o);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << o.$(B).p << "\n";
|
|
||||||
return ( o.$(B).p == "works" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// MAIN //
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
BEGIN_TESTING(PropableTest);
|
|
||||||
|
|
||||||
TEST1( test_xml_direct() );
|
|
||||||
TEST1( test_xml_pointer() );
|
|
||||||
TEST1( test_xml_objsave() );
|
|
||||||
|
|
||||||
END_TESTING;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
106
src/Math/Dense.h
106
src/Math/Dense.h
@@ -23,9 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* <one line to give the program's name and a brief idea of what it does.>
|
* <one line to give the program's name and a brief idea of what it does.>
|
||||||
* Copyright (C) 2012 Andrea Rigoni Garola <andrea@pcimg05>
|
* Copyright (C) 2012 Andrea Rigoni Garola <andrea@pcimg05>
|
||||||
@@ -47,7 +44,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ULIB_DENSEMATRIX_H
|
#ifndef ULIB_DENSEMATRIX_H
|
||||||
#define ULIB_DENSEMATRIX_H
|
#define ULIB_DENSEMATRIX_H
|
||||||
|
|
||||||
@@ -55,27 +51,29 @@
|
|||||||
|
|
||||||
#include <Eigen/Dense>
|
#include <Eigen/Dense>
|
||||||
|
|
||||||
|
|
||||||
//// BOOST SERIALIZATION ///////////////////////////////////////////////////////
|
//// BOOST SERIALIZATION ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/serialization/string.hpp>
|
|
||||||
#include <boost/serialization/array.hpp>
|
#include <boost/serialization/array.hpp>
|
||||||
|
#include <boost/serialization/string.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace serialization {
|
namespace serialization {
|
||||||
|
|
||||||
template<class Archive, class Scalar, int RowsAtCompileTime, int ColsAtCompileTime>
|
template <class Archive, class Scalar, int RowsAtCompileTime,
|
||||||
void serialize(Archive & ar, ::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> & m, const unsigned int /*version*/) {
|
int ColsAtCompileTime>
|
||||||
ar & boost::serialization::make_array(m.data(), RowsAtCompileTime * ColsAtCompileTime);
|
void serialize(Archive &ar,
|
||||||
|
::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> &m,
|
||||||
|
const unsigned int /*version*/) {
|
||||||
|
ar &boost::serialization::make_array(m.data(),
|
||||||
|
RowsAtCompileTime * ColsAtCompileTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // serialization
|
} // namespace serialization
|
||||||
} // boost
|
} // namespace boost
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -89,21 +87,22 @@ std::istream & operator >> (std::istream &is, Eigen::Matrix<T,size,1> &vec) {
|
|||||||
for (unsigned int i = 0; i < size; i++) {
|
for (unsigned int i = 0; i < size; i++) {
|
||||||
is >> std::skipws;
|
is >> std::skipws;
|
||||||
is >> str;
|
is >> str;
|
||||||
if(is.fail()) vec(i) = 0;
|
if (is.fail())
|
||||||
else vec(i) = boost::lexical_cast<T>(str);
|
vec(i) = 0;
|
||||||
|
else
|
||||||
|
vec(i) = boost::lexical_cast<T>(str);
|
||||||
}
|
}
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
template <typename T, int size>
|
template <typename T, int size>
|
||||||
std::ostream & operator << (std::ostream &os, const Eigen::Matrix<T,size,1> &vec) {
|
std::ostream &operator<<(std::ostream &os,
|
||||||
|
const Eigen::Matrix<T, size, 1> &vec) {
|
||||||
os << vec.transpose();
|
os << vec.transpose();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
} // Eigen
|
} // namespace Eigen
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace uLib {
|
namespace uLib {
|
||||||
|
|
||||||
typedef id_t Id_t;
|
typedef id_t Id_t;
|
||||||
@@ -115,8 +114,6 @@ typedef unsigned long Scalarul;
|
|||||||
typedef float Scalarf;
|
typedef float Scalarf;
|
||||||
typedef double Scalard;
|
typedef double Scalard;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef Eigen::Matrix<int, 1, 1> Matrix1i;
|
typedef Eigen::Matrix<int, 1, 1> Matrix1i;
|
||||||
typedef Eigen::Matrix2i Matrix2i;
|
typedef Eigen::Matrix2i Matrix2i;
|
||||||
typedef Eigen::Matrix3i Matrix3i;
|
typedef Eigen::Matrix3i Matrix3i;
|
||||||
@@ -137,8 +134,6 @@ typedef Eigen::Vector2f Vector2f;
|
|||||||
typedef Eigen::Vector3f Vector3f;
|
typedef Eigen::Vector3f Vector3f;
|
||||||
typedef Eigen::Vector4f Vector4f;
|
typedef Eigen::Vector4f Vector4f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Vector String interaction ///////////////////////////////////////////////////
|
// Vector String interaction ///////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -149,15 +144,18 @@ typedef Eigen::Vector4f Vector4f;
|
|||||||
*
|
*
|
||||||
* \param vec A double vector to be populated with the results
|
* \param vec A double vector to be populated with the results
|
||||||
* \param str A string to be parsed as a series of doubles.
|
* \param str A string to be parsed as a series of doubles.
|
||||||
* \param delim Delimiters of the text (a typical default is " ," for comma and space-delimited text
|
* \param delim Delimiters of the text (a typical default is " ," for comma and
|
||||||
|
* space-delimited text
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template <typename T, int size>
|
template <typename T, int size>
|
||||||
void VectorxT_StringTo(Eigen::Matrix<T,size,1> &vec, std::string str, const char *delim = " ,;\t\n") {
|
void VectorxT_StringTo(Eigen::Matrix<T, size, 1> &vec, std::string str,
|
||||||
|
const char *delim = " ,;\t\n") {
|
||||||
std::vector<std::string> strvec;
|
std::vector<std::string> strvec;
|
||||||
|
|
||||||
boost::algorithm::trim_if(str, boost::algorithm::is_any_of(delim));
|
boost::algorithm::trim_if(str, boost::algorithm::is_any_of(delim));
|
||||||
boost::algorithm::split(strvec,str,boost::algorithm::is_any_of(delim), boost::algorithm::token_compress_on);
|
boost::algorithm::split(strvec, str, boost::algorithm::is_any_of(delim),
|
||||||
|
boost::algorithm::token_compress_on);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < size; i++) {
|
for (unsigned int i = 0; i < size; i++) {
|
||||||
vec(i) = boost::lexical_cast<T>(strvec[i]);
|
vec(i) = boost::lexical_cast<T>(strvec[i]);
|
||||||
@@ -171,9 +169,9 @@ std::string VectorxT_ToString(const Eigen::Matrix<T,size,1> &vec) {
|
|||||||
return sst.str();
|
return sst.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// template <typename T, int size>
|
// template <typename T, int size>
|
||||||
//Eigen::Matrix<T,size,1> & operator >> (std::istream &is, Eigen::Matrix<T,size,1> &vec) {
|
// Eigen::Matrix<T,size,1> & operator >> (std::istream &is,
|
||||||
|
// Eigen::Matrix<T,size,1> &vec) {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
template <typename T, int size>
|
template <typename T, int size>
|
||||||
@@ -181,80 +179,66 @@ void operator>> (std::string& str, Eigen::Matrix<T,size,1> &vec){
|
|||||||
VectorxT_StringTo(vec, str);
|
VectorxT_StringTo(vec, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////// HOMOGENEOUS VECTORS //////////////////////////////////////////////////
|
////// HOMOGENEOUS VECTORS //////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <bool p>
|
template <bool p> class _HPoint3f : public Eigen::Matrix<Scalarf, 4, 1> {
|
||||||
class _HPoint3f : public Eigen::Matrix< Scalarf,4,1 > {
|
|
||||||
public:
|
public:
|
||||||
typedef Eigen::Matrix<Scalarf, 4, 1> BaseClass;
|
typedef Eigen::Matrix<Scalarf, 4, 1> BaseClass;
|
||||||
|
|
||||||
_HPoint3f<p>() : BaseClass(0,0,0,p) {}
|
_HPoint3f() : BaseClass(0, 0, 0, p) {}
|
||||||
_HPoint3f<p>(float x,float y,float z) : BaseClass(x,y,z,p) {}
|
_HPoint3f(float x, float y, float z) : BaseClass(x, y, z, p) {}
|
||||||
_HPoint3f<p>(Vector3f &in) : BaseClass(in.homogeneous()) { this->operator()(3) = p; }
|
_HPoint3f(Vector3f &in) : BaseClass(in.homogeneous()) {
|
||||||
|
this->operator()(3) = p;
|
||||||
|
}
|
||||||
|
|
||||||
void operator delete(void *_p, size_t _s) {}
|
void operator delete(void *_p, size_t _s) {}
|
||||||
|
|
||||||
// This constructor allows to construct MyVectorType from Eigen expressions
|
// This constructor allows to construct MyVectorType from Eigen expressions
|
||||||
template <typename OtherDerived>
|
template <typename OtherDerived>
|
||||||
inline _HPoint3f<p>(const Eigen::MatrixBase<OtherDerived>& other)
|
inline _HPoint3f(const Eigen::MatrixBase<OtherDerived> &other)
|
||||||
: BaseClass(other)
|
: BaseClass(other) {}
|
||||||
{ }
|
|
||||||
|
|
||||||
// This method allows to assign Eigen expressions to Vector3H
|
// This method allows to assign Eigen expressions to Vector3H
|
||||||
template <typename OtherDerived>
|
template <typename OtherDerived>
|
||||||
inline _HPoint3f<p> & operator= (const Eigen::MatrixBase <OtherDerived>& other)
|
inline _HPoint3f &operator=(const Eigen::MatrixBase<OtherDerived> &other) {
|
||||||
{
|
|
||||||
this->BaseClass::operator=(other);
|
this->BaseClass::operator=(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef _HPoint3f<false> HVector3f;
|
typedef _HPoint3f<false> HVector3f;
|
||||||
typedef _HPoint3f<true> HPoint3f;
|
typedef _HPoint3f<true> HPoint3f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////// HOMOGENEOUS LINE //////////////////////////////////////////////////
|
////// HOMOGENEOUS LINE //////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct _HLine3f {
|
||||||
struct _HLine3f
|
|
||||||
{
|
|
||||||
HPoint3f origin;
|
HPoint3f origin;
|
||||||
HVector3f direction;
|
HVector3f direction;
|
||||||
};
|
};
|
||||||
typedef struct _HLine3f HLine3f;
|
typedef struct _HLine3f HLine3f;
|
||||||
|
|
||||||
inline std::ostream&
|
inline std::ostream &operator<<(std::ostream &stream, const HLine3f &line) {
|
||||||
operator<< (std::ostream& stream, const HLine3f &line) {
|
stream << "HLine3f(" << "pt[" << line.origin.transpose() << "] , dr["
|
||||||
stream << "HLine3f(" << "pt[" << line.origin.transpose() <<"] , dr[" << line.direction.transpose() << "]) ";
|
<< line.direction.transpose() << "]) ";
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _HError3f {
|
||||||
|
|
||||||
|
|
||||||
struct _HError3f
|
|
||||||
{
|
|
||||||
HVector3f position_error;
|
HVector3f position_error;
|
||||||
HVector3f direction_error;
|
HVector3f direction_error;
|
||||||
};
|
};
|
||||||
typedef struct _HError3f HError3f;
|
typedef struct _HError3f HError3f;
|
||||||
|
|
||||||
inline std::ostream&
|
inline std::ostream &operator<<(std::ostream &stream, const HError3f &err) {
|
||||||
operator<< (std::ostream& stream, const HError3f &err) {
|
stream << "HError3f(" << "ept[" << err.position_error.transpose()
|
||||||
stream << "HError3f(" << "ept[" << err.position_error.transpose() <<"] , edr[" << err.direction_error.transpose() << "]) ";
|
<< "] , edr[" << err.direction_error.transpose() << "]) ";
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace uLib
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -268,13 +252,9 @@ ULIB_SERIALIZABLE(uLib::HPoint3f)
|
|||||||
|
|
||||||
ULIB_SERIALIZABLE(uLib::HVector3f)
|
ULIB_SERIALIZABLE(uLib::HVector3f)
|
||||||
|
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(uLib::HLine3f)
|
ULIB_SERIALIZABLE(uLib::HLine3f)
|
||||||
|
|
||||||
ULIB_SERIALIZABLE(uLib::HError3f)
|
ULIB_SERIALIZABLE(uLib::HError3f)
|
||||||
#endif // ULIB_SERIALIZATION_ON
|
#endif // ULIB_SERIALIZATION_ON
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // U_DENSEMATRIX_H
|
#endif // U_DENSEMATRIX_H
|
||||||
|
|||||||
@@ -23,11 +23,10 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "VoxRaytracer.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "VoxRaytracer.h"
|
||||||
|
|
||||||
#define unlikely(expr) __builtin_expect(!!(expr), 0)
|
#define unlikely(expr) __builtin_expect(!!(expr), 0)
|
||||||
|
|
||||||
@@ -39,29 +38,25 @@ namespace uLib {
|
|||||||
///// RAY DATA /////////////////////////////////////////////////////////////////
|
///// RAY DATA /////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void VoxRaytracer::RayData::AddElement(Id_t id, float L)
|
void VoxRaytracer::RayData::AddElement(Id_t id, float L) {
|
||||||
{
|
|
||||||
Element el = {id, L};
|
Element el = {id, L};
|
||||||
m_Data.push_back(el);
|
m_Data.push_back(el);
|
||||||
m_TotalLength += L;
|
m_TotalLength += L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in) {
|
||||||
void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in)
|
|
||||||
{
|
|
||||||
if (unlikely(!in.m_Data.size())) {
|
if (unlikely(!in.m_Data.size())) {
|
||||||
std::cout << "Warinig: PoCA on exit border!\n";
|
std::cout << "Warinig: PoCA on exit border!\n";
|
||||||
return;
|
return;
|
||||||
}
|
} else if (unlikely(!m_Data.size())) {
|
||||||
else if (unlikely(!m_Data.size())) {
|
|
||||||
m_Data = in.m_Data;
|
m_Data = in.m_Data;
|
||||||
std::cout << "Warinig: PoCA on entrance border!\n";
|
std::cout << "Warinig: PoCA on entrance border!\n";
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Opzione 1) un voxel in piu' //
|
// Opzione 1) un voxel in piu' //
|
||||||
m_Data.reserve(m_Data.size() + in.m_Data.size());
|
if (in.m_Data.size() > 0) {
|
||||||
m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
|
m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
|
||||||
|
}
|
||||||
// Opzione 2) merge dei voxel nel poca.
|
// Opzione 2) merge dei voxel nel poca.
|
||||||
// RayData::Element &e1 = m_Data.back();
|
// RayData::Element &e1 = m_Data.back();
|
||||||
// const RayData::Element &e2 = in.m_Data.front();
|
// const RayData::Element &e2 = in.m_Data.front();
|
||||||
@@ -69,32 +64,30 @@ void VoxRaytracer::RayData::AppendRay(const VoxRaytracer::RayData &in)
|
|||||||
// {
|
// {
|
||||||
// m_Data.reserve(m_Data.size() + in.m_Data.size() - 1);
|
// m_Data.reserve(m_Data.size() + in.m_Data.size() - 1);
|
||||||
// e1.L += e2.L; //fix//
|
// e1.L += e2.L; //fix//
|
||||||
// m_Data.insert(m_Data.end(), in.m_Data.begin()+1, in.m_Data.end());
|
// m_Data.insert(m_Data.end(), in.m_Data.begin()+1,
|
||||||
|
// in.m_Data.end());
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
// m_Data.reserve(m_Data.size() + in.m_Data.size());
|
// m_Data.reserve(m_Data.size() + in.m_Data.size());
|
||||||
// m_Data.insert(m_Data.end(), in.m_Data.begin(), in.m_Data.end());
|
// m_Data.insert(m_Data.end(), in.m_Data.begin(),
|
||||||
|
// in.m_Data.end());
|
||||||
// }
|
// }
|
||||||
m_TotalLength += in.m_TotalLength;
|
m_TotalLength += in.m_TotalLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxRaytracer::RayData::PrintSelf(std::ostream &o)
|
void VoxRaytracer::RayData::PrintSelf(std::ostream &o) {
|
||||||
{
|
|
||||||
o << "Ray: total lenght " << m_TotalLength << "\n";
|
o << "Ray: total lenght " << m_TotalLength << "\n";
|
||||||
std::vector<Element>::iterator it;
|
std::vector<Element>::iterator it;
|
||||||
for (it = m_Data.begin(); it < m_Data.end(); ++it)
|
for (it = m_Data.begin(); it < m_Data.end(); ++it)
|
||||||
o << "[ " << (*it).vox_id << ", " << (*it).L << "] \n";
|
o << "[ " << (*it).vox_id << ", " << (*it).L << "] \n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//// RAY TRACER ////////////////////////////////////////////////////////////////
|
//// RAY TRACER ////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt) {
|
||||||
bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt)
|
|
||||||
{
|
|
||||||
Vector4f s = m_Image->GetLocalPoint(line.direction);
|
Vector4f s = m_Image->GetLocalPoint(line.direction);
|
||||||
pt = m_Image->GetLocalPoint(line.origin);
|
pt = m_Image->GetLocalPoint(line.origin);
|
||||||
|
|
||||||
@@ -111,9 +104,9 @@ bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt)
|
|||||||
offset(i) = (s(i) > 0) - (pt(i) - floor(pt(i)));
|
offset(i) = (s(i) > 0) - (pt(i) - floor(pt(i)));
|
||||||
offset = offset.cwiseProduct(L).cwiseAbs();
|
offset = offset.cwiseProduct(L).cwiseAbs();
|
||||||
|
|
||||||
int id; float d;
|
int id;
|
||||||
for(int loop=0; loop<8; loop++)
|
float d;
|
||||||
{
|
for (int loop = 0; loop < 8; loop++) {
|
||||||
int check_border = 0;
|
int check_border = 0;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
check_border += pt(i) > 1;
|
check_border += pt(i) > 1;
|
||||||
@@ -132,7 +125,6 @@ bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt)
|
|||||||
|
|
||||||
pt(id) = rintf(pt(id));
|
pt(id) = rintf(pt(id));
|
||||||
|
|
||||||
|
|
||||||
offset.array() -= d;
|
offset.array() -= d;
|
||||||
offset(id) = fabs(L(id));
|
offset(id) = fabs(L(id));
|
||||||
}
|
}
|
||||||
@@ -142,18 +134,15 @@ bool VoxRaytracer::GetEntryPoint(const HLine3f &line, HPoint3f &pt)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoxRaytracer::GetExitPoint(const HLine3f &line, HPoint3f &pt)
|
bool VoxRaytracer::GetExitPoint(const HLine3f &line, HPoint3f &pt) {
|
||||||
{
|
|
||||||
HLine3f out = line;
|
HLine3f out = line;
|
||||||
out.direction *= -1;
|
out.direction *= -1;
|
||||||
return GetEntryPoint(out, pt);
|
return GetEntryPoint(out, pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VoxRaytracer::RayData
|
||||||
VoxRaytracer::RayData VoxRaytracer::TraceBetweenPoints(const HPoint3f &in,
|
VoxRaytracer::TraceBetweenPoints(const HPoint3f &in,
|
||||||
const HPoint3f &out)
|
const HPoint3f &out) const {
|
||||||
const
|
|
||||||
{
|
|
||||||
RayData ray;
|
RayData ray;
|
||||||
Vector4f pt1 = m_Image->GetLocalPoint(in);
|
Vector4f pt1 = m_Image->GetLocalPoint(in);
|
||||||
Vector4f pt2 = m_Image->GetLocalPoint(out);
|
Vector4f pt2 = m_Image->GetLocalPoint(out);
|
||||||
@@ -168,7 +157,8 @@ const
|
|||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
||||||
|
|
||||||
Vector3f offset;
|
Vector3f offset;
|
||||||
for(int i=0;i<3;++i) offset(i) = (s(i)>=0) - (pt1(i)-floor(pt1(i))) ;
|
for (int i = 0; i < 3; ++i)
|
||||||
|
offset(i) = (s(i) >= 0) - (pt1(i) - floor(pt1(i)));
|
||||||
offset = offset.cwiseProduct(L).cwiseAbs();
|
offset = offset.cwiseProduct(L).cwiseAbs();
|
||||||
L = L.cwiseAbs();
|
L = L.cwiseAbs();
|
||||||
|
|
||||||
@@ -180,7 +170,8 @@ const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---- Otherwise, loop until ray is finished
|
//---- Otherwise, loop until ray is finished
|
||||||
int id; float d;
|
int id;
|
||||||
|
float d;
|
||||||
while (l > 0) {
|
while (l > 0) {
|
||||||
|
|
||||||
d = offset.minCoeff(&id);
|
d = offset.minCoeff(&id);
|
||||||
@@ -205,8 +196,7 @@ const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 20150528 SV for absorbed muons
|
// 20150528 SV for absorbed muons
|
||||||
VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const
|
VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const {
|
||||||
{
|
|
||||||
RayData ray;
|
RayData ray;
|
||||||
|
|
||||||
Vector4f pt = m_Image->GetLocalPoint(line.origin);
|
Vector4f pt = m_Image->GetLocalPoint(line.origin);
|
||||||
@@ -222,18 +212,18 @@ VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const
|
|||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
// (m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
||||||
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
// (m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
||||||
|
|
||||||
// offset is the fraction of the segment between grid lines when origin is insiede voxel
|
// offset is the fraction of the segment between grid lines when origin is
|
||||||
// cwiseAbs for having positive distances
|
// insiede voxel cwiseAbs for having positive distances
|
||||||
Vector3f offset;
|
Vector3f offset;
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
offset(i) = (s(i) >= 0) - (pt(i) - floor(pt(i)));
|
offset(i) = (s(i) >= 0) - (pt(i) - floor(pt(i)));
|
||||||
offset = offset.cwiseProduct(L).cwiseAbs();
|
offset = offset.cwiseProduct(L).cwiseAbs();
|
||||||
L = L.cwiseAbs();
|
L = L.cwiseAbs();
|
||||||
|
|
||||||
int id; float d;
|
int id;
|
||||||
|
float d;
|
||||||
Vector3i vid = m_Image->Find(line.origin);
|
Vector3i vid = m_Image->Find(line.origin);
|
||||||
while(m_Image->IsInsideGrid(vid))
|
while (m_Image->IsInsideGrid(vid)) {
|
||||||
{
|
|
||||||
// minimun coefficient of offset: id is the coordinate, d is the value
|
// minimun coefficient of offset: id is the coordinate, d is the value
|
||||||
// dependig on which grid line horizontal or vertical it is first intercept
|
// dependig on which grid line horizontal or vertical it is first intercept
|
||||||
d = offset.minCoeff(&id);
|
d = offset.minCoeff(&id);
|
||||||
@@ -250,4 +240,4 @@ VoxRaytracer::RayData VoxRaytracer::TraceLine(const HLine3f &line) const
|
|||||||
return ray;
|
return ray;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace uLib
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef U_ROOT_LINKDEF_H
|
#ifndef U_ROOT_LINKDEF_H
|
||||||
#define U_ROOT_LINKDEF_H
|
#define U_ROOT_LINKDEF_H
|
||||||
|
|
||||||
@@ -35,45 +33,14 @@
|
|||||||
#pragma link off all functions;
|
#pragma link off all functions;
|
||||||
#pragma link C++ nestedclasses;
|
#pragma link C++ nestedclasses;
|
||||||
|
|
||||||
#pragma link C++ class TestTObject+;
|
|
||||||
|
|
||||||
using namespace ROOT::Mutom;
|
using namespace ROOT::Mutom;
|
||||||
|
|
||||||
#pragma link C++ class ROOT::Math::Cartesian2D<int>+;
|
|
||||||
#pragma link C++ class ROOT::Math::Cartesian2D<float>+;
|
|
||||||
#pragma link C++ class ROOT::Math::Cartesian2D<double>+;
|
|
||||||
|
|
||||||
#pragma link C++ class ROOT::Math::Cartesian3D < int> + ;
|
#pragma link C++ class ROOT::Math::Cartesian3D < int> + ;
|
||||||
#pragma link C++ class ROOT::Math::Cartesian3D < float> + ;
|
#pragma link C++ class ROOT::Math::Cartesian3D < float> + ;
|
||||||
#pragma link C++ class ROOT::Math::Cartesian3D < double> + ;
|
#pragma link C++ class ROOT::Math::Cartesian3D < double> + ;
|
||||||
|
|
||||||
#pragma link C++ class Vector2i+;
|
|
||||||
#pragma link C++ class Vector2f+;
|
|
||||||
#pragma link C++ class Vector2d+;
|
|
||||||
|
|
||||||
#pragma link C++ class Vector3i+;
|
|
||||||
#pragma link C++ class Vector3f+;
|
|
||||||
#pragma link C++ class Vector3d+;
|
|
||||||
|
|
||||||
#pragma link C++ typedef Matrix3i;
|
|
||||||
#pragma link C++ typedef Matrix3f;
|
|
||||||
#pragma link C++ typedef Matrix3d;
|
|
||||||
|
|
||||||
#pragma link C++ class Line3f+;
|
|
||||||
#pragma link C++ class Line3d+;
|
|
||||||
|
|
||||||
#pragma link C++ class MuonTrack+;
|
|
||||||
#pragma link C++ class MuonScatter+;
|
|
||||||
#pragma link C++ function MuonScatter::p_mean() const;
|
|
||||||
|
|
||||||
// #pragma link C++ class DetectorChamber+;
|
// #pragma link C++ class DetectorChamber+;
|
||||||
|
|
||||||
#pragma link C++ class HitRaw+;
|
|
||||||
#pragma link C++ function HitRaw::Chm() const;
|
|
||||||
#pragma link C++ function HitRaw::Rob() const;
|
|
||||||
#pragma link C++ function HitRaw::Tdc() const;
|
|
||||||
#pragma link C++ function HitRaw::Ch() const;
|
|
||||||
|
|
||||||
#pragma link C++ class muCastorMCTrack + ;
|
#pragma link C++ class muCastorMCTrack + ;
|
||||||
#pragma link C++ class muCastorHit + ;
|
#pragma link C++ class muCastorHit + ;
|
||||||
#pragma link C++ class muCastorInfo + ;
|
#pragma link C++ class muCastorInfo + ;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ src/Core/testing/Flags.h
|
|||||||
src/Core/testing/ObjectCopyTest.cpp
|
src/Core/testing/ObjectCopyTest.cpp
|
||||||
src/Core/testing/ObjectFlagsTest.cpp
|
src/Core/testing/ObjectFlagsTest.cpp
|
||||||
src/Core/testing/ObjectParametersTest.cpp
|
src/Core/testing/ObjectParametersTest.cpp
|
||||||
src/Core/testing/ObjectPropableTest.cpp
|
|
||||||
src/Core/testing/OptionsTest.cpp
|
src/Core/testing/OptionsTest.cpp
|
||||||
src/Core/testing/PropertiesTest.cpp
|
src/Core/testing/PropertiesTest.cpp
|
||||||
src/Core/testing/SerializeDreadDiamondTest.cpp
|
src/Core/testing/SerializeDreadDiamondTest.cpp
|
||||||
@@ -59,7 +58,6 @@ src/Core/Macros.h
|
|||||||
src/Core/Mpl.h
|
src/Core/Mpl.h
|
||||||
src/Core/Object.cpp
|
src/Core/Object.cpp
|
||||||
src/Core/Object.h
|
src/Core/Object.h
|
||||||
src/Core/ObjectProps.h
|
|
||||||
src/Core/Options.cpp
|
src/Core/Options.cpp
|
||||||
src/Core/Options.h
|
src/Core/Options.h
|
||||||
src/Core/Serializable.cpp
|
src/Core/Serializable.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user