Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean namespace, ifdef macro and template instanciations #21

Merged
merged 5 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/BeamAdapter/component/BeamInterpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,16 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#define SOFA_PLUGIN_BEAMADAPTER_BEAMINTERPOLATION_CPP

#include <sofa/defaulttype/RigidTypes.h>
#include <sofa/core/ObjectFactory.h>

/// This define is here to prevent the declaration of the template instances as "extern".
/// Have a look a the end of BeamInterpolation.h
#define SOFA_BEAMINTERPOLATION_CPP
#include <BeamAdapter/component/BeamInterpolation.inl>

namespace sofa
{

namespace component
{

namespace fem
namespace sofa::component::fem
{

namespace _beaminterpolation_
Expand All @@ -66,17 +61,11 @@ static int BeamInterpolationClass = core::RegisterObject("Adaptive Beam Interpol
;



////////////////////////////////////////////////////////////////////////////////////////////////////
/// Explicit template instanciation of extern template.
////////////////////////////////////////////////////////////////////////////////////////////////////
template class SOFA_BEAMADAPTER_API BeamInterpolation<Rigid3Types>;

} /// namespace _beaminterpolation_

} /// namespace fem

} /// namespace component

} /// namespace sofa

} /// sofa::component::fem
22 changes: 4 additions & 18 deletions src/BeamAdapter/component/BeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef SOFA_COMPONENT_FEM_BEAMINTERPOLATION_H
#define SOFA_COMPONENT_FEM_BEAMINTERPOLATION_H

#pragma once

#include <BeamAdapter/config.h>
#include <sofa/core/behavior/ForceField.h>
Expand All @@ -43,13 +41,7 @@
#include <sofa/helper/logging/Messaging.h>
#include <sofa/helper/OptionsGroup.h>

namespace sofa
{

namespace component
{

namespace fem
namespace sofa::component::fem
{

namespace _beaminterpolation_
Expand Down Expand Up @@ -345,18 +337,12 @@ protected :
unsigned int m_numBeamsNotUnderControl {0} ;
};

#if !defined(SOFA_BEAMINTERPOLATION_CPP)
#if !defined(SOFA_PLUGIN_BEAMADAPTER_BEAMINTERPOLATION_CPP)
extern template class SOFA_BEAMADAPTER_API BeamInterpolation<Rigid3Types>;
#endif

} /// namespace _beaminterpolation_

using _beaminterpolation_::BeamInterpolation ;

} /// namespace fem

} /// namespace component

} /// namespace sofa

#endif /*SOFA_COMPONENT_FEM_BEAMINTERPOLATION_H*/
} /// namespace sofa::component::fem
19 changes: 3 additions & 16 deletions src/BeamAdapter/component/BeamInterpolation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef SOFA_COMPONENT_FEM_BEAMINTERPOLATION_INL
#define SOFA_COMPONENT_FEM_BEAMINTERPOLATION_INL
#pragma once

#include <BeamAdapter/component/BeamInterpolation.h>

Expand All @@ -47,13 +46,7 @@
#include <sofa/simulation/Simulation.h>
#include <sofa/gl/Axis.h>

namespace sofa
{

namespace component
{

namespace fem
namespace sofa::component::fem
{

namespace _beaminterpolation_
Expand Down Expand Up @@ -1543,10 +1536,4 @@ void BeamInterpolation<DataTypes>::MapForceOnNodeUsingSpline(unsigned int edgeIn

} /// namespace _beaminterpolation_

} /// namespace fem

} /// namespace component

} /// namespace sofa

#endif /* SOFA_COMPONENT_FEM_BEAMINTERPOLATION_INL */
} /// namespace sofa::component::fem
17 changes: 3 additions & 14 deletions src/BeamAdapter/component/WireBeamInterpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// Copyright: See COPYING file that comes with this distribution
//
//

#define SOFA_PLUGIN_BEAMADAPTER_WIREBEAMINTERPOLATION_CPP

#include <BeamAdapter/config.h>
#include <BeamAdapter/component/WireBeamInterpolation.inl>
Expand All @@ -39,13 +39,7 @@
#include <sofa/core/ObjectFactory.h>


namespace sofa
{

namespace component
{

namespace fem
namespace sofa::component::fem
{

namespace _wirebeaminterpolation_
Expand All @@ -68,9 +62,4 @@ template class SOFA_BEAMADAPTER_API WireBeamInterpolation<Rigid3Types>;

} // namespace _wirebeaminterpolation_

} // namespace fem

} // namespace component

} // namespace sofa

} // namespace sofa::component::fem
23 changes: 7 additions & 16 deletions src/BeamAdapter/component/WireBeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
//
// Copyright: See COPYING file that comes with this distribution
//
#ifndef SOFA_COMPONENT_FEM_WIREBEAMINTERPOLATION_H
#define SOFA_COMPONENT_FEM_WIREBEAMINTERPOLATION_H
#pragma once

#include <BeamAdapter/config.h>

Expand All @@ -50,13 +49,7 @@
#include <sofa/core/objectmodel/BaseObject.h>


namespace sofa
{

namespace component
{

namespace fem
namespace sofa::component::fem
{

namespace _wirebeaminterpolation_
Expand Down Expand Up @@ -256,15 +249,13 @@ class ProjectionSearch
bool testForProjection(Real curvAbs);
};

#if !defined(SOFA_PLUGIN_BEAMADAPTER_WIREBEAMINTERPOLATION_CPP)
extern template class SOFA_BEAMADAPTER_API WireBeamInterpolation<sofa::defaulttype::Rigid3Types>;
#endif

} // namespace _wirebeaminterpolation_

/// Import the privately defined into the expected sofa namespace.
using _wirebeaminterpolation_::WireBeamInterpolation ;

} // namespace fem

} // namespace component

} // namespace sofa

#endif /*SOFA_COMPONENT_FEM_WIREBEAMINTERPOLATION_H*/
} // namespace sofa::component::fem
19 changes: 3 additions & 16 deletions src/BeamAdapter/component/WireBeamInterpolation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef SOFA_COMPONENT_FEM_WIREBEAMINTERPOLATION_INL
#define SOFA_COMPONENT_FEM_WIREBEAMINTERPOLATION_INL
#pragma once

#include <sofa/core/behavior/ForceField.inl>
#include <sofa/core/topology/BaseMeshTopology.h>
Expand All @@ -50,13 +49,7 @@
#include <BeamAdapter/component/WireBeamInterpolation.h>
#include <BeamAdapter/component/BeamInterpolation.inl>

namespace sofa
{

namespace component
{

namespace fem
namespace sofa::component::fem
{

namespace _wirebeaminterpolation_
Expand Down Expand Up @@ -681,10 +674,4 @@ bool ProjectionSearch<DataTypes>::testForProjection(Real curvAbs)

} // namespace _wirebeaminterpolation_

} // namespace fem

} // namespace component

} // namespace sofa

#endif /* SOFA_COMPONENT_FEM_WIREBEAMINTERPOLATION_INL */
} // namespace sofa::component::fem
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#define SOFA_PLUGIN_BEAMADAPTER_ADAPTIVEBEAMLENGTHCONSTRAINT_CPP

#include <BeamAdapter/component/constraint/AdaptiveBeamLengthConstraint.inl>

#include <sofa/defaulttype/VecTypes.h>
#include <sofa/component/statecontainer/MechanicalObject.h>
#include <sofa/core/ObjectFactory.h>

namespace sofa
{

namespace component
{

namespace constraintset
namespace sofa::component::constraintset
{

namespace _adaptivebeamlengthconstraint_
Expand Down Expand Up @@ -84,9 +80,4 @@ template class AdaptiveBeamLengthConstraint<Rigid3Types>;

} /// namespace _adaptivebeamlengthconstraint_

} /// namespace constraintset

} /// namespace component

} /// namespace sofa

} /// namespace sofa::component::constraintset
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef SOFA_COMPONENT_CONSTRAINTSET_ADAPTIVEBEAMLENGTHCONSTRAINT_H
#define SOFA_COMPONENT_CONSTRAINTSET_ADAPTIVEBEAMLENGTHCONSTRAINT_H
#pragma once

//////////////////////// Inclusion of headers...from wider to narrower/closer //////////////////////
#include <sofa/helper/map.h>
Expand All @@ -41,13 +40,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Declarations
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace sofa
{

namespace component
{

namespace constraintset
namespace sofa::component::constraintset
{

/////////////////////////////////// private namespace pattern //////////////////////////////////////
Expand Down Expand Up @@ -168,15 +161,12 @@ class AdaptiveBeamLengthConstraint : public Constraint<DataTypes>
vector<IntervalDefinition<Real>> m_constraintIntervals;
};

#if !defined(SOFA_PLUGIN_BEAMADAPTER_ADAPTIVEBEAMLENGTHCONSTRAINT_CPP)
extern template class SOFA_BEAMADAPTER_API AdaptiveBeamLengthConstraint<defaulttype::Rigid3Types>;
#endif

} /// namespace _adaptivebeamlengthconstraint_

using _adaptivebeamlengthconstraint_::AdaptiveBeamLengthConstraint ;

} /// namespace constraintset

} /// namespace component

} /// namespace sofa

#endif // SOFA_COMPONENT_CONSTRAINTSET_ADAPTIVEBEAMLENGTHCONSTRAINT_H
} /// namespace sofa::component::constraintset
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef SOFA_COMPONENT_CONSTRAINTSET_ADAPTIVEBEAMLENGTHCONSTRAINT_INL
#define SOFA_COMPONENT_CONSTRAINTSET_ADAPTIVEBEAMLENGTHCONSTRAINT_INL
#pragma once

//////////////////////// Inclusion of headers...from wider to narrower/closer //////////////////////
#include <sofa/core/visual/VisualParams.h>
Expand All @@ -31,13 +30,7 @@
#include <sofa/core/behavior/ConstraintResolution.h>
#include <BeamAdapter/component/constraint/AdaptiveBeamLengthConstraint.h>

namespace sofa
{

namespace component
{

namespace constraintset
namespace sofa::component::constraintset
{

namespace _adaptivebeamlengthconstraint_
Expand Down Expand Up @@ -431,10 +424,4 @@ void AdaptiveBeamLengthConstraint<DataTypes>::draw(const VisualParams* vparams)

} /// namespace _adaptivebeamlengthconstraint_

} /// namespace constraintset

} /// namespace component

} /// namespace sofa

#endif
} /// namespace sofa::component::constraintset
Loading