Sketcher: Constraint improvements

=================================

Copy constructor made private, as copies are handled via copy() and clone() methods which generate pointers, not objects.
Private copy constructor, used for copy(),  made default implementation.
Destructor made default.
Copy and Clone made non-virtual, as the class does not have children.
Added override to persistance inherited virtual functions.
move operators explicitly disallowed to note that they are not intended in the current implementation.

Perfectly ok to have only private copy constructor for internal use
This commit is contained in:
Abdullah Tahiri
2019-04-07 15:47:09 +02:00
committed by wmayer
parent 504a687ad6
commit 2fabda1605
2 changed files with 23 additions and 34 deletions

View File

@@ -74,30 +74,6 @@ Constraint::Constraint()
tag = gen();
}
Constraint::Constraint(const Constraint& from)
: Value(from.Value),
Type(from.Type),
AlignmentType(from.AlignmentType),
Name(from.Name),
First(from.First),
FirstPos(from.FirstPos),
Second(from.Second),
SecondPos(from.SecondPos),
Third(from.Third),
ThirdPos(from.ThirdPos),
LabelDistance(from.LabelDistance),
LabelPosition(from.LabelPosition),
isDriving(from.isDriving),
InternalAlignmentIndex(from.InternalAlignmentIndex),
isInVirtualSpace(from.isInVirtualSpace),
tag(from.tag)
{
}
Constraint::~Constraint()
{
}
Constraint *Constraint::clone(void) const
{
return new Constraint(*this);

View File

@@ -83,20 +83,30 @@ class SketcherExport Constraint : public Base::Persistence
public:
Constraint();
Constraint(const Constraint&);
virtual ~Constraint();
virtual Constraint *clone(void) const; // does copy the tag, it will be treated as a rename by the expression engine.
virtual Constraint *copy(void) const; // does not copy the tag, but generates a new one
// PVS V690: It is perfectly fine to use copy operator only internally
// Constraints objects explicitly not copiable with standard methods
// Copy constructor is private for internal use only
Constraint &operator =(const Constraint &a) = delete;
// Constraints objects explicitly not movable
Constraint(Constraint&&) = delete;
Constraint& operator=(Constraint&&) = delete;
virtual ~Constraint() = default;
Constraint *clone(void) const; // does copy the tag, it will be treated as a rename by the expression engine.
Constraint *copy(void) const; // does not copy the tag, but generates a new one
static const int GeoUndef;
// from base class
virtual unsigned int getMemSize(void) const;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
virtual unsigned int getMemSize(void) const override;
virtual void Save(Base::Writer &/*writer*/) const override;
virtual void Restore(Base::XMLReader &/*reader*/) override;
virtual PyObject *getPyObject(void) override;
virtual PyObject *getPyObject(void);
Base::Quantity getPresentationValue() const;
inline void setValue(double newValue) {
Value = newValue;
@@ -112,6 +122,9 @@ public:
friend class PropertyConstraintList;
private:
Constraint(const Constraint&) = default; // only for internal use
private:
double Value;
public:
@@ -127,7 +140,7 @@ public:
float LabelDistance;
float LabelPosition;
bool isDriving;
int InternalAlignmentIndex; // Note: for InternalAlignment Type this index indexes equal internal geometry elements (e.g. index of pole in a bspline). It is not a GeoId!!
int InternalAlignmentIndex; // Note: for InternalAlignment Type this index indexes equal internal geometry elements (e.g. index of pole in a bspline). It is not a GeoId!!
bool isInVirtualSpace;
protected: