App: Apply clang format (part 1)

This commit is contained in:
wmayer
2024-11-15 17:43:49 +01:00
committed by wwmayer
parent 463cc08f3f
commit 6f5259af26
124 changed files with 6733 additions and 4886 deletions

View File

@@ -51,7 +51,7 @@ public:
/*! Constructor */
DocumentT();
/*! Constructor */
DocumentT(Document*); // explicit bombs
DocumentT(Document*); // explicit bombs
/*! Constructor */
explicit DocumentT(const std::string&);
/*! Constructor */
@@ -65,18 +65,20 @@ public:
/*! Assignment operator */
void operator=(const std::string&);
bool operator==(const DocumentT &other) const {
bool operator==(const DocumentT& other) const
{
return document == other.document;
}
bool operator<(const DocumentT &other) const {
bool operator<(const DocumentT& other) const
{
return document < other.document;
}
/*! Get a pointer to the document or 0 if it doesn't exist any more. */
Document* getDocument() const;
/*! Get the name of the document. */
const std::string &getDocumentName() const;
const std::string& getDocumentName() const;
/*! Get the document as Python command. */
std::string getDocumentPython() const;
@@ -85,9 +87,9 @@ private:
};
/**
* The DocumentObjectT class is a helper class to store the names of a document object and its document.
* This can be useful when you cannot rely on that the document or the object still exists when you have to
* access it.
* The DocumentObjectT class is a helper class to store the names of a document object and its
* document. This can be useful when you cannot rely on that the document or the object still exists
* when you have to access it.
*
* @author Werner Mayer
*/
@@ -97,23 +99,23 @@ public:
/*! Constructor */
DocumentObjectT();
/*! Constructor */
DocumentObjectT(const DocumentObjectT &);
DocumentObjectT(const DocumentObjectT&);
/*! Constructor */
DocumentObjectT(DocumentObjectT &&);
DocumentObjectT(DocumentObjectT&&);
/*! Constructor */
explicit DocumentObjectT(const DocumentObject*);
/*! Constructor */
DocumentObjectT(const Document*, const std::string& objName);
/*! Constructor */
DocumentObjectT(const char *docName, const char *objName);
DocumentObjectT(const char* docName, const char* objName);
/*! Constructor */
explicit DocumentObjectT(const Property*);
/*! Destructor */
~DocumentObjectT();
/*! Assignment operator */
DocumentObjectT &operator=(const DocumentObjectT&);
DocumentObjectT& operator=(const DocumentObjectT&);
/*! Assignment operator */
DocumentObjectT &operator=(DocumentObjectT &&);
DocumentObjectT& operator=(DocumentObjectT&&);
/*! Assignment operator */
void operator=(const DocumentObject*);
/*! Assignment operator */
@@ -124,7 +126,7 @@ public:
/*! Get a pointer to the document or 0 if it doesn't exist any more. */
Document* getDocument() const;
/*! Get the name of the document. */
const std::string &getDocumentName() const;
const std::string& getDocumentName() const;
/*! Get the document as Python command. */
std::string getDocumentPython() const;
/*! Get a pointer to the document object or 0 if it doesn't exist any more. */
@@ -132,16 +134,17 @@ public:
/*! Get a pointer to the property or 0 if it doesn't exist any more. */
Property* getProperty() const;
/*! Get the name of the document object. */
const std::string &getObjectName() const;
const std::string& getObjectName() const;
/*! Get the label of the document object. */
const std::string &getObjectLabel() const;
const std::string& getObjectLabel() const;
/*! Get the name of the property. */
const std::string &getPropertyName() const;
const std::string& getPropertyName() const;
/*! Get the document object as Python command. */
std::string getObjectPython() const;
/*! Get the property as Python command. */
std::string getPropertyPython() const;
/*! Get a pointer to the document or 0 if it doesn't exist any more or the type doesn't match. */
/*! Get a pointer to the document or 0 if it doesn't exist any more or the type doesn't match.
*/
template<typename T>
inline T* getObjectAs() const
{
@@ -160,72 +163,73 @@ private:
std::string property;
};
class AppExport SubObjectT : public DocumentObjectT
class AppExport SubObjectT: public DocumentObjectT
{
public:
/*! Constructor */
SubObjectT();
/*! Constructor */
SubObjectT(const SubObjectT &);
SubObjectT(const SubObjectT&);
/*! Constructor */
SubObjectT(SubObjectT &&);
SubObjectT(SubObjectT&&);
/*! Constructor */
SubObjectT(const DocumentObjectT & obj, const char *subname);
SubObjectT(const DocumentObjectT& obj, const char* subname);
/*! Constructor */
SubObjectT(const DocumentObject*, const char *subname);
SubObjectT(const DocumentObject*, const char* subname);
/*! Constructor */
SubObjectT(const DocumentObject*);// explicit bombs
SubObjectT(const DocumentObject*); // explicit bombs
/*! Constructor */
SubObjectT(const char *docName, const char *objName, const char *subname);
SubObjectT(const char* docName, const char* objName, const char* subname);
/*! Assignment operator */
SubObjectT &operator=(const SubObjectT&);
SubObjectT& operator=(const SubObjectT&);
/*! Assignment operator */
SubObjectT &operator=(SubObjectT &&);
SubObjectT& operator=(SubObjectT&&);
/*! Assignment operator */
SubObjectT &operator=(const DocumentObjectT&);
SubObjectT& operator=(const DocumentObjectT&);
/*! Assignment operator */
SubObjectT &operator=(const App::DocumentObject*);
SubObjectT& operator=(const App::DocumentObject*);
/*! Equality operator */
bool operator==(const SubObjectT&) const;
/// Set the subname path to the sub-object
void setSubName(const char *subname);
void setSubName(const char* subname);
/// Set the subname path to the sub-object
void setSubName(const std::string &subname) {
void setSubName(const std::string& subname)
{
setSubName(subname.c_str());
}
/// Return the subname path
const std::string &getSubName() const;
const std::string& getSubName() const;
/** Return docname#objname (label)
* @param docName: optional document name. The document prefix will only be printed
* if it is different then the given 'doc'.
*/
std::string getObjectFullName(const char *docName=nullptr) const;
std::string getObjectFullName(const char* docName = nullptr) const;
/** Return docname#objname.subname (label)
* @param doc: optional document name. The document prefix will only be printed
* if it is different then the given 'doc'.
*/
std::string getSubObjectFullName(const char *docName=nullptr) const;
std::string getSubObjectFullName(const char* docName = nullptr) const;
/// Return the subname path without sub-element
std::string getSubNameNoElement() const;
/// Return the sub-element (Face, Edge, etc) of the subname path
const char *getElementName() const;
const char* getElementName() const;
/// Check if there is any sub object reference
bool hasSubObject() const;
@@ -239,17 +243,17 @@ public:
/** Return the old style sub-element name
* @param index: if given, then return the element type, and extract the index
*/
std::string getOldElementName(int *index=nullptr) const;
std::string getOldElementName(int* index = nullptr) const;
/// Return the sub-object
DocumentObject *getSubObject() const;
DocumentObject* getSubObject() const;
/// Return all objects along the subname path
std::vector<DocumentObject *> getSubObjectList() const;
std::vector<DocumentObject*> getSubObjectList() const;
bool operator<(const SubObjectT &other) const;
bool operator<(const SubObjectT& other) const;
std::string getSubObjectPython(bool force=true) const;
std::string getSubObjectPython(bool force = true) const;
/// Options used by normalize()
enum class NormalizeOption : uint8_t
@@ -299,16 +303,17 @@ public:
PropertyLinkT();
/*! Constructor */
explicit PropertyLinkT(DocumentObject *obj);
explicit PropertyLinkT(DocumentObject* obj);
/*! Constructor */
PropertyLinkT(DocumentObject *obj, const std::vector<std::string>& subNames);
PropertyLinkT(DocumentObject* obj, const std::vector<std::string>& subNames);
/*! Constructor */
explicit PropertyLinkT(const std::vector<DocumentObject*>& objs);
/*! Constructor */
PropertyLinkT(const std::vector<DocumentObject*>& objs, const std::vector<std::string>& subNames);
PropertyLinkT(const std::vector<DocumentObject*>& objs,
const std::vector<std::string>& subNames);
/*! Get the property as Python command. */
std::string getPropertyPython() const;
@@ -379,7 +384,7 @@ public:
* \brief operator =
* Assignment operator
*/
DocumentObjectWeakPtrT& operator= (App::DocumentObject* p);
DocumentObjectWeakPtrT& operator=(App::DocumentObject* p);
/*!
* \brief operator *
* \return pointer to the document object
@@ -394,12 +399,12 @@ public:
* \brief operator ==
* \return true if both objects are equal, false otherwise
*/
bool operator== (const DocumentObjectWeakPtrT& p) const noexcept;
bool operator==(const DocumentObjectWeakPtrT& p) const noexcept;
/*!
* \brief operator !=
* \return true if both objects are inequal, false otherwise
*/
bool operator!= (const DocumentObjectWeakPtrT& p) const noexcept;
bool operator!=(const DocumentObjectWeakPtrT& p) const noexcept;
/*! Get a pointer to the object or 0 if it doesn't exist any more or the type doesn't match. */
template<typename T>
inline T* get() const noexcept
@@ -423,33 +428,37 @@ private:
/**
* @brief The WeakPtrT class
*/
template <class T>
template<class T>
class WeakPtrT
{
public:
explicit WeakPtrT(T* t) : ptr(t) {
}
explicit WeakPtrT(T* t)
: ptr(t)
{}
~WeakPtrT() = default;
/*!
* \brief reset
* Releases the reference to the managed object. After the call *this manages no object.
*/
void reset() {
void reset()
{
ptr.reset();
}
/*!
* \brief expired
* \return true if the managed object has already been deleted, false otherwise.
*/
bool expired() const {
bool expired() const
{
return ptr.expired();
}
/*!
* \brief operator =
* Assignment operator
*/
WeakPtrT<T>& operator= (T* p) {
WeakPtrT<T>& operator=(T* p)
{
ptr = p;
return *this;
}
@@ -457,28 +466,32 @@ public:
* \brief operator ->
* \return pointer to the document object
*/
T* operator*() const {
T* operator*() const
{
return ptr.get<T>();
}
/*!
* \brief operator ->
* \return pointer to the document object
*/
T* operator->() const {
T* operator->() const
{
return ptr.get<T>();
}
/*!
* \brief operator ==
* \return true if both objects are equal, false otherwise
*/
bool operator== (const WeakPtrT<T>& p) const {
bool operator==(const WeakPtrT<T>& p) const
{
return ptr == p.ptr;
}
/*!
* \brief operator !=
* \return true if both objects are inequal, false otherwise
*/
bool operator!= (const WeakPtrT<T>& p) const {
bool operator!=(const WeakPtrT<T>& p) const
{
return ptr != p.ptr;
}
/*! Get a pointer to the object or 0 if it doesn't exist any more. */
@@ -561,7 +574,7 @@ private:
*
* @author Werner Mayer
*/
class AppExport DocumentObjectObserver : public DocumentObserver
class AppExport DocumentObjectObserver: public DocumentObserver
{
public:
@@ -587,18 +600,18 @@ private:
void slotDeletedObject(const App::DocumentObject& Obj) override;
/** The property of an observed object has changed */
void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) override;
/** This method gets called when all observed objects are deleted or the whole document is deleted.
* This method can be re-implemented to perform an extra step like closing a dialog that observes
* a document.
*/
/** This method gets called when all observed objects are deleted or the whole document is
* deleted. This method can be re-implemented to perform an extra step like closing a dialog
* that observes a document.
*/
virtual void cancelObservation();
private:
std::set<App::DocumentObject*> _objects;
};
} //namespace App
} // namespace App
ENABLE_BITMASK_OPERATORS(App::SubObjectT::NormalizeOption)
#endif // APP_DOCUMENTOBSERVER_H
#endif // APP_DOCUMENTOBSERVER_H