├── .gitignore ├── .travis.yml ├── Build ├── Readme.md ├── build.bat ├── build.sh └── verpatch.exe ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Documentation ├── IDL.md └── images │ ├── ACT_logo_50px.png │ ├── O.png │ ├── O32.png │ ├── Tick.png │ ├── Tick32.png │ ├── X.png │ ├── X32.png │ ├── element_binding.png │ ├── element_bindings.png │ ├── element_class.png │ ├── element_component.png │ ├── element_enum.png │ ├── element_error.png │ ├── element_errors.png │ ├── element_functiontype.png │ ├── element_global.png │ ├── element_implementation.png │ ├── element_implementations.png │ ├── element_importcomponent.png │ ├── element_license.png │ ├── element_line.png │ ├── element_member.png │ ├── element_method.png │ ├── element_option.png │ ├── element_param.png │ ├── element_struct.png │ ├── type_export.png │ └── type_functiontype.png ├── Examples ├── Calculator │ ├── Calculator.xml │ └── Calculator_component │ │ ├── Bindings │ │ ├── CppDynamic │ │ │ ├── calculator_abi.hpp │ │ │ ├── calculator_dynamic.h │ │ │ ├── calculator_dynamic.hpp │ │ │ └── calculator_types.hpp │ │ ├── Pascal │ │ │ └── Unit_Calculator.pas │ │ └── Python │ │ │ └── Calculator.py │ │ ├── Examples │ │ ├── CppDynamic │ │ │ ├── CMakeLists.txt │ │ │ └── Calculator_example.cpp │ │ ├── Pascal │ │ │ ├── Calculator_Example.lpi │ │ │ └── Calculator_Example.lpr │ │ └── Python │ │ │ └── Calculator_Example.py │ │ └── Implementations │ │ ├── Cpp │ │ ├── Interfaces │ │ │ ├── calculator_abi.hpp │ │ │ ├── calculator_interfaceexception.cpp │ │ │ ├── calculator_interfaceexception.hpp │ │ │ ├── calculator_interfaces.hpp │ │ │ ├── calculator_interfacewrapper.cpp │ │ │ └── calculator_types.hpp │ │ └── Stub │ │ │ ├── calculator.cpp │ │ │ ├── calculator_base.cpp │ │ │ ├── calculator_base.hpp │ │ │ ├── calculator_calculator.cpp │ │ │ ├── calculator_calculator.hpp │ │ │ ├── calculator_variable.cpp │ │ │ └── calculator_variable.hpp │ │ └── Pascal │ │ ├── Interfaces │ │ ├── calculator.lpr │ │ ├── calculator_exception.pas │ │ ├── calculator_exports.pas │ │ ├── calculator_interfaces.pas │ │ └── calculator_types.pas │ │ ├── Stub │ │ ├── calculator_impl.pas │ │ ├── calculator_impl_base.pas │ │ ├── calculator_impl_calculator.pas │ │ └── calculator_impl_variable.pas │ │ ├── calculator.def │ │ └── calculator.lpi ├── Injection │ ├── Calculation.xml │ ├── Calculation_component │ │ ├── Bindings │ │ │ ├── Cpp │ │ │ │ ├── calculation_abi.hpp │ │ │ │ ├── calculation_implicit.hpp │ │ │ │ └── calculation_types.hpp │ │ │ ├── CppDynamic │ │ │ │ ├── calculation_abi.hpp │ │ │ │ ├── calculation_dynamic.h │ │ │ │ ├── calculation_dynamic.hpp │ │ │ │ └── calculation_types.hpp │ │ │ ├── Pascal │ │ │ │ └── Unit_Calculation.pas │ │ │ └── Python │ │ │ │ └── Calculation.py │ │ ├── Examples │ │ │ ├── Cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── Calculation_example.cpp │ │ │ ├── CppDynamic │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── Calculation_example.cpp │ │ │ ├── Pascal │ │ │ │ ├── Calculation_Example.lpi │ │ │ │ └── Calculation_Example.lpr │ │ │ └── Python │ │ │ │ └── Calculation_Example.py │ │ └── Implementations │ │ │ ├── Cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── Interfaces │ │ │ │ ├── calculation_abi.hpp │ │ │ │ ├── calculation_interfaceexception.cpp │ │ │ │ ├── calculation_interfaceexception.hpp │ │ │ │ ├── calculation_interfaces.hpp │ │ │ │ ├── calculation_interfacewrapper.cpp │ │ │ │ └── calculation_types.hpp │ │ │ └── Stub │ │ │ │ ├── calculation.cpp │ │ │ │ ├── calculation_base.cpp │ │ │ │ ├── calculation_base.hpp │ │ │ │ ├── calculation_calculator.cpp │ │ │ │ └── calculation_calculator.hpp │ │ │ └── Pascal │ │ │ ├── Interfaces │ │ │ ├── calculation.lpr │ │ │ ├── calculation_exception.pas │ │ │ ├── calculation_exports.pas │ │ │ ├── calculation_interfaces.pas │ │ │ └── calculation_types.pas │ │ │ ├── Stub │ │ │ ├── calculation_impl.pas │ │ │ ├── calculation_impl_base.pas │ │ │ └── calculation_impl_calculator.pas │ │ │ ├── calculation.def │ │ │ └── calculation.lpi │ ├── Numbers.xml │ ├── Numbers_component │ │ ├── Bindings │ │ │ ├── CppDynamic │ │ │ │ ├── numbers_abi.hpp │ │ │ │ ├── numbers_dynamic.h │ │ │ │ ├── numbers_dynamic.hpp │ │ │ │ └── numbers_types.hpp │ │ │ ├── Pascal │ │ │ │ └── Unit_Numbers.pas │ │ │ └── Python │ │ │ │ └── Numbers.py │ │ └── Implementations │ │ │ ├── Cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── Interfaces │ │ │ │ ├── numbers_abi.hpp │ │ │ │ ├── numbers_interfaceexception.cpp │ │ │ │ ├── numbers_interfaceexception.hpp │ │ │ │ ├── numbers_interfaces.hpp │ │ │ │ ├── numbers_interfacewrapper.cpp │ │ │ │ └── numbers_types.hpp │ │ │ └── Stub │ │ │ │ ├── numbers.cpp │ │ │ │ ├── numbers_base.cpp │ │ │ │ ├── numbers_base.hpp │ │ │ │ ├── numbers_variable.cpp │ │ │ │ └── numbers_variable.hpp │ │ │ └── Pascal │ │ │ ├── Interfaces │ │ │ ├── numbers.lpr │ │ │ ├── numbers_exception.pas │ │ │ ├── numbers_exports.pas │ │ │ ├── numbers_interfaces.pas │ │ │ └── numbers_types.pas │ │ │ ├── Stub │ │ │ ├── numbers_impl.pas │ │ │ ├── numbers_impl_base.pas │ │ │ └── numbers_impl_variable.pas │ │ │ ├── numbers.def │ │ │ └── numbers.lpi │ └── Readme.md ├── OptionalClass │ ├── .gitignore │ ├── OptClass_component │ │ ├── Bindings │ │ │ ├── Cpp │ │ │ │ ├── optclass_abi.hpp │ │ │ │ ├── optclass_implicit.hpp │ │ │ │ └── optclass_types.hpp │ │ │ ├── CppDynamic │ │ │ │ ├── optclass_abi.hpp │ │ │ │ ├── optclass_dynamic.h │ │ │ │ ├── optclass_dynamic.hpp │ │ │ │ └── optclass_types.hpp │ │ │ ├── Go │ │ │ │ ├── optclass._go │ │ │ │ └── optclass_impl._go │ │ │ ├── Pascal │ │ │ │ └── Unit_OptClass.pas │ │ │ └── Python │ │ │ │ └── OptClass.py │ │ ├── Examples │ │ │ ├── Cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── OptClass_example.cpp │ │ │ ├── CppDynamic │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── OptClass_example.cpp │ │ │ ├── Go │ │ │ │ └── OptClass_example._go │ │ │ ├── Pascal │ │ │ │ ├── OptClass_Example.lpi │ │ │ │ └── OptClass_Example.lpr │ │ │ └── Python │ │ │ │ └── OptClass_Example.py │ │ ├── Implementations │ │ │ ├── Cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Interfaces │ │ │ │ │ ├── optclass_abi.hpp │ │ │ │ │ ├── optclass_interfaceexception.cpp │ │ │ │ │ ├── optclass_interfaceexception.hpp │ │ │ │ │ ├── optclass_interfacejournal.cpp │ │ │ │ │ ├── optclass_interfacejournal.hpp │ │ │ │ │ ├── optclass_interfaces.hpp │ │ │ │ │ ├── optclass_interfacewrapper.cpp │ │ │ │ │ └── optclass_types.hpp │ │ │ │ └── Stub │ │ │ │ │ ├── optclass.cpp │ │ │ │ │ ├── optclass_base.cpp │ │ │ │ │ └── optclass_base.hpp │ │ │ └── Pascal │ │ │ │ ├── Interfaces │ │ │ │ ├── optclass.lpr │ │ │ │ ├── optclass_exception.pas │ │ │ │ ├── optclass_exports.pas │ │ │ │ ├── optclass_interfaces.pas │ │ │ │ └── optclass_types.pas │ │ │ │ ├── Stub │ │ │ │ ├── optclass_impl.pas │ │ │ │ └── optclass_impl_base.pas │ │ │ │ ├── optclass.def │ │ │ │ └── optclass.lpi │ │ └── license.txt │ ├── OptionalClass.xml │ └── Readme.md ├── Primes │ ├── .gitignore │ ├── LibPrimes_component │ │ ├── Bindings │ │ │ ├── CDynamic │ │ │ │ ├── libprimes_dynamic.cc │ │ │ │ ├── libprimes_dynamic.h │ │ │ │ └── libprimes_types.h │ │ │ ├── CSharp │ │ │ │ └── LibPrimes.cs │ │ │ ├── Cpp │ │ │ │ ├── libprimes_abi.hpp │ │ │ │ ├── libprimes_implicit.hpp │ │ │ │ └── libprimes_types.hpp │ │ │ ├── CppDynamic │ │ │ │ ├── libprimes_abi.hpp │ │ │ │ ├── libprimes_dynamic.h │ │ │ │ ├── libprimes_dynamic.hpp │ │ │ │ └── libprimes_types.hpp │ │ │ ├── Pascal │ │ │ │ └── Unit_LibPrimes.pas │ │ │ └── Python │ │ │ │ └── LibPrimes.py │ │ ├── Examples │ │ │ ├── CDynamic │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── LibPrimes_example.c │ │ │ ├── CSharp │ │ │ │ ├── LibPrimes_Example.cs │ │ │ │ ├── LibPrimes_Example.csproj │ │ │ │ └── LibPrimes_Example.sln │ │ │ ├── Cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── LibPrimes_example.cpp │ │ │ ├── CppDynamic │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── LibPrimes_example.cpp │ │ │ ├── Pascal │ │ │ │ ├── LibPrimes_Example.lpi │ │ │ │ └── LibPrimes_Example.lpr │ │ │ └── Python │ │ │ │ └── LibPrimes_Example.py │ │ ├── Implementations │ │ │ ├── Cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Interfaces │ │ │ │ │ ├── libprimes_abi.hpp │ │ │ │ │ ├── libprimes_interfaceexception.cpp │ │ │ │ │ ├── libprimes_interfaceexception.hpp │ │ │ │ │ ├── libprimes_interfacejournal.cpp │ │ │ │ │ ├── libprimes_interfacejournal.hpp │ │ │ │ │ ├── libprimes_interfaces.hpp │ │ │ │ │ ├── libprimes_interfacewrapper.cpp │ │ │ │ │ └── libprimes_types.hpp │ │ │ │ └── Stub │ │ │ │ │ ├── libprimes.cpp │ │ │ │ │ ├── libprimes_base.cpp │ │ │ │ │ ├── libprimes_base.hpp │ │ │ │ │ ├── libprimes_calculator.cpp │ │ │ │ │ ├── libprimes_calculator.hpp │ │ │ │ │ ├── libprimes_factorizationcalculator.cpp │ │ │ │ │ ├── libprimes_factorizationcalculator.hpp │ │ │ │ │ ├── libprimes_sievecalculator.cpp │ │ │ │ │ └── libprimes_sievecalculator.hpp │ │ │ └── Pascal │ │ │ │ ├── Interfaces │ │ │ │ ├── libprimes.lpr │ │ │ │ ├── libprimes_exception.pas │ │ │ │ ├── libprimes_exports.pas │ │ │ │ ├── libprimes_interfaces.pas │ │ │ │ └── libprimes_types.pas │ │ │ │ ├── Stub │ │ │ │ ├── libprimes_impl.pas │ │ │ │ ├── libprimes_impl_base.pas │ │ │ │ ├── libprimes_impl_calculator.pas │ │ │ │ ├── libprimes_impl_factorizationcalculator.pas │ │ │ │ └── libprimes_impl_sievecalculator.pas │ │ │ │ ├── libprimes.def │ │ │ │ └── libprimes.lpi │ │ └── license.txt │ ├── Tutorial.md │ ├── libPrimes.xml │ └── resources │ │ ├── 310 │ │ └── libPrimes.xml │ │ ├── 315 │ │ └── libPrimes.xml │ │ ├── 510 │ │ └── libPrimes.xml │ │ ├── 610 │ │ └── libPrimes.xml │ │ └── VSProperties.png ├── UnitTest │ ├── Project │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── Source │ │ │ └── Custom │ │ │ │ ├── libunittest_implementation.cpp │ │ │ │ ├── libunittest_implementation_testclass.cpp │ │ │ │ └── libunittest_implementation_testclass.hpp │ │ └── libUnitTest │ │ │ └── main.cpp │ └── libUnitTest.xml └── Version │ ├── libVersion.1.1.0.xml │ ├── libVersion.1.2.0.xml │ ├── libVersion.1.3.0.xml │ ├── libVersion.2.0.0.xml │ ├── libVersion.3.0.0.xml │ ├── libVersion.3.1.0.xml │ ├── libVersion.4.0.0.xml │ ├── libVersion.4.1.0.xml │ ├── libVersion.4.2.0.xml │ └── libVersion.xml ├── LICENSE.md ├── README.md ├── Source ├── .gitignore ├── ACT.xsd ├── actutils.go ├── automaticcomponenttoolkit.go ├── buildbindingccpp.go ├── buildbindingcsharp.go ├── buildbindinggo.go ├── buildbindingnode.go ├── buildbindingpascal.go ├── buildbindingpython.go ├── buildimplementationcpp.go ├── buildimplementationpascal.go ├── componentdefinition.go ├── componentdiff.go ├── languagec.go ├── languagecpp.go ├── languagepascal.go └── languagewriter.go ├── act.arm.linux32 ├── act.arm.linux64 ├── act.linux32 ├── act.linux64 └── go.mod /.gitignore: -------------------------------------------------------------------------------- 1 | *.cpp 2 | *.hpp 3 | *.h 4 | *.exe 5 | *.linux 6 | *.darwin 7 | *.exe 8 | *.c 9 | *.go 10 | *.orig 11 | 12 | # Visual Studio Code 13 | debug 14 | .vscode 15 | 16 | *_headers 17 | *_component 18 | 19 | Examples/*.xml 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Configuration file for Travis CI (https://travis-ci.org) 2 | # 3 | # It used as a status check for all PRs and 4 | # to generate the build-status-icon in the main README.md-file. 5 | 6 | language: go 7 | 8 | go: 9 | - 1.11.x 10 | 11 | matrix: 12 | include: 13 | - os: linux 14 | compiler: gcc 15 | - os: osx 16 | osx_image: xcode7.2 17 | 18 | before_script: 19 | - cd Build 20 | 21 | script: 22 | - sh build.sh 23 | -------------------------------------------------------------------------------- /Build/Readme.md: -------------------------------------------------------------------------------- 1 | # Release process for ACT 2 | 3 | 1. Create Release branch 4 | 5 | 2. Prepare tutorial etc 6 | 7 | 3. (optional) Pre-release RC, gather feedback + fix stuff 8 | 9 | 4. Modify release branch such that all links point to the master-branch/Actual.Version.Number 10 | 11 | 5. build: 12 | 13 | 1. Update the properties of the target act.exe by adapting the call to `build/verpatch.exe ...` in `build/build.bat` 14 | 15 | 2. `build/build.bat` 16 | 17 | 3. Ensure the binary's properties are suitable 18 | 19 | 4. sign act.exe 20 | 21 | 6. Merge release branch into master (squash) 22 | 23 | 7. Create github release 24 | 25 | 8. Merge Release branch into develop (rebase or merge) 26 | 27 | 9. Update paths and version in all documents on develop branch 28 | 29 | 30 | 31 | __Notes__: 32 | 33 | verpatch.exe is an _amazing_ tool to change resource information in EXEs and DLLs 34 | 35 | https://github.com/pavel-a/ddverpatch/releases 36 | 37 | Call like this 38 | ``` 39 | verpatch.exe ..\act.exe /high /va 1.5.0 /pv "1.5.0-RC1+buildnumber-5" /s copyright "(c) 2018-2019 ACT Developers" /s desc "ACT is a code generator for software components" /s productName "Automatic Component Toolkit" 40 | ``` -------------------------------------------------------------------------------- /Build/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set startingDir="%CD%" 3 | set basepath="%~dp0" 4 | 5 | cd %basepath%\..\Source 6 | set Sources=actutils.go automaticcomponenttoolkit.go buildbindingccpp.go buildbindingcsharp.go buildbindinggo.go buildbindingnode.go buildbindingpascal.go buildbindingpython.go buildimplementationcpp.go buildimplementationpascal.go componentdefinition.go componentdiff.go languagewriter.go languagec.go languagecpp.go languagepascal.go 7 | set GOARCH=amd64 8 | 9 | set GOOS=windows 10 | echo "Build act.exe" 11 | go build -o ..\act.exe %Sources% 12 | 13 | echo "Patching properties of act.exe" 14 | ..\build\verpatch ..\act.exe /high /va 1.6.0 /pv "1.6.0" /s copyright "(c) 2018-2019 ACT Developers" /s desc "ACT is a code generator for software components" /s productName "Automatic Component Toolkit" 15 | 16 | set GOOS=linux 17 | echo "Build act.linux" 18 | go build -o ..\act.linux %Sources% 19 | 20 | set GOOS=darwin 21 | echo "Build act.darwin" 22 | go build -o ..\act.darwin %Sources% 23 | 24 | cd %startingDir% 25 | -------------------------------------------------------------------------------- /Build/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | startingpath="$(pwd)" 4 | basepath="$(cd "$(dirname "$0")" && pwd)" 5 | cd "$basepath/../Source" 6 | 7 | Sources="actutils.go automaticcomponenttoolkit.go buildbindingccpp.go buildbindingcsharp.go buildbindinggo.go buildbindingnode.go buildbindingpascal.go buildbindingpython.go buildimplementationcpp.go buildimplementationpascal.go componentdefinition.go componentdiff.go languagewriter.go languagec.go languagecpp.go languagepascal.go" 8 | GOARCH="amd64" 9 | 10 | echo "Build act.exe" 11 | GOOS="windows" 12 | go build -o ../act.exe $Sources 13 | 14 | echo "Build act.linux" 15 | GOOS="linux" 16 | go build -o ../act.linux $Sources 17 | 18 | echo "Build act.darwin" 19 | GOOS="darwin" 20 | go build -o ../act.darwin $Sources 21 | 22 | cd "$startingpath" 23 | -------------------------------------------------------------------------------- /Build/verpatch.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Build/verpatch.exe -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributor's Guide 2 | The Automatic Component Toolkit is an open source project. 3 | 4 | Contributions are welcome and we are looking for people that can improve existing language bindings or create new bindings or implementation stubs. 5 | 6 | You can also contribute by reporting bugs in the [Issue tracker](../../issues), helping review pull requests, participate in discussions about issues and more. 7 | 8 | ## Filing issues 9 | 1. When filing an [issue](../../issues) to report errors or problems, make sure to answer these five questions: 10 | 1. Which version of ACT are you using? 11 | Run
`act.* -v`
to print ACT's version. 12 | 2. Which operating system, programming language(s) and development tools (compiler/interpreter) are you using? 13 | 3. What did you do? 14 | 4. What did you expect to see? 15 | 5. What did you see instead? 16 | 17 | 2. When contributing to this repository, please first discuss the change you wish to make via issue with the [maintainers](#maintainers) of this repository. This way, we can ensure that there is no overlap between contributions or internal development work. 18 | 19 | 3. Adhere to the [code of conduct](CODE_OF_CONDUCT.md). 20 | 21 | ## Submitting a pull request 22 | When ready to contribute, fork this repository and submit a pull request that references the issue it resolves. Be sure to include a clear and detailed description of the changes you've made so that we can verify them and eventually merge. 23 | 24 | ACT follows the [git-flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) branching model. New developments are integrated into the [develop](../../tree/develop)-branch. ACT's maintainers will create releases from the develop-branch when appropriate. 25 | 26 | __NOTE__ _Before your code can be accepted into the project you must also sign the Contributor License Agreement (CLA). Please contact the maintainers via automatic-component-toolkit.contributor.agreements@autodesk.com for a copy of the CLA._ 27 | 28 | 29 | ## Maintainers 30 | Maintainers are responsible for responding to pull requests and issues, as well as guiding the direction of the project. 31 | 32 | We currently have two maintainers: 33 | - Alexander Oster alexander.oster@autodesk.com 34 | - Martin Weismann martin.weismann@autodesk.com 35 | 36 | If you've established yourself as an impactful contributor to the project, and are willing take on the extra work, we'd love to have your help maintaining it! Email the current maintainers for details. 37 | -------------------------------------------------------------------------------- /Documentation/images/ACT_logo_50px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/ACT_logo_50px.png -------------------------------------------------------------------------------- /Documentation/images/O.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/O.png -------------------------------------------------------------------------------- /Documentation/images/O32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/O32.png -------------------------------------------------------------------------------- /Documentation/images/Tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/Tick.png -------------------------------------------------------------------------------- /Documentation/images/Tick32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/Tick32.png -------------------------------------------------------------------------------- /Documentation/images/X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/X.png -------------------------------------------------------------------------------- /Documentation/images/X32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/X32.png -------------------------------------------------------------------------------- /Documentation/images/element_binding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_binding.png -------------------------------------------------------------------------------- /Documentation/images/element_bindings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_bindings.png -------------------------------------------------------------------------------- /Documentation/images/element_class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_class.png -------------------------------------------------------------------------------- /Documentation/images/element_component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_component.png -------------------------------------------------------------------------------- /Documentation/images/element_enum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_enum.png -------------------------------------------------------------------------------- /Documentation/images/element_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_error.png -------------------------------------------------------------------------------- /Documentation/images/element_errors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_errors.png -------------------------------------------------------------------------------- /Documentation/images/element_functiontype.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_functiontype.png -------------------------------------------------------------------------------- /Documentation/images/element_global.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_global.png -------------------------------------------------------------------------------- /Documentation/images/element_implementation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_implementation.png -------------------------------------------------------------------------------- /Documentation/images/element_implementations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_implementations.png -------------------------------------------------------------------------------- /Documentation/images/element_importcomponent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_importcomponent.png -------------------------------------------------------------------------------- /Documentation/images/element_license.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_license.png -------------------------------------------------------------------------------- /Documentation/images/element_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_line.png -------------------------------------------------------------------------------- /Documentation/images/element_member.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_member.png -------------------------------------------------------------------------------- /Documentation/images/element_method.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_method.png -------------------------------------------------------------------------------- /Documentation/images/element_option.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_option.png -------------------------------------------------------------------------------- /Documentation/images/element_param.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_param.png -------------------------------------------------------------------------------- /Documentation/images/element_struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/element_struct.png -------------------------------------------------------------------------------- /Documentation/images/type_export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/type_export.png -------------------------------------------------------------------------------- /Documentation/images/type_functiontype.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Documentation/images/type_functiontype.png -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Examples/CppDynamic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMake Project that demonstrates the 10 | usage of the Dynamic C++ bindings of Calculator library 11 | 12 | Interface version: 1.0.0 13 | 14 | 15 | ]] 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | set(CMAKE_CURRENT_BINDING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Bindings/CppDynamic) 20 | project(CalculatorExample_CPPDynamic) 21 | set(CMAKE_CXX_STANDARD 11) 22 | add_executable(CalculatorExample_CPPDynamic "${CMAKE_CURRENT_SOURCE_DIR}/Calculator_example.cpp") 23 | if (UNIX) 24 | target_link_libraries(CalculatorExample_CPPDynamic ${CMAKE_DL_LIBS}) 25 | endif (UNIX) 26 | target_include_directories(CalculatorExample_CPPDynamic PRIVATE "${CMAKE_CURRENT_BINDING_DIR}") 27 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Examples/CppDynamic/Calculator_example.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ application that demonstrates the 10 | usage of the Dynamic C++ bindings of Calculator library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include 17 | #include "calculator_dynamic.hpp" 18 | 19 | 20 | int main() 21 | { 22 | try 23 | { 24 | std::string libpath = (""); // TODO: put the location of the Calculator-library file here. 25 | auto wrapper = Calculator::CWrapper::loadLibrary(libpath + "/calculator."); // TODO: add correct suffix of the library 26 | Calculator_uint32 nMajor, nMinor, nMicro; 27 | wrapper->GetVersion(nMajor, nMinor, nMicro); 28 | std::cout << "Calculator.Version = " << nMajor << "." << nMinor << "." << nMicro; 29 | std::cout << std::endl; 30 | 31 | auto calculator = wrapper->CreateCalculator(); 32 | { 33 | auto v1 = wrapper->CreateVariable(2); 34 | calculator->EnlistVariable(v1.get()); 35 | 36 | auto v2 = wrapper->CreateVariable(3); 37 | calculator->EnlistVariable(v2.get()); 38 | 39 | // The application releases ownership of v1 and v2, 40 | // the calculator, however, still holds these instances. 41 | } 42 | 43 | std::cout << " sum = " << calculator->Add()->GetValue() << std::endl; 44 | { 45 | auto v1Again = calculator->GetEnlistedVariable(0); 46 | std::cout << "Changing the value of the first summand" << std::endl; 47 | v1Again->SetValue(10); 48 | std::cout << "newSum = " << calculator->Add()->GetValue() << std::endl; 49 | } 50 | 51 | } 52 | catch (std::exception &e) 53 | { 54 | std::cout << e.what() << std::endl; 55 | return 1; 56 | } 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Examples/Python/Calculator_Example.py: -------------------------------------------------------------------------------- 1 | '''++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Python application that demonstrates the 10 | usage of the Python bindings of Calculator library 11 | 12 | Interface version: 1.0.0 13 | 14 | ''' 15 | 16 | 17 | import os 18 | import sys 19 | sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "Bindings", "Python")) 20 | import Calculator 21 | 22 | 23 | def main(): 24 | libpath = '' # TODO add the location of the shared library binary here 25 | wrapper = Calculator.Wrapper(os.path.join(libpath, "calculator")) 26 | 27 | major, minor, micro = wrapper.GetVersion() 28 | print("Calculator version: {:d}.{:d}.{:d}".format(major, minor, micro), end="") 29 | print("") 30 | 31 | calculator = wrapper.CreateCalculator() 32 | 33 | calculator.EnlistVariable(wrapper.CreateVariable(2.0)) 34 | calculator.EnlistVariable(wrapper.CreateVariable(3.0)) 35 | 36 | print(" sum = " + str(calculator.Add().GetValue())) 37 | print("Changing the value of the first summand") 38 | calculator.GetEnlistedVariable(0).SetValue(10) 39 | print("newSum = " + str(calculator.Add().GetValue())) 40 | 41 | if __name__ == "__main__": 42 | try: 43 | main() 44 | except Calculator.ECalculatorException as e: 45 | print(e) 46 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Interfaces/calculator_interfaceexception.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ Implementation file with the basic internal 10 | exception type in order to allow an easy use of Calculator library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | 17 | #include 18 | 19 | #include "calculator_interfaceexception.hpp" 20 | 21 | /************************************************************************************************************************* 22 | Class ECalculatorInterfaceException 23 | **************************************************************************************************************************/ 24 | ECalculatorInterfaceException::ECalculatorInterfaceException(CalculatorResult errorCode) 25 | : m_errorMessage("Calculator Error " + std::to_string (errorCode)) 26 | { 27 | m_errorCode = errorCode; 28 | } 29 | 30 | ECalculatorInterfaceException::ECalculatorInterfaceException(CalculatorResult errorCode, std::string errorMessage) 31 | : m_errorMessage(errorMessage + " (" + std::to_string (errorCode) + ")") 32 | { 33 | m_errorCode = errorCode; 34 | } 35 | 36 | CalculatorResult ECalculatorInterfaceException::getErrorCode () 37 | { 38 | return m_errorCode; 39 | } 40 | 41 | const char * ECalculatorInterfaceException::what () const noexcept 42 | { 43 | return m_errorMessage.c_str(); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Interfaces/calculator_interfaceexception.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ Header file with the basic internal 10 | exception type in order to allow an easy use of Calculator library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #ifndef __CALCULATOR_INTERFACEEXCEPTION_HEADER 17 | #define __CALCULATOR_INTERFACEEXCEPTION_HEADER 18 | 19 | #include 20 | #include 21 | #include "calculator_types.hpp" 22 | 23 | /************************************************************************************************************************* 24 | Class ECalculatorInterfaceException 25 | **************************************************************************************************************************/ 26 | 27 | 28 | class ECalculatorInterfaceException : public std::exception { 29 | protected: 30 | /** 31 | * Error code for the Exception. 32 | */ 33 | CalculatorResult m_errorCode; 34 | /** 35 | * Error message for the Exception. 36 | */ 37 | std::string m_errorMessage; 38 | 39 | public: 40 | /** 41 | * Exception Constructor. 42 | */ 43 | ECalculatorInterfaceException(CalculatorResult errorCode); 44 | 45 | /** 46 | * Custom Exception Constructor. 47 | */ 48 | ECalculatorInterfaceException(CalculatorResult errorCode, std::string errorMessage); 49 | 50 | /** 51 | * Returns error code 52 | */ 53 | CalculatorResult getErrorCode(); 54 | /** 55 | * Returns error message 56 | */ 57 | const char* what() const noexcept override; 58 | }; 59 | 60 | #endif // __CALCULATOR_INTERFACEEXCEPTION_HEADER 61 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Stub/calculator.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ implementation file in order to allow easy 10 | development of Calculator library. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include "calculator_abi.hpp" 17 | #include "calculator_interfaces.hpp" 18 | #include "calculator_interfaceexception.hpp" 19 | 20 | #include "calculator_calculator.hpp" 21 | #include "calculator_variable.hpp" 22 | 23 | using namespace Calculator; 24 | using namespace Calculator::Impl; 25 | 26 | void CWrapper::GetVersion(Calculator_uint32 & nMajor, Calculator_uint32 & nMinor, Calculator_uint32 & nMicro) 27 | { 28 | nMajor = CALCULATOR_VERSION_MAJOR; 29 | nMinor = CALCULATOR_VERSION_MINOR; 30 | nMicro = CALCULATOR_VERSION_MICRO; 31 | } 32 | 33 | bool CWrapper::GetLastError(IBase* pInstance, std::string & sErrorMessage) 34 | { 35 | return pInstance->GetLastErrorMessage(sErrorMessage); 36 | } 37 | 38 | void CWrapper::ReleaseInstance(IBase* pInstance) 39 | { 40 | IBase::ReleaseBaseClassInterface(pInstance); 41 | } 42 | 43 | void CWrapper::AcquireInstance(IBase* pInstance) 44 | { 45 | IBase::AcquireBaseClassInterface(pInstance); 46 | } 47 | 48 | IVariable * CWrapper::CreateVariable(const Calculator_double dInitialValue) 49 | { 50 | return new CVariable(dInitialValue); 51 | } 52 | 53 | ICalculator * CWrapper::CreateCalculator() 54 | { 55 | return new CCalculator(); 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Stub/calculator_base.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CBase 8 | 9 | */ 10 | 11 | #include "calculator_base.hpp" 12 | #include "calculator_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace Calculator::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CBase 21 | **************************************************************************************************************************/ 22 | 23 | bool CBase::GetLastErrorMessage(std::string & sErrorMessage) 24 | { 25 | if (m_pErrors && !m_pErrors->empty()) { 26 | sErrorMessage = m_pErrors->back(); 27 | return true; 28 | } else { 29 | sErrorMessage = ""; 30 | return false; 31 | } 32 | } 33 | 34 | void CBase::ClearErrorMessages() 35 | { 36 | m_pErrors.reset(); 37 | } 38 | 39 | void CBase::RegisterErrorMessage(const std::string & sErrorMessage) 40 | { 41 | if (!m_pErrors) { 42 | m_pErrors.reset(new std::list()); 43 | } 44 | m_pErrors->clear(); 45 | m_pErrors->push_back(sErrorMessage); 46 | } 47 | 48 | void CBase::IncRefCount() 49 | { 50 | ++m_nReferenceCount; 51 | } 52 | 53 | bool CBase::DecRefCount() 54 | { 55 | m_nReferenceCount--; 56 | if (!m_nReferenceCount) {; 57 | delete this; 58 | return true; 59 | } 60 | return false; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Stub/calculator_base.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CBase 8 | 9 | */ 10 | 11 | 12 | #ifndef __CALCULATOR_BASE 13 | #define __CALCULATOR_BASE 14 | 15 | #include "calculator_interfaces.hpp" 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // Include custom headers here. 22 | 23 | 24 | namespace Calculator { 25 | namespace Impl { 26 | 27 | 28 | /************************************************************************************************************************* 29 | Class declaration of CBase 30 | **************************************************************************************************************************/ 31 | 32 | class CBase : public virtual IBase { 33 | private: 34 | 35 | std::unique_ptr> m_pErrors; 36 | Calculator_uint32 m_nReferenceCount = 1; 37 | 38 | /** 39 | * Put private members here. 40 | */ 41 | 42 | protected: 43 | 44 | /** 45 | * Put protected members here. 46 | */ 47 | 48 | public: 49 | 50 | /** 51 | * Put additional public members here. They will not be visible in the external API. 52 | */ 53 | 54 | bool GetLastErrorMessage(std::string & sErrorMessage); 55 | 56 | void ClearErrorMessages(); 57 | 58 | void RegisterErrorMessage(const std::string & sErrorMessage); 59 | 60 | void IncRefCount(); 61 | 62 | bool DecRefCount(); 63 | 64 | 65 | /** 66 | * Public member functions to implement. 67 | */ 68 | 69 | }; 70 | 71 | } // namespace Impl 72 | } // namespace Calculator 73 | 74 | #endif // __CALCULATOR_BASE 75 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Stub/calculator_calculator.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CCalculator 8 | 9 | */ 10 | 11 | #include "calculator_calculator.hpp" 12 | #include "calculator_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | #include "calculator_variable.hpp" 16 | 17 | using namespace Calculator::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CCalculator 21 | **************************************************************************************************************************/ 22 | 23 | void CCalculator::EnlistVariable(IVariable* pVariable) 24 | { 25 | m_pVariables.push_back(PIVariable(pVariable)); 26 | } 27 | 28 | IVariable * CCalculator::GetEnlistedVariable(const Calculator_uint32 nIndex) 29 | { 30 | if (nIndex < m_pVariables.size()) { 31 | return m_pVariables[nIndex].getCoOwningPtr(); 32 | } 33 | else { 34 | throw ECalculatorInterfaceException(CALCULATOR_ERROR_INVALIDPARAM, "Invalid Index"); 35 | } 36 | } 37 | 38 | void CCalculator::ClearVariables() 39 | { 40 | m_pVariables.clear(); 41 | } 42 | 43 | IVariable * CCalculator::Multiply() 44 | { 45 | Calculator_double dValue = 1.0; 46 | for (const PIVariable & pVariable : m_pVariables) { 47 | dValue *= pVariable->GetValue(); 48 | } 49 | return new CVariable(dValue); 50 | } 51 | 52 | IVariable * CCalculator::Add() 53 | { 54 | Calculator_double dValue = 0.0; 55 | for (const PIVariable & pVariable : m_pVariables) { 56 | dValue += pVariable->GetValue(); 57 | } 58 | return new CVariable(dValue); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Stub/calculator_calculator.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CCalculator 8 | 9 | */ 10 | 11 | 12 | #ifndef __CALCULATOR_CALCULATOR 13 | #define __CALCULATOR_CALCULATOR 14 | 15 | #include "calculator_interfaces.hpp" 16 | 17 | // Parent classes 18 | #include "calculator_base.hpp" 19 | #ifdef _MSC_VER 20 | #pragma warning(push) 21 | #pragma warning(disable : 4250) 22 | #endif 23 | 24 | // Include custom headers here. 25 | 26 | #include 27 | 28 | namespace Calculator { 29 | namespace Impl { 30 | 31 | 32 | /************************************************************************************************************************* 33 | Class declaration of CCalculator 34 | **************************************************************************************************************************/ 35 | 36 | class CCalculator : public virtual ICalculator, public virtual CBase { 37 | private: 38 | 39 | /** 40 | * Put private members here. 41 | */ 42 | 43 | std::vector m_pVariables; 44 | 45 | protected: 46 | 47 | /** 48 | * Put protected members here. 49 | */ 50 | 51 | public: 52 | 53 | /** 54 | * Put additional public members here. They will not be visible in the external API. 55 | */ 56 | 57 | 58 | /** 59 | * Public member functions to implement. 60 | */ 61 | 62 | void EnlistVariable(IVariable* pVariable); 63 | 64 | IVariable * GetEnlistedVariable(const Calculator_uint32 nIndex); 65 | 66 | void ClearVariables(); 67 | 68 | IVariable * Multiply(); 69 | 70 | IVariable * Add(); 71 | 72 | }; 73 | 74 | } // namespace Impl 75 | } // namespace Calculator 76 | 77 | #ifdef _MSC_VER 78 | #pragma warning(pop) 79 | #endif 80 | #endif // __CALCULATOR_CALCULATOR 81 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Stub/calculator_variable.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CVariable 8 | 9 | */ 10 | 11 | #include "calculator_variable.hpp" 12 | #include "calculator_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace Calculator::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CVariable 21 | **************************************************************************************************************************/ 22 | 23 | CVariable::CVariable(Calculator_double dValue) 24 | : m_dValue(dValue) 25 | { 26 | 27 | } 28 | 29 | Calculator_double CVariable::GetValue() 30 | { 31 | return m_dValue; 32 | } 33 | 34 | void CVariable::SetValue(const Calculator_double dValue) 35 | { 36 | m_dValue = dValue; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Cpp/Stub/calculator_variable.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CVariable 8 | 9 | */ 10 | 11 | 12 | #ifndef __CALCULATOR_VARIABLE 13 | #define __CALCULATOR_VARIABLE 14 | 15 | #include "calculator_interfaces.hpp" 16 | 17 | // Parent classes 18 | #include "calculator_base.hpp" 19 | #ifdef _MSC_VER 20 | #pragma warning(push) 21 | #pragma warning(disable : 4250) 22 | #endif 23 | 24 | // Include custom headers here. 25 | 26 | 27 | namespace Calculator { 28 | namespace Impl { 29 | 30 | 31 | /************************************************************************************************************************* 32 | Class declaration of CVariable 33 | **************************************************************************************************************************/ 34 | 35 | class CVariable : public virtual IVariable, public virtual CBase { 36 | private: 37 | 38 | Calculator_double m_dValue; 39 | 40 | /** 41 | * Put private members here. 42 | */ 43 | 44 | protected: 45 | 46 | /** 47 | * Put protected members here. 48 | */ 49 | 50 | public: 51 | 52 | /** 53 | * Put additional public members here. They will not be visible in the external API. 54 | */ 55 | CVariable(Calculator_double); 56 | 57 | /** 58 | * Public member functions to implement. 59 | */ 60 | 61 | Calculator_double GetValue(); 62 | 63 | void SetValue(const Calculator_double dValue); 64 | 65 | }; 66 | 67 | } // namespace Impl 68 | } // namespace Calculator 69 | 70 | #ifdef _MSC_VER 71 | #pragma warning(pop) 72 | #endif 73 | #endif // __CALCULATOR_VARIABLE 74 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Pascal/Interfaces/calculator.lpr: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal project file in order to allow easy 10 | development of Calculator library. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | library calculator; 18 | 19 | uses 20 | {$IFDEF UNIX} 21 | cthreads, 22 | {$ENDIF UNIX} 23 | syncobjs, 24 | calculator_types, 25 | calculator_exports, 26 | Classes, 27 | sysutils; 28 | 29 | exports 30 | calculator_variable_getvalue, 31 | calculator_variable_setvalue, 32 | calculator_calculator_enlistvariable, 33 | calculator_calculator_getenlistedvariable, 34 | calculator_calculator_clearvariables, 35 | calculator_calculator_multiply, 36 | calculator_calculator_add, 37 | calculator_getversion, 38 | calculator_getlasterror, 39 | calculator_releaseinstance, 40 | calculator_acquireinstance, 41 | calculator_createvariable, 42 | calculator_createcalculator; 43 | 44 | begin 45 | 46 | end. 47 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Pascal/Interfaces/calculator_interfaces.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal interface definition file in order to allow easy 10 | development of Calculator library. The functions in this file need to be implemented. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | {$INTERFACES CORBA} 18 | unit calculator_interfaces; 19 | 20 | interface 21 | 22 | uses 23 | calculator_types, 24 | Classes, 25 | sysutils; 26 | 27 | 28 | type 29 | 30 | (************************************************************************************************************************* 31 | Interface definition for Base 32 | **************************************************************************************************************************) 33 | 34 | ICalculatorBase = interface 35 | ['{52FDFC07-2182-454F-963F-5F0F9A621D72}'] 36 | 37 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 38 | procedure ClearErrorMessages(); 39 | procedure RegisterErrorMessage(const AErrorMessage: String); 40 | procedure IncRefCount(); 41 | function DecRefCount(): Boolean; 42 | end; 43 | 44 | 45 | (************************************************************************************************************************* 46 | Interface definition for Variable 47 | **************************************************************************************************************************) 48 | 49 | ICalculatorVariable = interface(ICalculatorBase) 50 | ['{9566C74D-1003-4C4D-BBBB-0407D1E2C649}'] 51 | 52 | function GetValue(): Double; 53 | procedure SetValue(const AValue: Double); 54 | end; 55 | 56 | 57 | (************************************************************************************************************************* 58 | Interface definition for Calculator 59 | **************************************************************************************************************************) 60 | 61 | ICalculatorCalculator = interface(ICalculatorBase) 62 | ['{81855AD8-681D-4D86-91E9-1E00167939CB}'] 63 | 64 | procedure EnlistVariable(AVariable: TObject); 65 | function GetEnlistedVariable(const AIndex: Cardinal): TObject; 66 | procedure ClearVariables(); 67 | function Multiply(): TObject; 68 | function Add(): TObject; 69 | end; 70 | 71 | implementation 72 | 73 | end. 74 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Pascal/Interfaces/calculator_types.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal type definition file in order to allow easy 10 | development of Calculator library. The functions in this file need to be implemented. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | unit calculator_types; 18 | 19 | interface 20 | 21 | uses 22 | Classes, 23 | sysutils; 24 | 25 | (************************************************************************************************************************* 26 | Version definition for Calculator 27 | **************************************************************************************************************************) 28 | 29 | const 30 | CALCULATOR_VERSION_MAJOR = 1; 31 | CALCULATOR_VERSION_MINOR = 0; 32 | CALCULATOR_VERSION_MICRO = 0; 33 | CALCULATOR_VERSION_PRERELEASEINFO = ''; 34 | CALCULATOR_VERSION_BUILDINFO = ''; 35 | 36 | 37 | (************************************************************************************************************************* 38 | General type definitions 39 | **************************************************************************************************************************) 40 | 41 | type 42 | TCalculatorResult = Cardinal; 43 | TCalculatorHandle = Pointer; 44 | 45 | PCalculatorResult = ^TCalculatorResult; 46 | PCalculatorHandle = ^TCalculatorHandle; 47 | 48 | (************************************************************************************************************************* 49 | Error Constants for Calculator 50 | **************************************************************************************************************************) 51 | 52 | const 53 | CALCULATOR_SUCCESS = 0; 54 | CALCULATOR_ERROR_NOTIMPLEMENTED = 1; 55 | CALCULATOR_ERROR_INVALIDPARAM = 2; 56 | CALCULATOR_ERROR_INVALIDCAST = 3; 57 | CALCULATOR_ERROR_BUFFERTOOSMALL = 4; 58 | CALCULATOR_ERROR_GENERICEXCEPTION = 5; 59 | CALCULATOR_ERROR_COULDNOTLOADLIBRARY = 6; 60 | CALCULATOR_ERROR_COULDNOTFINDLIBRARYEXPORT = 7; 61 | CALCULATOR_ERROR_INCOMPATIBLEBINARYVERSION = 8; 62 | 63 | 64 | implementation 65 | 66 | end. 67 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Pascal/Stub/calculator_impl.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal implementation file in order to allow easy 10 | development of Calculator library. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | Unit calculator_impl; 18 | 19 | interface 20 | 21 | uses 22 | calculator_types, 23 | calculator_exception, 24 | calculator_interfaces, 25 | calculator_impl_variable, 26 | calculator_impl_calculator, 27 | Classes, 28 | sysutils; 29 | 30 | type 31 | TCalculatorWrapper = class (TObject) 32 | public 33 | class procedure GetVersion(out AMajor: Cardinal; out AMinor: Cardinal; out AMicro: Cardinal); 34 | class function GetLastError(AInstance: TObject; out AErrorMessage: String): Boolean; 35 | class procedure ReleaseInstance(AInstance: TObject); 36 | class procedure AcquireInstance(AInstance: TObject); 37 | class function CreateVariable(const AInitialValue: Double): TObject; 38 | class function CreateCalculator(): TObject; 39 | end; 40 | 41 | 42 | implementation 43 | 44 | class procedure TCalculatorWrapper.GetVersion(out AMajor: Cardinal; out AMinor: Cardinal; out AMicro: Cardinal); 45 | begin 46 | AMajor := CALCULATOR_VERSION_MAJOR; 47 | AMinor := CALCULATOR_VERSION_MINOR; 48 | AMicro := CALCULATOR_VERSION_MICRO; 49 | end; 50 | 51 | class function TCalculatorWrapper.GetLastError(AInstance: TObject; out AErrorMessage: String): Boolean; 52 | begin 53 | result := (AInstance as ICalculatorBase).GetLastErrorMessage(AErrorMessage); 54 | end; 55 | 56 | class procedure TCalculatorWrapper.ReleaseInstance(AInstance: TObject); 57 | begin 58 | (AInstance as ICalculatorBase).DecRefCount(); 59 | end; 60 | 61 | class procedure TCalculatorWrapper.AcquireInstance(AInstance: TObject); 62 | begin 63 | (AInstance as ICalculatorBase).IncRefCount(); 64 | end; 65 | 66 | class function TCalculatorWrapper.CreateVariable(const AInitialValue: Double): TObject; 67 | begin 68 | result := TCalculatorVariable.Create(); 69 | (result as TCalculatorVariable).SetValue(AInitialValue); 70 | end; 71 | 72 | class function TCalculatorWrapper.CreateCalculator(): TObject; 73 | begin 74 | result := TCalculatorCalculator.Create(); 75 | end; 76 | 77 | 78 | end. 79 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Pascal/Stub/calculator_impl_base.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TCalculatorBase 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit calculator_impl_base; 13 | 14 | interface 15 | 16 | uses 17 | calculator_types, 18 | calculator_interfaces, 19 | calculator_exception, 20 | Classes, 21 | sysutils; 22 | 23 | type 24 | TCalculatorBase = class(TObject, ICalculatorBase) 25 | private 26 | FMessages: TStringList; 27 | FReferenceCount: integer; 28 | 29 | protected 30 | 31 | public 32 | constructor Create(); 33 | destructor Destroy(); override; 34 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 35 | procedure ClearErrorMessages(); 36 | procedure RegisterErrorMessage(const AErrorMessage: String); 37 | procedure IncRefCount(); 38 | function DecRefCount(): Boolean; 39 | end; 40 | 41 | implementation 42 | 43 | constructor TCalculatorBase.Create(); 44 | begin 45 | inherited Create(); 46 | FMessages := TStringList.Create(); 47 | FReferenceCount := 1; 48 | end; 49 | 50 | destructor TCalculatorBase.Destroy(); 51 | begin 52 | FreeAndNil(FMessages); 53 | inherited Destroy(); 54 | end; 55 | 56 | function TCalculatorBase.GetLastErrorMessage(out AErrorMessage: String): Boolean; 57 | begin 58 | result := (FMessages.Count>0); 59 | if (result) then 60 | AErrorMessage := FMessages[FMessages.Count-1]; 61 | end; 62 | 63 | procedure TCalculatorBase.ClearErrorMessages(); 64 | begin 65 | FMessages.Clear(); 66 | end; 67 | 68 | procedure TCalculatorBase.RegisterErrorMessage(const AErrorMessage: String); 69 | begin 70 | FMessages.Clear(); 71 | FMessages.Add(AErrorMessage); 72 | end; 73 | 74 | procedure TCalculatorBase.IncRefCount(); 75 | begin 76 | inc(FReferenceCount); 77 | end; 78 | 79 | function TCalculatorBase.DecRefCount(): Boolean; 80 | begin 81 | dec(FReferenceCount); 82 | if (FReferenceCount = 0) then begin 83 | result := true; 84 | self.Destroy(); 85 | end; 86 | result := false; 87 | end; 88 | 89 | end. 90 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Pascal/Stub/calculator_impl_variable.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculator developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TCalculatorVariable 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit calculator_impl_variable; 13 | 14 | interface 15 | 16 | uses 17 | calculator_types, 18 | calculator_interfaces, 19 | calculator_exception, 20 | calculator_impl_base, 21 | Classes, 22 | sysutils; 23 | 24 | type 25 | TCalculatorVariable = class(TCalculatorBase, ICalculatorVariable) 26 | private 27 | FValue : double; 28 | protected 29 | 30 | public 31 | function GetValue(): Double; 32 | procedure SetValue(const AValue: Double); 33 | end; 34 | 35 | implementation 36 | 37 | function TCalculatorVariable.GetValue(): Double; 38 | begin 39 | result := FValue; 40 | end; 41 | 42 | procedure TCalculatorVariable.SetValue(const AValue: Double); 43 | begin 44 | FValue := AValue; 45 | end; 46 | 47 | end. 48 | -------------------------------------------------------------------------------- /Examples/Calculator/Calculator_component/Implementations/Pascal/calculator.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | calculator_getversion 3 | calculator_getlasterror 4 | calculator_releaseinstance 5 | calculator_acquireinstance 6 | calculator_createvariable 7 | calculator_createcalculator 8 | calculator_variable_getvalue 9 | calculator_variable_setvalue 10 | calculator_calculator_enlistvariable 11 | calculator_calculator_getenlistedvariable 12 | calculator_calculator_clearvariables 13 | calculator_calculator_multiply 14 | calculator_calculator_add 15 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Examples/Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMake Project that demonstrates the 10 | usage of the C++ bindings of Calculation library 11 | 12 | Interface version: 1.0.0 13 | 14 | 15 | ]] 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | set(CMAKE_CURRENT_BINDING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Bindings/Cpp) 20 | project(CalculationExample_CPPImplicit) 21 | set(CMAKE_CXX_STANDARD 11) 22 | add_executable(CalculationExample_CPPImplicit "${CMAKE_CURRENT_SOURCE_DIR}/Calculation_example.cpp") 23 | if (UNIX) 24 | target_link_libraries(CalculationExample_CPPImplicit ${CMAKE_DL_LIBS}) 25 | endif (UNIX) 26 | find_library(CALCULATIONLOCATION NAMES calculation.dll calculation.so calculation.dylib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../Implementations/Cpp/build/") 27 | target_link_libraries(CalculationExample_CPPImplicit ${CALCULATIONLOCATION}) 28 | target_include_directories(CalculationExample_CPPImplicit PRIVATE "${CMAKE_CURRENT_BINDING_DIR}") 29 | target_include_directories(CalculationExample_CPPImplicit PRIVATE "${CMAKE_CURRENT_BINDING_DIR}/../../../Numbers_component/Bindings/CppDynamic") 30 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Examples/Cpp/Calculation_example.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ application that demonstrates the 10 | usage of the C++ bindings of Calculation library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include 17 | #include "calculation_implicit.hpp" 18 | 19 | 20 | int main() 21 | { 22 | try 23 | { 24 | auto wrapper = Calculation::CWrapper::loadLibrary(); 25 | Calculation_uint32 nMajor, nMinor, nMicro; 26 | wrapper->GetVersion(nMajor, nMinor, nMicro); 27 | std::cout << "Calculation.Version = " << nMajor << "." << nMinor << "." << nMicro; 28 | std::cout << std::endl; 29 | 30 | std::string libpath = ""; 31 | auto numbers = Numbers::CWrapper::loadLibrary(libpath + "/numbers."); 32 | numbers->GetVersion(nMajor, nMinor, nMicro); 33 | std::cout << "Numbers.Version = " << nMajor << "." << nMinor << "." << nMicro; 34 | std::cout << std::endl; 35 | 36 | wrapper->InjectComponent("Numbers", numbers->GetSymbolLookupMethod()); 37 | 38 | auto calculator = wrapper->CreateCalculator(); 39 | auto v1 = numbers->CreateVariable(10.0); 40 | calculator->EnlistVariable(v1.get()); 41 | 42 | calculator->EnlistVariable(numbers->CreateVariable(5.0).get()); 43 | 44 | Numbers::PVariable pSum = calculator->Add(); 45 | std::cout << " sum = " << pSum->GetValue() << std::endl; 46 | 47 | { 48 | auto v2New = calculator->GetEnlistedVariable(1); 49 | v2New->SetValue(15.0); 50 | } 51 | 52 | std::cout << "newSum = " << calculator->Add()->GetValue() << std::endl; 53 | } 54 | catch (std::exception &e) 55 | { 56 | std::cout << e.what() << std::endl; 57 | return 1; 58 | } 59 | return 0; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Examples/CppDynamic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMake Project that demonstrates the 10 | usage of the Dynamic C++ bindings of Calculation library 11 | 12 | Interface version: 1.0.0 13 | 14 | 15 | ]] 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | set(CMAKE_CURRENT_BINDING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Bindings/CppDynamic) 20 | project(CalculationExample_CPPDynamic) 21 | set(CMAKE_CXX_STANDARD 11) 22 | add_executable(CalculationExample_CPPDynamic "${CMAKE_CURRENT_SOURCE_DIR}/Calculation_example.cpp") 23 | if (UNIX) 24 | target_link_libraries(CalculationExample_CPPDynamic ${CMAKE_DL_LIBS}) 25 | endif (UNIX) 26 | target_include_directories(CalculationExample_CPPDynamic PRIVATE "${CMAKE_CURRENT_BINDING_DIR}") 27 | target_include_directories(CalculationExample_CPPDynamic PRIVATE "${CMAKE_CURRENT_BINDING_DIR}/../../../Numbers_component/Bindings/CppDynamic") 28 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Examples/CppDynamic/Calculation_example.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ application that demonstrates the 10 | usage of the Dynamic C++ bindings of Calculation library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include 17 | #include "calculation_dynamic.hpp" 18 | 19 | 20 | int main() 21 | { 22 | try 23 | { 24 | std::string libpath = ""; // TODO: put the location of the Calculation-library file here. 25 | auto wrapper = Calculation::CWrapper::loadLibrary(libpath + "/calculation."); // TODO: add correct suffix of the library 26 | 27 | libpath = ""; 28 | auto numbers = Numbers::CWrapper::loadLibrary(libpath + "/numbers."); 29 | 30 | Calculation_uint32 nMajor, nMinor, nMicro; 31 | wrapper->GetVersion(nMajor, nMinor, nMicro); 32 | std::cout << "Calculation.Version = " << nMajor << "." << nMinor << "." << nMicro; 33 | std::cout << std::endl; 34 | 35 | wrapper->InjectComponent("Numbers", numbers->GetSymbolLookupMethod()); 36 | 37 | 38 | auto calculator = wrapper->CreateCalculator(); 39 | auto v1 = numbers->CreateVariable(10.0); 40 | calculator->EnlistVariable(v1.get()); 41 | 42 | calculator->EnlistVariable(numbers->CreateVariable(5.0).get()); 43 | 44 | Numbers::PVariable pSum = calculator->Add(); 45 | std::cout << " sum = " << pSum->GetValue() << std::endl; 46 | 47 | { 48 | auto v2New = calculator->GetEnlistedVariable(1); 49 | v2New->SetValue(15.0); 50 | } 51 | 52 | std::cout << "newSum = " << calculator->Add()->GetValue() << std::endl; 53 | 54 | } 55 | catch (std::exception &e) 56 | { 57 | std::cout << e.what() << std::endl; 58 | return 1; 59 | } 60 | return 0; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Examples/Python/Calculation_Example.py: -------------------------------------------------------------------------------- 1 | '''++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Python application that demonstrates the 10 | usage of the Python bindings of Calculation library 11 | 12 | Interface version: 1.0.0 13 | 14 | ''' 15 | 16 | 17 | import os 18 | import sys 19 | sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "Bindings", "Python")) 20 | import Calculation 21 | 22 | 23 | def main(): 24 | libpath = '' # TODO add the location of the shared library binary here 25 | wrapper = Calculation.Wrapper(libraryName = os.path.join(libpath, "calculation")) 26 | 27 | major, minor, micro = wrapper.GetVersion() 28 | print("Calculation version: {:d}.{:d}.{:d}".format(major, minor, micro), end="") 29 | print("") 30 | 31 | libpath = '' # TODO add the location of the shared library binary here 32 | numbers = Calculation.Numbers.Wrapper(os.path.join(libpath, "numbers")) 33 | major, minor, micro = numbers.GetVersion() 34 | print("Numbers version: {:d}.{:d}.{:d}".format(major, minor, micro), end="") 35 | print("") 36 | 37 | wrapper.InjectComponent("Numbers", numbers.GetSymbolLookupMethod()) 38 | 39 | calculator = wrapper.CreateCalculator() 40 | calculator.EnlistVariable(numbers.CreateVariable(10.0)) 41 | calculator.EnlistVariable(numbers.CreateVariable(5.0)) 42 | print(" sum="+str(calculator.Add().GetValue())) 43 | calculator.GetEnlistedVariable(1).SetValue(15.0) 44 | print("newSum="+str(calculator.Add().GetValue())) 45 | 46 | if __name__ == "__main__": 47 | try: 48 | main() 49 | except Calculation.ECalculationException as e: 50 | print(e) 51 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMakeLists file for the development of Calculation library. 10 | 11 | Interface version: 1.0.0 12 | 13 | 14 | ]] 15 | 16 | cmake_minimum_required(VERSION 3.5) 17 | 18 | ### The implementation of the Calculation library component 19 | project(Calculation) 20 | 21 | set (CMAKE_CXX_STANDARD 11) 22 | 23 | # The location of autogenerated interfaces 24 | set(CMAKE_CURRENT_AUTOGENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces) 25 | 26 | file(GLOB CALCULATION_SRC 27 | ${CMAKE_CURRENT_SOURCE_DIR}/Stub/*.cpp 28 | ) 29 | file(GLOB CALCULATION_HDR 30 | ${CMAKE_CURRENT_SOURCE_DIR}/Stub/*.hpp 31 | ) 32 | set(CALCULATION_SRC ${CALCULATION_SRC} ${CALCULATION_SRC} 33 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/calculation_interfaceexception.cpp 34 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/calculation_interfacewrapper.cpp 35 | ) 36 | 37 | add_library(calculation SHARED ${CALCULATION_SRC}) 38 | # Do not prefix the binary's name with "lib" on Unix systems: 39 | set_target_properties(calculation PROPERTIES PREFIX "" IMPORT_PREFIX "" ) 40 | # The following two properties are crucial to reduce the number of undesirably exported symbols 41 | set_target_properties(calculation PROPERTIES CXX_VISIBILITY_PRESET hidden) 42 | set_target_properties(calculation PROPERTIES VISIBILITY_INLINES_HIDDEN ON) 43 | # This makes sure symbols are exported 44 | target_compile_options(calculation PRIVATE "-D__CALCULATION_EXPORTS") 45 | target_include_directories(calculation PRIVATE ${CMAKE_CURRENT_AUTOGENERATED_DIR}) 46 | target_include_directories(calculation PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Stub) 47 | target_include_directories(calculation PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../../Numbers_component/Bindings/CppDynamic") 48 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Cpp/Interfaces/calculation_interfaceexception.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ Implementation file with the basic internal 10 | exception type in order to allow an easy use of Calculation library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | 17 | #include 18 | 19 | #include "calculation_interfaceexception.hpp" 20 | 21 | /************************************************************************************************************************* 22 | Class ECalculationInterfaceException 23 | **************************************************************************************************************************/ 24 | ECalculationInterfaceException::ECalculationInterfaceException(CalculationResult errorCode) 25 | : m_errorMessage("Calculation Error " + std::to_string (errorCode)) 26 | { 27 | m_errorCode = errorCode; 28 | } 29 | 30 | ECalculationInterfaceException::ECalculationInterfaceException(CalculationResult errorCode, std::string errorMessage) 31 | : m_errorMessage(errorMessage + " (" + std::to_string (errorCode) + ")") 32 | { 33 | m_errorCode = errorCode; 34 | } 35 | 36 | CalculationResult ECalculationInterfaceException::getErrorCode () 37 | { 38 | return m_errorCode; 39 | } 40 | 41 | const char * ECalculationInterfaceException::what () const noexcept 42 | { 43 | return m_errorMessage.c_str(); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Cpp/Interfaces/calculation_interfaceexception.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ Header file with the basic internal 10 | exception type in order to allow an easy use of Calculation library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #ifndef __CALCULATION_INTERFACEEXCEPTION_HEADER 17 | #define __CALCULATION_INTERFACEEXCEPTION_HEADER 18 | 19 | #include 20 | #include 21 | #include "calculation_types.hpp" 22 | 23 | /************************************************************************************************************************* 24 | Class ECalculationInterfaceException 25 | **************************************************************************************************************************/ 26 | 27 | 28 | class ECalculationInterfaceException : public std::exception { 29 | protected: 30 | /** 31 | * Error code for the Exception. 32 | */ 33 | CalculationResult m_errorCode; 34 | /** 35 | * Error message for the Exception. 36 | */ 37 | std::string m_errorMessage; 38 | 39 | public: 40 | /** 41 | * Exception Constructor. 42 | */ 43 | ECalculationInterfaceException(CalculationResult errorCode); 44 | 45 | /** 46 | * Custom Exception Constructor. 47 | */ 48 | ECalculationInterfaceException(CalculationResult errorCode, std::string errorMessage); 49 | 50 | /** 51 | * Returns error code 52 | */ 53 | CalculationResult getErrorCode(); 54 | /** 55 | * Returns error message 56 | */ 57 | const char* what() const noexcept override; 58 | }; 59 | 60 | #endif // __CALCULATION_INTERFACEEXCEPTION_HEADER 61 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Cpp/Stub/calculation.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ implementation file in order to allow easy 10 | development of Calculation library. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include "calculation_abi.hpp" 17 | #include "calculation_interfaces.hpp" 18 | #include "calculation_interfaceexception.hpp" 19 | 20 | #include "calculation_calculator.hpp" 21 | 22 | using namespace Calculation; 23 | using namespace Calculation::Impl; 24 | 25 | // Injected Components 26 | Numbers::PWrapper CWrapper::sPNumbersWrapper; 27 | 28 | ICalculator * CWrapper::CreateCalculator() 29 | { 30 | return new CCalculator(); 31 | } 32 | 33 | void CWrapper::GetVersion(Calculation_uint32 & nMajor, Calculation_uint32 & nMinor, Calculation_uint32 & nMicro) 34 | { 35 | nMajor = CALCULATION_VERSION_MAJOR; 36 | nMinor = CALCULATION_VERSION_MINOR; 37 | nMicro = CALCULATION_VERSION_MICRO; 38 | } 39 | 40 | bool CWrapper::GetLastError(IBase* pInstance, std::string & sErrorMessage) 41 | { 42 | if (pInstance) { 43 | return pInstance->GetLastErrorMessage(sErrorMessage); 44 | } 45 | else { 46 | throw ECalculationInterfaceException(CALCULATION_ERROR_INVALIDPARAM); 47 | } 48 | } 49 | 50 | void CWrapper::ReleaseInstance(IBase* pInstance) 51 | { 52 | IBase::ReleaseBaseClassInterface(pInstance); 53 | } 54 | 55 | void CWrapper::AcquireInstance(IBase* pInstance) 56 | { 57 | IBase::AcquireBaseClassInterface(pInstance); 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Cpp/Stub/calculation_base.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CBase 8 | 9 | */ 10 | 11 | #include "calculation_base.hpp" 12 | #include "calculation_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace Calculation::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CBase 21 | **************************************************************************************************************************/ 22 | 23 | bool CBase::GetLastErrorMessage(std::string & sErrorMessage) 24 | { 25 | if (m_pErrors && !m_pErrors->empty()) { 26 | sErrorMessage = m_pErrors->back(); 27 | return true; 28 | } else { 29 | sErrorMessage = ""; 30 | return false; 31 | } 32 | } 33 | 34 | void CBase::ClearErrorMessages() 35 | { 36 | m_pErrors.reset(); 37 | } 38 | 39 | void CBase::RegisterErrorMessage(const std::string & sErrorMessage) 40 | { 41 | if (!m_pErrors) { 42 | m_pErrors.reset(new std::list()); 43 | } 44 | m_pErrors->clear(); 45 | m_pErrors->push_back(sErrorMessage); 46 | } 47 | 48 | void CBase::IncRefCount() 49 | { 50 | ++m_nReferenceCount; 51 | } 52 | 53 | bool CBase::DecRefCount() 54 | { 55 | m_nReferenceCount--; 56 | if (!m_nReferenceCount) {; 57 | delete this; 58 | return true; 59 | } 60 | return false; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Cpp/Stub/calculation_base.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CBase 8 | 9 | */ 10 | 11 | 12 | #ifndef __CALCULATION_BASE 13 | #define __CALCULATION_BASE 14 | 15 | #include "calculation_interfaces.hpp" 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // Include custom headers here. 22 | 23 | 24 | namespace Calculation { 25 | namespace Impl { 26 | 27 | 28 | /************************************************************************************************************************* 29 | Class declaration of CBase 30 | **************************************************************************************************************************/ 31 | 32 | class CBase : public virtual IBase { 33 | private: 34 | 35 | std::unique_ptr> m_pErrors; 36 | Calculation_uint32 m_nReferenceCount = 1; 37 | 38 | /** 39 | * Put private members here. 40 | */ 41 | 42 | protected: 43 | 44 | /** 45 | * Put protected members here. 46 | */ 47 | 48 | public: 49 | 50 | /** 51 | * Put additional public members here. They will not be visible in the external API. 52 | */ 53 | 54 | bool GetLastErrorMessage(std::string & sErrorMessage); 55 | 56 | void ClearErrorMessages(); 57 | 58 | void RegisterErrorMessage(const std::string & sErrorMessage); 59 | 60 | void IncRefCount(); 61 | 62 | bool DecRefCount(); 63 | 64 | 65 | /** 66 | * Public member functions to implement. 67 | */ 68 | 69 | }; 70 | 71 | } // namespace Impl 72 | } // namespace Calculation 73 | 74 | #endif // __CALCULATION_BASE 75 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Cpp/Stub/calculation_calculator.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CCalculator 8 | 9 | */ 10 | 11 | #include "calculation_calculator.hpp" 12 | #include "calculation_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace Calculation::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CCalculator 21 | **************************************************************************************************************************/ 22 | 23 | void CCalculator::EnlistVariable(Numbers::PVariable pVariable) 24 | { 25 | m_vVariables.push_back(pVariable); 26 | } 27 | 28 | Numbers::PVariable CCalculator::GetEnlistedVariable(const Calculation_uint32 nIndex) 29 | { 30 | return m_vVariables[nIndex]; 31 | } 32 | 33 | void CCalculator::ClearVariables() 34 | { 35 | m_vVariables.clear(); 36 | } 37 | 38 | Numbers::PVariable CCalculator::Multiply() 39 | { 40 | double sum = 1.0; 41 | for (auto& pVar : m_vVariables) { 42 | sum += pVar->GetValue(); 43 | } 44 | return CWrapper::sPNumbersWrapper->CreateVariable(sum); 45 | } 46 | 47 | Numbers::PVariable CCalculator::Add() 48 | { 49 | double sum = 0.; 50 | for (auto& pVar : m_vVariables) { 51 | sum += pVar->GetValue(); 52 | } 53 | return CWrapper::sPNumbersWrapper->CreateVariable(sum); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Cpp/Stub/calculation_calculator.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CCalculator 8 | 9 | */ 10 | 11 | 12 | #ifndef __CALCULATION_CALCULATOR 13 | #define __CALCULATION_CALCULATOR 14 | 15 | #include "calculation_interfaces.hpp" 16 | 17 | // Parent classes 18 | #include "calculation_base.hpp" 19 | #ifdef _MSC_VER 20 | #pragma warning(push) 21 | #pragma warning(disable : 4250) 22 | #endif 23 | 24 | // Include custom headers here. 25 | #include 26 | 27 | namespace Calculation { 28 | namespace Impl { 29 | 30 | 31 | /************************************************************************************************************************* 32 | Class declaration of CCalculator 33 | **************************************************************************************************************************/ 34 | 35 | class CCalculator : public virtual ICalculator, public virtual CBase { 36 | private: 37 | 38 | std::vector m_vVariables; 39 | /** 40 | * Put private members here. 41 | */ 42 | 43 | protected: 44 | 45 | /** 46 | * Put protected members here. 47 | */ 48 | 49 | public: 50 | 51 | /** 52 | * Put additional public members here. They will not be visible in the external API. 53 | */ 54 | 55 | 56 | /** 57 | * Public member functions to implement. 58 | */ 59 | 60 | void EnlistVariable(Numbers::PVariable pVariable); 61 | 62 | Numbers::PVariable GetEnlistedVariable(const Calculation_uint32 nIndex); 63 | 64 | void ClearVariables(); 65 | 66 | Numbers::PVariable Multiply(); 67 | 68 | Numbers::PVariable Add(); 69 | 70 | }; 71 | 72 | } // namespace Impl 73 | } // namespace Calculation 74 | 75 | #ifdef _MSC_VER 76 | #pragma warning(pop) 77 | #endif 78 | #endif // __CALCULATION_CALCULATOR 79 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Pascal/Interfaces/calculation.lpr: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal project file in order to allow easy 10 | development of Calculation library. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | library calculation; 18 | 19 | uses 20 | {$IFDEF UNIX} 21 | cthreads, 22 | {$ENDIF UNIX} 23 | syncobjs, 24 | calculation_types, 25 | calculation_exports, 26 | Classes, 27 | sysutils; 28 | 29 | exports 30 | calculation_calculator_enlistvariable, 31 | calculation_calculator_getenlistedvariable, 32 | calculation_calculator_clearvariables, 33 | calculation_calculator_multiply, 34 | calculation_calculator_add, 35 | calculation_createcalculator, 36 | calculation_getversion, 37 | calculation_getlasterror, 38 | calculation_releaseinstance, 39 | calculation_acquireinstance, 40 | calculation_injectcomponent, 41 | calculation_getsymbollookupmethod; 42 | 43 | begin 44 | 45 | end. 46 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Pascal/Interfaces/calculation_interfaces.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal interface definition file in order to allow easy 10 | development of Calculation library. The functions in this file need to be implemented. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | {$INTERFACES CORBA} 18 | unit calculation_interfaces; 19 | 20 | interface 21 | 22 | uses 23 | calculation_types, 24 | Unit_Numbers, 25 | Classes, 26 | sysutils; 27 | 28 | 29 | type 30 | 31 | (************************************************************************************************************************* 32 | Interface definition for Base 33 | **************************************************************************************************************************) 34 | 35 | ICalculationBase = interface 36 | ['{81855AD8-681D-4D86-91E9-1E00167939CB}'] 37 | 38 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 39 | procedure ClearErrorMessages(); 40 | procedure RegisterErrorMessage(const AErrorMessage: String); 41 | procedure IncRefCount(); 42 | function DecRefCount(): Boolean; 43 | end; 44 | 45 | 46 | (************************************************************************************************************************* 47 | Interface definition for Calculator 48 | **************************************************************************************************************************) 49 | 50 | ICalculationCalculator = interface(ICalculationBase) 51 | ['{6694D2C4-22AC-4208-A007-2939487F6999}'] 52 | 53 | procedure EnlistVariable(AVariable: TNumbersVariable); 54 | function GetEnlistedVariable(const AIndex: Cardinal): TNumbersVariable; 55 | procedure ClearVariables(); 56 | function Multiply(): TNumbersVariable; 57 | function Add(): TNumbersVariable; 58 | end; 59 | 60 | implementation 61 | 62 | end. 63 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Pascal/Interfaces/calculation_types.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal type definition file in order to allow easy 10 | development of Calculation library. The functions in this file need to be implemented. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | unit calculation_types; 18 | 19 | interface 20 | 21 | uses 22 | Classes, 23 | sysutils; 24 | 25 | (************************************************************************************************************************* 26 | Version definition for Calculation 27 | **************************************************************************************************************************) 28 | 29 | const 30 | CALCULATION_VERSION_MAJOR = 1; 31 | CALCULATION_VERSION_MINOR = 0; 32 | CALCULATION_VERSION_MICRO = 0; 33 | CALCULATION_VERSION_PRERELEASEINFO = ''; 34 | CALCULATION_VERSION_BUILDINFO = ''; 35 | 36 | 37 | (************************************************************************************************************************* 38 | General type definitions 39 | **************************************************************************************************************************) 40 | 41 | type 42 | TCalculationResult = Cardinal; 43 | TCalculationHandle = Pointer; 44 | 45 | PCalculationResult = ^TCalculationResult; 46 | PCalculationHandle = ^TCalculationHandle; 47 | 48 | (************************************************************************************************************************* 49 | Error Constants for Calculation 50 | **************************************************************************************************************************) 51 | 52 | const 53 | CALCULATION_SUCCESS = 0; 54 | CALCULATION_ERROR_NOTIMPLEMENTED = 1; 55 | CALCULATION_ERROR_INVALIDPARAM = 2; 56 | CALCULATION_ERROR_INVALIDCAST = 3; 57 | CALCULATION_ERROR_BUFFERTOOSMALL = 4; 58 | CALCULATION_ERROR_GENERICEXCEPTION = 5; 59 | CALCULATION_ERROR_COULDNOTLOADLIBRARY = 6; 60 | CALCULATION_ERROR_COULDNOTFINDLIBRARYEXPORT = 7; 61 | CALCULATION_ERROR_INCOMPATIBLEBINARYVERSION = 8; 62 | 63 | 64 | implementation 65 | 66 | end. 67 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Pascal/Stub/calculation_impl.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal implementation file in order to allow easy 10 | development of Calculation library. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | Unit calculation_impl; 18 | 19 | interface 20 | 21 | uses 22 | calculation_types, 23 | calculation_exception, 24 | calculation_interfaces, 25 | Classes, 26 | Unit_Numbers, 27 | calculation_impl_calculator, 28 | sysutils; 29 | 30 | type 31 | TCalculationWrapper = class(TObject) 32 | private 33 | class var GNumbersWrapper: TNumbersWrapper; 34 | class function GetNumbersWrapper: TNumbersWrapper; static; 35 | class procedure SetNumbersWrapper(ANumbersWrapper: TNumbersWrapper); static; 36 | public 37 | class property NumbersWrapper: TNumbersWrapper read GetNumbersWrapper write SetNumbersWrapper; 38 | class function CreateCalculator(): TObject; 39 | class procedure GetVersion(out AMajor: Cardinal; out AMinor: Cardinal; out AMicro: Cardinal); 40 | class function GetLastError(AInstance: TObject; out AErrorMessage: String): Boolean; 41 | class procedure ReleaseInstance(AInstance: TObject); 42 | class procedure AcquireInstance(AInstance: TObject); 43 | end; 44 | 45 | 46 | implementation 47 | 48 | class procedure TCalculationWrapper.SetNumbersWrapper(ANumbersWrapper: TNumbersWrapper); 49 | begin 50 | if assigned(GNumbersWrapper) then 51 | raise ECalculationException.Create(CALCULATION_ERROR_COULDNOTLOADLIBRARY); 52 | GNumbersWrapper := ANumbersWrapper; 53 | end; 54 | 55 | class function TCalculationWrapper.GetNumbersWrapper(): TNumbersWrapper; 56 | begin 57 | if not assigned(GNumbersWrapper) then 58 | raise ECalculationException.Create(CALCULATION_ERROR_COULDNOTLOADLIBRARY); 59 | result := GNumbersWrapper; 60 | end; 61 | 62 | class function TCalculationWrapper.CreateCalculator(): TObject; 63 | begin 64 | result := TCalculationCalculator.Create(); 65 | end; 66 | 67 | class procedure TCalculationWrapper.GetVersion(out AMajor: Cardinal; out AMinor: Cardinal; out AMicro: Cardinal); 68 | begin 69 | AMajor := CALCULATION_VERSION_MAJOR; 70 | AMinor := CALCULATION_VERSION_MINOR; 71 | AMicro := CALCULATION_VERSION_MICRO; 72 | end; 73 | 74 | class function TCalculationWrapper.GetLastError(AInstance: TObject; out AErrorMessage: String): Boolean; 75 | begin 76 | result := false; 77 | if supports(AInstance, ICalculationBase) then 78 | result := (AInstance as ICalculationBase).GetLastErrorMessage(AErrorMessage); 79 | end; 80 | 81 | class procedure TCalculationWrapper.ReleaseInstance(AInstance: TObject); 82 | begin 83 | (AInstance as ICalculationBase).DecRefCount(); 84 | end; 85 | 86 | class procedure TCalculationWrapper.AcquireInstance(AInstance: TObject); 87 | begin 88 | (AInstance as ICalculationBase).IncRefCount(); 89 | end; 90 | 91 | 92 | end. 93 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Pascal/Stub/calculation_impl_base.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TCalculationBase 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit calculation_impl_base; 13 | 14 | interface 15 | 16 | uses 17 | calculation_types, 18 | calculation_interfaces, 19 | calculation_exception, 20 | Unit_Numbers, 21 | Classes, 22 | sysutils; 23 | 24 | type 25 | TCalculationBase = class(TObject, ICalculationBase) 26 | private 27 | FMessages: TStringList; 28 | FReferenceCount: integer; 29 | 30 | protected 31 | 32 | public 33 | constructor Create(); 34 | destructor Destroy(); override; 35 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 36 | procedure ClearErrorMessages(); 37 | procedure RegisterErrorMessage(const AErrorMessage: String); 38 | procedure IncRefCount(); 39 | function DecRefCount(): Boolean; 40 | end; 41 | 42 | implementation 43 | 44 | constructor TCalculationBase.Create(); 45 | begin 46 | inherited Create(); 47 | FMessages := TStringList.Create(); 48 | FReferenceCount := 1; 49 | end; 50 | 51 | destructor TCalculationBase.Destroy(); 52 | begin 53 | FreeAndNil(FMessages); 54 | inherited Destroy(); 55 | end; 56 | 57 | function TCalculationBase.GetLastErrorMessage(out AErrorMessage: String): Boolean; 58 | begin 59 | result := (FMessages.Count>0); 60 | if (result) then 61 | AErrorMessage := FMessages[FMessages.Count-1]; 62 | end; 63 | 64 | procedure TCalculationBase.ClearErrorMessages(); 65 | begin 66 | FMessages.Clear(); 67 | end; 68 | 69 | procedure TCalculationBase.RegisterErrorMessage(const AErrorMessage: String); 70 | begin 71 | FMessages.Clear(); 72 | FMessages.Add(AErrorMessage); 73 | end; 74 | 75 | procedure TCalculationBase.IncRefCount(); 76 | begin 77 | inc(FReferenceCount); 78 | end; 79 | 80 | function TCalculationBase.DecRefCount(): Boolean; 81 | begin 82 | dec(FReferenceCount); 83 | if (FReferenceCount = 0) then begin 84 | result := true; 85 | self.Destroy(); 86 | end; 87 | result := false; 88 | end; 89 | 90 | end. 91 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Pascal/Stub/calculation_impl_calculator.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Calculation developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TCalculationCalculator 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit calculation_impl_calculator; 13 | 14 | interface 15 | 16 | uses 17 | calculation_types, 18 | calculation_interfaces, 19 | calculation_exception, 20 | calculation_impl_base, 21 | Unit_Numbers, 22 | Classes, 23 | sysutils, 24 | contnrs; 25 | 26 | type 27 | TCalculationCalculator = class(TCalculationBase, ICalculationCalculator) 28 | private 29 | FVariableList : TObjectList; 30 | protected 31 | 32 | public 33 | constructor Create(); 34 | destructor Destroy(); override; 35 | procedure EnlistVariable(AVariable: TNumbersVariable); 36 | function GetEnlistedVariable(const AIndex: Cardinal): TNumbersVariable; 37 | procedure ClearVariables(); 38 | function Multiply(): TNumbersVariable; 39 | function Add(): TNumbersVariable; 40 | end; 41 | 42 | implementation 43 | 44 | uses calculation_impl; 45 | 46 | constructor TCalculationCalculator.Create(); 47 | begin 48 | inherited Create(); 49 | 50 | FVariableList := TObjectList.Create(True); 51 | end; 52 | 53 | destructor TCalculationCalculator.Destroy(); 54 | begin 55 | ClearVariables(); 56 | 57 | FreeAndNil(FVariableList); 58 | inherited Destroy(); 59 | end; 60 | 61 | procedure TCalculationCalculator.EnlistVariable(AVariable: TNumbersVariable); 62 | begin 63 | FVariableList.Add(AVariable); 64 | end; 65 | 66 | function TCalculationCalculator.GetEnlistedVariable(const AIndex: Cardinal): TNumbersVariable; 67 | begin 68 | if AIndex >= FVariableList.Count then begin 69 | raise ECalculationException.Create(CALCULATION_ERROR_INVALIDPARAM); 70 | end; 71 | result := FVariableList[AIndex] as TNumbersVariable; 72 | end; 73 | 74 | procedure TCalculationCalculator.ClearVariables(); 75 | begin 76 | FVariableList.Clear; 77 | end; 78 | 79 | function TCalculationCalculator.Multiply(): TNumbersVariable; 80 | var 81 | AVar: TNumbersVariable; 82 | I: integer; 83 | ResVal : double; 84 | begin 85 | ResVal := 1.0; 86 | For I := 0 to FVariableList.Count - 1 do begin 87 | AVar := (FVariableList[I] as TNumbersVariable); 88 | ResVal := ResVal * AVar.GetValue(); 89 | end; 90 | result := TCalculationWrapper.NumbersWrapper.CreateVariable(ResVal); 91 | end; 92 | 93 | function TCalculationCalculator.Add(): TNumbersVariable; 94 | var 95 | AVar: TNumbersVariable; 96 | I: integer; 97 | ResVal : double; 98 | begin 99 | ResVal := 0.0; 100 | For I := 0 to FVariableList.Count - 1 do begin 101 | AVar := (FVariableList[I] as TNumbersVariable); 102 | ResVal := ResVal + AVar.GetValue(); 103 | end; 104 | result := TCalculationWrapper.NumbersWrapper.CreateVariable(ResVal); 105 | end; 106 | 107 | end. 108 | -------------------------------------------------------------------------------- /Examples/Injection/Calculation_component/Implementations/Pascal/calculation.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | calculation_createcalculator 3 | calculation_getversion 4 | calculation_getlasterror 5 | calculation_releaseinstance 6 | calculation_acquireinstance 7 | calculation_injectcomponent 8 | calculation_getsymbollookupmethod 9 | calculation_calculator_enlistvariable 10 | calculation_calculator_getenlistedvariable 11 | calculation_calculator_clearvariables 12 | calculation_calculator_multiply 13 | calculation_calculator_add 14 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMakeLists file for the development of Numbers library. 10 | 11 | Interface version: 1.0.0 12 | 13 | 14 | ]] 15 | 16 | cmake_minimum_required(VERSION 3.5) 17 | 18 | ### The implementation of the Numbers library component 19 | project(Numbers) 20 | 21 | set (CMAKE_CXX_STANDARD 11) 22 | 23 | # The location of autogenerated interfaces 24 | set(CMAKE_CURRENT_AUTOGENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces) 25 | 26 | file(GLOB NUMBERS_SRC 27 | ${CMAKE_CURRENT_SOURCE_DIR}/Stub/*.cpp 28 | ) 29 | file(GLOB NUMBERS_HDR 30 | ${CMAKE_CURRENT_SOURCE_DIR}/Stub/*.hpp 31 | ) 32 | set(NUMBERS_SRC ${NUMBERS_SRC} ${NUMBERS_SRC} 33 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/numbers_interfaceexception.cpp 34 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/numbers_interfacewrapper.cpp 35 | ) 36 | 37 | add_library(numbers SHARED ${NUMBERS_SRC}) 38 | # Do not prefix the binary's name with "lib" on Unix systems: 39 | set_target_properties(numbers PROPERTIES PREFIX "" IMPORT_PREFIX "" ) 40 | # The following two properties are crucial to reduce the number of undesirably exported symbols 41 | set_target_properties(numbers PROPERTIES CXX_VISIBILITY_PRESET hidden) 42 | set_target_properties(numbers PROPERTIES VISIBILITY_INLINES_HIDDEN ON) 43 | # This makes sure symbols are exported 44 | target_compile_options(numbers PRIVATE "-D__NUMBERS_EXPORTS") 45 | target_include_directories(numbers PRIVATE ${CMAKE_CURRENT_AUTOGENERATED_DIR}) 46 | target_include_directories(numbers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Stub) 47 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Cpp/Interfaces/numbers_interfaceexception.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ Implementation file with the basic internal 10 | exception type in order to allow an easy use of Numbers library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | 17 | #include 18 | 19 | #include "numbers_interfaceexception.hpp" 20 | 21 | /************************************************************************************************************************* 22 | Class ENumbersInterfaceException 23 | **************************************************************************************************************************/ 24 | ENumbersInterfaceException::ENumbersInterfaceException(NumbersResult errorCode) 25 | : m_errorMessage("Numbers Error " + std::to_string (errorCode)) 26 | { 27 | m_errorCode = errorCode; 28 | } 29 | 30 | ENumbersInterfaceException::ENumbersInterfaceException(NumbersResult errorCode, std::string errorMessage) 31 | : m_errorMessage(errorMessage + " (" + std::to_string (errorCode) + ")") 32 | { 33 | m_errorCode = errorCode; 34 | } 35 | 36 | NumbersResult ENumbersInterfaceException::getErrorCode () 37 | { 38 | return m_errorCode; 39 | } 40 | 41 | const char * ENumbersInterfaceException::what () const noexcept 42 | { 43 | return m_errorMessage.c_str(); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Cpp/Interfaces/numbers_interfaceexception.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ Header file with the basic internal 10 | exception type in order to allow an easy use of Numbers library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #ifndef __NUMBERS_INTERFACEEXCEPTION_HEADER 17 | #define __NUMBERS_INTERFACEEXCEPTION_HEADER 18 | 19 | #include 20 | #include 21 | #include "numbers_types.hpp" 22 | 23 | /************************************************************************************************************************* 24 | Class ENumbersInterfaceException 25 | **************************************************************************************************************************/ 26 | 27 | 28 | class ENumbersInterfaceException : public std::exception { 29 | protected: 30 | /** 31 | * Error code for the Exception. 32 | */ 33 | NumbersResult m_errorCode; 34 | /** 35 | * Error message for the Exception. 36 | */ 37 | std::string m_errorMessage; 38 | 39 | public: 40 | /** 41 | * Exception Constructor. 42 | */ 43 | ENumbersInterfaceException(NumbersResult errorCode); 44 | 45 | /** 46 | * Custom Exception Constructor. 47 | */ 48 | ENumbersInterfaceException(NumbersResult errorCode, std::string errorMessage); 49 | 50 | /** 51 | * Returns error code 52 | */ 53 | NumbersResult getErrorCode(); 54 | /** 55 | * Returns error message 56 | */ 57 | const char* what() const noexcept override; 58 | }; 59 | 60 | #endif // __NUMBERS_INTERFACEEXCEPTION_HEADER 61 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Cpp/Stub/numbers.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ implementation file in order to allow easy 10 | development of Numbers library. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include "numbers_abi.hpp" 17 | #include "numbers_interfaces.hpp" 18 | #include "numbers_interfaceexception.hpp" 19 | 20 | #include "numbers_variable.hpp" 21 | 22 | using namespace Numbers; 23 | using namespace Numbers::Impl; 24 | 25 | IVariable * CWrapper::CreateVariable(const Numbers_double dInitialValue) 26 | { 27 | return new CVariable(dInitialValue); 28 | } 29 | 30 | void CWrapper::GetVersion(Numbers_uint32 & nMajor, Numbers_uint32 & nMinor, Numbers_uint32 & nMicro) 31 | { 32 | nMajor = NUMBERS_VERSION_MAJOR; 33 | nMinor = NUMBERS_VERSION_MINOR; 34 | nMicro = NUMBERS_VERSION_MICRO; 35 | } 36 | 37 | bool CWrapper::GetLastError(IBase* pInstance, std::string & sErrorMessage) 38 | { 39 | if (pInstance) { 40 | return pInstance->GetLastErrorMessage(sErrorMessage); 41 | } 42 | else { 43 | throw ENumbersInterfaceException(NUMBERS_ERROR_INVALIDPARAM); 44 | } 45 | } 46 | 47 | void CWrapper::ReleaseInstance(IBase* pInstance) 48 | { 49 | IBase::ReleaseBaseClassInterface(pInstance); 50 | } 51 | 52 | void CWrapper::AcquireInstance(IBase* pInstance) 53 | { 54 | IBase::AcquireBaseClassInterface(pInstance); 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Cpp/Stub/numbers_base.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CBase 8 | 9 | */ 10 | 11 | #include "numbers_base.hpp" 12 | #include "numbers_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace Numbers::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CBase 21 | **************************************************************************************************************************/ 22 | 23 | bool CBase::GetLastErrorMessage(std::string & sErrorMessage) 24 | { 25 | if (m_pErrors && !m_pErrors->empty()) { 26 | sErrorMessage = m_pErrors->back(); 27 | return true; 28 | } else { 29 | sErrorMessage = ""; 30 | return false; 31 | } 32 | } 33 | 34 | void CBase::ClearErrorMessages() 35 | { 36 | m_pErrors.reset(); 37 | } 38 | 39 | void CBase::RegisterErrorMessage(const std::string & sErrorMessage) 40 | { 41 | if (!m_pErrors) { 42 | m_pErrors.reset(new std::list()); 43 | } 44 | m_pErrors->clear(); 45 | m_pErrors->push_back(sErrorMessage); 46 | } 47 | 48 | void CBase::IncRefCount() 49 | { 50 | ++m_nReferenceCount; 51 | } 52 | 53 | bool CBase::DecRefCount() 54 | { 55 | m_nReferenceCount--; 56 | if (!m_nReferenceCount) {; 57 | delete this; 58 | return true; 59 | } 60 | return false; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Cpp/Stub/numbers_base.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CBase 8 | 9 | */ 10 | 11 | 12 | #ifndef __NUMBERS_BASE 13 | #define __NUMBERS_BASE 14 | 15 | #include "numbers_interfaces.hpp" 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // Include custom headers here. 22 | 23 | 24 | namespace Numbers { 25 | namespace Impl { 26 | 27 | 28 | /************************************************************************************************************************* 29 | Class declaration of CBase 30 | **************************************************************************************************************************/ 31 | 32 | class CBase : public virtual IBase { 33 | private: 34 | 35 | std::unique_ptr> m_pErrors; 36 | Numbers_uint32 m_nReferenceCount = 1; 37 | 38 | /** 39 | * Put private members here. 40 | */ 41 | 42 | protected: 43 | 44 | /** 45 | * Put protected members here. 46 | */ 47 | 48 | public: 49 | 50 | /** 51 | * Put additional public members here. They will not be visible in the external API. 52 | */ 53 | 54 | bool GetLastErrorMessage(std::string & sErrorMessage); 55 | 56 | void ClearErrorMessages(); 57 | 58 | void RegisterErrorMessage(const std::string & sErrorMessage); 59 | 60 | void IncRefCount(); 61 | 62 | bool DecRefCount(); 63 | 64 | 65 | /** 66 | * Public member functions to implement. 67 | */ 68 | 69 | }; 70 | 71 | } // namespace Impl 72 | } // namespace Numbers 73 | 74 | #endif // __NUMBERS_BASE 75 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Cpp/Stub/numbers_variable.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CVariable 8 | 9 | */ 10 | 11 | #include "numbers_variable.hpp" 12 | #include "numbers_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace Numbers::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CVariable 21 | **************************************************************************************************************************/ 22 | 23 | CVariable::CVariable(double dInitialValue) 24 | : m_dValue(dInitialValue) 25 | { 26 | 27 | } 28 | 29 | Numbers_double CVariable::GetValue() 30 | { 31 | return m_dValue; 32 | } 33 | 34 | void CVariable::SetValue(const Numbers_double dValue) 35 | { 36 | m_dValue = dValue; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Cpp/Stub/numbers_variable.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CVariable 8 | 9 | */ 10 | 11 | 12 | #ifndef __NUMBERS_VARIABLE 13 | #define __NUMBERS_VARIABLE 14 | 15 | #include "numbers_interfaces.hpp" 16 | 17 | // Parent classes 18 | #include "numbers_base.hpp" 19 | #ifdef _MSC_VER 20 | #pragma warning(push) 21 | #pragma warning(disable : 4250) 22 | #endif 23 | 24 | // Include custom headers here. 25 | 26 | 27 | namespace Numbers { 28 | namespace Impl { 29 | 30 | 31 | /************************************************************************************************************************* 32 | Class declaration of CVariable 33 | **************************************************************************************************************************/ 34 | 35 | class CVariable : public virtual IVariable, public virtual CBase { 36 | private: 37 | 38 | double m_dValue; 39 | 40 | protected: 41 | 42 | /** 43 | * Put protected members here. 44 | */ 45 | 46 | public: 47 | 48 | /** 49 | * Put additional public members here. They will not be visible in the external API. 50 | */ 51 | CVariable(double dInitialValue); 52 | 53 | /** 54 | * Public member functions to implement. 55 | */ 56 | 57 | Numbers_double GetValue(); 58 | 59 | void SetValue(const Numbers_double dValue); 60 | 61 | }; 62 | 63 | } // namespace Impl 64 | } // namespace Numbers 65 | 66 | #ifdef _MSC_VER 67 | #pragma warning(pop) 68 | #endif 69 | #endif // __NUMBERS_VARIABLE 70 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Pascal/Interfaces/numbers.lpr: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal project file in order to allow easy 10 | development of Numbers library. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | library numbers; 18 | 19 | uses 20 | {$IFDEF UNIX} 21 | cthreads, 22 | {$ENDIF UNIX} 23 | syncobjs, 24 | numbers_types, 25 | numbers_exports, 26 | Classes, 27 | sysutils; 28 | 29 | exports 30 | numbers_variable_getvalue, 31 | numbers_variable_setvalue, 32 | numbers_createvariable, 33 | numbers_getversion, 34 | numbers_getlasterror, 35 | numbers_releaseinstance, 36 | numbers_acquireinstance, 37 | numbers_getsymbollookupmethod; 38 | 39 | begin 40 | 41 | end. 42 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Pascal/Interfaces/numbers_interfaces.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal interface definition file in order to allow easy 10 | development of Numbers library. The functions in this file need to be implemented. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | {$INTERFACES CORBA} 18 | unit numbers_interfaces; 19 | 20 | interface 21 | 22 | uses 23 | numbers_types, 24 | Classes, 25 | sysutils; 26 | 27 | 28 | type 29 | 30 | (************************************************************************************************************************* 31 | Interface definition for Base 32 | **************************************************************************************************************************) 33 | 34 | INumbersBase = interface 35 | ['{52FDFC07-2182-454F-963F-5F0F9A621D72}'] 36 | 37 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 38 | procedure ClearErrorMessages(); 39 | procedure RegisterErrorMessage(const AErrorMessage: String); 40 | procedure IncRefCount(); 41 | function DecRefCount(): Boolean; 42 | end; 43 | 44 | 45 | (************************************************************************************************************************* 46 | Interface definition for Variable 47 | **************************************************************************************************************************) 48 | 49 | INumbersVariable = interface(INumbersBase) 50 | ['{9566C74D-1003-4C4D-BBBB-0407D1E2C649}'] 51 | 52 | function GetValue(): Double; 53 | procedure SetValue(const AValue: Double); 54 | end; 55 | 56 | implementation 57 | 58 | end. 59 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Pascal/Interfaces/numbers_types.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal type definition file in order to allow easy 10 | development of Numbers library. The functions in this file need to be implemented. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | unit numbers_types; 18 | 19 | interface 20 | 21 | uses 22 | Classes, 23 | sysutils; 24 | 25 | (************************************************************************************************************************* 26 | Version definition for Numbers 27 | **************************************************************************************************************************) 28 | 29 | const 30 | NUMBERS_VERSION_MAJOR = 1; 31 | NUMBERS_VERSION_MINOR = 0; 32 | NUMBERS_VERSION_MICRO = 0; 33 | NUMBERS_VERSION_PRERELEASEINFO = ''; 34 | NUMBERS_VERSION_BUILDINFO = ''; 35 | 36 | 37 | (************************************************************************************************************************* 38 | General type definitions 39 | **************************************************************************************************************************) 40 | 41 | type 42 | TNumbersResult = Cardinal; 43 | TNumbersHandle = Pointer; 44 | 45 | PNumbersResult = ^TNumbersResult; 46 | PNumbersHandle = ^TNumbersHandle; 47 | 48 | (************************************************************************************************************************* 49 | Error Constants for Numbers 50 | **************************************************************************************************************************) 51 | 52 | const 53 | NUMBERS_SUCCESS = 0; 54 | NUMBERS_ERROR_NOTIMPLEMENTED = 1; 55 | NUMBERS_ERROR_INVALIDPARAM = 2; 56 | NUMBERS_ERROR_INVALIDCAST = 3; 57 | NUMBERS_ERROR_BUFFERTOOSMALL = 4; 58 | NUMBERS_ERROR_GENERICEXCEPTION = 5; 59 | NUMBERS_ERROR_COULDNOTLOADLIBRARY = 6; 60 | NUMBERS_ERROR_COULDNOTFINDLIBRARYEXPORT = 7; 61 | NUMBERS_ERROR_INCOMPATIBLEBINARYVERSION = 8; 62 | 63 | 64 | implementation 65 | 66 | end. 67 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Pascal/Stub/numbers_impl.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal implementation file in order to allow easy 10 | development of Numbers library. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | Unit numbers_impl; 18 | 19 | interface 20 | 21 | uses 22 | numbers_types, 23 | numbers_exception, 24 | numbers_interfaces, 25 | numbers_impl_variable, 26 | Classes, 27 | sysutils; 28 | 29 | type 30 | TNumbersWrapper = class(TObject) 31 | public 32 | class function CreateVariable(const AInitialValue: Double): TObject; 33 | class procedure GetVersion(out AMajor: Cardinal; out AMinor: Cardinal; out AMicro: Cardinal); 34 | class function GetLastError(AInstance: TObject; out AErrorMessage: String): Boolean; 35 | class procedure ReleaseInstance(AInstance: TObject); 36 | class procedure AcquireInstance(AInstance: TObject); 37 | end; 38 | 39 | 40 | implementation 41 | 42 | class function TNumbersWrapper.CreateVariable(const AInitialValue: Double): TObject; 43 | begin 44 | result := TNumbersVariable.Create(AInitialValue); 45 | end; 46 | 47 | class procedure TNumbersWrapper.GetVersion(out AMajor: Cardinal; out AMinor: Cardinal; out AMicro: Cardinal); 48 | begin 49 | AMajor := NUMBERS_VERSION_MAJOR; 50 | AMinor := NUMBERS_VERSION_MINOR; 51 | AMicro := NUMBERS_VERSION_MICRO; 52 | end; 53 | 54 | class function TNumbersWrapper.GetLastError(AInstance: TObject; out AErrorMessage: String): Boolean; 55 | begin 56 | result := false; 57 | if supports(AInstance, INumbersBase) then 58 | result := (AInstance as INumbersBase).GetLastErrorMessage(AErrorMessage); 59 | end; 60 | 61 | class procedure TNumbersWrapper.ReleaseInstance(AInstance: TObject); 62 | begin 63 | (AInstance as INumbersBase).DecRefCount(); 64 | end; 65 | 66 | class procedure TNumbersWrapper.AcquireInstance(AInstance: TObject); 67 | begin 68 | (AInstance as INumbersBase).IncRefCount(); 69 | end; 70 | 71 | 72 | end. 73 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Pascal/Stub/numbers_impl_base.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TNumbersBase 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit numbers_impl_base; 13 | 14 | interface 15 | 16 | uses 17 | numbers_types, 18 | numbers_interfaces, 19 | numbers_exception, 20 | Classes, 21 | sysutils; 22 | 23 | type 24 | TNumbersBase = class(TObject, INumbersBase) 25 | private 26 | FMessages: TStringList; 27 | FReferenceCount: integer; 28 | 29 | protected 30 | 31 | public 32 | constructor Create(); 33 | destructor Destroy(); override; 34 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 35 | procedure ClearErrorMessages(); 36 | procedure RegisterErrorMessage(const AErrorMessage: String); 37 | procedure IncRefCount(); 38 | function DecRefCount(): Boolean; 39 | end; 40 | 41 | implementation 42 | 43 | constructor TNumbersBase.Create(); 44 | begin 45 | inherited Create(); 46 | FMessages := TStringList.Create(); 47 | FReferenceCount := 1; 48 | end; 49 | 50 | destructor TNumbersBase.Destroy(); 51 | begin 52 | FreeAndNil(FMessages); 53 | inherited Destroy(); 54 | end; 55 | 56 | function TNumbersBase.GetLastErrorMessage(out AErrorMessage: String): Boolean; 57 | begin 58 | result := (FMessages.Count>0); 59 | if (result) then 60 | AErrorMessage := FMessages[FMessages.Count-1]; 61 | end; 62 | 63 | procedure TNumbersBase.ClearErrorMessages(); 64 | begin 65 | FMessages.Clear(); 66 | end; 67 | 68 | procedure TNumbersBase.RegisterErrorMessage(const AErrorMessage: String); 69 | begin 70 | FMessages.Clear(); 71 | FMessages.Add(AErrorMessage); 72 | end; 73 | 74 | procedure TNumbersBase.IncRefCount(); 75 | begin 76 | inc(FReferenceCount); 77 | end; 78 | 79 | function TNumbersBase.DecRefCount(): Boolean; 80 | begin 81 | dec(FReferenceCount); 82 | if (FReferenceCount = 0) then begin 83 | result := true; 84 | self.Destroy(); 85 | end; 86 | result := false; 87 | end; 88 | 89 | end. 90 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Pascal/Stub/numbers_impl_variable.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 Numbers developers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TNumbersVariable 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit numbers_impl_variable; 13 | 14 | interface 15 | 16 | uses 17 | numbers_types, 18 | numbers_interfaces, 19 | numbers_exception, 20 | numbers_impl_base, 21 | Classes, 22 | sysutils; 23 | 24 | type 25 | TNumbersVariable = class(TNumbersBase, INumbersVariable) 26 | private 27 | FValue : double; 28 | protected 29 | 30 | public 31 | constructor Create(AInitialValue: double); 32 | function GetValue(): Double; 33 | procedure SetValue(const AValue: Double); 34 | end; 35 | 36 | implementation 37 | 38 | constructor TNumbersVariable.Create(AInitialValue: double); 39 | begin 40 | inherited Create(); 41 | FValue := AInitialValue; 42 | end; 43 | 44 | function TNumbersVariable.GetValue(): Double; 45 | begin 46 | result := FValue; 47 | end; 48 | 49 | procedure TNumbersVariable.SetValue(const AValue: Double); 50 | begin 51 | FValue := AValue; 52 | end; 53 | 54 | end. 55 | -------------------------------------------------------------------------------- /Examples/Injection/Numbers_component/Implementations/Pascal/numbers.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | numbers_createvariable 3 | numbers_getversion 4 | numbers_getlasterror 5 | numbers_releaseinstance 6 | numbers_acquireinstance 7 | numbers_getsymbollookupmethod 8 | numbers_variable_getvalue 9 | numbers_variable_setvalue 10 | -------------------------------------------------------------------------------- /Examples/OptionalClass/.gitignore: -------------------------------------------------------------------------------- 1 | OptClass_component 2 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Examples/Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated CMake Project that demonstrates the 9 | usage of the C++ bindings of Optional Class Library 10 | 11 | Interface version: 1.0.0 12 | 13 | 14 | ]] 15 | 16 | cmake_minimum_required(VERSION 3.5) 17 | 18 | set(CMAKE_CURRENT_BINDING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Bindings/Cpp) 19 | project(OptClassExample_CPPImplicit) 20 | set(CMAKE_CXX_STANDARD 11) 21 | add_executable(OptClassExample_CPPImplicit "${CMAKE_CURRENT_SOURCE_DIR}/OptClass_example.cpp") 22 | find_library(OPTCLASSLOCATION optclass "D:/PUBLIC/AutomaticComponentToolkit/Examples/OptionalClass//OptClass_component/Bindings/Cpp/../../Implementations/*/*/*") 23 | target_link_libraries(OptClassExample_CPPImplicit ${OPTCLASSLOCATION}) 24 | target_include_directories(OptClassExample_CPPImplicit PRIVATE "${CMAKE_CURRENT_BINDING_DIR}") 25 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Examples/Cpp/OptClass_example.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated C++ application that demonstrates the 9 | usage of the C++ bindings of Optional Class Library 10 | 11 | Interface version: 1.0.0 12 | 13 | */ 14 | 15 | #include 16 | #include "optclass_implicit.hpp" 17 | 18 | 19 | int main() 20 | { 21 | try 22 | { 23 | auto wrapper = OptClass::CWrapper::loadLibrary(); 24 | OptClass_uint32 nMajor, nMinor, nMicro; 25 | wrapper->GetVersion(nMajor, nMinor, nMicro); 26 | std::cout << "OptClass.Version = " << nMajor << "." << nMinor << "." << nMicro; 27 | std::cout << std::endl; 28 | } 29 | catch (std::exception &e) 30 | { 31 | std::cout << e.what() << std::endl; 32 | return 1; 33 | } 34 | return 0; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Examples/CppDynamic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated CMake Project that demonstrates the 9 | usage of the Dynamic C++ bindings of Optional Class Library 10 | 11 | Interface version: 1.0.0 12 | 13 | 14 | ]] 15 | 16 | cmake_minimum_required(VERSION 3.5) 17 | 18 | set(CMAKE_CURRENT_BINDING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Bindings/CppDynamic) 19 | project(OptClassExample_CPPDynamic) 20 | set(CMAKE_CXX_STANDARD 11) 21 | add_executable(OptClassExample_CPPDynamic "${CMAKE_CURRENT_SOURCE_DIR}/OptClass_example.cpp") 22 | if (UNIX) 23 | target_link_libraries(OptClassExample_CPPDynamic ${CMAKE_DL_LIBS}) 24 | endif (UNIX) 25 | target_include_directories(OptClassExample_CPPDynamic PRIVATE "${CMAKE_CURRENT_BINDING_DIR}") 26 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Examples/CppDynamic/OptClass_example.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated C++ application that demonstrates the 9 | usage of the Dynamic C++ bindings of Optional Class Library 10 | 11 | Interface version: 1.0.0 12 | 13 | */ 14 | 15 | #include 16 | #include "optclass_dynamic.hpp" 17 | 18 | 19 | int main() 20 | { 21 | try 22 | { 23 | std::string libpath = (""); // TODO: put the location of the OptClass-library file here. 24 | auto wrapper = OptClass::CWrapper::loadLibrary(libpath + "/optclass.dll"); // TODO: add correct suffix of the library 25 | OptClass_uint32 nMajor, nMinor, nMicro; 26 | wrapper->GetVersion(nMajor, nMinor, nMicro); 27 | std::cout << "OptClass.Version = " << nMajor << "." << nMinor << "." << nMicro; 28 | std::cout << std::endl; 29 | 30 | wrapper->CreateInstanceWithName("A"); 31 | auto baseA = wrapper->FindInstanceA("A"); 32 | if (baseA == nullptr) { 33 | std::cout << "Error: Expected to find Instance \"A\"." << std::endl; 34 | return 1; 35 | } 36 | 37 | OptClass::PBase baseB; 38 | wrapper->FindInstanceB("DoesNotExist", baseB); 39 | if (baseB != nullptr) { 40 | std::cout << "Error: Did not expect to find Instance \"DoesNotExist\"." << std::endl; 41 | return 1; 42 | } 43 | 44 | if (!wrapper->UseInstanceMaybe(baseA.get())) { 45 | std::cout << "Error: Expected to use Instance \"A\"." << std::endl; 46 | return 1; 47 | } 48 | if (wrapper->UseInstanceMaybe(baseB.get())) { 49 | std::cout << "Error: Did not expect to use Instance \"DoesNotExist\"." << std::endl; 50 | return 1; 51 | } 52 | 53 | std::cout << "Passed." << std::endl; 54 | } 55 | catch (std::exception &e) 56 | { 57 | std::cout << e.what() << std::endl; 58 | return 1; 59 | } 60 | return 0; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Examples/Go/OptClass_example._go: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated Go application that demonstrates the 9 | usage of the Go bindings of Optional Class Library 10 | 11 | Interface version: 1.0.0 12 | 13 | */ 14 | 15 | 16 | package main 17 | 18 | import ( 19 | "fmt" 20 | "log" 21 | "../../Bindings/Go" 22 | ) 23 | 24 | func main() { 25 | wrapper, err := optclass.OptClassLoadWrapper("../../Implementations/Cpp/build/Debug/optclass.dll") // TODO: add-path here 26 | if (err != nil) { 27 | log.Fatal(err) 28 | } 29 | 30 | nMajor, nMinor, nMicro, err := wrapper.GetVersion() 31 | if (err != nil) { 32 | log.Fatal(err) 33 | } 34 | versionString := fmt.Sprintf("optclass.version = %d.%d.%d", nMajor, nMinor, nMicro) 35 | 36 | fmt.Println(versionString) 37 | 38 | err = wrapper.CreateInstanceWithName("A") 39 | if (err != nil) { 40 | log.Fatal(err) 41 | } 42 | 43 | baseA, err := wrapper.FindInstanceA("A") 44 | if (err != nil) { 45 | log.Fatal(err) 46 | } 47 | if (!baseA.Handle.IsValid()) { 48 | log.Fatal("Error: Expected to find Instance \"A\".") 49 | } 50 | baseB, err := wrapper.FindInstanceB("DoesNotExist") 51 | if (err != nil) { 52 | log.Fatal(err) 53 | } 54 | if (baseB.Handle.IsValid()) { 55 | log.Fatal("Error: Did not expect to find Instance \"DoesNotExist\".") 56 | } 57 | 58 | usedA, err := wrapper.UseInstanceMaybe(baseA.Handle) 59 | if (err != nil) { 60 | log.Fatal(err) 61 | } 62 | if (!usedA) { 63 | log.Fatal("Error: Expected to use Instance \"A\".") 64 | } 65 | 66 | usedB, err := wrapper.UseInstanceMaybe(baseB.Handle) 67 | if (err != nil) { 68 | log.Fatal(err) 69 | } 70 | if (usedB) { 71 | log.Fatal("Error: Did not expect to use Instance \"DoesNotExist\".") 72 | } 73 | 74 | fmt.Println("Passed.") 75 | } 76 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Examples/Python/OptClass_Example.py: -------------------------------------------------------------------------------- 1 | '''++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated Python application that demonstrates the 9 | usage of the Python bindings of Optional Class Library 10 | 11 | Interface version: 1.0.0 12 | 13 | ''' 14 | 15 | 16 | import os 17 | import sys 18 | sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "Bindings", "Python")) 19 | import OptClass 20 | 21 | 22 | def main(): 23 | libpath = '' # TODO add the location of the shared library binary here 24 | wrapper = OptClass.Wrapper(libraryName = os.path.join(libpath, "projectoptclass")) 25 | 26 | major, minor, micro = wrapper.GetVersion() 27 | print("OptClass version: {:d}.{:d}.{:d}".format(major, minor, micro), end="") 28 | print("") 29 | 30 | wrapper.CreateInstanceWithName("A") 31 | baseA = wrapper.FindInstanceA("A") 32 | if baseA is None: 33 | print("Error: Expected to find Instance \"A\".") 34 | return 1 35 | 36 | baseB = wrapper.FindInstanceB("DoesNotExist") 37 | if baseB is not None: 38 | print("Error: Did not expect to find Instance \"DoesNotExist\".") 39 | return 1 40 | 41 | if not wrapper.UseInstanceMaybe(baseA): 42 | print("Error: Expected to use Instance \"A\".") 43 | return 1 44 | 45 | if wrapper.UseInstanceMaybe(baseB): 46 | print("Error: Expected to use Instance \"DoesNotExist\".") 47 | return 1 48 | 49 | print("Passed.") 50 | 51 | if __name__ == "__main__": 52 | try: 53 | main() 54 | except OptClass.EOptClassException as e: 55 | print(e) 56 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated CMakeLists file for the development of Optional Class Library. 9 | 10 | Interface version: 1.0.0 11 | 12 | 13 | ]] 14 | 15 | cmake_minimum_required(VERSION 3.5) 16 | 17 | ### The implementation of the Optional Class Library component 18 | project(OptClass) 19 | 20 | set (CMAKE_CXX_STANDARD 11) 21 | 22 | # The location of autogenerated interfaces 23 | set(CMAKE_CURRENT_AUTOGENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces) 24 | 25 | file(GLOB OPTCLASS_SRC 26 | ${CMAKE_CURRENT_SOURCE_DIR}/Stub/*.cpp 27 | ) 28 | file(GLOB OPTCLASS_HDR 29 | ${CMAKE_CURRENT_SOURCE_DIR}/Stub/*.hpp 30 | ) 31 | set(OPTCLASS_SRC ${OPTCLASS_SRC} ${OPTCLASS_SRC} 32 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/optclass_interfaceexception.cpp 33 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/optclass_interfacewrapper.cpp 34 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/optclass_interfacejournal.cpp 35 | ) 36 | 37 | add_library(optclass SHARED ${OPTCLASS_SRC}) 38 | # Do not prefix the binary's name with "lib" on Unix systems: 39 | set_target_properties(optclass PROPERTIES PREFIX "" IMPORT_PREFIX "" ) 40 | # The following two properties are crucial to reduce the number of undesirably exported symbols 41 | set_target_properties(optclass PROPERTIES CXX_VISIBILITY_PRESET hidden) 42 | set_target_properties(optclass PROPERTIES VISIBILITY_INLINES_HIDDEN ON) 43 | # This makes sure symbols are exported 44 | target_compile_options(optclass PRIVATE "-D__OPTCLASS_EXPORTS") 45 | target_include_directories(optclass PRIVATE ${CMAKE_CURRENT_AUTOGENERATED_DIR}) 46 | target_include_directories(optclass PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Stub) 47 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Cpp/Interfaces/optclass_interfaceexception.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated C++ Implementation file with the basic internal 9 | exception type in order to allow an easy use of Optional Class Library 10 | 11 | Interface version: 1.0.0 12 | 13 | */ 14 | 15 | 16 | #include 17 | 18 | #include "optclass_interfaceexception.hpp" 19 | 20 | /************************************************************************************************************************* 21 | Class EOptClassInterfaceException 22 | **************************************************************************************************************************/ 23 | EOptClassInterfaceException::EOptClassInterfaceException(OptClassResult errorCode) 24 | : m_errorMessage("OptClass Error " + std::to_string (errorCode)) 25 | { 26 | m_errorCode = errorCode; 27 | } 28 | 29 | EOptClassInterfaceException::EOptClassInterfaceException(OptClassResult errorCode, std::string errorMessage) 30 | : m_errorMessage(errorMessage + " (" + std::to_string (errorCode) + ")") 31 | { 32 | m_errorCode = errorCode; 33 | } 34 | 35 | OptClassResult EOptClassInterfaceException::getErrorCode () 36 | { 37 | return m_errorCode; 38 | } 39 | 40 | const char * EOptClassInterfaceException::what () const noexcept 41 | { 42 | return m_errorMessage.c_str(); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Cpp/Interfaces/optclass_interfaceexception.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated C++ Header file with the basic internal 9 | exception type in order to allow an easy use of Optional Class Library 10 | 11 | Interface version: 1.0.0 12 | 13 | */ 14 | 15 | #ifndef __OPTCLASS_INTERFACEEXCEPTION_HEADER 16 | #define __OPTCLASS_INTERFACEEXCEPTION_HEADER 17 | 18 | #include 19 | #include 20 | #include "optclass_types.hpp" 21 | 22 | /************************************************************************************************************************* 23 | Class EOptClassInterfaceException 24 | **************************************************************************************************************************/ 25 | 26 | 27 | class EOptClassInterfaceException : public std::exception { 28 | protected: 29 | /** 30 | * Error code for the Exception. 31 | */ 32 | OptClassResult m_errorCode; 33 | /** 34 | * Error message for the Exception. 35 | */ 36 | std::string m_errorMessage; 37 | 38 | public: 39 | /** 40 | * Exception Constructor. 41 | */ 42 | EOptClassInterfaceException(OptClassResult errorCode); 43 | 44 | /** 45 | * Custom Exception Constructor. 46 | */ 47 | EOptClassInterfaceException(OptClassResult errorCode, std::string errorMessage); 48 | 49 | /** 50 | * Returns error code 51 | */ 52 | OptClassResult getErrorCode(); 53 | /** 54 | * Returns error message 55 | */ 56 | const char* what() const noexcept override; 57 | }; 58 | 59 | #endif // __OPTCLASS_INTERFACEEXCEPTION_HEADER 60 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Cpp/Stub/optclass.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated C++ implementation file in order to allow easy 9 | development of Optional Class Library. It needs to be generated only once. 10 | 11 | Interface version: 1.0.0 12 | 13 | */ 14 | 15 | #include "optclass_abi.hpp" 16 | #include "optclass_interfaces.hpp" 17 | #include "optclass_interfaceexception.hpp" 18 | 19 | #include "optclass_base.hpp" 20 | 21 | #include 22 | #include 23 | 24 | using namespace OptClass; 25 | using namespace OptClass::Impl; 26 | 27 | std::map gObjects; 28 | 29 | void CWrapper::AcquireInstance(IBase* pInstance) 30 | { 31 | IBase::AcquireBaseClassInterface(pInstance); 32 | } 33 | 34 | void CWrapper::ReleaseInstance(IBase* pInstance) 35 | { 36 | IBase::ReleaseBaseClassInterface(pInstance); 37 | } 38 | 39 | void CWrapper::GetVersion(OptClass_uint32 & nMajor, OptClass_uint32 & nMinor, OptClass_uint32 & nMicro) 40 | { 41 | nMajor = OPTCLASS_VERSION_MAJOR; 42 | nMinor = OPTCLASS_VERSION_MINOR; 43 | nMicro = OPTCLASS_VERSION_MICRO; 44 | } 45 | 46 | bool CWrapper::GetLastError(IBase* pInstance, std::string & sErrorMessage) 47 | { 48 | throw EOptClassInterfaceException(OPTCLASS_ERROR_NOTIMPLEMENTED); 49 | } 50 | 51 | void CWrapper::CreateInstanceWithName(const std::string & sIdentifier) 52 | { 53 | gObjects.insert(std::make_pair(sIdentifier, PIBase(new CBase))); 54 | } 55 | 56 | IBase * CWrapper::FindInstanceA(const std::string & sIdentifier) 57 | { 58 | try { 59 | PIBase pBase = gObjects.at(sIdentifier); 60 | return pBase.getCoOwningPtr(); 61 | } 62 | catch (...) { 63 | return nullptr; 64 | } 65 | } 66 | 67 | void CWrapper::FindInstanceB(const std::string & sIdentifier, IBase*& pInstance) 68 | { 69 | try { 70 | PIBase pBase = gObjects.at(sIdentifier); 71 | pInstance = pBase.getCoOwningPtr(); 72 | } 73 | catch (...) { 74 | pInstance = nullptr; 75 | } 76 | } 77 | 78 | bool CWrapper::UseInstanceMaybe(IBase* pInstance) 79 | { 80 | return pInstance != nullptr; 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Cpp/Stub/optclass_base.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | Abstract: This is a stub class definition of CBase 7 | 8 | */ 9 | 10 | #include "optclass_base.hpp" 11 | #include "optclass_interfaceexception.hpp" 12 | 13 | // Include custom headers here. 14 | 15 | 16 | using namespace OptClass::Impl; 17 | 18 | /************************************************************************************************************************* 19 | Class definition of CBase 20 | **************************************************************************************************************************/ 21 | 22 | bool CBase::GetLastErrorMessage(std::string & sErrorMessage) 23 | { 24 | if (m_pErrors && !m_pErrors->empty()) { 25 | sErrorMessage = m_pErrors->back(); 26 | return true; 27 | } else { 28 | sErrorMessage = ""; 29 | return false; 30 | } 31 | } 32 | 33 | void CBase::ClearErrorMessages() 34 | { 35 | m_pErrors.reset(); 36 | } 37 | 38 | void CBase::RegisterErrorMessage(const std::string & sErrorMessage) 39 | { 40 | if (!m_pErrors) { 41 | m_pErrors.reset(new std::list()); 42 | } 43 | m_pErrors->clear(); 44 | m_pErrors->push_back(sErrorMessage); 45 | } 46 | 47 | void CBase::IncRefCount() 48 | { 49 | ++m_nReferenceCount; 50 | } 51 | 52 | bool CBase::DecRefCount() 53 | { 54 | m_nReferenceCount--; 55 | if (!m_nReferenceCount) { 56 | delete this; 57 | return true; 58 | } 59 | return false; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Cpp/Stub/optclass_base.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | Abstract: This is the class declaration of CBase 7 | 8 | */ 9 | 10 | 11 | #ifndef __OPTCLASS_BASE 12 | #define __OPTCLASS_BASE 13 | 14 | #include "optclass_interfaces.hpp" 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | // Include custom headers here. 21 | 22 | 23 | namespace OptClass { 24 | namespace Impl { 25 | 26 | 27 | /************************************************************************************************************************* 28 | Class declaration of CBase 29 | **************************************************************************************************************************/ 30 | 31 | class CBase : public virtual IBase { 32 | private: 33 | 34 | std::unique_ptr> m_pErrors; 35 | OptClass_uint32 m_nReferenceCount = 1; 36 | 37 | /** 38 | * Put private members here. 39 | */ 40 | 41 | protected: 42 | 43 | /** 44 | * Put protected members here. 45 | */ 46 | 47 | public: 48 | 49 | /** 50 | * Put additional public members here. They will not be visible in the external API. 51 | */ 52 | 53 | bool GetLastErrorMessage(std::string & sErrorMessage) override; 54 | 55 | void ClearErrorMessages() override; 56 | 57 | void RegisterErrorMessage(const std::string & sErrorMessage) override; 58 | 59 | void IncRefCount() override; 60 | 61 | bool DecRefCount() override; 62 | 63 | 64 | /** 65 | * Public member functions to implement. 66 | */ 67 | 68 | }; 69 | 70 | } // namespace Impl 71 | } // namespace OptClass 72 | 73 | #endif // __OPTCLASS_BASE 74 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Pascal/Interfaces/optclass.lpr: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated Pascal project file in order to allow easy 9 | development of Optional Class Library. 10 | 11 | Interface version: 1.0.0 12 | 13 | *) 14 | 15 | {$MODE DELPHI} 16 | library optclass; 17 | 18 | uses 19 | {$IFDEF UNIX} 20 | cthreads, 21 | {$ENDIF UNIX} 22 | syncobjs, 23 | optclass_types, 24 | optclass_exports, 25 | Classes, 26 | sysutils; 27 | 28 | exports 29 | optclass_acquireinstance, 30 | optclass_releaseinstance, 31 | optclass_getversion, 32 | optclass_getlasterror, 33 | optclass_setjournal, 34 | optclass_createinstancewithname, 35 | optclass_findinstancea, 36 | optclass_findinstanceb, 37 | optclass_useinstancemaybe; 38 | 39 | begin 40 | 41 | end. 42 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Pascal/Interfaces/optclass_interfaces.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated Pascal interface definition file in order to allow easy 9 | development of Optional Class Library. The functions in this file need to be implemented. It needs to be generated only once. 10 | 11 | Interface version: 1.0.0 12 | 13 | *) 14 | 15 | {$MODE DELPHI} 16 | {$INTERFACES CORBA} 17 | unit optclass_interfaces; 18 | 19 | interface 20 | 21 | uses 22 | optclass_types, 23 | Classes, 24 | sysutils; 25 | 26 | 27 | type 28 | 29 | (************************************************************************************************************************* 30 | Interface definition for Base 31 | **************************************************************************************************************************) 32 | 33 | IOptClassBase = interface 34 | ['{52FDFC07-2182-454F-963F-5F0F9A621D72}'] 35 | 36 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 37 | procedure ClearErrorMessages(); 38 | procedure RegisterErrorMessage(const AErrorMessage: String); 39 | procedure IncRefCount(); 40 | function DecRefCount(): Boolean; 41 | end; 42 | 43 | implementation 44 | 45 | end. 46 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Pascal/Interfaces/optclass_types.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 7 | 8 | Abstract: This is an autogenerated Pascal type definition file in order to allow easy 9 | development of Optional Class Library. The functions in this file need to be implemented. It needs to be generated only once. 10 | 11 | Interface version: 1.0.0 12 | 13 | *) 14 | 15 | {$MODE DELPHI} 16 | unit optclass_types; 17 | 18 | interface 19 | 20 | uses 21 | Classes, 22 | sysutils; 23 | 24 | (************************************************************************************************************************* 25 | Version definition for OptClass 26 | **************************************************************************************************************************) 27 | 28 | const 29 | OPTCLASS_VERSION_MAJOR = 1; 30 | OPTCLASS_VERSION_MINOR = 0; 31 | OPTCLASS_VERSION_MICRO = 0; 32 | OPTCLASS_VERSION_PRERELEASEINFO = ''; 33 | OPTCLASS_VERSION_BUILDINFO = ''; 34 | 35 | 36 | (************************************************************************************************************************* 37 | General type definitions 38 | **************************************************************************************************************************) 39 | 40 | type 41 | TOptClassResult = Cardinal; 42 | TOptClassHandle = Pointer; 43 | 44 | POptClassResult = ^TOptClassResult; 45 | POptClassHandle = ^TOptClassHandle; 46 | 47 | (************************************************************************************************************************* 48 | Error Constants for OptClass 49 | **************************************************************************************************************************) 50 | 51 | const 52 | OPTCLASS_SUCCESS = 0; 53 | OPTCLASS_ERROR_NOTIMPLEMENTED = 1; 54 | OPTCLASS_ERROR_INVALIDPARAM = 2; 55 | OPTCLASS_ERROR_INVALIDCAST = 3; 56 | OPTCLASS_ERROR_BUFFERTOOSMALL = 4; 57 | OPTCLASS_ERROR_GENERICEXCEPTION = 5; 58 | OPTCLASS_ERROR_COULDNOTLOADLIBRARY = 6; 59 | OPTCLASS_ERROR_COULDNOTFINDLIBRARYEXPORT = 7; 60 | OPTCLASS_ERROR_INCOMPATIBLEBINARYVERSION = 8; 61 | 62 | 63 | implementation 64 | 65 | end. 66 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Pascal/Stub/optclass_impl_base.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 ACT Developers 4 | 5 | 6 | Abstract: This is the class declaration of TOptClassBase 7 | 8 | *) 9 | 10 | {$MODE DELPHI} 11 | unit optclass_impl_base; 12 | 13 | interface 14 | 15 | uses 16 | optclass_types, 17 | optclass_interfaces, 18 | optclass_exception, 19 | Classes, 20 | sysutils; 21 | 22 | type 23 | TOptClassBase = class(TObject, IOptClassBase) 24 | private 25 | FMessages: TStringList; 26 | FReferenceCount: integer; 27 | 28 | protected 29 | 30 | public 31 | constructor Create(); 32 | destructor Destroy(); override; 33 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 34 | procedure ClearErrorMessages(); 35 | procedure RegisterErrorMessage(const AErrorMessage: String); 36 | procedure IncRefCount(); 37 | function DecRefCount(): Boolean; 38 | end; 39 | 40 | implementation 41 | 42 | constructor TOptClassBase.Create(); 43 | begin 44 | inherited Create(); 45 | FMessages := TStringList.Create(); 46 | FReferenceCount := 1; 47 | end; 48 | 49 | destructor TOptClassBase.Destroy(); 50 | begin 51 | FreeAndNil(FMessages); 52 | inherited Destroy(); 53 | end; 54 | 55 | function TOptClassBase.GetLastErrorMessage(out AErrorMessage: String): Boolean; 56 | begin 57 | result := (FMessages.Count>0); 58 | if (result) then 59 | AErrorMessage := FMessages[FMessages.Count-1]; 60 | end; 61 | 62 | procedure TOptClassBase.ClearErrorMessages(); 63 | begin 64 | FMessages.Clear(); 65 | end; 66 | 67 | procedure TOptClassBase.RegisterErrorMessage(const AErrorMessage: String); 68 | begin 69 | FMessages.Clear(); 70 | FMessages.Add(AErrorMessage); 71 | end; 72 | 73 | procedure TOptClassBase.IncRefCount(); 74 | begin 75 | inc(FReferenceCount); 76 | end; 77 | 78 | function TOptClassBase.DecRefCount(): Boolean; 79 | begin 80 | dec(FReferenceCount); 81 | if (FReferenceCount = 0) then begin 82 | result := true; 83 | self.Destroy(); 84 | end; 85 | result := false; 86 | end; 87 | 88 | end. 89 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/Implementations/Pascal/optclass.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | optclass_acquireinstance 3 | optclass_releaseinstance 4 | optclass_getversion 5 | optclass_getlasterror 6 | optclass_setjournal 7 | optclass_createinstancewithname 8 | optclass_findinstancea 9 | optclass_findinstanceb 10 | optclass_useinstancemaybe 11 | -------------------------------------------------------------------------------- /Examples/OptionalClass/OptClass_component/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2019 ACT Developers 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Examples/OptionalClass/Readme.md: -------------------------------------------------------------------------------- 1 | # ![ACT logo](../../Documentation/images/ACT_logo_50px.png) Automatic Component Toolkit 2 | 3 | ## Example: Usage of the `optionalclass`-parameter 4 | 5 | This example demonstrates the usage of the `optionalclass`-parameter. 6 | The OptClass-component implements an instance of a map from string to instances of a class. It is not a usefull component, and held deliberatively small to focus on the usage of the `optionalclass`-parameter. 7 | 8 | 1. Run ACT for `OptionalClass.xml` (optional, this repo already contains autogenerated sources) 9 | 2. Build the implementations: 10 | 1. C++ 11 | 2. Pascal 12 | 3. Build and run one of the following examples 13 | 1. CppDynamic 14 | 2. Cpp 15 | 3. Pascal 16 | 4. Python 17 | 5. Golang (rename files to \*.go from \*._go) 18 | 19 | -------------------------------------------------------------------------------- /Examples/Primes/.gitignore: -------------------------------------------------------------------------------- 1 | LibPrimes_component 2 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/CDynamic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMake Project that demonstrates the 10 | usage of the C bindings of Prime Numbers Library 11 | 12 | Interface version: 1.2.0 13 | 14 | 15 | ]] 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | set(CMAKE_CURRENT_BINDING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Bindings/CDynamic) 20 | 21 | project(LibPrimesExample_CDynamic C) 22 | 23 | SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINDING_DIR}/libprimes_dynamic.cc" PROPERTIES LANGUAGE C) 24 | add_executable(LibPrimesExample_CDynamic 25 | "${CMAKE_CURRENT_SOURCE_DIR}/LibPrimes_example.c" 26 | "${CMAKE_CURRENT_BINDING_DIR}/libprimes_dynamic.cc" 27 | 28 | ) 29 | set_property(TARGET LibPrimesExample_CDynamic PROPERTY C_STANDARD 99) 30 | if (UNIX) 31 | target_link_libraries(LibPrimesExample_CDynamic ${CMAKE_DL_LIBS}) 32 | endif (UNIX) 33 | target_include_directories(LibPrimesExample_CDynamic PRIVATE "${CMAKE_CURRENT_BINDING_DIR}") 34 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/CDynamic/LibPrimes_example.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C application that demonstrates the 10 | usage of the C bindings of Prime Numbers Library 11 | 12 | Interface version: 1.2.0 13 | 14 | */ 15 | 16 | #include 17 | #include "libprimes_dynamic.h" 18 | 19 | 20 | void releaseWrapper(sLibPrimesDynamicWrapperTable* pWrapperTable) { 21 | LibPrimesResult eResult = ReleaseLibPrimesWrapperTable(pWrapperTable); 22 | printf_s("Failed releasing wrapper table\n"); 23 | } 24 | 25 | int main() 26 | { 27 | // TODO: put a path the LibPrimes-library file here. 28 | const char* libpath = ""; 29 | sLibPrimesDynamicWrapperTable sWrapperTable; 30 | LibPrimesResult eResult = LIBPRIMES_SUCCESS; 31 | 32 | eResult = InitLibPrimesWrapperTable(&sWrapperTable); 33 | if (LIBPRIMES_SUCCESS != eResult) { 34 | printf_s("Failed initializing wrapper table\n"); 35 | return eResult; 36 | } 37 | 38 | eResult = LoadLibPrimesWrapperTable(&sWrapperTable, libpath); 39 | if (LIBPRIMES_SUCCESS != eResult) { 40 | printf_s("Failed loading libprimes-binary\n"); 41 | return eResult; 42 | } 43 | LibPrimes_uint32 nMajor, nMinor, nMicro; 44 | eResult = sWrapperTable.m_GetVersion(&nMajor, &nMinor, &nMicro); 45 | if (LIBPRIMES_SUCCESS != eResult) { 46 | printf_s("Failed to get version\n"); 47 | releaseWrapper(&sWrapperTable); 48 | return eResult; 49 | } 50 | printf_s("LibPrimes.Version = %d.%d.%d", nMajor, nMinor, nMicro); 51 | 52 | printf_s("\n"); 53 | 54 | eResult = ReleaseLibPrimesWrapperTable(&sWrapperTable); 55 | if (LIBPRIMES_SUCCESS != eResult) { 56 | printf_s("Failed releasing wrapper table\n"); 57 | return eResult; 58 | } 59 | 60 | return 0; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/CSharp/LibPrimes_Example.cs: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CSharp application that demonstrates the 10 | usage of the CSharp bindings of Prime Numbers Library 11 | 12 | Interface version: 1.2.0 13 | 14 | */ 15 | 16 | 17 | using System; 18 | namespace LibPrimes_Example 19 | { 20 | class LibPrimes_Example 21 | { 22 | static void Main() 23 | { 24 | try 25 | { 26 | UInt32 nMajor, nMinor, nMicro; 27 | LibPrimes.Wrapper.GetVersion(out nMajor, out nMinor, out nMicro); 28 | string versionString = string.Format("LibPrimes.version = {0}.{1}.{2}", nMajor, nMinor, nMicro); 29 | Console.WriteLine(versionString); 30 | 31 | LibPrimes.CFactorizationCalculator factorization = LibPrimes.Wrapper.CreateFactorizationCalculator(); 32 | factorization.SetValue(735); 33 | factorization.Calculate(); 34 | LibPrimes.sPrimeFactor[] aPrimeFactors; 35 | factorization.GetPrimeFactors(out aPrimeFactors); 36 | 37 | Console.Write(string.Format("{0} = 1 ", factorization.GetValue())); 38 | foreach (LibPrimes.sPrimeFactor pF in aPrimeFactors) 39 | { 40 | Console.Write(string.Format("* {0}^{1} ", pF.Prime, pF.Multiplicity)); 41 | } 42 | Console.WriteLine(); 43 | } 44 | catch (Exception e) 45 | { 46 | Console.WriteLine("Exception: " + e.Message); 47 | } 48 | Console.WriteLine("Press any key to exit."); 49 | Console.ReadKey(); 50 | } 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/CSharp/LibPrimes_Example.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | LibPrimes_Example.LibPrimes_Example 7 | 8 | x64 9 | 10 | 11 | true 12 | 13 | 14 | true 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/CSharp/LibPrimes_Example.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 15 3 | VisualStudioVersion = 15.0.28307.539 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibPrimes_Example", "LibPrimes_Example.csproj", "{CC8B08F1-CA5B-4AE4-BACC-74B5119FC89A}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|x64 = Debug|x64 10 | Release|x64 = Release|x64 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {CC8B08F1-CA5B-4AE4-BACC-74B5119FC89A}.Debug|x64.ActiveCfg = Debug|x64 14 | {CC8B08F1-CA5B-4AE4-BACC-74B5119FC89A}.Debug|x64.Build.0 = Debug|x64 15 | {CC8B08F1-CA5B-4AE4-BACC-74B5119FC89A}.Release|x64.ActiveCfg = Release|x64 16 | {CC8B08F1-CA5B-4AE4-BACC-74B5119FC89A}.Release|x64.Build.0 = Release|x64 17 | EndGlobalSection 18 | GlobalSection(SolutionProperties) = preSolution 19 | HideSolutionNode = FALSE 20 | EndGlobalSection 21 | GlobalSection(ExtensibilityGlobals) = postSolution 22 | SolutionGuid = 2785aa7c-3a04-4e15-9e14-3090c14a4ca3 23 | EndGlobalSection 24 | EndGlobal 25 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMake Project that demonstrates the 10 | usage of the C++ bindings of Prime Numbers Library 11 | 12 | Interface version: 1.0.0 13 | 14 | 15 | ]] 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | project(LibPrimesExample_CPPImplicit) 20 | set(CMAKE_CXX_STANDARD 11) 21 | add_executable(LibPrimesExample_CPPImplicit "${CMAKE_CURRENT_SOURCE_DIR}/LibPrimes_example.cpp") 22 | find_library(LIBPRIMESLOCATION libprimes "${CMAKE_CURRENT_SOURCE_DIR}/../../Implementations/*/*/*") 23 | target_link_libraries(LibPrimesExample_CPPImplicit ${LIBPRIMESLOCATION}) 24 | target_include_directories(LibPrimesExample_CPPImplicit PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../Bindings/Cpp") 25 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/Cpp/LibPrimes_example.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ application that demonstrates the 10 | usage of the C++ bindings of Prime Numbers Library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include 17 | #include "libprimes_implicit.hpp" 18 | 19 | void progressCallback(LibPrimes_single progress, bool* shouldAbort) 20 | { 21 | std::cout << "Progress = " << std::round(progress * 100) << "%" << std::endl; 22 | if (shouldAbort) { 23 | *shouldAbort = progress > 0.5; 24 | } 25 | } 26 | 27 | int main() 28 | { 29 | try 30 | { 31 | auto wrapper = LibPrimes::CWrapper::loadLibrary(); 32 | wrapper->SetJournal("journal_cpp.xml"); 33 | LibPrimes_uint32 nMajor, nMinor, nMicro; 34 | wrapper->GetVersion(nMajor, nMinor, nMicro); 35 | std::cout << "LibPrimes.Version = " << nMajor << "." << nMinor << "." << nMicro; 36 | std::cout << std::endl; 37 | 38 | auto factorization = wrapper->CreateFactorizationCalculator(); 39 | factorization->SetValue(735); 40 | factorization->SetProgressCallback(progressCallback); 41 | factorization->Calculate(); 42 | std::vector primeFactors; 43 | factorization->GetPrimeFactors(primeFactors); 44 | 45 | std::cout << factorization->GetValue() << " = "; 46 | for (size_t i = 0; i < primeFactors.size(); i++) { 47 | auto pF = primeFactors[i]; 48 | std::cout << pF.m_Prime << "^" << pF.m_Multiplicity << ((i < (primeFactors.size() - 1)) ? " * " : ""); 49 | } 50 | std::cout << std::endl; 51 | } 52 | catch (std::exception &e) 53 | { 54 | std::cout << e.what() << std::endl; 55 | return 1; 56 | } 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/CppDynamic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMake Project that demonstrates the 10 | usage of the Dynamic C++ bindings of Prime Numbers Library 11 | 12 | Interface version: 1.2.0 13 | 14 | 15 | ]] 16 | 17 | cmake_minimum_required(VERSION 3.5) 18 | 19 | set(CMAKE_CURRENT_BINDING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Bindings/CppDynamic) 20 | project(LibPrimesExample_CPPDynamic) 21 | set(CMAKE_CXX_STANDARD 11) 22 | add_executable(LibPrimesExample_CPPDynamic "${CMAKE_CURRENT_SOURCE_DIR}/LibPrimes_example.cpp") 23 | if (UNIX) 24 | target_link_libraries(LibPrimesExample_CPPDynamic ${CMAKE_DL_LIBS}) 25 | endif (UNIX) 26 | target_include_directories(LibPrimesExample_CPPDynamic PRIVATE "${CMAKE_CURRENT_BINDING_DIR}") 27 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/CppDynamic/LibPrimes_example.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0 8 | 9 | Abstract: This is an autogenerated C++ application that demonstrates the 10 | usage of the Dynamic C++ bindings of Prime Numbers Library 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include 17 | #include "libprimes_dynamic.hpp" 18 | #include 19 | 20 | void progressCallback(LibPrimes_single progress, bool* shouldAbort) 21 | { 22 | std::cout << "Progress = " << std::round(progress * 100) << "%" << std::endl; 23 | if (shouldAbort) { 24 | *shouldAbort = progress > 0.5; 25 | } 26 | } 27 | 28 | int main() 29 | { 30 | try 31 | { 32 | std::string libpath = ("D:/PUBLIC/AutomaticComponentToolkit/Examples/Primes/LibPrimes_component/Implementations/Cpp/_build/Debug"); // TODO: put the location of the LibPrimes-library file here. 33 | auto wrapper = LibPrimes::CWrapper::loadLibrary(libpath + "/libprimes.dll"); // TODO: add correct suffix of the library 34 | wrapper->SetJournal("journal_cppdynamic.xml"); 35 | LibPrimes_uint32 nMajor, nMinor, nMicro; 36 | wrapper->GetVersion(nMajor, nMinor, nMicro); 37 | std::cout << "LibPrimes.Version = " << nMajor << "." << nMinor << "." << nMicro; 38 | std::cout << std::endl; 39 | 40 | auto factorization = wrapper->CreateFactorizationCalculator(); 41 | factorization->SetValue(735); 42 | factorization->SetProgressCallback(progressCallback); 43 | factorization->Calculate(); 44 | std::vector primeFactors; 45 | factorization->GetPrimeFactors(primeFactors); 46 | 47 | std::cout << factorization->GetValue() << " = "; 48 | for (size_t i = 0; i < primeFactors.size(); i++) { 49 | auto pF = primeFactors[i]; 50 | std::cout << pF.m_Prime << "^" << pF.m_Multiplicity << ((i < (primeFactors.size() - 1)) ? " * " : ""); 51 | } 52 | std::cout << std::endl; 53 | } 54 | catch (std::exception &e) 55 | { 56 | std::cout << e.what() << std::endl; 57 | return 1; 58 | } 59 | return 0; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/Pascal/LibPrimes_Example.lpr: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal application that demonstrates the 10 | usage of the Pascal bindings of Prime Numbers Library 11 | 12 | Interface version: 1.2.0 13 | 14 | *) 15 | 16 | program LibPrimesPascalTest; 17 | 18 | uses 19 | {$IFDEF UNIX}{$IFDEF UseCThreads} 20 | cthreads, 21 | {$ENDIF}{$ENDIF} 22 | Classes, SysUtils, CustApp, 23 | Unit_LibPrimes 24 | { you can add units after this }; 25 | 26 | type 27 | 28 | TLibPrimes_Example = class(TCustomApplication) 29 | protected 30 | procedure DoRun; override; 31 | procedure TestLibPrimes (); 32 | public 33 | constructor Create(TheOwner: TComponent); override; 34 | destructor Destroy; override; 35 | end; 36 | 37 | 38 | procedure TLibPrimes_Example.TestLibPrimes (); 39 | var 40 | ALibPrimesWrapper: TLibPrimesWrapper; 41 | AMajor, AMinor, AMicro: Cardinal; 42 | AVersionString: string; 43 | ALibPath: string; 44 | begin 45 | writeln ('loading DLL'); 46 | ALibPath := ''; // TODO add the location of the shared library binary here 47 | ALibPrimesWrapper := TLibPrimesWrapper.Create (ALibPath + '/' + 'libprimes.'); // TODO add the extension of the shared library file here 48 | try 49 | writeln ('loading DLL Done'); 50 | ALibPrimesWrapper.GetVersion(AMajor, AMinor, AMicro); 51 | AVersionString := Format('LibPrimes.version = %d.%d.%d', [AMajor, AMinor, AMicro]); 52 | writeln(AVersionString); 53 | finally 54 | FreeAndNil(ALibPrimesWrapper); 55 | end; 56 | end; 57 | 58 | procedure TLibPrimes_Example.DoRun; 59 | begin 60 | try 61 | TestLibPrimes(); 62 | except 63 | On E: Exception do 64 | writeln ('Fatal error: ', E.Message); 65 | end; 66 | Terminate 67 | end; 68 | 69 | constructor TLibPrimes_Example.Create(TheOwner: TComponent); 70 | begin 71 | inherited Create(TheOwner); 72 | StopOnException:=True; 73 | end; 74 | 75 | destructor TLibPrimes_Example.Destroy; 76 | begin 77 | inherited Destroy; 78 | end; 79 | 80 | 81 | var 82 | Application: TLibPrimes_Example; 83 | begin 84 | Application:=TLibPrimes_Example.Create(nil); 85 | Application.Run; 86 | Application.Free; 87 | end. 88 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Examples/Python/LibPrimes_Example.py: -------------------------------------------------------------------------------- 1 | '''++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Python application that demonstrates the 10 | usage of the Python bindings of Prime Numbers Library 11 | 12 | Interface version: 1.0.0 13 | 14 | ''' 15 | 16 | 17 | import os 18 | import sys 19 | sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "Bindings", "Python")) 20 | import LibPrimes 21 | 22 | def progressCallback(progress, shouldAbort): 23 | print("Progress = {:d}%".format(round(progress*100))) 24 | if (shouldAbort is not None): 25 | shouldAbort[0] = progress > 0.5 26 | 27 | def main(): 28 | libpath = '' # TODO add the location of the shared library binary here 29 | wrapper = LibPrimes.Wrapper(os.path.join(libpath, "libprimes")) 30 | wrapper.SetJournal('journal_python.xml') 31 | major, minor, micro = wrapper.GetVersion() 32 | print("LibPrimes version: {:d}.{:d}.{:d}".format(major, minor, micro), end="") 33 | print("") 34 | 35 | factorization = wrapper.CreateFactorizationCalculator() 36 | factorization.SetValue(735) 37 | cTypesCallback = LibPrimes.ProgressCallback(progressCallback) 38 | factorization.SetProgressCallback(cTypesCallback) 39 | factorization.Calculate() 40 | primeFactors = factorization.GetPrimeFactors() 41 | productString = "*" 42 | print("{:d} = ".format(factorization.GetValue()), end="") 43 | for i in range(0, len(primeFactors)): 44 | pF = primeFactors[i] 45 | if i == len(primeFactors) - 1: 46 | productString = "\n" 47 | print(" {:d}^{:d} ".format(pF.Prime, pF.Multiplicity), end=productString) 48 | 49 | 50 | if __name__ == "__main__": 51 | try: 52 | main() 53 | except LibPrimes.ELibPrimesException as e: 54 | print(e) 55 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[[++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated CMakeLists file for the development of Prime Numbers Library. 10 | 11 | Interface version: 1.0.0 12 | 13 | 14 | ]] 15 | 16 | cmake_minimum_required(VERSION 3.5) 17 | 18 | ### The implementation of the Prime Numbers Library component 19 | project(LibPrimes) 20 | 21 | set (CMAKE_CXX_STANDARD 11) 22 | 23 | # The location of autogenerated interfaces 24 | set(CMAKE_CURRENT_AUTOGENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces) 25 | 26 | file(GLOB LIBPRIMES_SRC 27 | ${CMAKE_CURRENT_SOURCE_DIR}/Stub/*.cpp 28 | ) 29 | file(GLOB LIBPRIMES_HDR 30 | ${CMAKE_CURRENT_SOURCE_DIR}/Stub/*.hpp 31 | ) 32 | set(LIBPRIMES_SRC ${LIBPRIMES_SRC} ${LIBPRIMES_SRC} 33 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/libprimes_interfaceexception.cpp 34 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/libprimes_interfacewrapper.cpp 35 | ${CMAKE_CURRENT_AUTOGENERATED_DIR}/libprimes_interfacejournal.cpp 36 | ) 37 | 38 | add_library(libprimes SHARED ${LIBPRIMES_SRC}) 39 | # Do not prefix the binary's name with "lib" on Unix systems: 40 | set_target_properties(libprimes PROPERTIES PREFIX "" IMPORT_PREFIX "" ) 41 | # The following two properties are crucial to reduce the number of undesirably exported symbols 42 | set_target_properties(libprimes PROPERTIES CXX_VISIBILITY_PRESET hidden) 43 | set_target_properties(libprimes PROPERTIES VISIBILITY_INLINES_HIDDEN ON) 44 | # This makes sure symbols are exported 45 | target_compile_options(libprimes PRIVATE "-D__LIBPRIMES_EXPORTS") 46 | target_include_directories(libprimes PRIVATE ${CMAKE_CURRENT_AUTOGENERATED_DIR}) 47 | target_include_directories(libprimes PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Stub) 48 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Interfaces/libprimes_interfaceexception.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ Implementation file with the basic internal 10 | exception type in order to allow an easy use of Prime Numbers Library 11 | 12 | Interface version: 1.2.0 13 | 14 | */ 15 | 16 | 17 | #include 18 | 19 | #include "libprimes_interfaceexception.hpp" 20 | 21 | /************************************************************************************************************************* 22 | Class ELibPrimesInterfaceException 23 | **************************************************************************************************************************/ 24 | ELibPrimesInterfaceException::ELibPrimesInterfaceException(LibPrimesResult errorCode) 25 | : m_errorMessage("LibPrimes Error " + std::to_string (errorCode)) 26 | { 27 | m_errorCode = errorCode; 28 | } 29 | 30 | ELibPrimesInterfaceException::ELibPrimesInterfaceException(LibPrimesResult errorCode, std::string errorMessage) 31 | : m_errorMessage(errorMessage + " (" + std::to_string (errorCode) + ")") 32 | { 33 | m_errorCode = errorCode; 34 | } 35 | 36 | LibPrimesResult ELibPrimesInterfaceException::getErrorCode () 37 | { 38 | return m_errorCode; 39 | } 40 | 41 | const char * ELibPrimesInterfaceException::what () const noexcept 42 | { 43 | return m_errorMessage.c_str(); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Interfaces/libprimes_interfaceexception.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ Header file with the basic internal 10 | exception type in order to allow an easy use of Prime Numbers Library 11 | 12 | Interface version: 1.2.0 13 | 14 | */ 15 | 16 | #ifndef __LIBPRIMES_INTERFACEEXCEPTION_HEADER 17 | #define __LIBPRIMES_INTERFACEEXCEPTION_HEADER 18 | 19 | #include 20 | #include 21 | #include "libprimes_types.hpp" 22 | 23 | /************************************************************************************************************************* 24 | Class ELibPrimesInterfaceException 25 | **************************************************************************************************************************/ 26 | 27 | 28 | class ELibPrimesInterfaceException : public std::exception { 29 | protected: 30 | /** 31 | * Error code for the Exception. 32 | */ 33 | LibPrimesResult m_errorCode; 34 | /** 35 | * Error message for the Exception. 36 | */ 37 | std::string m_errorMessage; 38 | 39 | public: 40 | /** 41 | * Exception Constructor. 42 | */ 43 | ELibPrimesInterfaceException(LibPrimesResult errorCode); 44 | 45 | /** 46 | * Custom Exception Constructor. 47 | */ 48 | ELibPrimesInterfaceException(LibPrimesResult errorCode, std::string errorMessage); 49 | 50 | /** 51 | * Returns error code 52 | */ 53 | LibPrimesResult getErrorCode(); 54 | /** 55 | * Returns error message 56 | */ 57 | const char* what() const noexcept override; 58 | }; 59 | 60 | #endif // __LIBPRIMES_INTERFACEEXCEPTION_HEADER 61 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated C++ implementation file in order to allow easy 10 | development of Prime Numbers Library. It needs to be generated only once. 11 | 12 | Interface version: 1.0.0 13 | 14 | */ 15 | 16 | #include "libprimes_abi.hpp" 17 | #include "libprimes_interfaces.hpp" 18 | #include "libprimes_interfaceexception.hpp" 19 | 20 | #include "libprimes_factorizationcalculator.hpp" 21 | #include "libprimes_sievecalculator.hpp" 22 | 23 | using namespace LibPrimes; 24 | using namespace LibPrimes::Impl; 25 | 26 | void CWrapper::GetVersion(LibPrimes_uint32 & nMajor, LibPrimes_uint32 & nMinor, LibPrimes_uint32 & nMicro) 27 | { 28 | nMajor = LIBPRIMES_VERSION_MAJOR; 29 | nMinor = LIBPRIMES_VERSION_MINOR; 30 | nMicro = LIBPRIMES_VERSION_MICRO; 31 | } 32 | 33 | bool CWrapper::GetLastError(IBase* pInstance, std::string & sErrorMessage) 34 | { 35 | return pInstance->GetLastErrorMessage(sErrorMessage); 36 | } 37 | 38 | IFactorizationCalculator * CWrapper::CreateFactorizationCalculator() 39 | { 40 | return new CFactorizationCalculator(); 41 | } 42 | 43 | ISieveCalculator * CWrapper::CreateSieveCalculator() 44 | { 45 | return new CSieveCalculator(); 46 | } 47 | 48 | void CWrapper::AcquireInstance(IBase* pInstance) 49 | { 50 | IBase::AcquireBaseClassInterface(pInstance); 51 | } 52 | 53 | void CWrapper::ReleaseInstance(IBase* pInstance) 54 | { 55 | IBase::ReleaseBaseClassInterface(pInstance); 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes_base.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CBase 8 | 9 | */ 10 | 11 | #include "libprimes_base.hpp" 12 | #include "libprimes_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace LibPrimes::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CBase 21 | **************************************************************************************************************************/ 22 | 23 | bool CBase::GetLastErrorMessage(std::string & sErrorMessage) 24 | { 25 | if (m_pErrors && !m_pErrors->empty()) { 26 | sErrorMessage = m_pErrors->back(); 27 | return true; 28 | } else { 29 | sErrorMessage = ""; 30 | return false; 31 | } 32 | } 33 | 34 | void CBase::ClearErrorMessages() 35 | { 36 | m_pErrors.reset(); 37 | } 38 | 39 | void CBase::RegisterErrorMessage(const std::string & sErrorMessage) 40 | { 41 | if (!m_pErrors) { 42 | m_pErrors.reset(new std::list()); 43 | } 44 | m_pErrors->clear(); 45 | m_pErrors->push_back(sErrorMessage); 46 | } 47 | 48 | void CBase::IncRefCount() 49 | { 50 | ++m_nReferenceCount; 51 | } 52 | 53 | bool CBase::DecRefCount() 54 | { 55 | m_nReferenceCount--; 56 | if (!m_nReferenceCount) { 57 | delete this; 58 | return true; 59 | } 60 | return false; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes_base.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CBase 8 | 9 | */ 10 | 11 | 12 | #ifndef __LIBPRIMES_BASE 13 | #define __LIBPRIMES_BASE 14 | 15 | #include "libprimes_interfaces.hpp" 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // Include custom headers here. 22 | 23 | 24 | namespace LibPrimes { 25 | namespace Impl { 26 | 27 | 28 | /************************************************************************************************************************* 29 | Class declaration of CBase 30 | **************************************************************************************************************************/ 31 | 32 | class CBase : public virtual IBase { 33 | private: 34 | 35 | std::unique_ptr> m_pErrors; 36 | LibPrimes_uint32 m_nReferenceCount = 1; 37 | 38 | /** 39 | * Put private members here. 40 | */ 41 | 42 | protected: 43 | 44 | /** 45 | * Put protected members here. 46 | */ 47 | 48 | public: 49 | 50 | /** 51 | * Put additional public members here. They will not be visible in the external API. 52 | */ 53 | 54 | bool GetLastErrorMessage(std::string & sErrorMessage) override; 55 | 56 | void ClearErrorMessages() override; 57 | 58 | void RegisterErrorMessage(const std::string & sErrorMessage) override; 59 | 60 | void IncRefCount() override; 61 | 62 | bool DecRefCount() override; 63 | 64 | 65 | /** 66 | * Public member functions to implement. 67 | */ 68 | 69 | }; 70 | 71 | } // namespace Impl 72 | } // namespace LibPrimes 73 | 74 | #endif // __LIBPRIMES_BASE 75 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes_calculator.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CCalculator 8 | 9 | */ 10 | 11 | #include "libprimes_calculator.hpp" 12 | #include "libprimes_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace LibPrimes::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CCalculator 21 | **************************************************************************************************************************/ 22 | 23 | LibPrimes_uint64 CCalculator::GetValue() 24 | { 25 | return m_value; 26 | } 27 | 28 | void CCalculator::SetValue(const LibPrimes_uint64 nValue) 29 | { 30 | m_value = nValue; 31 | } 32 | 33 | void CCalculator::Calculate() 34 | { 35 | throw ELibPrimesInterfaceException(LIBPRIMES_ERROR_NOTIMPLEMENTED); 36 | } 37 | 38 | void CCalculator::SetProgressCallback(const LibPrimes::ProgressCallback pProgressCallback) 39 | { 40 | m_Callback = pProgressCallback; 41 | } 42 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes_calculator.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CCalculator 8 | 9 | */ 10 | 11 | 12 | #ifndef __LIBPRIMES_CALCULATOR 13 | #define __LIBPRIMES_CALCULATOR 14 | 15 | #include "libprimes_interfaces.hpp" 16 | 17 | // Parent classes 18 | #include "libprimes_base.hpp" 19 | #ifdef _MSC_VER 20 | #pragma warning(push) 21 | #pragma warning(disable : 4250) 22 | #endif 23 | 24 | // Include custom headers here. 25 | 26 | 27 | namespace LibPrimes { 28 | namespace Impl { 29 | 30 | 31 | /************************************************************************************************************************* 32 | Class declaration of CCalculator 33 | **************************************************************************************************************************/ 34 | 35 | class CCalculator : public virtual ICalculator, public virtual CBase { 36 | private: 37 | 38 | /** 39 | * Put private members here. 40 | */ 41 | 42 | protected: 43 | 44 | /** 45 | * Put protected members here. 46 | */ 47 | LibPrimes_uint64 m_value; 48 | ProgressCallback m_Callback; 49 | public: 50 | 51 | /** 52 | * Put additional public members here. They will not be visible in the external API. 53 | */ 54 | 55 | 56 | /** 57 | * Public member functions to implement. 58 | */ 59 | 60 | LibPrimes_uint64 GetValue() override; 61 | 62 | void SetValue(const LibPrimes_uint64 nValue) override; 63 | 64 | void Calculate() override; 65 | 66 | void SetProgressCallback(const ProgressCallback pProgressCallback) override; 67 | 68 | }; 69 | 70 | } // namespace Impl 71 | } // namespace LibPrimes 72 | 73 | #ifdef _MSC_VER 74 | #pragma warning(pop) 75 | #endif 76 | #endif // __LIBPRIMES_CALCULATOR 77 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes_factorizationcalculator.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CFactorizationCalculator 8 | 9 | */ 10 | 11 | #include "libprimes_factorizationcalculator.hpp" 12 | #include "libprimes_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | 16 | 17 | using namespace LibPrimes::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CFactorizationCalculator 21 | **************************************************************************************************************************/ 22 | 23 | void CFactorizationCalculator::GetPrimeFactors(LibPrimes_uint64 nPrimeFactorsBufferSize, LibPrimes_uint64* pPrimeFactorsNeededCount, LibPrimes::sPrimeFactor * pPrimeFactorsBuffer) 24 | { 25 | if (primeFactors.size() == 0) 26 | throw ELibPrimesInterfaceException(LIBPRIMES_ERROR_NORESULTAVAILABLE); 27 | 28 | if (pPrimeFactorsNeededCount) 29 | *pPrimeFactorsNeededCount = (LibPrimes_uint64)primeFactors.size(); 30 | 31 | if (nPrimeFactorsBufferSize >= primeFactors.size() && pPrimeFactorsBuffer) 32 | { 33 | for (int i = 0; i < primeFactors.size(); i++) 34 | { 35 | pPrimeFactorsBuffer[i] = primeFactors[i]; 36 | } 37 | } 38 | } 39 | 40 | void CFactorizationCalculator::Calculate() 41 | { 42 | primeFactors.clear(); 43 | 44 | LibPrimes_uint64 nValue = m_value; 45 | for (LibPrimes_uint64 i = 2; i <= nValue; i++) { 46 | 47 | if (m_Callback) { 48 | bool shouldAbort = false; 49 | (*m_Callback)(1 - float(nValue) / m_value, &shouldAbort); 50 | if (shouldAbort) { 51 | throw ELibPrimesInterfaceException(LIBPRIMES_ERROR_CALCULATIONABORTED); 52 | } 53 | } 54 | 55 | sPrimeFactor primeFactor; 56 | primeFactor.m_Prime = i; 57 | primeFactor.m_Multiplicity = 0; 58 | while (nValue % i == 0) { 59 | primeFactor.m_Multiplicity++; 60 | nValue = nValue / i; 61 | } 62 | if (primeFactor.m_Multiplicity > 0) { 63 | primeFactors.push_back(primeFactor); 64 | } 65 | } 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes_factorizationcalculator.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CFactorizationCalculator 8 | 9 | */ 10 | 11 | 12 | #ifndef __LIBPRIMES_FACTORIZATIONCALCULATOR 13 | #define __LIBPRIMES_FACTORIZATIONCALCULATOR 14 | 15 | #include "libprimes_interfaces.hpp" 16 | 17 | // Parent classes 18 | #include "libprimes_calculator.hpp" 19 | #ifdef _MSC_VER 20 | #pragma warning(push) 21 | #pragma warning(disable : 4250) 22 | #endif 23 | 24 | // Include custom headers here. 25 | 26 | 27 | namespace LibPrimes { 28 | namespace Impl { 29 | 30 | 31 | /************************************************************************************************************************* 32 | Class declaration of CFactorizationCalculator 33 | **************************************************************************************************************************/ 34 | 35 | class CFactorizationCalculator : public virtual IFactorizationCalculator, public virtual CCalculator { 36 | private: 37 | 38 | /** 39 | * Put private members here. 40 | */ 41 | std::vector primeFactors; 42 | 43 | protected: 44 | 45 | /** 46 | * Put protected members here. 47 | */ 48 | 49 | public: 50 | 51 | /** 52 | * Put additional public members here. They will not be visible in the external API. 53 | */ 54 | 55 | 56 | /** 57 | * Public member functions to implement. 58 | */ 59 | 60 | void GetPrimeFactors(LibPrimes_uint64 nPrimeFactorsBufferSize, LibPrimes_uint64* pPrimeFactorsNeededCount, LibPrimes::sPrimeFactor * pPrimeFactorsBuffer) override; 61 | 62 | void Calculate() override; 63 | }; 64 | 65 | } // namespace Impl 66 | } // namespace LibPrimes 67 | 68 | #ifdef _MSC_VER 69 | #pragma warning(pop) 70 | #endif 71 | #endif // __LIBPRIMES_FACTORIZATIONCALCULATOR 72 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes_sievecalculator.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CSieveCalculator 8 | 9 | */ 10 | 11 | #include "libprimes_sievecalculator.hpp" 12 | #include "libprimes_interfaceexception.hpp" 13 | 14 | // Include custom headers here. 15 | #include 16 | 17 | using namespace LibPrimes::Impl; 18 | 19 | /************************************************************************************************************************* 20 | Class definition of CSieveCalculator 21 | **************************************************************************************************************************/ 22 | 23 | void CSieveCalculator::GetPrimes(LibPrimes_uint64 nPrimesBufferSize, LibPrimes_uint64* pPrimesNeededCount, LibPrimes_uint64 * pPrimesBuffer) 24 | { 25 | if (primes.size() == 0) 26 | throw ELibPrimesInterfaceException(LIBPRIMES_ERROR_NORESULTAVAILABLE); 27 | if (pPrimesNeededCount) 28 | *pPrimesNeededCount = (LibPrimes_uint64)primes.size(); 29 | if (nPrimesBufferSize >= primes.size() && pPrimesBuffer) 30 | { 31 | for (int i = 0; i < primes.size(); i++) 32 | { 33 | pPrimesBuffer[i] = primes[i]; 34 | } 35 | } 36 | } 37 | 38 | void CSieveCalculator::Calculate() 39 | { 40 | primes.clear(); 41 | 42 | std::vector strikenOut(m_value + 1); 43 | for (LibPrimes_uint64 i = 0; i <= m_value; i++) { 44 | strikenOut[i] = i < 2; 45 | } 46 | LibPrimes_uint64 sqrtValue = (LibPrimes_uint64)(std::sqrt(m_value)); 47 | for (LibPrimes_uint64 i = 2; i <= sqrtValue; i++) { 48 | if (!strikenOut[i]) { 49 | primes.push_back(i); 50 | for (LibPrimes_uint64 j = i * i; j < m_value; j += i) { 51 | strikenOut[j] = true; 52 | } 53 | } 54 | } 55 | for (LibPrimes_uint64 i = sqrtValue; i <= m_value; i++) { 56 | if (!strikenOut[i]) { 57 | primes.push_back(i); 58 | } 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Cpp/Stub/libprimes_sievecalculator.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CSieveCalculator 8 | 9 | */ 10 | 11 | 12 | #ifndef __LIBPRIMES_SIEVECALCULATOR 13 | #define __LIBPRIMES_SIEVECALCULATOR 14 | 15 | #include "libprimes_interfaces.hpp" 16 | 17 | // Parent classes 18 | #include "libprimes_calculator.hpp" 19 | #ifdef _MSC_VER 20 | #pragma warning(push) 21 | #pragma warning(disable : 4250) 22 | #endif 23 | 24 | // Include custom headers here. 25 | 26 | 27 | namespace LibPrimes { 28 | namespace Impl { 29 | 30 | 31 | /************************************************************************************************************************* 32 | Class declaration of CSieveCalculator 33 | **************************************************************************************************************************/ 34 | 35 | class CSieveCalculator : public virtual ISieveCalculator, public virtual CCalculator { 36 | private: 37 | 38 | /** 39 | * Put private members here. 40 | */ 41 | std::vector primes; 42 | protected: 43 | 44 | /** 45 | * Put protected members here. 46 | */ 47 | 48 | public: 49 | 50 | /** 51 | * Put additional public members here. They will not be visible in the external API. 52 | */ 53 | 54 | 55 | /** 56 | * Public member functions to implement. 57 | */ 58 | 59 | void GetPrimes(LibPrimes_uint64 nPrimesBufferSize, LibPrimes_uint64* pPrimesNeededCount, LibPrimes_uint64 * pPrimesBuffer) override; 60 | 61 | void Calculate() override; 62 | }; 63 | 64 | } // namespace Impl 65 | } // namespace LibPrimes 66 | 67 | #ifdef _MSC_VER 68 | #pragma warning(pop) 69 | #endif 70 | #endif // __LIBPRIMES_SIEVECALCULATOR 71 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Pascal/Interfaces/libprimes.lpr: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal project file in order to allow easy 10 | development of Prime Numbers Library. 11 | 12 | Interface version: 1.2.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | library libprimes; 18 | 19 | uses 20 | {$IFDEF UNIX} 21 | cthreads, 22 | {$ENDIF UNIX} 23 | syncobjs, 24 | libprimes_types, 25 | libprimes_exports, 26 | Classes, 27 | sysutils; 28 | 29 | exports 30 | libprimes_calculator_getvalue, 31 | libprimes_calculator_setvalue, 32 | libprimes_calculator_calculate, 33 | libprimes_calculator_setprogresscallback, 34 | libprimes_factorizationcalculator_getprimefactors, 35 | libprimes_sievecalculator_getprimes, 36 | libprimes_getversion, 37 | libprimes_getlasterror, 38 | libprimes_acquireinstance, 39 | libprimes_releaseinstance, 40 | libprimes_createfactorizationcalculator, 41 | libprimes_createsievecalculator, 42 | libprimes_setjournal; 43 | 44 | begin 45 | 46 | end. 47 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Pascal/Interfaces/libprimes_interfaces.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal interface definition file in order to allow easy 10 | development of Prime Numbers Library. The functions in this file need to be implemented. It needs to be generated only once. 11 | 12 | Interface version: 1.2.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | {$INTERFACES CORBA} 18 | unit libprimes_interfaces; 19 | 20 | interface 21 | 22 | uses 23 | libprimes_types, 24 | Classes, 25 | sysutils; 26 | 27 | 28 | type 29 | 30 | (************************************************************************************************************************* 31 | Interface definition for Base 32 | **************************************************************************************************************************) 33 | 34 | ILibPrimesBase = interface 35 | ['{52FDFC07-2182-454F-963F-5F0F9A621D72}'] 36 | 37 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 38 | procedure ClearErrorMessages(); 39 | procedure RegisterErrorMessage(const AErrorMessage: String); 40 | procedure IncRefCount(); 41 | function DecRefCount(): Boolean; 42 | end; 43 | 44 | 45 | (************************************************************************************************************************* 46 | Interface definition for Calculator 47 | **************************************************************************************************************************) 48 | 49 | ILibPrimesCalculator = interface(ILibPrimesBase) 50 | ['{9566C74D-1003-4C4D-BBBB-0407D1E2C649}'] 51 | 52 | function GetValue(): QWord; 53 | procedure SetValue(const AValue: QWord); 54 | procedure Calculate(); 55 | procedure SetProgressCallback(const AProgressCallback: PLibPrimes_ProgressCallback); 56 | end; 57 | 58 | 59 | (************************************************************************************************************************* 60 | Interface definition for FactorizationCalculator 61 | **************************************************************************************************************************) 62 | 63 | ILibPrimesFactorizationCalculator = interface(ILibPrimesCalculator) 64 | ['{81855AD8-681D-4D86-91E9-1E00167939CB}'] 65 | 66 | procedure GetPrimeFactors(const APrimeFactorsCount: QWord; PPrimeFactorsNeededCount: PQWord; APrimeFactors: PLibPrimesPrimeFactor); 67 | end; 68 | 69 | 70 | (************************************************************************************************************************* 71 | Interface definition for SieveCalculator 72 | **************************************************************************************************************************) 73 | 74 | ILibPrimesSieveCalculator = interface(ILibPrimesCalculator) 75 | ['{6694D2C4-22AC-4208-A007-2939487F6999}'] 76 | 77 | procedure GetPrimes(const APrimesCount: QWord; PPrimesNeededCount: PQWord; APrimes: PQWord); 78 | end; 79 | 80 | implementation 81 | 82 | end. 83 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Pascal/Stub/libprimes_impl.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0. 8 | 9 | Abstract: This is an autogenerated Pascal implementation file in order to allow easy 10 | development of Prime Numbers Library. It needs to be generated only once. 11 | 12 | Interface version: 1.2.0 13 | 14 | *) 15 | 16 | {$MODE DELPHI} 17 | Unit libprimes_impl; 18 | 19 | interface 20 | 21 | uses 22 | libprimes_types, 23 | libprimes_exception, 24 | libprimes_interfaces, 25 | libprimes_impl_factorizationcalculator, 26 | libprimes_impl_sievecalculator, 27 | Classes, 28 | sysutils; 29 | 30 | type 31 | TLibPrimesWrapper = class (TObject) 32 | public 33 | class procedure GetVersion(out AMajor: Cardinal; out AMinor: Cardinal; out AMicro: Cardinal); 34 | class function GetLastError(AInstance: TObject; out AErrorMessage: String): Boolean; 35 | class procedure AcquireInstance(AInstance: TObject); 36 | class procedure ReleaseInstance(AInstance: TObject); 37 | class function CreateFactorizationCalculator(): TObject; 38 | class function CreateSieveCalculator(): TObject; 39 | class procedure SetJournal(const AFileName: String); 40 | end; 41 | 42 | 43 | implementation 44 | 45 | class procedure TLibPrimesWrapper.GetVersion(out AMajor: Cardinal; out AMinor: Cardinal; out AMicro: Cardinal); 46 | begin 47 | AMajor := LIBPRIMES_VERSION_MAJOR; 48 | AMinor := LIBPRIMES_VERSION_MINOR; 49 | AMicro := LIBPRIMES_VERSION_MICRO; 50 | end; 51 | 52 | class function TLibPrimesWrapper.GetLastError(AInstance: TObject; out AErrorMessage: String): Boolean; 53 | begin 54 | result := (AInstance as ILibPrimesBase).GetLastErrorMessage(AErrorMessage); 55 | end; 56 | 57 | class procedure TLibPrimesWrapper.AcquireInstance(AInstance: TObject); 58 | begin 59 | (AInstance as ILibPrimesBase).IncRefCount(); 60 | end; 61 | 62 | class procedure TLibPrimesWrapper.ReleaseInstance(AInstance: TObject); 63 | begin 64 | (AInstance as ILibPrimesBase).DecRefCount(); 65 | end; 66 | 67 | class function TLibPrimesWrapper.CreateFactorizationCalculator(): TObject; 68 | begin 69 | result := TLibPrimesFactorizationCalculator.Create(); 70 | end; 71 | 72 | class function TLibPrimesWrapper.CreateSieveCalculator(): TObject; 73 | begin 74 | result := TLibPrimesSieveCalculator.Create(); 75 | end; 76 | 77 | class procedure TLibPrimesWrapper.SetJournal(const AFileName: String); 78 | begin 79 | end; 80 | 81 | 82 | end. 83 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Pascal/Stub/libprimes_impl_base.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TLibPrimesBase 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit libprimes_impl_base; 13 | 14 | interface 15 | 16 | uses 17 | libprimes_types, 18 | libprimes_interfaces, 19 | libprimes_exception, 20 | Classes, 21 | sysutils; 22 | 23 | type 24 | TLibPrimesBase = class(TObject, ILibPrimesBase) 25 | private 26 | FMessages: TStringList; 27 | FReferenceCount: integer; 28 | 29 | protected 30 | 31 | public 32 | constructor Create(); 33 | destructor Destroy(); override; 34 | function GetLastErrorMessage(out AErrorMessage: String): Boolean; 35 | procedure ClearErrorMessages(); 36 | procedure RegisterErrorMessage(const AErrorMessage: String); 37 | procedure IncRefCount(); 38 | function DecRefCount(): Boolean; 39 | end; 40 | 41 | implementation 42 | 43 | constructor TLibPrimesBase.Create(); 44 | begin 45 | inherited Create(); 46 | FMessages := TStringList.Create(); 47 | FReferenceCount := 1; 48 | end; 49 | 50 | destructor TLibPrimesBase.Destroy(); 51 | begin 52 | FreeAndNil(FMessages); 53 | inherited Destroy(); 54 | end; 55 | 56 | function TLibPrimesBase.GetLastErrorMessage(out AErrorMessage: String): Boolean; 57 | begin 58 | result := (FMessages.Count>0); 59 | if (result) then 60 | AErrorMessage := FMessages[FMessages.Count-1]; 61 | end; 62 | 63 | procedure TLibPrimesBase.ClearErrorMessages(); 64 | begin 65 | FMessages.Clear(); 66 | end; 67 | 68 | procedure TLibPrimesBase.RegisterErrorMessage(const AErrorMessage: String); 69 | begin 70 | FMessages.Clear(); 71 | FMessages.Add(AErrorMessage); 72 | end; 73 | 74 | procedure TLibPrimesBase.IncRefCount(); 75 | begin 76 | inc(FReferenceCount); 77 | end; 78 | 79 | function TLibPrimesBase.DecRefCount(): Boolean; 80 | begin 81 | dec(FReferenceCount); 82 | if (FReferenceCount = 0) then begin 83 | result := true; 84 | self.Destroy(); 85 | end; 86 | result := false; 87 | end; 88 | 89 | end. 90 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Pascal/Stub/libprimes_impl_calculator.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TLibPrimesCalculator 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit libprimes_impl_calculator; 13 | 14 | interface 15 | 16 | uses 17 | libprimes_types, 18 | libprimes_interfaces, 19 | libprimes_exception, 20 | libprimes_impl_base, 21 | Classes, 22 | sysutils; 23 | 24 | type 25 | TLibPrimesCalculator = class(TLibPrimesBase, ILibPrimesCalculator) 26 | private 27 | 28 | protected 29 | FValue : QWord; 30 | FProgressCallback: PLibPrimes_ProgressCallback; 31 | public 32 | function GetValue(): QWord; 33 | procedure SetValue(const AValue: QWord); 34 | procedure Calculate(); virtual; 35 | procedure SetProgressCallback(const AProgressCallback: PLibPrimes_ProgressCallback); 36 | end; 37 | 38 | implementation 39 | 40 | function TLibPrimesCalculator.GetValue(): QWord; 41 | begin 42 | result := FValue; 43 | end; 44 | 45 | procedure TLibPrimesCalculator.SetValue(const AValue: QWord); 46 | begin 47 | FValue := AValue; 48 | end; 49 | 50 | procedure TLibPrimesCalculator.Calculate(); 51 | begin 52 | raise ELibPrimesException.Create(LIBPRIMES_ERROR_NOTIMPLEMENTED); 53 | end; 54 | 55 | procedure TLibPrimesCalculator.SetProgressCallback(const AProgressCallback: PLibPrimes_ProgressCallback); 56 | begin 57 | FProgressCallback:=AProgressCallback 58 | end; 59 | 60 | end. 61 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Pascal/Stub/libprimes_impl_factorizationcalculator.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TLibPrimesFactorizationCalculator 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit libprimes_impl_factorizationcalculator; 13 | 14 | interface 15 | 16 | uses 17 | libprimes_types, 18 | libprimes_interfaces, 19 | libprimes_exception, 20 | libprimes_impl_calculator, 21 | Classes, 22 | sysutils; 23 | 24 | type 25 | TLibPrimesFactorizationCalculator = class(TLibPrimesCalculator, ILibPrimesFactorizationCalculator) 26 | private 27 | FPrimeFactors : Array Of TLibPrimesPrimeFactor; 28 | protected 29 | 30 | public 31 | destructor Destroy(); override; 32 | procedure GetPrimeFactors(const APrimeFactorsCount: QWord; PPrimeFactorsNeededCount: PQWord; APrimeFactors: PLibPrimesPrimeFactor); 33 | procedure Calculate(); override; 34 | end; 35 | 36 | implementation 37 | 38 | destructor TLibPrimesFactorizationCalculator.Destroy(); 39 | begin 40 | SetLength(FPrimeFactors, 0); 41 | inherited Destroy(); 42 | end; 43 | 44 | procedure TLibPrimesFactorizationCalculator.GetPrimeFactors(const APrimeFactorsCount: QWord; PPrimeFactorsNeededCount: PQWord; APrimeFactors: PLibPrimesPrimeFactor); 45 | var 46 | i : QWord; 47 | begin 48 | if (Length(FPrimeFactors) = 0) then 49 | raise ELibPrimesException.Create(LIBPRIMES_ERROR_NORESULTAVAILABLE); 50 | 51 | if (assigned(PPrimeFactorsNeededCount)) then 52 | PPrimeFactorsNeededCount^ := Length(FPrimeFactors); 53 | 54 | if (APrimeFactorsCount >= Length(FPrimeFactors)) then 55 | begin 56 | for i:=0 to Length(FPrimeFactors) -1 do begin 57 | APrimeFactors^ := FPrimeFactors[i]; 58 | inc(APrimeFactors); 59 | end; 60 | end; 61 | end; 62 | 63 | procedure TLibPrimesFactorizationCalculator.Calculate(); 64 | var 65 | AValue: QWord; 66 | I: QWord; 67 | APFCount: QWord; 68 | APrimeFactor: TLibPrimesPrimeFactor; 69 | AShouldAbort: Byte; 70 | begin 71 | SetLength(FPrimeFactors, 0); 72 | 73 | APFCount := 0; 74 | AValue := FValue; 75 | I := 2; 76 | while I < AValue 77 | do begin 78 | if (assigned(FProgressCallback)) then begin 79 | AShouldAbort := 0; 80 | FProgressCallback(1 - 1.0*AValue / FValue, AShouldAbort); 81 | if (AShouldAbort <> 0) then 82 | raise ELibPrimesException.Create(LIBPRIMES_ERROR_CALCULATIONABORTED); 83 | end; 84 | 85 | APrimeFactor.FMultiplicity:=0; 86 | APrimeFactor.FPrime:=I; 87 | while (AValue mod i = 0) do begin 88 | inc(APrimeFactor.FMultiplicity); 89 | AValue := AValue div I; 90 | end; 91 | if (APrimeFactor.FMultiplicity > 0) then begin 92 | inc(APFCount); 93 | SetLength(FPrimeFactors, APFCount); 94 | FPrimeFactors[APFCount-1] := APrimeFactor; 95 | end; 96 | inc(I); 97 | end; 98 | end; 99 | 100 | end. 101 | 102 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Pascal/Stub/libprimes_impl_sievecalculator.pas: -------------------------------------------------------------------------------- 1 | (*++ 2 | 3 | Copyright (C) 2019 PrimeDevelopers 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of TLibPrimesSieveCalculator 8 | 9 | *) 10 | 11 | {$MODE DELPHI} 12 | unit libprimes_impl_sievecalculator; 13 | 14 | interface 15 | 16 | uses 17 | libprimes_types, 18 | libprimes_interfaces, 19 | libprimes_exception, 20 | libprimes_impl_calculator, 21 | Classes, 22 | sysutils; 23 | 24 | type 25 | TLibPrimesSieveCalculator = class(TLibPrimesCalculator, ILibPrimesSieveCalculator) 26 | private 27 | FPrimes: array of QWord; 28 | protected 29 | 30 | public 31 | destructor Destroy(); override; 32 | procedure GetPrimes(const APrimesCount: QWord; PPrimesNeededCount: PQWord; APrimes: PQWord); 33 | procedure Calculate(); override; 34 | end; 35 | 36 | implementation 37 | 38 | destructor TLibPrimesSieveCalculator.Destroy(); 39 | begin 40 | SetLength(FPrimes, 0); 41 | inherited Destroy(); 42 | end; 43 | 44 | procedure TLibPrimesSieveCalculator.GetPrimes(const APrimesCount: QWord; PPrimesNeededCount: PQWord; APrimes: PQWord); 45 | var 46 | i : QWord; 47 | begin 48 | if (Length(FPrimes) = 0) then 49 | raise ELibPrimesException.Create(LIBPRIMES_ERROR_NORESULTAVAILABLE); 50 | 51 | if (assigned(PPrimesNeededCount)) then 52 | PPrimesNeededCount^ := Length(FPrimes); 53 | 54 | if (APrimesCount >= Length(FPrimes)) then 55 | begin 56 | for i:=0 to Length(FPrimes) -1 do begin 57 | APrimes^ := FPrimes[i]; 58 | inc(APrimes); 59 | end; 60 | end; 61 | end; 62 | 63 | procedure TLibPrimesSieveCalculator.Calculate(); 64 | var 65 | AStrikenOut : array of Boolean; 66 | I, J : QWord; 67 | ASqrtValue : QWord; 68 | ANumPrimes: QWord; 69 | begin 70 | SetLength(FPrimes, 0); 71 | ANumPrimes := 0; 72 | 73 | SetLength(AStrikenOut, FValue + 1); 74 | for I := 0 to FValue do begin 75 | AStrikenOut[I] := I < 2; 76 | end; 77 | 78 | ASqrtValue := round(sqrt(FValue)); 79 | 80 | for I := 2 to ASqrtValue do begin 81 | if not AStrikenOut[I] then begin 82 | inc(ANumPrimes); 83 | SetLength(FPrimes, ANumPrimes); 84 | FPrimes[ANumPrimes - 1] := I; 85 | J := I*I; 86 | while (J <= FValue) do begin 87 | AStrikenOut[j] := true; 88 | inc(J, I); 89 | end; 90 | end; 91 | end; 92 | 93 | for I:= ASqrtValue to FValue do begin 94 | if not AStrikenOut[i] then begin 95 | inc(ANumPrimes); 96 | SetLength(FPrimes, ANumPrimes); 97 | FPrimes[ANumPrimes - 1] := I; 98 | end; 99 | end; 100 | end; 101 | 102 | end. 103 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/Implementations/Pascal/libprimes.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | libprimes_getversion 3 | libprimes_getlasterror 4 | libprimes_acquireinstance 5 | libprimes_releaseinstance 6 | libprimes_createfactorizationcalculator 7 | libprimes_createsievecalculator 8 | libprimes_setjournal 9 | libprimes_calculator_getvalue 10 | libprimes_calculator_setvalue 11 | libprimes_calculator_calculate 12 | libprimes_calculator_setprogresscallback 13 | libprimes_factorizationcalculator_getprimefactors 14 | libprimes_sievecalculator_getprimes 15 | -------------------------------------------------------------------------------- /Examples/Primes/LibPrimes_component/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2019 PrimeDevelopers 2 | 3 | All rights reserved. 4 | 5 | 6 | -------------------------------------------------------------------------------- /Examples/Primes/resources/310/libPrimes.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Examples/Primes/resources/VSProperties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/Examples/Primes/resources/VSProperties.png -------------------------------------------------------------------------------- /Examples/UnitTest/Project/.gitignore: -------------------------------------------------------------------------------- 1 | build* 2 | _build* 3 | 4 | -------------------------------------------------------------------------------- /Examples/UnitTest/Project/README.md: -------------------------------------------------------------------------------- 1 | To build the libUnitTest-test project 2 | 3 | `mkdir _build` 4 | 5 | `cd _build` 6 | 7 | `cmake -G "Visual Studio 14 Win64"` .. 8 | 9 | cmake . 10 | 11 | -------------------------------------------------------------------------------- /Examples/UnitTest/Project/Source/Custom/libunittest_implementation.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2018 Autodesk 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is an autogenerated C++ implementation file in order to allow easy 8 | development of ACT UnitTest FrameWork. 9 | Interface version: 1.0.0 10 | 11 | **/ 12 | 13 | #include "libunittest.h" 14 | #include "libunittest_interfaces.hpp" 15 | #include "libunittest_interfaceexception.hpp" 16 | 17 | using namespace LibUnitTest; 18 | 19 | IInternalLibUnitTestTestClass * CInternalLibUnitTestWrapper::CreateTestClass () 20 | { 21 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 22 | } 23 | 24 | void CInternalLibUnitTestWrapper::ReleaseInstance (IInternalLibUnitTestBaseClass* pInstance) 25 | { 26 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 27 | } 28 | 29 | void CInternalLibUnitTestWrapper::GetLibraryVersion (unsigned int & nMajor, unsigned int & nMinor, unsigned int & nMicro) 30 | { 31 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 32 | } 33 | 34 | void CInternalLibUnitTestWrapper::SetJournal (const std::string sFileName) 35 | { 36 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /Examples/UnitTest/Project/Source/Custom/libunittest_implementation_testclass.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2018 Autodesk 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is a stub class definition of CInternalLibUnitTestTestClass 8 | Interface version: 1.0.0 9 | 10 | **/ 11 | 12 | #include "libunittest_implementation_testclass.hpp" 13 | #include "libunittest_interfaceexception.hpp" 14 | 15 | // Include custom headers here. 16 | 17 | 18 | using namespace LibUnitTest; 19 | 20 | /************************************************************************************************************************* 21 | Class definition of CInternalLibUnitTestTestClass 22 | **************************************************************************************************************************/ 23 | 24 | double CInternalLibUnitTestTestClass::Value () 25 | { 26 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 27 | } 28 | 29 | void CInternalLibUnitTestTestClass::SetValue (const double dValue) 30 | { 31 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 32 | } 33 | 34 | void CInternalLibUnitTestTestClass::SetValueInt (const long long nValue) 35 | { 36 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 37 | } 38 | 39 | void CInternalLibUnitTestTestClass::SetValueString (const std::string sValue) 40 | { 41 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 42 | } 43 | 44 | void CInternalLibUnitTestTestClass::UnitTest1 (const unsigned char nValue1, const unsigned short nValue2, const unsigned int nValue3, const unsigned long long nValue4, unsigned char & nOutValue1, unsigned short & nOutValue2, unsigned int & nOutValue3, unsigned long long & nOutValue4) 45 | { 46 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 47 | } 48 | 49 | void CInternalLibUnitTestTestClass::UnitTest2 (const char nValue1, const short nValue2, const int nValue3, const long long nValue4, char & nOutValue1, short & nOutValue2, int & nOutValue3, long long & nOutValue4) 50 | { 51 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 52 | } 53 | 54 | void CInternalLibUnitTestTestClass::UnitTest3 (const bool bValue1, const float fValue2, const double dValue3, const eLibUnitTestTestEnum eValue4, bool & bOutValue1, float & fOutValue2, double & dOutValue3, eLibUnitTestTestEnum & eOutValue4) 55 | { 56 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 57 | } 58 | 59 | void CInternalLibUnitTestTestClass::UnitTest4 (const unsigned int nValue1BufferSize, const unsigned char * pValue1Buffer, const unsigned int nValue2BufferSize, const unsigned short * pValue2Buffer, const unsigned int nValue3BufferSize, const unsigned int * pValue3Buffer, const unsigned int nValue4BufferSize, const unsigned long long * pValue4Buffer) 60 | { 61 | throw ELibUnitTestInterfaceException (LIBUNITTEST_ERROR_NOTIMPLEMENTED); 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Examples/UnitTest/Project/Source/Custom/libunittest_implementation_testclass.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2018 Autodesk 4 | 5 | All rights reserved. 6 | 7 | Abstract: This is the class declaration of CInternalLibUnitTestTestClass 8 | Interface version: 1.0.0 9 | 10 | **/ 11 | 12 | 13 | #ifndef __LIBUNITTEST_LIBUNITTESTTESTCLASS 14 | #define __LIBUNITTEST_LIBUNITTESTTESTCLASS 15 | 16 | #include "libunittest_interfaces.hpp" 17 | 18 | 19 | // Include custom headers here. 20 | 21 | 22 | namespace LibUnitTest { 23 | 24 | 25 | /************************************************************************************************************************* 26 | Class declaration of CInternalLibUnitTestTestClass 27 | **************************************************************************************************************************/ 28 | 29 | class CInternalLibUnitTestTestClass : public virtual IInternalLibUnitTestTestClass { 30 | private: 31 | 32 | /** 33 | * Put private members here. 34 | */ 35 | 36 | protected: 37 | 38 | /** 39 | * Put protected members here. 40 | */ 41 | 42 | public: 43 | 44 | /** 45 | * Put additional public members here. They will not be visible in the external API. 46 | */ 47 | 48 | 49 | /** 50 | * Public member functions to implement. 51 | */ 52 | 53 | double Value (); 54 | 55 | void SetValue (const double dValue); 56 | 57 | void SetValueInt (const long long nValue); 58 | 59 | void SetValueString (const std::string sValue); 60 | 61 | void UnitTest1 (const unsigned char nValue1, const unsigned short nValue2, const unsigned int nValue3, const unsigned long long nValue4, unsigned char & nOutValue1, unsigned short & nOutValue2, unsigned int & nOutValue3, unsigned long long & nOutValue4); 62 | 63 | void UnitTest2 (const char nValue1, const short nValue2, const int nValue3, const long long nValue4, char & nOutValue1, short & nOutValue2, int & nOutValue3, long long & nOutValue4); 64 | 65 | void UnitTest3 (const bool bValue1, const float fValue2, const double dValue3, const eLibUnitTestTestEnum eValue4, bool & bOutValue1, float & fOutValue2, double & dOutValue3, eLibUnitTestTestEnum & eOutValue4); 66 | 67 | void UnitTest4 (const unsigned int nValue1BufferSize, const unsigned char * pValue1Buffer, const unsigned int nValue2BufferSize, const unsigned short * pValue2Buffer, const unsigned int nValue3BufferSize, const unsigned int * pValue3Buffer, const unsigned int nValue4BufferSize, const unsigned long long * pValue4Buffer); 68 | 69 | }; 70 | 71 | } 72 | 73 | #endif // __LIBUNITTEST_LIBUNITTESTTESTCLASS 74 | -------------------------------------------------------------------------------- /Examples/UnitTest/Project/libUnitTest/main.cpp: -------------------------------------------------------------------------------- 1 | #ifdef MACHININGUSECPPDYNAMIC 2 | #include "LibNumbers_dynamic.hpp" 3 | #else 4 | #include "LibNumbers.hpp" 5 | #endif 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace LibNumbers; 12 | 13 | void tryout() 14 | { 15 | #ifdef MACHININGUSECPPDYNAMIC 16 | std::cout << "LibNumbers_dynamic" << std::endl; 17 | auto wrapper = LibOMV::CLibNumbersWrapper::CLibNumbersWrapper("LibNumbers.dll"); 18 | auto number = wrapper->CreateNumber(); 19 | #else 20 | std::cout << "LibNumbers" << std::endl; 21 | auto number = CLibNumbersWrapper::CreateNumber(); 22 | #endif 23 | number->SetValueString("1e3"); 24 | number->SetValueString("3.14"); 25 | number->SetValueString("3,14"); 26 | } 27 | 28 | int main() 29 | { 30 | try { 31 | tryout(); 32 | } 33 | catch (std::runtime_error &e) { 34 | std::cout << "Error: " << e.what() << std::endl; 35 | return -1; 36 | } 37 | catch (...) { 38 | std::cout << "Generic Error" << std::endl; 39 | return -1; 40 | } 41 | std::cout << "Success" << std::endl; 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /Examples/Version/libVersion.1.1.0.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Examples/Version/libVersion.1.2.0.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Examples/Version/libVersion.1.3.0.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Examples/Version/libVersion.2.0.0.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Examples/Version/libVersion.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | <> 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2018 Autodesk Inc. (Original Author) 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /Source/.gitignore: -------------------------------------------------------------------------------- 1 | *.xml 2 | -------------------------------------------------------------------------------- /Source/actutils.go: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (C) 2018 Autodesk Inc. (Original Author) 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | --*/ 28 | 29 | ////////////////////////////////////////////////////////////////////////////////////////////////////// 30 | // actutils.go 31 | // Utility functions for ACT 32 | ////////////////////////////////////////////////////////////////////////////////////////////////////// 33 | 34 | package main 35 | 36 | import ( 37 | "os" 38 | ) 39 | 40 | // FileExists returns true if and only if the file in a given path exists 41 | func FileExists(path string) bool { 42 | _, err := os.Stat(path) 43 | return !os.IsNotExist(err) 44 | } 45 | -------------------------------------------------------------------------------- /act.arm.linux32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/act.arm.linux32 -------------------------------------------------------------------------------- /act.arm.linux64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/act.arm.linux64 -------------------------------------------------------------------------------- /act.linux32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/act.linux32 -------------------------------------------------------------------------------- /act.linux64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Autodesk/AutomaticComponentToolkit/33422936d34156d0d683e8ab363a8e10b14491c6/act.linux64 -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module Source 2 | 3 | go 1.20 4 | --------------------------------------------------------------------------------