Skip to content

Commit

Permalink
finished implementation and integration of SpecializedNodeManagers
Browse files Browse the repository at this point in the history
  • Loading branch information
mxgrey committed Jan 7, 2016
1 parent fadb2ec commit c07f7db
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 157 deletions.
2 changes: 1 addition & 1 deletion dart/common/NameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class NameManager
const std::string& _defaultName = "default");

/// Destructor
virtual ~NameManager();
virtual ~NameManager() = default;

/// Set a new pattern for name generation.
///
Expand Down
7 changes: 0 additions & 7 deletions dart/common/detail/NameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ NameManager<T>::NameManager(const std::string& _managerName,
// Do nothing
}

//==============================================================================
template <class T>
NameManager<T>::~NameManager()
{
// Do nothing
}

//==============================================================================
template <class T>
bool NameManager<T>::setPattern(const std::string& _newPattern)
Expand Down
141 changes: 140 additions & 1 deletion dart/dynamics/Addon.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define DART_DYNAMICS_ADDON_H_

#include "dart/common/Addon.h"
#include "dart/dynamics/Skeleton.h"
#include "dart/dynamics/SmartPointer.h"

namespace dart {
namespace dynamics {
Expand Down Expand Up @@ -228,6 +228,145 @@ class AddonWithProtectedStateAndPropertiesInSkeleton : public common::Addon
} // namespace dynamics
} // namespace dart

//==============================================================================
#define DART_DYNAMICS_ADDON_PROPERTY_CONSTRUCTOR( ClassName, UpdatePropertiesMacro )\
ClassName (const ClassName &) = delete;\
inline ClassName (dart::common::AddonManager* mgr, const PropertiesData& properties)\
: AddonWithProtectedPropertiesInSkeleton< Base, PropertiesData, ManagerType, UpdatePropertiesMacro, Optional>(mgr, properties) { }

//==============================================================================
#define DART_DYNAMICS_JOINT_ADDON_CONSTRUCTOR( ClassName )\
DART_DYNAMICS_ADDON_PROPERTY_CONSTRUCTOR( ClassName, &detail::JointPropertyUpdate )

//==============================================================================
#define DART_DYNAMICS_ADDON_STATE_PROPERTY_CONSTRUCTORS( ClassName, UpdateStateMacro, UpdatePropertiesMacro )\
ClassName (const ClassName &) = delete;\
inline ClassName (dart::common::AddonManager* mgr, const StateData& state = StateData(), const PropertiesData& properties = PropertiesData())\
: AddonWithProtectedStateAndPropertiesInSkeleton< Base, StateData, PropertiesData, ManagerType, UpdateStateMacro, UpdatePropertiesMacro, Optional >(mgr, state, properties) { }\
inline ClassName (dart::common::AddonManager* mgr, const PropertiesData& properties, const StateData state = StateData())\
: AddonWithProtectedStateAndPropertiesInSkeleton< Base, StateData, PropertiesData, ManagerType, UpdateStateMacro, UpdatePropertiesMacro, Optional >(mgr, properties, state) { }

//==============================================================================
#define DART_DYNAMICS_SET_ADDON_PROPERTY_CUSTOM( Type, Name, Update )\
inline void set ## Name (const Type & value)\
{ mProperties.m ## Name = value; Update(this); incrementSkeletonVersion(); }

//==============================================================================
#define DART_DYNAMICS_SET_ADDON_PROPERTY( Type, Name )\
DART_DYNAMICS_SET_ADDON_PROPERTY_CUSTOM( Type, Name, UpdateProperties )

//==============================================================================
#define DART_DYNAMICS_GET_ADDON_PROPERTY( Type, Name )\
inline const Type& get ## Name () const\
{ return mProperties.m ## Name; }

//==============================================================================
#define DART_DYNAMICS_SET_GET_ADDON_PROPERTY( Type, Name )\
DART_DYNAMICS_SET_ADDON_PROPERTY( Type, Name )\
DART_DYNAMICS_GET_ADDON_PROPERTY( Type, Name )

//==============================================================================
#define DART_DYNAMICS_SET_ADDON_PROPERTY_ARRAY( Class, SingleType, VectorType, SingleName, PluralName, Size, UpdatePrefix )\
void set ## SingleName (size_t index, const SingleType & value)\
{\
if( index >= Size )\
{\
dterr << "[" #Class << "::set" #SingleName << "] Invalid index (" << index << "). "\
<< "The specified index must be less than " #Size << "!\n";\
assert(false); return;\
}\
this->mProperties.m ## PluralName [index] = value;\
UpdatePrefix :: UpdateProperties(this);\
this->incrementSkeletonVersion();\
}\
void set ## PluralName (const VectorType & vec)\
{\
this->mProperties.m ## PluralName = vec;\
UpdatePrefix :: UpdateProperties(this);\
this->incrementSkeletonVersion();\
}

//==============================================================================
#define DART_DYNAMICS_GET_ADDON_PROPERTY_ARRAY(Class, SingleType, VectorType, SingleName, PluralName, Size)\
inline const SingleType& get ## SingleName (size_t index) const\
{\
if(index >= Size)\
{\
dterr << "[" #Class << "::get" #SingleName << "] Invalid index (" << index << "). "\
<< "The specified index must be less than " #Size << "!\n";\
assert(false); index = 0;\
}\
return this->mProperties.m ## PluralName [index];\
}\
inline const VectorType& get ## PluralName () const\
{\
return this->mProperties.m ## PluralName;\
}

//==============================================================================
#define DART_DYNAMICS_IRREGULAR_SET_GET_ADDON_PROPERTY_ARRAY( Class, SingleType, VectorType, SingleName, PluralName, Size, UpdatePrefix )\
DART_DYNAMICS_SET_ADDON_PROPERTY_ARRAY( Class, SingleType, VectorType, SingleName, PluralName, Size, UpdatePrefix )\
DART_DYNAMICS_GET_ADDON_PROPERTY_ARRAY( Class, SingleType, VectorType, SingleName, PluralName, Size )

//==============================================================================
#define DART_DYNAMICS_SET_GET_ADDON_PROPERTY_ARRAY( Class, SingleType, VectorType, SingleName, Size, UpdatePrefix )\
DART_DYNAMICS_IRREGULAR_SET_GET_ADDON_PROPERTY_ARRAY( Class, SingleType, VectorType, SingleName, SingleName ## s, Size, UpdatePrefix )

//==============================================================================
#define DART_DYNAMICS_IRREGULAR_SET_GET_MULTIDOF_ADDON( SingleType, VectorType, SingleName, PluralName )\
DART_DYNAMICS_IRREGULAR_SET_GET_ADDON_PROPERTY_ARRAY( MultiDofJointAddon, SingleType, VectorType, SingleName, PluralName, DOF, MultiDofJoint<DOF>::Addon )

//==============================================================================
#define DART_DYNAMICS_SET_GET_MULTIDOF_ADDON( SingleType, VectorType, SingleName )\
DART_DYNAMICS_IRREGULAR_SET_GET_MULTIDOF_ADDON( SingleType, VectorType, SingleName, SingleName ## s )

//==============================================================================
#define DETAIL_DART_ADDON_PROPERTIES_UPDATE( AddonName, GetAddon )\
AddonName :: UpdateProperties( GetAddon () );\
GetAddon ()->incrementSkeletonVersion();

//==============================================================================
#define DETAIL_DART_ADDON_STATE_PROPERTIES_UPDATE( AddonName, GetAddon )\
AddonName :: UpdateState( GetAddon () );\
DETAIL_DART_ADDON_PROPERTIES_UPDATE( AddonName, GetAddon );

//==============================================================================
// Used for Addons that have Properties (but no State) inside of a Skeleton
#define DART_DYNAMICS_SKEL_PROPERTIES_ADDON_INLINE( AddonName )\
DETAIL_DART_SPECIALIZED_ADDON_INLINE( AddonName,\
DETAIL_DART_ADDON_PROPERTIES_UPDATE( AddonName, get ## AddonName ) )

//==============================================================================
// Used for Addons that have both State and Properties inside of a Skeleton
#define DART_DYNAMICS_SKEL_ADDON_INLINE( AddonName )\
DETAIL_DART_SPECIALIZED_ADDON_INLINE( AddonName,\
DETAIL_DART_ADDON_STATE_PROPERTIES_UPDATE( AddonName, get ## AddonName ) )

//==============================================================================
// Used for edge cases, such as nested template classes, that have Properties
// (but no State) inside of a Skeleton
#define DART_DYNAMICS_IRREGULAR_SKEL_PROPERTIES_ADDON_INLINE( TypeName, HomogenizedName )\
DETAIL_DART_IRREGULAR_SPECIALIZED_ADDON_INLINE( TypeName, HomogenizedName,\
DETAIL_DART_ADDON_PROPERTIES_UPDATE( TypeName, get ## HomogenizedName ) )

//==============================================================================
// Used for edge cases, such as nested template classes, that have both State
// and Properties inside of a Skeleton
#define DART_DYNAMICS_IRREGULAR_SKEL_ADDON_INLINE( TypeName, HomogenizedName )\
DETAIL_DART_IRREGULAR_SPECIALIZED_ADDON_INLINE( TypeName, HomogenizedName,\
DETAIL_DART_ADDON_STATE_PROPERTIES_UPDATE( TypeName, get ## HomogenizedName ) )

//==============================================================================
// Used for nested-class Addons that have Properties (but no State) inside of a Skeleton
#define DART_DYNAMICS_NESTED_SKEL_PROPERTIES_ADDON_INLINE( ParentName, AddonName )\
DART_DYNAMICS_IRREGULAR_SKEL_PROPERTIES_ADDON_INLINE( ParentName :: AddonName, ParentName ## AddonName )

//==============================================================================
// Used for nested-class Addons that have both State and Properties inside of a Skeleton
#define DART_DYNAMICS_NESTED_SKEL_ADDON_INLINE( ParentName, AddonName )\
DART_DYNAMICS_IRREGULAR_SKEL_ADDON_INLINE( ParentName :: AddonName, ParentName ## AddonName )

#include "dart/dynamics/Skeleton.h"
#include "dart/dynamics/detail/Addon.h"

#endif // DART_DYNAMICS_ADDON_H_
6 changes: 3 additions & 3 deletions dart/dynamics/BodyNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Marker;
/// BodyNode of the BodyNode.
class BodyNode :
public virtual common::AddonManager,
public virtual detail::BasicNodeManagerForBodyNode,
public virtual SpecializedNodeManagerForBodyNode<EndEffector>,
public SkeletonRefCountingBase,
public TemplatedJacobianNode<BodyNode>
{
Expand Down Expand Up @@ -1236,7 +1236,7 @@ class BodyNode :
} // namespace dart

#include "dart/dynamics/Skeleton.h"
// Developer's Note: Skeleton.h needs to be included after the BodyNode class is
// defined in order for the header dependencies to work out correctly.
// These headers need to be included after the BodyNode class is defined in
// order for the header dependencies to work out correctly.

#endif // DART_DYNAMICS_BODYNODE_H_
5 changes: 4 additions & 1 deletion dart/dynamics/Skeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace dynamics {
/// class Skeleton
class Skeleton : public virtual common::AddonManager,
public MetaSkeleton,
public virtual detail::BasicNodeManagerForSkeleton
public virtual SpecializedNodeManagerForSkeleton<EndEffector>
{
public:

Expand Down Expand Up @@ -1313,6 +1313,9 @@ class Skeleton : public virtual common::AddonManager,
} // namespace dynamics
} // namespace dart

#include "dart/dynamics/EndEffector.h"
#include "dart/dynamics/detail/SpecializedNodeManager.h"

#include "dart/dynamics/detail/Skeleton.h"
#include "dart/dynamics/detail/BodyNode.h"

Expand Down
11 changes: 6 additions & 5 deletions dart/dynamics/SpecializedNodeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#ifndef DART_DYNAMICS_SPECIALIZEDNODEMANAGER_H_
#define DART_DYNAMICS_SPECIALIZEDNODEMANAGER_H_

#include "dart/common/Virtual.h"
#include "dart/dynamics/detail/BasicNodeManager.h"
#include "dart/dynamics/NodeManagerJoiner.h"

Expand Down Expand Up @@ -114,8 +115,8 @@ class SpecializedNodeManagerForBodyNode<SpecNode> :
template <class SpecNode1, class... OtherSpecNodes>
class SpecializedNodeManagerForBodyNode<SpecNode1, OtherSpecNodes...> :
public NodeManagerJoinerForBodyNode<
SpecializedNodeManagerForBodyNode<SpecNode1>,
SpecializedNodeManagerForBodyNode<OtherSpecNodes...> > { };
common::Virtual< SpecializedNodeManagerForBodyNode<SpecNode1> >,
common::Virtual< SpecializedNodeManagerForBodyNode<OtherSpecNodes...> > > { };

//==============================================================================
/// Declaration of the variadic template
Expand Down Expand Up @@ -201,12 +202,12 @@ class SpecializedNodeManagerForSkeleton<SpecNode> :
template <class SpecNode1, class... OtherSpecNodes>
class SpecializedNodeManagerForSkeleton<SpecNode1, OtherSpecNodes...> :
public NodeManagerJoinerForSkeleton<
SpecializedNodeManagerForSkeleton<SpecNode1>,
SpecializedNodeManagerForSkeleton<OtherSpecNodes...> > { };
common::Virtual< SpecializedNodeManagerForSkeleton<SpecNode1> >,
common::Virtual< SpecializedNodeManagerForSkeleton<OtherSpecNodes...> > > { };

} // namespace dynamics
} // namespace dart

#include "dart/dynamics/detail/SpecializedNodeManager.h"
#include "dart/dynamics/BodyNode.h"

#endif // DART_DYNAMICS_SPECIALIZEDNODEMANAGER_H_
Loading

0 comments on commit c07f7db

Please sign in to comment.