App: modernize C++: use default member init

This commit is contained in:
wmayer
2023-08-23 19:51:44 +02:00
committed by wwmayer
parent 4fb07bcfd6
commit ee0fad4c90
39 changed files with 96 additions and 160 deletions
+1 -3
View File
@@ -233,9 +233,7 @@ init_image_module()
}
Application::Application(std::map<std::string,std::string> &mConfig)
: _mConfig(mConfig), _pActiveDoc(nullptr), _isRestoring(false),_allowPartial(false)
, _isClosingAll(false), _objCount(-1), _activeTransactionID(0)
, _activeTransactionGuard(0), _activeTransactionTmpName(false)
: _mConfig(mConfig)
{
//_hApp = new ApplicationOCC;
mpcPramManager["System parameter"] = _pcSysParamMngr;
+8 -8
View File
@@ -607,7 +607,7 @@ private:
mutable std::map<std::string,Document*> DocFileMap;
std::map<std::string,Base::Reference<ParameterManager>> mpcPramManager;
std::map<std::string,std::string> &_mConfig;
App::Document* _pActiveDoc;
App::Document* _pActiveDoc{nullptr};
std::deque<std::string> _pendingDocs;
std::deque<std::string> _pendingDocsReopen;
@@ -617,19 +617,19 @@ private:
// missing object
std::map<std::string,std::set<std::string> > _docReloadAttempts;
bool _isRestoring;
bool _allowPartial;
bool _isClosingAll;
bool _isRestoring{false};
bool _allowPartial{false};
bool _isClosingAll{false};
// for estimate max link depth
int _objCount;
int _objCount{-1};
friend class AutoTransaction;
std::string _activeTransactionName;
int _activeTransactionID;
int _activeTransactionGuard;
bool _activeTransactionTmpName;
int _activeTransactionID{0};
int _activeTransactionGuard{0};
bool _activeTransactionTmpName{false};
static Base::ConsoleObserverStd *_pConsoleObserverStd;
static Base::ConsoleObserverFile *_pConsoleObserverFile;
+2 -12
View File
@@ -157,16 +157,7 @@ void ColorField::interpolate (Color clCol1, std::size_t usInd1, Color clCol2, st
}
ColorGradientProfile::ColorGradientProfile()
: tStyle{ColorBarStyle::FLOW}
, fMin{}
, fMax{}
, ctColors{}
, tColorModel{}
, visibility{Visibility::Default}
{
}
ColorGradientProfile::ColorGradientProfile() = default;
bool ColorGradientProfile::isEqual(const ColorGradientProfile& cg) const
{
@@ -309,8 +300,7 @@ void ColorGradient::setColorModel ()
}
}
ColorLegend::ColorLegend ()
: outsideGrayed(false)
ColorLegend::ColorLegend()
{
// default blue, green, red
colorFields.emplace_back(0, 0, 1);
+7 -7
View File
@@ -342,12 +342,12 @@ inline std::size_t ColorField::getColorIndex (float fVal) const
struct AppExport ColorGradientProfile
{
ColorBarStyle tStyle;
float fMin;
float fMax;
std::size_t ctColors;
std::size_t tColorModel;
VisibilityFlags visibility;
ColorBarStyle tStyle{ColorBarStyle::FLOW};
float fMin{};
float fMax{};
std::size_t ctColors{};
std::size_t tColorModel{};
VisibilityFlags visibility{Visibility::Default};
ColorGradientProfile();
ColorGradientProfile (const ColorGradientProfile &) = default;
@@ -484,7 +484,7 @@ protected:
std::deque<Color> colorFields;
std::deque<std::string> names;
std::deque<float> values;
bool outsideGrayed;
bool outsideGrayed{false};
};
inline Color ColorLegend::getColor (float fVal) const
+1 -4
View File
@@ -55,10 +55,7 @@ using namespace Data;
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
ComplexGeoData::ComplexGeoData()
:Tag(0)
{
}
ComplexGeoData::ComplexGeoData() = default;
Data::Segment* ComplexGeoData::getSubElementByName(const char* name) const
{
+1 -1
View File
@@ -335,7 +335,7 @@ protected:
static_cast<float>(tmp.z));
}
public:
mutable long Tag;
mutable long Tag{0};
public:
+1 -1
View File
@@ -63,7 +63,7 @@ DocumentObjectExecReturn *DocumentObject::StdReturn = nullptr;
//===========================================================================
DocumentObject::DocumentObject()
: ExpressionEngine(),_pDoc(nullptr),pcNameInDocument(nullptr),_Id(0)
: ExpressionEngine()
{
// define Label of type 'Output' to avoid being marked as touched after relabeling
ADD_PROPERTY_TYPE(Label,("Unnamed"),"Base",Prop_Output,"User name of the object (UTF8)");
+3 -3
View File
@@ -626,20 +626,20 @@ private:
protected: // attributes
Py::SmartPtr PythonObject;
/// pointer to the document this object belongs to
App::Document* _pDoc;
App::Document* _pDoc{nullptr};
/// Old label; used for renaming expressions
std::string oldLabel;
// pointer to the document name string (for performance)
const std::string *pcNameInDocument;
const std::string *pcNameInDocument{nullptr};
private:
// accessed by App::Document to record and restore the correct view provider type
std::string _pcViewProviderName;
// unique identifier (among a document) of this object.
long _Id;
long _Id{0};
private:
// Back pointer to all the fathers in a DAG of the document
+2 -2
View File
@@ -471,11 +471,11 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds)
bool transform = Base::asBoolean(doTransform);
struct SubInfo {
App::DocumentObject *sobj;
App::DocumentObject *sobj{nullptr};
Py::Object obj;
Py::Object pyObj;
Base::Matrix4D mat;
explicit SubInfo(const Base::Matrix4D &mat) : sobj(nullptr), mat(mat){}
explicit SubInfo(const Base::Matrix4D &mat) : mat(mat){}
};
Base::Matrix4D mat;
+2 -2
View File
@@ -595,7 +595,7 @@ App::Document* DocumentWeakPtrT::operator->() const noexcept
class DocumentObjectWeakPtrT::Private {
public:
explicit Private(App::DocumentObject* obj) : object(obj), indocument(false) {
explicit Private(App::DocumentObject* obj) : object(obj) {
set(obj);
}
void deletedDocument(const App::Document& doc) {
@@ -642,7 +642,7 @@ public:
}
App::DocumentObject* object;
bool indocument;
bool indocument{false};
using Connection = boost::signals2::scoped_connection;
Connection connectApplicationDeletedDocument;
Connection connectDocumentCreatedObject;
+10 -10
View File
@@ -967,7 +967,7 @@ std::map<App::ObjectIdentifier,bool> Expression::getIdentifiers() const {
class AdjustLinksExpressionVisitor : public ExpressionVisitor {
public:
explicit AdjustLinksExpressionVisitor(const std::set<App::DocumentObject*> &inList)
:inList(inList),res(false)
:inList(inList)
{}
void visit(Expression &e) override {
@@ -976,7 +976,7 @@ public:
}
const std::set<App::DocumentObject*> &inList;
bool res;
bool res{false};
};
bool Expression::adjustLinks(const std::set<App::DocumentObject*> &inList) {
@@ -1871,7 +1871,7 @@ bool FunctionExpression::isTouched() const
class Collector {
public:
Collector() : first(true) { }
Collector() = default;
virtual ~Collector() = default;
virtual void collect(Quantity value) {
if (first)
@@ -1881,7 +1881,7 @@ public:
return q;
}
protected:
bool first;
bool first{true};
Quantity q;
};
@@ -1899,7 +1899,7 @@ public:
class AverageCollector : public Collector {
public:
AverageCollector() : Collector(), n(0) { }
AverageCollector() : Collector() { }
void collect(Quantity value) override {
Collector::collect(value);
@@ -1911,12 +1911,12 @@ public:
Quantity getQuantity() const override { return q/(double)n; }
private:
unsigned int n;
unsigned int n{0};
};
class StdDevCollector : public Collector {
public:
StdDevCollector() : Collector(), n(0) { }
StdDevCollector() : Collector() { }
void collect(Quantity value) override {
Collector::collect(value);
@@ -1941,14 +1941,14 @@ public:
}
private:
unsigned int n;
unsigned int n{0};
Quantity mean;
Quantity M2;
};
class CountCollector : public Collector {
public:
CountCollector() : Collector(), n(0) { }
CountCollector() : Collector() { }
void collect(Quantity value) override {
Collector::collect(value);
@@ -1959,7 +1959,7 @@ public:
Quantity getQuantity() const override { return Quantity(n); }
private:
unsigned int n;
unsigned int n{0};
};
class MinCollector : public Collector {
+1 -2
View File
@@ -84,7 +84,6 @@ public:
: prop(_prop)
, propLink(Base::freecad_dynamic_cast<App::PropertyLinkBase>(&prop))
, signaller(_prop,false)
, _changed(0)
{}
~ExpressionModifier() override = default;
@@ -104,7 +103,7 @@ protected:
P & prop;
App::PropertyLinkBase *propLink;
typename AtomicPropertyChangeInterface<P>::AtomicPropertyChange signaller;
int _changed;
int _changed{0};
};
/**
+5 -6
View File
@@ -522,12 +522,12 @@ public:
Base::Quantity scaler;
std::string unitStr;
} quantity;
Expression::Component *component;
Expression * expr;
Expression::Component *component{nullptr};
Expression * expr{nullptr};
ObjectIdentifier path;
std::deque<ObjectIdentifier::Component> components;
long long int ivalue;
double fvalue;
long long int ivalue{0};
double fvalue{0};
struct {
const char *name = "";
double fvalue = 0;
@@ -537,8 +537,7 @@ public:
std::string string;
std::pair<FunctionExpression::Function,std::string> func;
ObjectIdentifier::String string_or_identifier;
semantic_type() : component(nullptr), expr(nullptr), ivalue(0), fvalue(0)
, func({FunctionExpression::NONE, std::string()}) {}
semantic_type() : func({FunctionExpression::NONE, std::string()}) {}
};
#define YYSTYPE semantic_type
+1 -1
View File
@@ -38,7 +38,7 @@
using namespace App;
FeaturePythonImp::FeaturePythonImp(App::DocumentObject* o)
: object(o), has__object__(false)
: object(o)
{
}
+1 -1
View File
@@ -86,7 +86,7 @@ public:
private:
App::DocumentObject* object;
bool has__object__;
bool has__object__{false};
#define FC_PY_FEATURE_PYTHON \
FC_PY_ELEMENT(execute)\
+2 -2
View File
@@ -94,7 +94,7 @@ void Document::exportGraphviz(std::ostream& out) const
class GraphCreator {
public:
explicit GraphCreator(struct DocumentP* _d) : d(_d), vertex_no(0), seed(std::random_device()()), distribution(0,255) {
explicit GraphCreator(struct DocumentP* _d) : d(_d), seed(std::random_device()()), distribution(0,255) {
build();
}
@@ -658,7 +658,7 @@ void Document::exportGraphviz(std::ostream& out) const
const struct DocumentP* d;
Graph DepList;
int vertex_no;
int vertex_no{0};
std::map<std::string, Vertex> LocalVertexList;
std::map<std::string, Vertex> GlobalVertexList;
std::set<const DocumentObject*> objects;
-2
View File
@@ -31,8 +31,6 @@ PROPERTY_SOURCE(Image::ImagePlane, App::GeoFeature)
ImagePlane::ImagePlane()
: XPixelsPerMeter{1000.0}
, YPixelsPerMeter{1000.0}
{
ADD_PROPERTY_TYPE( ImageFile,(nullptr) , "ImagePlane",App::Prop_None,"File of the image");
ADD_PROPERTY_TYPE( XSize, (100), "ImagePlane",App::Prop_None,"Size of a pixel in X");
+2 -2
View File
@@ -48,8 +48,8 @@ public:
void setXSizeInPixel(int);
void setYSizeInPixel(int);
double XPixelsPerMeter;
double YPixelsPerMeter;
double XPixelsPerMeter{1000.0};
double YPixelsPerMeter{1000.0};
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
-1
View File
@@ -148,7 +148,6 @@ void LinkParams::removeCopyOnChangeApplyToAll() {
EXTENSION_PROPERTY_SOURCE(App::LinkBaseExtension, App::DocumentObjectExtension)
LinkBaseExtension::LinkBaseExtension()
:enableLabelCache(false),hasOldSubElement(false),hasCopyOnChange(true)
{
initExtensionType(LinkBaseExtension::getExtensionClassTypeId());
EXTENSION_ADD_PROPERTY_TYPE(_LinkTouched, (false), " Link",
+3 -3
View File
@@ -385,12 +385,12 @@ protected:
long prevLinkedObjectID = 0;
mutable std::unordered_map<std::string,int> myLabelCache; // for label based subname lookup
mutable bool enableLabelCache;
bool hasOldSubElement;
mutable bool enableLabelCache{false};
bool hasOldSubElement{false};
std::vector<boost::signals2::scoped_connection> copyOnChangeConns;
std::vector<boost::signals2::scoped_connection> copyOnChangeSrcConns;
bool hasCopyOnChange;
bool hasCopyOnChange{true};
mutable bool checkingProperty = false;
bool pauseCopyOnChange = false;
+2 -1
View File
@@ -71,7 +71,8 @@ private:
};
}
MergeDocuments::MergeDocuments(App::Document* doc) : guiup(false), verbose(true), stream(nullptr), appdoc(doc)
MergeDocuments::MergeDocuments(App::Document* doc)
: appdoc(doc)
{
//NOLINTBEGIN
connectExport = doc->signalExportObjects.connect
+4 -4
View File
@@ -53,10 +53,10 @@ public:
const std::map<std::string, std::string> &getNameMap() const {return nameMap;}
private:
bool guiup;
bool verbose;
zipios::ZipInputStream* stream;
App::Document* appdoc;
bool guiup{false};
bool verbose{true};
zipios::ZipInputStream* stream{nullptr};
App::Document* appdoc{nullptr};
std::vector<App::DocumentObject*> objects;
std::map<std::string, std::string> nameMap;
using Connection = boost::signals2::connection;
+1 -8
View File
@@ -1120,11 +1120,7 @@ bool App::Meta::Dependency::operator==(const Dependency& rhs) const
&& dependencyType == rhs.dependencyType;
}
Meta::Version::Version()
: major(0),
minor(0),
patch(0)
{}
Meta::Version::Version() = default;
Meta::Version::Version(int major, int minor, int patch, std::string suffix)
: major(major),
@@ -1134,9 +1130,6 @@ Meta::Version::Version(int major, int minor, int patch, std::string suffix)
{}
Meta::Version::Version(const std::string& versionString)
: major(0),
minor(0),
patch(0)
{
std::istringstream stream(versionString);
char separator {'.'};
+2 -2
View File
@@ -107,8 +107,8 @@ struct AppExport Version {
explicit Version(const std::string& semanticString);
int major{};
int minor;
int patch;
int minor{};
int patch{};
std::string suffix;
std::string str() const;
+1 -9
View File
@@ -1968,15 +1968,7 @@ void ObjectIdentifier::resolveAmbiguity(ResolveResults &result) {
*/
ObjectIdentifier::ResolveResults::ResolveResults(const ObjectIdentifier &oi)
: propertyIndex(0)
, resolvedDocument(nullptr)
, resolvedDocumentName()
, resolvedDocumentObject(nullptr)
, resolvedDocumentObjectName()
, resolvedSubObject(nullptr)
, resolvedProperty(nullptr)
, propertyName()
, propertyType(PseudoNone)
: propertyType(PseudoNone)
{
oi.resolve(*this);
}
+6 -6
View File
@@ -448,16 +448,16 @@ protected:
explicit ResolveResults(const ObjectIdentifier & oi);
int propertyIndex;
App::Document * resolvedDocument;
int propertyIndex{0};
App::Document * resolvedDocument{nullptr};
String resolvedDocumentName;
App::DocumentObject * resolvedDocumentObject;
App::DocumentObject * resolvedDocumentObject{nullptr};
String resolvedDocumentObjectName;
String subObjectName;
App::DocumentObject * resolvedSubObject;
App::Property * resolvedProperty;
App::DocumentObject * resolvedSubObject{nullptr};
App::Property * resolvedProperty{nullptr};
std::string propertyName;
int propertyType;
int propertyType{0};
std::bitset<32> flags;
std::string resolveErrorString() const;
+1 -1
View File
@@ -54,7 +54,7 @@ static std::atomic<int64_t> _PropID;
// Here is the implementation! Description should take place in the header file!
Property::Property()
:father(nullptr), myName(nullptr), _id(++_PropID)
: _id(++_PropID)
{
}
+5 -5
View File
@@ -296,8 +296,8 @@ private:
void syncType(unsigned type);
private:
PropertyContainer *father;
const char *myName;
PropertyContainer *father{nullptr};
const char *myName{nullptr};
int64_t _id;
public:
@@ -334,7 +334,7 @@ public:
*/
template<class P> class AtomicPropertyChangeInterface {
protected:
AtomicPropertyChangeInterface() : signalCounter(0), hasChanged(false) { }
AtomicPropertyChangeInterface() = default;
public:
class AtomicPropertyChange {
@@ -409,8 +409,8 @@ public:
};
protected:
int signalCounter; /**< Counter for invoking transaction start/stop */
bool hasChanged;
int signalCounter{0}; /**< Counter for invoking transaction start/stop */
bool hasChanged{false};
};
+1 -2
View File
@@ -87,8 +87,7 @@ TYPESYSTEM_SOURCE(App::PropertyExpressionEngine , App::PropertyExpressionContain
*/
PropertyExpressionEngine::PropertyExpressionEngine()
: running(false)
, validator(0)
: validator(0)
{
}
+1 -1
View File
@@ -192,7 +192,7 @@ private:
void slotChangedProperty(const App::DocumentObject &obj, const App::Property &prop);
void updateHiddenReference(const std::string &key);
bool running; /**< Boolean used to avoid loops */
bool running = false; /**< Boolean used to avoid loops */
bool restoring = false;
ExpressionMap expressions; /**< Stored expressions */
+3 -18
View File
@@ -380,12 +380,7 @@ TYPESYSTEM_SOURCE(App::PropertyLinkHidden , App::PropertyLink)
// Construction/Destruction
PropertyLink::PropertyLink()
:_pcLink(nullptr)
{
}
PropertyLink::PropertyLink() = default;
PropertyLink::~PropertyLink()
{
@@ -882,11 +877,7 @@ TYPESYSTEM_SOURCE(App::PropertyLinkSubHidden, App::PropertyLinkSub)
// Construction/Destruction
PropertyLinkSub::PropertyLinkSub()
: _pcLinkSub(nullptr), _restoreLabel(false)
{
}
PropertyLinkSub::PropertyLinkSub() = default;
PropertyLinkSub::~PropertyLinkSub()
{
@@ -2525,7 +2516,7 @@ public:
DocInfoMap::iterator myPos;
std::string myPath;
App::Document *pcDoc;
App::Document *pcDoc{nullptr};
std::set<PropertyXLink*> links;
static std::string getDocPath(
@@ -2637,12 +2628,6 @@ public:
return myPath.c_str();
}
DocInfo()
:pcDoc(nullptr)
{}
~DocInfo() = default;
void deinit() {
FC_LOG("deinit " << (pcDoc?pcDoc->getName():filePath()));
assert(links.empty());
+3 -3
View File
@@ -630,7 +630,7 @@ public:
Property *CopyOnLinkReplace(const App::DocumentObject *parent,
App::DocumentObject *oldObj, App::DocumentObject *newObj) const override;
protected:
App::DocumentObject *_pcLink;
App::DocumentObject *_pcLink{nullptr};
};
/** The general Link Property with Child scope
@@ -860,11 +860,11 @@ public:
void setSyncSubObject(bool enable);
protected:
App::DocumentObject* _pcLinkSub;
App::DocumentObject* _pcLinkSub{nullptr};
std::vector<std::string> _cSubList;
std::vector<ShadowSub> _ShadowSubList;
std::vector<int> _mapped;
bool _restoreLabel;
bool _restoreLabel{false};
};
/** The general Link Property with Child scope
+2 -11
View File
@@ -600,12 +600,7 @@ TYPESYSTEM_SOURCE(App::PropertyIntegerConstraint, App::PropertyInteger)
// Construction/Destruction
PropertyIntegerConstraint::PropertyIntegerConstraint()
: _ConstStruct(nullptr)
{
}
PropertyIntegerConstraint::PropertyIntegerConstraint() = default;
PropertyIntegerConstraint::~PropertyIntegerConstraint()
{
@@ -1044,11 +1039,7 @@ TYPESYSTEM_SOURCE(App::PropertyFloatConstraint, App::PropertyFloat)
// Construction/Destruction
PropertyFloatConstraint::PropertyFloatConstraint()
: _ConstStruct(nullptr)
{
}
PropertyFloatConstraint::PropertyFloatConstraint() = default;
PropertyFloatConstraint::~PropertyFloatConstraint()
{
+2 -2
View File
@@ -310,7 +310,7 @@ public:
void setPyObject(PyObject *) override;
protected:
const Constraints* _ConstStruct;
const Constraints* _ConstStruct{nullptr};
};
/** Percent property
@@ -613,7 +613,7 @@ public:
void setPyObject(PyObject *) override;
protected:
const Constraints* _ConstStruct;
const Constraints* _ConstStruct{nullptr};
};
+3 -4
View File
@@ -84,7 +84,7 @@ class AppExport PropertyQuantityConstraint : public PropertyQuantity
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
PropertyQuantityConstraint():_ConstStruct(nullptr){}
PropertyQuantityConstraint() = default;
~PropertyQuantityConstraint() override = default;
/// Constraint methods
@@ -113,9 +113,8 @@ public:
const char* getEditorName() const override;
void setPyObject(PyObject *) override;
protected:
const Constraints* _ConstStruct;
private:
const Constraints* _ConstStruct{nullptr};
};
// ------------------------------------------------------
+1 -4
View File
@@ -272,10 +272,7 @@ TYPESYSTEM_SOURCE_ABSTRACT(App::TransactionObject, Base::Persistence)
* A constructor.
* A more elaborate description of the constructor.
*/
TransactionObject::TransactionObject()
: status(New)
{
}
TransactionObject::TransactionObject() = default;
/**
* A destructor.
+1 -1
View File
@@ -128,7 +128,7 @@ public:
friend class Transaction;
protected:
enum Status {New,Del,Chn} status;
enum Status {New,Del,Chn} status{New};
struct PropData : DynamicProperty::PropData {
Base::Type propertyType;
+1 -3
View File
@@ -37,7 +37,7 @@ using namespace App;
PROPERTY_SOURCE(App::VRMLObject, App::GeoFeature)
VRMLObject::VRMLObject() : index(0)
VRMLObject::VRMLObject()
{
ADD_PROPERTY_TYPE(VrmlFile,(nullptr),"",Prop_None,"Included file with the VRML definition");
ADD_PROPERTY_TYPE(Urls,(""),"",static_cast<PropertyType>(Prop_ReadOnly|Prop_Output|Prop_Transient),
@@ -48,8 +48,6 @@ VRMLObject::VRMLObject() : index(0)
Resources.setSize(0);
}
VRMLObject::~VRMLObject() = default;
short VRMLObject::mustExecute() const
{
return 0;
+3 -2
View File
@@ -38,7 +38,6 @@ class AppExport VRMLObject : public GeoFeature
public:
/// Constructor
VRMLObject();
~VRMLObject() override;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
@@ -54,9 +53,11 @@ public:
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
//NOLINTBEGIN
PropertyFileIncluded VrmlFile;
PropertyStringList Urls;
PropertyStringList Resources;
//NOLINTEND
protected:
void onChanged(const App::Property*) override;
@@ -66,7 +67,7 @@ protected:
private:
mutable std::string vrmlPath;
mutable int index;
mutable int index{0};
};
} //namespace App