Commit Graph

31 Commits

Author SHA1 Message Date
wmayer
3e35b5f606 App: modernize C++: use equals default 2023-08-20 18:10:17 +02:00
wmayer
89bdd489b0 App: modernize C++: return braced init list 2023-08-18 00:36:24 +02:00
Abdullah Tahiri
4dea0df06c App: Extension/ExtensionContainer - handle property change
==========================================================

Currently changes of name or type of properties in a property container are handled by:
void PropertyContainer::handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName)
void PropertyContainer::changedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop)

There is no mechanism for handling property changes by extensions. Sometimes the solution is to explicitly call the extension
from the container. However, this is a breach of the SRP, as the container should not be in a position to decide whether the
extension needs or not handle property changes. The handling code of the container changes for two different reasons, for
adapting the container to a property change of its own, and for adapting that of a property of the extension.

Illustrating it with an example, following inheritance, it goes like this:
PropertyContainer => ExtensionContainer => TransactionalObject => ViewProvider
App::Extension => ViewProviderExtension

The extension is currently not notified by the ExtensionContainer that a property needs handling. So a change in a property of
a ViewProviderExtension needs code at the ViewProvider it was added to.

This commit provides a mechanism in ExtensionContainer to call the extensions so that they can handle property changes. This
functions:

  virtual bool extensionHandleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName);
  virtual bool extensionHandleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, Property * prop);

Containers should always call the base class for any unhandled property change. If a sub-class container of ExtensionContainer
handles property changes itself, but not the ones of the extensions, this call to the base class ultimately ensures that if the
property was not handled by the container hierarchy, any extension is given an opportunity to handle it.

Some examples:

* A container handles the extension property change or its own:

void ContainerSubClass::handleChangedPropertyType(...)
{
    if (prop == &PropertyOfExt) {

    }
    else if (prop == &PropertyOfCont) {

    }
    else {
        ContainerBaseClass::handleChangedPropertyType(...);
    }
}

* A container and the extension handle their own:

void ContainerSubClass::handleChangedPropertyType(...)
{
    if (prop == &PropertyOfCont) {

    }
    else {
        // This will call ExtensionContainer::handleChangedPropertyType
        ContainerBaseClass::handleChangedPropertyType(...);
    }
}

bool ExtensionSubClass::extensionHandleChangedPropertyType(...)
{
    if (prop == &PropertyOfCont) {

        return true;
    }
    return false;
}
2023-02-25 23:13:55 +01:00
marioalexis
9ccb9eecb2 App: Replace C cast 2022-09-18 11:06:51 -05:00
berniev
b40de7a509 remove redundant void 2022-07-31 10:27:44 +02:00
wmayer
ca3c8185e0 App/Gui: move template classes (ViewProvider)ExtensionPythonT to their own header files 2022-03-04 18:54:42 +01:00
Uwe
b4fff07d9e [App] Expression and Extension: remove unused includes 2022-02-25 18:06:57 +01:00
luz paz
bfdffb50be App: Fix header uniformity, trailing whitespace, and doxygen headers 2020-11-19 13:38:37 +01:00
luz.paz
d36c3ebe57 Trivial code formatting for some {.cpp,.h} files 2020-04-06 12:55:27 +02:00
luz.paz
4f308dc03c src/App: [skip ci] fix header uniformity
This PR fixes header uniformity across all `src/App` files
2019-12-25 11:38:43 +01:00
asapelkin
8bc5b585c8 Used single quotes for single character in string::find algorithm, more efficient 2019-11-21 18:59:43 +01:00
wmayer
b50b21576e core system
force strict ISO C++ (-Wpedantic)
TODO: still a lot of variadic macros are not valid ISO C++
2019-09-18 01:01:14 +02:00
Unknown
a8ecffb652 Misc. typo fixes
Various workbenches
2017-12-23 14:30:30 +01:00
wmayer
1673ab801e use specialized exception classes 2017-04-28 18:49:11 +02:00
Kunda
3017173c9a source typo fixes pt6 2017-03-07 13:43:46 -03:00
Stefan Tröger
47ed29fffd Extensions: GeoFeatureGroup only for GeoFeature 2017-01-04 16:01:58 +01:00
wmayer
0074f7c352 minor improvements 2016-12-11 19:27:35 +01:00
Stefan Tröger
cd1c753fa2 Extensions: Implement persistence 2016-12-11 19:27:35 +01:00
wmayer
956a21a81a fix dangling pointer, remove superfluous semicolons, avoid excessive report messages of extension object 2016-12-09 23:03:18 +01:00
Stefan Tröger
19e708879f Extensions: Fix ViewProvider python interface 2016-12-04 17:35:00 +01:00
wmayer
e0a0aa7786 fix typos 2016-11-12 17:57:14 +01:00
wmayer
9ac1810ea3 Fix issues:
+ improve formatting
+ remove superfluous semicolons
+ comment unused parameters
+ rename Initialisation to Initialization
+ rename Deinitialisation to Finalization
+ remove spaces
2016-10-08 12:48:34 +02:00
Stefan Tröger
3a51404dd5 Extenions: Drop virtual inheritance
Due to problems onthe windows platform the virtual inheritance approach must be dropped. NExt to the already reimplemented proeprty interface the Type interface is reimplemented too. This change allows to revert some earlier changes.
2016-10-08 12:48:34 +02:00
Stefan Tröger
22fa3b3922 Extension: Fix order-of-initialisation crash
FreeCADs property system utilises some pointer math to calculate the offset between
property and base class. Due to virtual inheritance of th ePropertyContainer the memory
layout has been changed to rather random, which has lead to crashes dependend on the
order of object initialisation.

The solution is to not make PropertyContaner virtual but a class below, Base::Persitance.
Then the memory layout is random for Persistance, but it is perfectly aligned for the
base class chains from PropertyContainer onwards as well as from Extension onwards.
Hence the proeprty system was changed to take the offset always from those two.
2016-10-08 12:48:34 +02:00
Stefan Tröger
b27875a777 Extension: Delete extensions correctly 2016-10-08 12:48:34 +02:00
Stefan Tröger
0a539538de Extensions: Port ViewProvider of groups 2016-10-08 12:48:34 +02:00
Stefan Tröger
7bcb6519cc Extensions: Make Python Integration work 2016-10-08 12:48:34 +02:00
Stefan Tröger
93222098f0 Extensions: Allow them to be added dynamically 2016-10-08 12:48:34 +02:00
Stefan Tröger
a8d0accdad Extensions: special calls for document object extensions 2016-10-08 12:48:34 +02:00
Stefan Tröger
4c42181e34 Extensions: Show up in the python interface 2016-10-08 12:48:34 +02:00
Stefan Tröger
c5a2419e14 Extensions: Introduce classes and port App groups 2016-10-08 12:48:34 +02:00