Commit ef4d2970 authored by Andreas Nüßing's avatar Andreas Nüßing

Merge branch 'feature/remove-simbio' into 'master'

[SimBio] remove the analytical solution

See merge request duneuro/duneuro!32
parents 175f8007 27be0304
......@@ -3,5 +3,4 @@ add_subdirectory(eeg)
add_subdirectory(meeg)
add_subdirectory(io)
add_subdirectory(meg)
add_subdirectory(legacy)
add_subdirectory(test)
#ifndef DUNEURO_ANALYTICSOLUTION_HH
#define DUNEURO_ANALYTICSOLUTION_HH
#include <cassert>
#include <vector>
#include <dune/common/dynmatrix.hh>
#include <dune/common/fvector.hh>
#include <dune/common/parametertree.hh>
#include <dune/common/timer.hh>
#include <duneuro/common/dipole.hh>
#include <duneuro/common/exceptions.hh>
#include <duneuro/common/matrix_utilities.hh>
#include <duneuro/io/data_tree.hh>
#include <duneuro/legacy/analytic_solution.hh>
namespace duneuro
{
/** compute the analytic solution of the eeg-forward problem in a multi
* layer sphere model
*/
template <class ctype>
class AnalyticSolution
{
public:
enum { dim = 3 };
AnalyticSolution(std::vector<ctype> sphereRadii, Dune::FieldVector<ctype, dim> sphereCenter,
std::vector<ctype> conductivities,
std::vector<Dune::FieldVector<ctype, dim>> electrodePositions)
: sphereRadii_(sphereRadii)
, sphereCenter_(sphereCenter)
, conductivities_(conductivities)
, electrodePositions_(electrodePositions)
{
if (sphereRadii_.size() != conductivities_.size()) {
DUNE_THROW(IllegalArgumentException,
"number of spheres does not match number of conductivities ("
<< sphereRadii_.size() << " vs " << conductivities_.size() << ")");
}
}
AnalyticSolution(const Dune::ParameterTree& config,
std::vector<Dune::FieldVector<ctype, dim>> electrodePositions)
: sphereRadii_(config.get<std::vector<ctype>>("radii"))
, sphereCenter_(config.get<Dune::FieldVector<ctype, dim>>("center"))
, conductivities_(config.get<std::vector<ctype>>("conductivities"))
, electrodePositions_(electrodePositions)
{
if (sphereRadii_.size() != conductivities_.size()) {
DUNE_THROW(IllegalArgumentException,
"number of spheres does not match number of conductivities ("
<< sphereRadii_.size() << " vs " << conductivities_.size() << ")");
}
}
std::vector<ctype> operator()(const Dipole<ctype, dim>& dipole) const
{
return Legacy::analytic_solution(sphereRadii_, sphereCenter_, conductivities_,
electrodePositions_, dipole.moment(), dipole.position());
}
private:
unsigned int numberOfLayers_;
std::vector<ctype> sphereRadii_;
Dune::FieldVector<ctype, dim> sphereCenter_;
std::vector<ctype> conductivities_;
std::vector<Dune::FieldVector<ctype, dim>> electrodePositions_;
};
template <class ctype, int dim>
Dune::DynamicMatrix<ctype>
compute_analytic_solution(const std::vector<Dune::FieldVector<ctype, dim>>& electrodes,
const std::vector<Dipole<ctype, dim>>& dipoles,
const Dune::ParameterTree& config, DataTree output = DataTree())
{
Dune::Timer timer;
Dune::DynamicMatrix<ctype> leadFieldMatrix(electrodes.size(), dipoles.size());
AnalyticSolution<ctype> as(config, electrodes);
std::vector<std::vector<ctype>> solutionsAtElectrodes;
std::transform(dipoles.begin(), dipoles.end(), std::back_inserter(solutionsAtElectrodes), as);
for (unsigned int i = 0; i < solutionsAtElectrodes.size(); ++i)
for (unsigned int j = 0; j < solutionsAtElectrodes[i].size(); ++j)
leadFieldMatrix[j][i] = solutionsAtElectrodes[i][j];
duneuro::subtract_column_means(leadFieldMatrix);
output.set("time", timer.elapsed());
return leadFieldMatrix;
}
template <class ctype, int dim>
std::vector<ctype>
compute_analytic_solution(const std::vector<Dune::FieldVector<ctype, dim>>& electrodes,
const Dipole<ctype, dim>& dipole, const Dune::ParameterTree& config,
DataTree output = DataTree())
{
auto sol = AnalyticSolution<ctype>(config, electrodes)(dipole);
subtract_mean(sol);
return sol;
}
}
#endif // DUNEURO_ANALYTICSOLUTION_HH
add_subdirectory(SimBio)
install(FILES analytic_solution.hh DESTINATION include/duneuro/legacy)
//$2 24.02.2000 Frank N. Changed define for bad_allcoc
//$1 17.08.1999 Frank Z. Created
//-------------------------------------------------------------------------
// ANT Software BV (c)
///////////////////////////////////////////////////////////////////////////////
//
// NeuroFEM license:
// =================
// Copyright (c) 2007 by
// Dr.Carsten Wolters, Dr.Alfred Anwander, Dr.Matthias Duempelmann,
// Dr.Thomas Knoesche, Dr.Frank Zanow, Frank Neumann.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of the NeuroFEM software and associated documentation files
// (the "Software"), to deal in the Software without restrictions, including
// without limitations the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the following
// conditions:
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
// SOFTWARE IS WITH YOU.
//
// The above copyright notice, permission and warranty notices shall be
// included in all copies of the Software. A copyright notice of the
// contributing authors and the above permission and warranty notices
// shall be included in all source code files of the Software.
//
///////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------
// File name : CON_UtilitiesDef.h
//-------------------------------------------------------------------------
// CON_UtilitiesDef.h : defintion header file for UtilitiesDll
//
#ifndef __ANALYSISDEF_H__
#define __ANALYSISDEF_H__
#ifndef ANALYSIS_EXPORT
#ifndef _WINDLL
#define ANALYSIS_EXPORT
#else
#ifndef ANALYSIS_DLL
#define ANALYSIS_EXPORT __declspec( dllimport )
#else
#define ANALYSIS_EXPORT __declspec( dllexport )
#endif // ANALYSIS_DLL
#endif // _WINDLL
#endif // ANALYSIS_EXPORT
#endif // __ANALYSISDEF_H__
set(SimBio_SOURCES Error.cpp
IP_SIM_SimulatorEEGSpheres_c.cpp
IP_SIM_ParameterSimulator_c.cpp
IP_SIM_AbstractSimulatorEEGMEG_c.cpp
IP_SIM_AbstractSimulator_c.cpp
IP_SIM_SensorConfiguration_c.cpp)
dune_add_library(SimBio OBJECT ${SimBio_SOURCES})
//$7 10.07.2000 Matthias D. Removed capital letters from file names
//$6 05.07.2000 Frank N. Adapted for Simbio
//$5 02.09.1999 Frank N. Took out operators for vector
//$4 23.08.1999 Frank N. Fixed for BC++
//$3 13.08.1999 Frank N. Use std::vector
//$2 02.07.1999 Frank N. Added Serialize()
//$1 02.07.1999 Frank N. Created
//
///////////////////////////////////////////////////////////////////////////////
//
// NeuroFEM license:
// =================
// Copyright (c) 2007 by
// Dr.Carsten Wolters, Dr.Alfred Anwander, Dr.Matthias Duempelmann,
// Dr.Thomas Knoesche,
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of the NeuroFEM software and associated documentation files
// (the "Software"), to deal in the Software without restrictions, including
// without limitations the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the following
// conditions:
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
// SOFTWARE IS WITH YOU.
//
// The above copyright notice, permission and warranty notices shall be
// included in all copies of the Software. A copyright notice of the
// contributing authors and the above permission and warranty notices
// shall be included in all source code files of the Software.
//
///////////////////////////////////////////////////////////////////////////////
// CON_AbstractPersistentClass_t.h: interface for the CON_AbstractPersistentClass_t template class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_UTABSTARCTPERSISTENTCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_)
#define AFX_UTABSTARCTPERSISTENTCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <typeinfo>
#include "CON_AbstractPersistenceArchive_i.h"
#include "CON_PersistentClassRegistry_c.h"
//////////////////////////////////////////////////////////////////////
// CON_AbstractPersistentClass_t
template <class T >
class NO_VTABLE CON_AbstractPersistentClass_t
{
public:
// Serialization
virtual void Serialize(class CON_AbstractPersistenceArchive_i& ar) = 0;
#ifdef WIN32
// Operators
friend class CON_AbstractPersistenceArchive_i& operator<<(class CON_AbstractPersistenceArchive_i& ar, const T* pT);
friend class CON_AbstractPersistenceArchive_i& operator>>(class CON_AbstractPersistenceArchive_i& ar, T*& pT);
#endif
// Registration
#ifdef WIN32
inline static bool RegisterAbstractPersistentClass()
{
return CON_PersistentClassRegistry_c::RegisterAbstractPersistentClass( typeid( T ) );
}
#else
inline static bool RegisterAbstractPersistentClass()
{
ASSERT(FALSE);
return false;
}
#endif
};
#endif // !defined(AFX_UTABSTARCTPERSISTENTCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_)
This diff is collapsed.
This diff is collapsed.
//$12 17.10.2003 Anwander A. Changed for gcc 3.3 std::type_info
//$11 08.02.2002 Matthias D. Adapted for stand alone workspace
//$10 22.09.2001 Frank N. Added REGISTER_PERSISTENT_COM_TEMPLATE_CLASS2
//$9 10.07.2000 Matthias D. Removed capital letters from file names
//$8 05.07.2000 Matthias D. Made some changes to work on Linux
//$7 12.01.2000 Frank N. Added REGISTER_PERSISTENT_TEMPLATE_CLASS2 and REGISTER_ABSTRACT_PERSISTENT_TEMPLATE_CLASS2
//$6 02.11.1999 Frank N. Added utPersistentCOMClassRegistrar_t
//$5 22.10.1999 Frank N. Made m_RegisteredPersistentClasses non static
//$4 02.09.1999 Frank N. Added REGISTER_PERSISTENT_TEMPLATE_CLASS1 and REGISTER_ABSTRACT_PERSISTENT_TEMPLATE_CLASS1
//$3 05.08.1999 TRK multmap template got third argument (old STL problem)
//$2 31.07.1999 Frank N. Added std::
//$1 02.07.1999 Frank N. Created
//
///////////////////////////////////////////////////////////////////////////////
//
// NeuroFEM license:
// =================
// Copyright (c) 2007 by
// Dr.Carsten Wolters, Dr.Alfred Anwander, Dr.Matthias Duempelmann,
// Dr.Thomas Knoesche,
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of the NeuroFEM software and associated documentation files
// (the "Software"), to deal in the Software without restrictions, including
// without limitations the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the following
// conditions:
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
// SOFTWARE IS WITH YOU.
//
// The above copyright notice, permission and warranty notices shall be
// included in all copies of the Software. A copyright notice of the
// contributing authors and the above permission and warranty notices
// shall be included in all source code files of the Software.
//
///////////////////////////////////////////////////////////////////////////////
// CON_PersistentClassRegistry_c.h: interface for the CON_PersistentClassRegistry_c class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CON_PERSISTENTCLASSREGISTRY_C_H__42067FC6_2F96_11D3_96D4_0080C8FD5716__INCLUDED_)
#define AFX_CON_PERSISTENTCLASSREGISTRY_C_H__42067FC6_2F96_11D3_96D4_0080C8FD5716__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <typeinfo>
#include "CON_UtilitiesDef.h"
#include "CON_AbstractPersistentClass_t.h"
#include "CON_PersistentClass_t.h"
#include "CON_PersistentComClass_t.h"
class CON_PersistentClassRegistry_c;
//////////////////////////////////////////////////////////////////////
// Some helpers
UTILITIES_EXPORT CON_PersistentClassRegistry_c* utGetPersistentClassRegistry();
UTILITIES_EXPORT void utSetPersistentClassRegistry(CON_PersistentClassRegistry_c* pNewPersistentClassRegistry);
//////////////////////////////////////////////////////////////////////
// utAbstractPersistentClassRegistrar_t
#ifdef WIN32
#define REGISTER_ABSTRACT_PERSISTENT_CLASS(class_name) \
utAbstractPersistentClassRegistrar_t< class_name > class_name##AbstractPersistentClassRegistrar;
#define REGISTER_ABSTRACT_PERSISTENT_TEMPLATE_CLASS1(class_name, templateType) \
utAbstractPersistentClassRegistrar_t< class_name< templateType > > class_name##templateType##AbstractPersistentClassRegistrar;
#define REGISTER_ABSTRACT_PERSISTENT_TEMPLATE_CLASS2(class_name, templateType1, templateType2) \
utAbstractPersistentClassRegistrar_t< class_name< templateType1 < templateType2 > > > class_name##templateType1##templateType2##AbstractPersistentClassRegistrar;
#endif
template < class T >
class utAbstractPersistentClassRegistrar_t
{
public:
utAbstractPersistentClassRegistrar_t()
{
VERIFY( CON_AbstractPersistentClass_t< T >::RegisterAbstractPersistentClass() );
}
};
//////////////////////////////////////////////////////////////////////
// utPersistentClassRegistrar_t
#ifdef WIN32
#define REGISTER_PERSISTENT_CLASS(class_name) \
utPersistentClassRegistrar_t< class_name > class_name##PersistentClassRegistrar;
#define REGISTER_PERSISTENT_TEMPLATE_CLASS1(class_name, templateType) \
utPersistentClassRegistrar_t< class_name< templateType > > class_name##templateType##PersistentClassRegistrar;
#define REGISTER_PERSISTENT_TEMPLATE_CLASS2(class_name, templateType1, templateType2) \
utPersistentClassRegistrar_t< class_name< templateType1 < templateType2 > > > class_name##templateType1##templateType2##PersistentClassRegistrar;
#endif
template < class T >
class utPersistentClassRegistrar_t
{
public:
utPersistentClassRegistrar_t()
{
VERIFY( CON_PersistentClass_t< T >::RegisterPersistentClass() );
}
};
//////////////////////////////////////////////////////////////////////
// utPersistentCOMClassRegistrar_t
#ifdef WIN32
#define REGISTER_PERSISTENT_COM_CLASS(class_name) \
utPersistentCOMClassRegistrar_t< class_name > class_name##PersistentCOMClassRegistrar;
#define REGISTER_PERSISTENT_COM_TEMPLATE_CLASS1(class_name, templateType) \
utPersistentCOMClassRegistrar_t< class_name< templateType > > class_name##templateType##PersistentCOMClassRegistrar;
#define REGISTER_PERSISTENT_COM_TEMPLATE_CLASS2(class_name, templateType1, templateType2) \
utPersistentCOMClassRegistrar_t< class_name< templateType1 < templateType2 > > > class_name##templateType1##templateType2##PersistentCOMClassRegistrar;
#endif
template < class T >
class utPersistentCOMClassRegistrar_t
{
public:
utPersistentCOMClassRegistrar_t()
{
VERIFY( CON_PersistentComClass_t< T >::RegisterPersistentCOMClass() );
}
};
//////////////////////////////////////////////////////////////////////
// CON_PersistentClassRegistry_c
class UTILITIES_EXPORT CON_PersistentClassRegistry_c
{
public:
CON_PersistentClassRegistry_c();
virtual ~CON_PersistentClassRegistry_c();
// Register
#ifdef WIN32
static bool RegisterPersistentClass(const type_info& typeInfo, void*(__cdecl* pCreateInstanceFunction)());
#else
static bool RegisterPersistentClass(const std::type_info& typeInfo, void*(pCreateInstanceFunction)());
#endif
static bool RegisterAbstractPersistentClass(const std::type_info& typeInfo);
#ifdef WIN32
// Create an instance from the given type
static void* CreateInstance(const type_info& typeInfo);
static void* CreateInstance(const std::string& typeName);
#endif
// Data
protected:
std::multimap<std::string, void*,std::less<std::string> > m_RegisteredPersistentClasses;
};
#endif // !defined(AFX_UTPERSISTENTCLASSREGISTRY_C_H__42067FC6_2F96_11D3_96D4_0080C8FD5716__INCLUDED_)
//$9 08.02.2002 Matthias D. Adapted for Linux
//$8 10.07.2000 Matthias D. Removed capital letetrs from file names
//$7 05.07.2000 Frank N. Adapted for Simbio
//$6 02.09.1999 Frank N. Took out operators for vector
//$5 23.08.1999 Frank N. Fixed for BC++
//$4 04.08.1999 Frank N. Added DECLARE_PERSISTENT_CLASS
//$3 31.07.1999 Frank N. Added std::
//$2 02.07.1999 Frank N. Added Serialize()
//$1 02.07.1999 Frank N. Created
//
///////////////////////////////////////////////////////////////////////////////
//
// NeuroFEM license:
// =================
// Copyright (c) 2007 by
// Dr.Carsten Wolters, Dr.Alfred Anwander, Dr.Matthias Duempelmann,
// Dr.Thomas Knoesche,
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of the NeuroFEM software and associated documentation files
// (the "Software"), to deal in the Software without restrictions, including
// without limitations the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the following
// conditions:
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
// SOFTWARE IS WITH YOU.
//
// The above copyright notice, permission and warranty notices shall be
// included in all copies of the Software. A copyright notice of the
// contributing authors and the above permission and warranty notices
// shall be included in all source code files of the Software.
//
///////////////////////////////////////////////////////////////////////////////
// CON_PersistentClass_t.h: interface for the CON_PersistentClass_t template class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CON_PERSISTENTCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_)
#define AFX_CON_PERSISTENTCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "CON_AbstractPersistenceArchive_i.h"
#include "CON_PersistentClassRegistry_c.h"
#include <typeinfo>
//////////////////////////////////////////////////////////////////////
// Helper makros
#ifdef WIN32
#define DECLARE_PERSISTENT_CLASS(class_name) \
friend CON_PersistentClass_t< class_name >;
#else
#define DECLARE_PERSISTENT_CLASS(class_name)
#endif
//////////////////////////////////////////////////////////////////////
// CON_PersistentClass_t
template <class T >
class NO_VTABLE CON_PersistentClass_t
{
public:
// Serialization
#ifdef WIN32
virtual void Serialize(class CON_AbstractPersistenceArchive_i& ar) = 0;
#endif
#ifdef WIN32
// Operators
friend class CON_AbstractPersistenceArchive_i& operator<<(class CON_AbstractPersistenceArchive_i& ar, const T* pT);
friend class CON_AbstractPersistenceArchive_i& operator>>(class CON_AbstractPersistenceArchive_i& ar, T*& pT);
#endif
// Creation
inline static T* CreateInstance()
{
return new T;
}
// Registration
#ifdef WIN32
inline static bool RegisterPersistentClass()
{
return CON_PersistentClassRegistry_c::RegisterPersistentClass(typeid(T), (void *(__cdecl *)(void))CON_PersistentClass_t< T >::CreateInstance);
}
#else
inline static bool RegisterPersistentClass()
{
ASSERT(FALSE);
return false;
}
#endif
};
#endif // !defined(AFX_UTPERSISTENTCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_)
//$5 08.02.2002 Matthias D. adapted for Linux
//$5 08.05.2001 Frank N. Don't use namespace ATL for ATL 7.0
//$4 10.07.2000 Matthias D. Removed captila letters from file names
//$3 05.07.2000 Frank N. Adapted for Simbio
//$2 03.12.1999 Frank N. Fixed RegisterPersistentCOMClass()
//$1 02.12.1999 Frank N. Created
//
///////////////////////////////////////////////////////////////////////////////
//
// NeuroFEM license:
// =================
// Copyright (c) 2007 by
// Dr.Carsten Wolters, Dr.Alfred Anwander, Dr.Matthias Duempelmann,
// Dr.Thomas Knoesche,
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of the NeuroFEM software and associated documentation files
// (the "Software"), to deal in the Software without restrictions, including
// without limitations the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the following
// conditions:
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
// SOFTWARE IS WITH YOU.
//
// The above copyright notice, permission and warranty notices shall be
// included in all copies of the Software. A copyright notice of the
// contributing authors and the above permission and warranty notices
// shall be included in all source code files of the Software.
//
///////////////////////////////////////////////////////////////////////////////
// CON_PersistentComClass_t.h: interface for the CON_PersistentComClass_t template class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CON_PERSISTENTCOMCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_)
#define AFX_CON_PERSISTENTCOMCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "CON_AbstractPersistenceArchive_i.h"
#include "CON_PersistentClassRegistry_c.h"
//////////////////////////////////////////////////////////////////////
// Helper makros
#ifdef WIN32
#define DECLARE_PERSISTENT_COM_CLASS(class_name) \
friend CON_PersistentComClass_t< class_name >;
#else
#define DECLARE_PERSISTENT_COM_CLASS(class_name)
#endif
//////////////////////////////////////////////////////////////////////
// CON_PersistentComClass_t
template <class T >
class NO_VTABLE CON_PersistentComClass_t
{
public:
// Serialization
virtual void Serialize(class CON_AbstractPersistenceArchive_i& ar) = 0;
#ifdef WIN32
// Operators
friend class CON_AbstractPersistenceArchive_i& operator<<(class CON_AbstractPersistenceArchive_i& ar, const T* pT);
friend class CON_AbstractPersistenceArchive_i& operator>>(class CON_AbstractPersistenceArchive_i& ar, T*& pT);
#endif
// Creation
#ifdef WIN32
inline static T* CreateInstance()
{
ATL::CComObject<T>* pTCOMObj = NULL;
VERIFY(SUCCEEDED(ATL::CComObject<T>::CreateInstance(&pTCOMObj)));
return dynamic_cast<T*>(pTCOMObj);
}
#endif
// Registration
#ifdef WIN32
inline static bool RegisterPersistentCOMClass()
{
// First register the normal class name:
bool bResult = CON_PersistentClassRegistry_c::RegisterPersistentClass(typeid(T), (void *(__cdecl *)(void))CON_PersistentComClass_t< T >::CreateInstance);
// Second register the class name used by the ATL::CComObject<T>:
bResult |= CON_PersistentClassRegistry_c::RegisterPersistentClass(typeid( ATL::CComObject< T > ), (void *(__cdecl *)(void))CON_PersistentComClass_t< T >::CreateInstance);
return bResult;
}
#else
inline static bool RegisterPersistentCOMClass()
{
ASSERT(FALSE);
return false;
}
#endif
};
#endif // !defined(AFX_UTPERSISTENTCOMCLASS_T_H__42067FC5_2F96_11D3_96D4_0080C8FD5716__INCLUDED_)
//$19 02.01.2006 Graichen U. removed bugs for new gnu compiler
//$18 13.02.2003 Anwander A. Changer sqrtl to sqrt for portability
//$17 29.04.2002 Stefan Defined a macro for memory leaks localisation
//$16 08.02.2002 Matthias D. Changed for Linux
//$15 23.06.2000 Matthias D Changes for ASSERT and VERIFY derfinitions
//$14 15.06.2000 Matthias D Added some typdefs for SDK and MFC types to make it work on Linux
//$13 24.02.2000 Frank N. Changed define for bad_allcoc
//$12 03.09.1999 Frank N. Suppress more STL related warnings for BC++
//$11 23.08.1999 Frank N. Fixed for BC++
//$10 22.08.1999 Frank N. Suppress a couple of STL specific warnings
//$9 05.08.1999 TRK BC++ redefine for xalloc
//$8 06.08.1999 Frank Z. Made changes working under MSC
//$8 05.08.1999 TRK Einige defines verndert, damit es unter Borland kompiliert
//$7 31.07.1999 Frank N. Added #include <set>
//$6 14.07.1999 Frank N. Added #include <shlwapi.h>
//$5 05.07.1999 Frank N. Added #include <objbase.h>
//$4 01.07.1999 Frank N. Added NO_VTABLE and #include <map> // STL map class
//$3 14.05.1999 Frank N. added <vector> include
//$2 10.05.1999 Frank N. changed includes for STL
//$1 05.05.1999 Frank N. completly redone
//-------------------------------------------------------------------------
//
///////////////////////////////////////////////////////////////////////////////
//
// NeuroFEM license:
// =================
// Copyright (c) 2007 by
// Dr.Carsten Wolters, Dr.Alfred Anwander, Dr.Matthias Duempelmann,
// Dr.Thomas Knoesche, Dr. U. Graichen
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of the NeuroFEM software and associated documentation files
// (the "Software"), to deal in the Software without restrictions, including
// without limitations the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the following
// conditions:
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR