Skip to content

ConstraintFunction simplification #20

Description

@aescande

Is there some cases where ConstraintFunction here is templated by multiple classes. There are no such case in Tasks and I could find one in client code either.

Getting rid of the variadic template gives a much simpler code:

template<typename Fun>
class ConstraintFunction : public Constraint, public Fun
{
public:
	virtual ~ConstraintFunction() {}

	void addToSolver(QPSolver& sol)
	{
		sol.addConstraint(this);
  		static_cast<Fun*>(this)->addToSolver(sol);
	}

	void addToSolver(const std::vector<rbd::MultiBody>& mbs, QPSolver& sol)
	{
		sol.addConstraint(mbs, this);
	  	static_cast<Fun*>(this)->addToSolver(sol);
	}

	void removeFromSolver(QPSolver& sol)
	{
		sol.removeConstraint(this);
   		static_cast<Fun*>(this)->removeFromSolver(sol);
	}
};

The impact on client code is minimal to non-existent. At worse, it is a matter of removing a few ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions