261 Commits

Author SHA1 Message Date
69e58a5d80 Merge branch 'master' into PIStringTest_11-20 2021-01-22 11:47:27 +03:00
27e3085cfd PIOpenCL native handlers, custom compile arguments 2021-01-22 11:14:23 +03:00
d9bba66cc7 Test for PIString 11-20 2021-01-22 10:46:36 +03:00
91cfea7450 Merge pull request '1-10 tests for PIString' (#56) from PIString_1-10 into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/56
2021-01-22 10:28:40 +03:00
29ca38d81c Merge pull request 'Add code coverage info support' (#57) from coverage into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/57
2021-01-21 17:15:46 +03:00
0ba2d950e2 Add code coverage info support 2021-01-21 16:47:32 +03:00
41cfaefda8 1-10 tests for PIString 2021-01-21 13:20:02 +03:00
ff9b0126be Merge pull request 'Fix windows build tests' (#54) from sanitaze into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/54
2021-01-20 19:28:16 +03:00
1dc827f16a Fix windows build tests 2021-01-20 16:52:57 +03:00
b2e9995e4d Merge pull request 'Configure address and undefined sanitizers & fix delete UB' (#53) from sanitaze into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/53
2021-01-14 17:49:41 +03:00
493b211886 Configure address and undefined sanitizers & fix delete UB 2021-01-12 13:53:32 +03:00
ec96adee3f Merge branch 'master' of https://git.shs.tools/SHS/pip 2020-12-23 16:52:35 +03:00
587d90f269 fix plugin path in picout 2020-12-23 16:52:27 +03:00
3c543e79f0 PISerial patch - close on read error 2020-12-06 13:09:29 +03:00
5de87eeed1 PIVariant::fromValue<PIVariant> fix
PIOpenCL new Buffer class
2020-12-03 21:38:30 +03:00
8bfd466f6b Merge pull request 'PIPropertyStorage: add return values and documentation in some functions' (#52) from propertystorage_imp into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/52
2020-11-25 12:48:16 +03:00
e0e8266b59 PIPropertyStorage: add return values and documentation in some functions 2020-11-25 12:39:15 +03:00
65d2f6b6e4 FindPIP.cmake SMSDK fix 2020-11-16 13:49:45 +03:00
efe2cbe4b6 FindPIP.cmake fix for SMSDK 2020-11-16 13:27:24 +03:00
5c0ef7173a pip_code_model macro now automatic add CMAKE_CURRENT_SOURCE_DIR to relative pathes, no ABSOLUTE need
PIOpenCL first working version
2020-11-15 11:40:47 +03:00
ce636245c7 esp includes 2020-11-06 18:20:56 +03:00
c47c63c8b3 rename esp pip 2020-11-06 18:17:13 +03:00
285c73e966 esp 2020-11-06 17:55:34 +03:00
1dd16cf29a esp32 2020-11-06 17:54:07 +03:00
488663c5a4 esp 2020-11-06 17:40:21 +03:00
ba0ea994da esp 2020-11-06 17:36:33 +03:00
102380a325 esp 2020-11-06 17:33:56 +03:00
56223ad67e esp 2020-11-06 17:32:20 +03:00
555dc74086 esp 2020-11-06 17:29:53 +03:00
04c08742ac esp 2020-11-06 17:23:09 +03:00
58c7f74de6 esp_flash.h 2020-11-06 16:25:13 +03:00
de756491d8 esp_flash_get_chip_size 2020-11-06 16:22:28 +03:00
80efa4b094 remove esp_spi_flash.h 2020-11-06 16:20:31 +03:00
6124452ac6 REGISTER_PIVARIANTSIMPLE 2020-11-06 16:16:14 +03:00
9d313f4c0a register pivariant for PIKbdListener Events 2020-11-06 16:09:22 +03:00
3457d87299 __VariantFunctions__<std::function<void(void*)> > 2020-11-06 16:06:25 +03:00
0c6e6358b2 register PIVariant std::function 2020-11-06 15:47:01 +03:00
9497b1bbb7 PIVariantSimple freertos fix 2020-11-06 15:39:14 +03:00
2898c56476 esp32 pip 2020-11-06 15:19:25 +03:00
0614c3df96 cmake fixes 2020-11-06 15:10:24 +03:00
ae08ff72ea static lib 2020-11-06 14:34:35 +03:00
69c7b13cc3 Merge branch 'master' of https://git.shs.tools/SHS/pip 2020-11-06 14:11:08 +03:00
9c5c3b5732 move esp32 components 2020-11-06 14:10:59 +03:00
a6954fd7bc PIEvaluator::usedVariables() now returns without i, pi, e 2020-11-03 13:08:18 +03:00
24559f33e3 Merge pull request 'Fix row check & remove matrix couts' (#49) from test_vector2d into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/49
2020-11-03 12:06:55 +03:00
a349af62bb Merge pull request 'deploy' (#50) from deploy into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/50
2020-11-03 12:03:07 +03:00
24d9d66c24 version 2.14.1 2020-11-03 12:00:27 +03:00
77031172a6 Fix row check & remove matrix couts 2020-11-02 15:53:14 +03:00
peri4
3e7344c95f deploy_tool "qt-modules" feature works on Windows (maybe on *nix). On MacOS - no(( 2020-10-28 18:07:53 +03:00
f99cd70921 Merge branch 'master' of https://git.shs.tools/SHS/pip 2020-10-28 17:12:48 +03:00
dd4f21c3e0 add at() to PIVector2D 2020-10-28 17:12:40 +03:00
673cf40d24 deploy_tool Qt additional modules start 2020-10-28 14:16:20 +03:00
173b8c9413 missing OpenCL in FindPIP 2020-10-28 14:14:55 +03:00
f951593c62 version 2020-10-23 15:11:38 +03:00
0189f28f43 PIMathMatrix add trace, assert for non square matrix, assert in operator * 2020-10-23 15:10:57 +03:00
fa85f414db fix tests and pimathmatrix.h 2020-10-22 18:56:01 +03:00
85dc0a4dc4 Merge pull request 'vectors&matrixes' (#48) from vectors&matrixes into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/48
2020-10-22 18:04:49 +03:00
c79f39ad2a cosmetic 2020-10-22 18:03:22 +03:00
91c1487a7e toDeg and toRad 2020-10-22 17:45:42 +03:00
fbe850abf0 template math functions in pimathmatrix.h and pimathvector.h and pimathbase.h
add PIMathMatrixT::rotate for matrix 2x2
2020-10-22 17:29:58 +03:00
f5652efc32 refactoring PIMathMatrix 2020-10-22 16:48:46 +03:00
7413c7252b refactor PIMathMatrixT and fix pimathvector.h 2020-10-22 16:13:39 +03:00
b46825a5a0 PIMathMatrixT remove scale and rotate funcs 2020-10-22 12:44:30 +03:00
13a0c1097a version 2020-10-21 18:55:31 +03:00
8f7b614b88 Merge branch 'vectors&matrixes' of https://git.shs.tools/SHS/pip into vectors&matrixes 2020-10-21 18:54:50 +03:00
47be2d3d62 pimathvector.h div and std::initializer_list 2020-10-21 18:54:41 +03:00
a7408922df add constexpr to pibase methods 2020-10-21 18:49:04 +03:00
6f3fdf4d49 pimathvector.h mul 2020-10-21 18:36:57 +03:00
7b5555f63d refactor pimathvector.h 2020-10-21 17:58:42 +03:00
6789d068e3 fix pimathmatrix 2020-10-19 17:59:52 +03:00
ff6d5cedaa PIVector2D tests 2020-10-19 17:52:51 +03:00
a7851ecf3e Merge remote-tracking branch 'remotes/origin/vector2d_tests' 2020-10-19 17:37:50 +03:00
d84adf2bc7 PIVector2D resize 2020-10-19 17:37:24 +03:00
ac911d9b3e Increase reduce cols tests granularity 2020-10-19 17:34:51 +03:00
b6430c0863 Complicate tests for PIVector2D::resize 2020-10-19 16:47:54 +03:00
16f22f38c7 Simple PIVector2D resize tests 2020-10-19 16:27:42 +03:00
94fc54159b version 2020-10-19 15:20:48 +03:00
e0d46463ae assert 2020-10-19 15:18:16 +03:00
2794d866fd PIPluginLoader fix 2020-10-18 19:51:59 +03:00
5078269d0f PIPluginLoader patch for several plugins 2020-10-18 19:50:07 +03:00
6d7da02de6 PIPluginLoader lib lastError 2020-10-18 12:00:52 +03:00
d0ef71c933 version 1.12.0_beta.
Very important fix in PIByteArray! Now containers stream operators for trivial types works correct
2020-10-17 21:16:26 +03:00
80c6809e42 test fix 2020-10-16 12:43:46 +03:00
43fb497b32 pip version 2020-10-16 12:30:06 +03:00
8ef4c9ca23 fix PIByteArray load/store operators for containers 2020-10-16 12:28:57 +03:00
51775a5ee6 next easing of PIChunkStream::extract() 2020-10-08 22:47:32 +03:00
2e3204806f pichunkstream.cpp documentation 2020-10-08 22:42:42 +03:00
16cfdc709b new PIChunkStream::extract() method 2020-10-08 22:29:47 +03:00
4c0fe72d71 PICrypt first init fail patch 2020-10-07 23:43:20 +03:00
0004d2696f PIString::fromAscii() new overload 2020-10-07 23:29:18 +03:00
cebe6f452f Merge branch 'master' into plugin 2020-10-06 10:03:03 +03:00
bf1808f1c4 version 2.10.1
Documentation of PIPluginLoader
Remove PIVariantSimple ability to assign any type, leave only assignable
2020-10-06 00:53:37 +03:00
b7aef483b7 PIVariantSimple now has no error when assign to non-copyable typeName
patch pip_cmg according to last PIByteArray changes
plugin system fix
2020-10-03 13:32:43 +03:00
f9b497b5c0 revert operator for PIMathVectorT 2020-10-02 15:07:36 +03:00
334efaefbe code clean 2020-10-02 15:04:15 +03:00
7421f8c9a0 first try 2020-10-02 14:23:05 +03:00
f57f2c47f4 version 2.10.0 2020-10-02 11:30:17 +03:00
0c83dffe9d Автооптимизация контейнеров и (де)сериализаций в PIByteArray
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/44
2020-10-02 11:22:24 +03:00
f3d6739869 code brush 2020-10-02 11:11:55 +03:00
298765b7d8 new class PIVariantSimple
PIObject::CONNECTU_QUEUED moved to PIVariantSimple
static_assert on undeclared operators PIByteArray << and >> with complex types
2020-10-01 21:50:41 +03:00
2ca8db70f3 pibytearray patch, now automatic supports all simple types 2020-10-01 19:04:10 +03:00
e474c5a8de remove __PICONTAINERS_SIMPLE_TYPE__ 2020-09-28 15:38:45 +03:00
9dc93b73c9 Merge pull request 'Improve template & doc for PIMathFloatNullCompare' (#43) from math into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/43
2020-09-28 11:52:33 +03:00
0e31de4f75 Improve template & doc for PIMathFloatNullCompare 2020-09-28 11:34:30 +03:00
7530ae5d30 Add PISpinlock and PISpinlockLocker 2020-09-27 20:07:47 +03:00
ff3dfab270 version 2020-09-26 19:47:33 +03:00
c971550535 pimathfloatnullcompare 2020-09-26 19:46:34 +03:00
a42e5a7756 template experiment, PIMutex recursive in all systems 2020-09-25 14:34:07 +03:00
53cd72a4b0 PIConditionVariable fix 2020-09-25 14:25:25 +03:00
1ec69cca81 fix toTimespec 2020-09-25 14:17:58 +03:00
b771eebfbb fix toTimespec 2 2020-09-25 14:15:46 +03:00
b6583c3d02 fix toTimespec 2020-09-25 14:13:36 +03:00
c3f0cc0b03 PISystemTime toTimespec and PIConditionVariable fix 2020-09-25 14:08:40 +03:00
d180c0c0dd Merge pull request 'cond_var' (#42) from cond_var into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/42
2020-09-25 13:34:16 +03:00
2ba05c81b1 disable pistring tests 2020-09-25 13:03:56 +03:00
829f0af9d2 Fix waitFor timeout behaviour 2020-09-25 12:03:15 +03:00
2d02cea40c Fix waitFor timeout behaviour 2020-09-25 12:01:53 +03:00
f10908a7e9 Merge pull request 'Fix nanosecond calc bug in piconditionvar.cpp' (#41) from cond_var into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/41
2020-09-24 17:59:58 +03:00
bf17a003e7 o(╥﹏╥)o 2020-09-24 17:20:25 +03:00
0e1a3d3a23 Fix nanosecond calc bug in piconditionvar.cpp 2020-09-24 17:04:55 +03:00
65b1243426 Merge pull request 'Restore piconditionvar.cpp after wrong fix' (#40) from cond_var into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/40
2020-09-24 16:47:26 +03:00
55f42f73f5 Restore piconditionvar.cpp after wrong fix 2020-09-24 16:44:53 +03:00
51c7355af4 version 2.8.0
new PIObject::deleteLater method
decompose piobject.h to 2 files
2020-09-18 14:59:24 +03:00
5f7c58c28e pip static initializer 2020-09-17 13:51:02 +03:00
351ad1bf30 deploy_tool qt-plugins patch 2020-09-16 16:23:47 +03:00
aae59106f0 Merge pull request 'tests' (#36) from tests into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/36
2020-09-15 15:40:56 +03:00
f9c1dbc661 bugzz 2020-09-15 15:39:17 +03:00
4f731d72a6 second tab correction 2020-09-15 14:56:58 +03:00
f73b7fb092 tab correction 2020-09-15 14:53:28 +03:00
6a1b67a374 bug fixes in docs 2020-09-15 14:50:19 +03:00
d19c6b1321 new docs 2020-09-15 12:48:14 +03:00
03679bd4c3 version 2020-09-15 12:44:11 +03:00
e4e4cc7c36 deploy_tool/main.cpp fix 2020-09-15 11:34:17 +03:00
78731bd971 PIString remove operator char* 2020-09-15 11:24:13 +03:00
53359ab286 bug fixed second 2020-09-15 10:43:13 +03:00
3ebb0d3fe0 Merge branch 'tests' of https://git.shs.tools/SHS/pip into tests 2020-09-15 10:13:54 +03:00
e10ff53547 reverted PIString[] operators 2020-09-11 22:51:10 +03:00
b3a3b32a6f private headers fix 2020-09-10 21:23:45 +03:00
Шишов Максим Денисович
c7ebbe30c1 bug fixes 2020-09-10 18:39:37 +03:00
Шишов Максим Денисович
2fa852a050 bug fixes 2020-09-10 18:39:37 +03:00
Шишов Максим Денисович
36fe9135db indentation in strings 2020-09-10 18:38:44 +03:00
Шишов Максим Денисович
05e935f552 overall PIMathMatrix tests correction 2020-09-10 18:38:32 +03:00
Шишов Максим Денисович
6b7594cc90 testing another operations 2020-09-10 18:38:15 +03:00
Шишов Максим Денисович
9e52a78022 final tab correction 2020-09-10 18:37:49 +03:00
Шишов Максим Денисович
7a8ab669d6 tab correction 2020-09-10 18:37:49 +03:00
Шишов Максим Денисович
d59d60b1a7 doc correction 2020-09-10 18:37:48 +03:00
42793522a4 Fix code formatting & grammar mistakes 2020-09-10 18:36:35 +03:00
Шишов Максим Денисович
8163a68e03 space correction 2020-09-10 18:35:14 +03:00
Шишов Максим Денисович
3a038ef50b Rotation remake 2020-09-10 18:32:46 +03:00
Шишов Максим Денисович
8b6a356349 PIMathMatrix document 2020-09-10 18:30:14 +03:00
Шишов Максим Денисович
604aa44e57 PIMathMatrix doc 2020-09-10 18:30:14 +03:00
Шишов Максим Денисович
d0e703751a bug fixes 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
8b5f80d6dc bug fixes 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
9f6fa4cb8e indentation in strings 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
2b2ad436f0 overall PIMathMatrix tests correction 2020-09-10 18:27:58 +03:00
Федоренко Дмитрий Витальевич
88a147e0a1 string tests 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
eab3317ae6 testing another operations 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
ee6b026c61 PIMathMatrix new tests version 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
7a94de5af8 tests correction 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
d003a2e7d8 final tab correction 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
2471231943 tab correction 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
012981baf7 doc correction 2020-09-10 18:27:58 +03:00
a0c53bf689 Fix code formatting & grammar mistakes 2020-09-10 18:27:58 +03:00
Шишов Максим Денисович
14a8c11a71 space correction 2020-09-10 18:26:42 +03:00
Шишов Максим Денисович
97a17a892d Rotation remake 2020-09-10 18:25:44 +03:00
Шишов Максим Денисович
781a1e75e2 PIMathMatrix document 2020-09-10 18:25:44 +03:00
Шишов Максим Денисович
608e09c9a0 PIMathMatrix doc 2020-09-10 18:25:44 +03:00
Шишов Максим Денисович
6ba17c1122 add CMakeLists.txt.user to .gitignore 2020-09-10 18:22:54 +03:00
Федоренко Дмитрий Витальевич
648c2e491e Merge branch 'tests' of https://git.shs.tools/SHS/pip into tests 2020-09-10 17:55:36 +03:00
Шишов Максим Денисович
d5da2e7c7f bug fixes 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
04da5daa41 bug fixes 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
9505669780 indentation in strings 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
f72d4bcda4 overall PIMathMatrix tests correction 2020-09-10 17:53:28 +03:00
Федоренко Дмитрий Витальевич
7948028022 string tests 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
4307890356 testing another operations 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
7312fa9a36 PIMathMatrix new tests version 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
d255224822 tests correction 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
49507b4a84 final tab correction 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
3092f4f45b tab correction 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
6e100e19f5 doc correction 2020-09-10 17:53:28 +03:00
740d38ccce Fix code formatting & grammar mistakes 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
33d1abd14c space correction 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
14e13fa8c1 Rotation remake 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
3f84598ec0 PIMathMatrix document 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
1646f1ada7 PIMathMatrix doc 2020-09-10 17:53:28 +03:00
Шишов Максим Денисович
3a4ac8badd add CMakeLists.txt.user to .gitignore 2020-09-10 17:52:48 +03:00
Шишов Максим Денисович
0ce6afa43c bug fixes 2020-09-10 17:48:39 +03:00
Шишов Максим Денисович
5bec25a628 bug fixes 2020-09-10 17:48:16 +03:00
9a6fab980c varsion 2020-09-10 17:33:33 +03:00
cb2ef7113a mising exports in PIString 2020-09-10 17:33:09 +03:00
Шишов Максим Денисович
7acc2f6b2f indentation in strings 2020-09-10 17:13:02 +03:00
Шишов Максим Денисович
641633f6f0 overall PIMathMatrix tests correction 2020-09-10 16:56:04 +03:00
Шишов Максим Денисович
f98874401f testing another operations 2020-09-10 15:27:09 +03:00
Шишов Максим Денисович
58a132a3a5 PIMathMatrix new tests version 2020-09-10 13:11:31 +03:00
05b48af153 remove at(index) reference function
remove chrUpr and chrLwr from PIString
2020-09-10 12:37:33 +03:00
Шишов Максим Денисович
98f77d90cd tests correction 2020-09-10 10:52:09 +03:00
Шишов Максим Денисович
ab16bb3ce0 final tab correction 2020-09-08 16:47:44 +03:00
Шишов Максим Денисович
6d83790358 tab correction 2020-09-08 16:44:01 +03:00
Шишов Максим Денисович
05a32ccf1a doc correction 2020-09-08 16:05:22 +03:00
b11ebc8100 Merge pull request 'shstk' (#37) from shstk into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/37
2020-09-08 15:13:33 +03:00
e6bc9638e7 fix some warnings 2020-09-08 15:10:49 +03:00
00321257b4 strip fix 2020-09-07 13:05:20 +03:00
b0c98d4464 cmake install fix 2020-09-07 12:37:32 +03:00
410bc42830 deploy_tool strip support 2020-09-07 10:40:52 +03:00
2511e96372 ready for shstk 2020-09-06 22:52:17 +03:00
f1a0a3ec4a Fix code formatting & grammar mistakes 2020-09-03 16:57:46 +03:00
Шишов Максим Денисович
8e7d7a54c4 space correction 2020-09-03 15:50:41 +03:00
Шишов Максим Денисович
9544d5ef0d Rotation remake 2020-09-03 15:23:54 +03:00
Шишов Максим Денисович
4d03ba1210 PIMathMatrix document 2020-09-03 13:54:47 +03:00
Шишов Максим Денисович
defbe3a4d7 PIMathMatrix doc 2020-09-03 13:54:02 +03:00
5ef37dc7fd Merge pull request 'tests' (#24) from tests into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/24
Reviewed-by: Фоменко Степан Владимирович <stepannk@mail.ru>
2020-09-01 21:01:44 +03:00
a9e6ed0753 PIConditionVariable timing fix 2020-09-01 20:57:49 +03:00
Шишов Максим Денисович
2913fc284b Merge with pip 3 2020-09-01 12:54:02 +03:00
Шишов Максим Денисович
3dd08bf944 Merge with pip 3 2020-09-01 12:38:13 +03:00
Шишов Максим Денисович
fcf91a26b6 Tests update 2020-09-01 12:10:56 +03:00
a4b3edb3e1 Merge branch 'master' of https://git.shs.tools/SHS/pip 2020-08-31 17:53:26 +03:00
6be22ac39f reemove piSwapBinary 2020-08-31 17:53:18 +03:00
37de1ec099 Merge pull request 'Fixed PIConditionVariable timeout bug on Linux' (#33) from cond_fix into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/33
2020-08-31 16:41:59 +03:00
32d060c8ce int 2020-08-31 16:41:01 +03:00
7065cbd9ee Fixed PIConditionVariable timeout bug on Linux 2020-08-31 16:01:35 +03:00
c5f70f4e09 picloud 2020-08-28 17:49:58 +03:00
234d4e73be picloud 2020-08-27 19:40:11 +03:00
e1f2c90790 version 2020-08-26 18:45:27 +03:00
93cf55d323 Merge branch 'master' of https://git.shs.tools/SHS/pip 2020-08-26 18:43:40 +03:00
2ef0ca6946 PIIODevice destructor fix 2020-08-26 18:43:33 +03:00
73bfe03433 PIEthernet disctonnect fix 2020-08-26 18:10:58 +03:00
2a42d2a341 Merge branch 'master' of https://git.shs.tools/SHS/pip 2020-08-26 18:01:23 +03:00
7f2c82dc69 PIEthernet reconnect 2020-08-26 18:01:17 +03:00
fa0475cac6 PIEthernet disctonnect fix 2020-08-26 17:59:28 +03:00
cfebf8cf23 cloud test 2020-08-26 17:28:56 +03:00
3965e54e38 start develop picloud 2020-08-24 13:23:31 +03:00
f033119a8b version 2.3.0_beta
optimize PIChunkStream::readAll()
optimize PIEvaluator
2020-08-24 02:08:23 +03:00
6b70045914 CMake set_version fix 2020-08-21 22:12:11 +03:00
cc580d9385 Merge branch 'master' of https://git.shs.tools/SHS/pip 2020-08-19 16:48:17 +03:00
05607ccf0e static_assert 2020-08-19 16:48:08 +03:00
fec68299c1 remove install duplicate 2020-08-19 16:22:01 +03:00
ccd6a9888f tree changes 2020-08-19 00:47:05 +03:00
c582d8ff46 PIStringList new constructor 2020-08-18 22:58:30 +03:00
9834ac177b debian version fix, "Maj.Min.Rev-Build-suffix" instead of "Maj.Min.Rev-suffix-Build" 2020-08-15 21:24:57 +03:00
31f0d88157 version 2.2.1
std::initializer_list supports for vector and dequeue
2020-08-14 18:00:28 +03:00
e76a07a3f3 binlog fixes 2020-08-13 18:03:25 +03:00
31a347250f version 2.2.0
remove deprecated members
PIVariantTypes::File add "is_save" flag
PIBinaryLog clear
2020-08-13 12:59:29 +03:00
294831df17 binlog user header 2020-08-12 20:01:24 +03:00
e77d3a86a9 opencl MacOS fix 2020-08-11 21:18:51 +03:00
66010c83eb export headers workaround 2020-08-11 20:59:12 +03:00
57a9ccb854 version 2.0.0_prealpha
PIFile::put() and get()
2020-08-11 20:09:34 +03:00
3ba6a7b0e8 rename PIBlockingDequeue -> PIBlockingQueue 2020-08-11 19:05:47 +03:00
8c3349d84a fix PIThreadPoolExecutor and PIBlockingDequeue 2020-08-11 17:26:44 +03:00
dac318c624 <T>_MAKE_VERSION macro add in "set_version()" CMake generated header 2020-08-06 17:25:16 +03:00
e08f805525 small fixes 2020-08-06 15:17:15 +03:00
26742a1fc3 PIFile::readAll patch 2020-08-06 15:01:31 +03:00
70a7363f76 some features
in main.cpp fastest Variant implementation
2020-08-05 00:53:27 +03:00
8405b564a4 Merged master and tests 2020-07-27 12:41:53 +03:00
Шишов Максим Денисович
494b09847e Merge branch 'tests' of https://git.shs.tools/SHS/pip into tests 2020-07-24 15:58:05 +03:00
Шишов Максим Денисович
f1951ee711 CMAKE NEEEEEW 2020-07-24 15:56:51 +03:00
c3257c7c50 Удалить 'CMakeLists.txt.user' 2020-07-24 15:28:11 +03:00
Шишов Максим Денисович
13bafdc7c1 core test 2020-07-24 15:26:37 +03:00
Шишов Максим Денисович
f71fbb0068 new cmake 2020-07-24 15:24:13 +03:00
Шишов Максим Денисович
bb635f6c51 matrix testing 2020-07-23 17:29:37 +03:00
Шишов Максим Денисович
d8e47afe13 matrix tests 2020-07-23 17:28:10 +03:00
dbb84885e3 pimatmatrix test 2020-07-16 16:33:31 +03:00
294 changed files with 8127 additions and 5539 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
/.svn
/doc/rtf
_unsused
CMakeLists.txt.user*

View File

@@ -1,46 +1,37 @@
cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(pip)
set(_PIP_MAJOR 1)
set(_PIP_MINOR 99)
set(_PIP_REVISION 3)
set(_PIP_SUFFIX _prebeta)
set(_PIP_COMPANY SHS)
set(_PIP_DOMAIN org.SHS)
set(pip_MAJOR 2)
set(pip_MINOR 15)
set(pip_REVISION 1)
set(pip_SUFFIX )
set(pip_COMPANY SHS)
set(pip_DOMAIN org.SHS)
if ("x${CMAKE_MODULE_PATH}" STREQUAL "x")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(PIP_BUILD 1)
include(CheckFunctionExists)
include(GenerateExportHeader)
include(DeployMacros)
include(PIPMacros)
if(NOT DEFINED BUILD_NUMBER)
set(BUILD_NUMBER 9999)
endif()
if("x${BUILD_NUMBER}" STREQUAL "x")
set(BUILD_NUMBER 0)
endif()
include(SHSTKMacros)
shstk_begin_project(pip PIP)
set(_ICU_DEFAULT OFF)
if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE))
set(_ICU_DEFAULT ON)
endif()
set(PIP_DLL_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "")
# Options
option(ICU "ICU support for convert codepages" ${_ICU_DEFAULT})
option(STD_IOSTREAM "Building with std iostream operators support" OFF)
option(INTROSPECTION "Build with introspection" OFF)
option(LIB "System install" ON)
option(STATIC_LIB OFF)
option(TESTS "Build tests and perform their before install step" OFF)
option(COVERAGE "Build project with coverage info" OFF)
set(PIP_UTILS 1)
if(LIBPROJECT)
set(PIP_UTILS ${UTILS})
endif()
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 11)
@@ -66,11 +57,13 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
set(HS)
set(PHS)
set(CRES)
file(GLOB_RECURSE CPPS "lib/${NAME}/*.cpp")
file(GLOB_RECURSE HS "lib/${NAME}/*.h")
file(GLOB_RECURSE PHS "lib/${NAME}/*_p.h")
file(GLOB_RECURSE RES "lib/${NAME}/*conf.h")
list(REMOVE_ITEM HS "${PHS}")
file(GLOB_RECURSE CPPS "libs/${NAME}/*.cpp")
file(GLOB_RECURSE HS "libs/${NAME}/*.h")
file(GLOB_RECURSE PHS "libs/${NAME}/*_p.h")
file(GLOB_RECURSE RES "libs/${NAME}/*.conf")
if (NOT "x${PHS}" STREQUAL "x")
list(REMOVE_ITEM HS ${PHS})
endif()
list(APPEND HDRS ${HS})
list(APPEND PHDRS ${PHS})
@@ -84,11 +77,11 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
string(TOUPPER "${_target}" DEF_NAME)
set(PIP_MSG_${NAME} "yes${MSG}")
import_version(${_target} PIP)
set_deploy_property(${_target} ${PIP_LIB_TYPE}
import_version(${_target} pip)
set_deploy_property(${_target} ${pip_LIB_TYPE}
LABEL "${LABEL}"
FULLNAME "${_PIP_DOMAIN}.${_target}"
COMPANY "${_PIP_COMPANY}"
FULLNAME "${pip_DOMAIN}.${_target}"
COMPANY "${pip_COMPANY}"
INFO "Platform-Independent Primitives")
make_rc(${_target} _RC)
@@ -101,23 +94,22 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
endif()
endforeach()
if (NOT "${RES}" STREQUAL "")
if (NOT "x${RES}" STREQUAL "x")
pip_resources(CRES "${RES}")
endif()
add_definitions(-D${DEF_NAME})
add_library(${_target} ${PIP_LIB_TYPE} ${CPPS} ${CRES} ${_RC})
if (NOT "${RES}" STREQUAL "")
add_library(${_target} ${pip_LIB_TYPE} ${CPPS} ${CRES} ${_RC})
target_include_directories(${_target} PUBLIC ${PIP_INCLUDES})
if (NOT "x${RES}" STREQUAL "x")
add_dependencies(${_target} pip_rc)
endif()
if (NOT "${INCLUDES}" STREQUAL "")
if (NOT "x${INCLUDES}" STREQUAL "x")
target_include_directories(${_target} PRIVATE ${INCLUDES})
endif()
generate_export_header(${_target})
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/${_target}_export.h")
list(APPEND PIP_EXPORTS "${DEF_NAME}_EXPORT")
target_link_libraries(${_target} ${LINK_LIBS})
list(APPEND PIP_MODULES ${_target})
if (NOT "${LIBS}" STREQUAL "")
if (NOT "x${LIBS}" STREQUAL "x")
list(APPEND LIBS_STATUS ${LIBS})
endif()
endmacro()
@@ -130,67 +122,9 @@ macro(pip_find_lib NAME)
endif()
endmacro()
if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
set(STATIC_LIB ON)
endif()
if(STATIC_LIB)
set(PIP_LIB_TYPE STATIC)
set(PIP_LIB_TYPE_MSG "Static")
add_definitions(-DPIP_STATIC_DEFINE)
else()
set(PIP_LIB_TYPE SHARED)
set(PIP_LIB_TYPE_MSG "Shared")
endif()
# Version
set_version(PIP
MAJOR "${_PIP_MAJOR}"
MINOR "${_PIP_MINOR}"
REVISION "${_PIP_REVISION}"
BUILD "${BUILD_NUMBER}"
SUFFIX "${_PIP_SUFFIX}"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
endif()
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_version.h")
if(MINGW)
find_package(MinGW REQUIRED)
list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB})
else()
if(APPLE)
if(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_NAME_DIR "@rpath")
else()
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib")
set(CMAKE_MACOSX_RPATH 1)
else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib")
endif()
endif()
if(LIB)
if(WIN32)
if(MINGW)
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
endif()
else()
if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else()
if(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX})
else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
endif()
endif()
endif()
endif()
if (NOT DEFINED PIP_CMG)
if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM))
@@ -210,18 +144,15 @@ get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
# Main lib
file(GLOB PIP_FOLDERS LIST_DIRECTORIES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/lib/main/*")
list(APPEND PIP_FOLDERS "${CMAKE_CURRENT_SOURCE_DIR}/lib/main")
set(PIP_MAIN_FOLDERS)
file(GLOB PIP_FOLDERS LIST_DIRECTORIES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/libs/main/*")
list(APPEND PIP_FOLDERS "${CMAKE_CURRENT_SOURCE_DIR}/libs/main")
set(PIP_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}")
foreach(F ${PIP_FOLDERS})
if (IS_DIRECTORY "${F}")
list(APPEND PIP_MAIN_FOLDERS "${F}")
include_directories("${F}")
list(APPEND PIP_INCLUDES "${F}")
#include_directories("${F}")
endif()
endforeach(F)
if (DEFINED LIBPROJECT)
set(PIP_MAIN_FOLDERS "${PIP_MAIN_FOLDERS}" PARENT_SCOPE)
endif()
if (TESTS)
set(PIP_ROOT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
@@ -231,7 +162,7 @@ endif()
if(PIP_FREERTOS)
add_definitions(-DPIP_FREERTOS)
set(ICU OFF)
set(LIB OFF)
set(LOCAL ON)
endif()
# Check Bessel functions
@@ -285,6 +216,18 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
endif()
set(PIP_COVERAGE "no")
if (COVERAGE)
find_program(GCOV_EXECUTABLE gcov)
if (GCOV_EXECUTABLE)
set(PIP_COVERAGE "yes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
else()
message(STATUS "GCOV_EXECUTABLE: not found")
endif()
endif()
# Check if std::iostream operators support
set(PIP_STD_IOSTREAM "no")
@@ -367,7 +310,6 @@ else()
pip_find_lib(${LIB_})
endforeach()
endif()
import_version(pip PIP)
if(WIN32)
add_definitions(-DPSAPI_VERSION=1)
if(${C_COMPILER} STREQUAL "cl.exe")
@@ -384,6 +326,15 @@ set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
pip_module(main "${LIBS_MAIN}" "PIP main library" "" "")
generate_export_header(pip)
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
foreach(_m ${PIP_SRC_MODULES})
set_target_properties(pip PROPERTIES DEFINE_SYMBOL pip_${_m}_EXPORTS)
generate_export_header(pip BASE_NAME "pip_${_m}")
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_${_m}_export.h")
endforeach()
set_target_properties(pip PROPERTIES DEFINE_SYMBOL pip_EXPORTS)
if (NOT CROSSTOOLS)
if (NOT PIP_FREERTOS)
@@ -462,7 +413,11 @@ if (NOT CROSSTOOLS)
if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
target_link_libraries(_opencl_lib OpenCL)
endif()
pip_module(opencl "${_opencl_lib}" "PIP OpenCL support" "" " (${OpenCL_VERSION_STRING})")
set(_opencl_inc "${OpenCL_INCLUDE_DIRS}")
if(APPLE)
set(_opencl_inc "${OpenCL_INCLUDE_DIRS}/Headers")
endif()
pip_module(opencl "${_opencl_lib}" "PIP OpenCL support" "${_opencl_inc}" " (${OpenCL_VERSION_STRING})")
endif()
@@ -479,39 +434,27 @@ if (NOT CROSSTOOLS)
endif()
find_package(Lua QUIET)
if (LUA_FOUND)
pip_module(lua "LUA" "PIP Lua support" "${LUA_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd" " (${LUA_VERSION_STRING})")
list(APPEND HDR_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd/LuaBridge")
pip_module(lua "LUA" "PIP Lua support" "${LUA_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd" " (${LUA_VERSION_STRING})")
list(APPEND HDR_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd/LuaBridge")
endif()
# Test program
if(PIP_UTILS)
#add_library(pip_plugin SHARED "test_plugin.h" "test_plugin.cpp")
#target_link_libraries(pip_plugin pip)
add_executable(pip_test "main.cpp")
target_link_libraries(pip_test pip)
target_link_libraries(pip_test pip pip_cloud)
if (LUA_FOUND)
target_link_libraries(pip_test pip_lua ${LUA_LIBRARIES})
endif()
endif()
else()
set(PIP_MSG_crypt "yes")
set(PIP_MSG_compress "yes")
set(PIP_MODULES pip)
add_definitions(-DPIP_CRYPT)
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
target_link_libraries(pip_crypt pip)
list(APPEND PIP_MODULES pip_crypt)
set(IO_UTILS_LIBS pip)
add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS})
list(APPEND IO_UTILS_LIBS pip_crypt)
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
list(APPEND PIP_MODULES pip_io_utils)
add_definitions(-DPIP_COMPRESS)
add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS})
target_link_libraries(pip_compress pip)
list(APPEND PIP_MODULES pip_compress)
pip_module(crypt "" "PIP crypt support" "" "")
pip_module(compress "" "PIP compression support" "" "")
pip_module(io_utils "pip_crypt" "PIP I/O support" "" " (+crypt)")
endif()
endif()
@@ -520,11 +463,10 @@ target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
# Install
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
if(LIB)
if(NOT LOCAL)
if(WIN32)
if(MINGW)
if (NOT CROSSTOOLS)
install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
if(HDR_DIRS)
install(DIRECTORY ${HDR_DIRS} DESTINATION ${MINGW_INCLUDE}/pip)
@@ -552,8 +494,6 @@ if(LIB)
endif()
install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
else()
if(NOT PIP_FREERTOS)
if(WIN32)
@@ -568,6 +508,8 @@ else()
endif()
endif()
endif()
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
if(NOT PIP_FREERTOS)
@@ -593,11 +535,9 @@ if(NOT PIP_FREERTOS)
endif()
# Libraries messages
if(DEFINED LIBPROJECT)
shstk_is_parent_exists(_pe)
if (_pe)
set(PIP_MODULES ${PIP_MODULES} PARENT_SCOPE)
list(APPEND _ALL_TARGETS ${PIP_MODULES})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
endif()
#
@@ -607,12 +547,12 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
include(PIPDocumentation)
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXY_PROJECT_NUMBER "${PIP_VERSION}")
set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
set(DOXY_PROJECT_NUMBER "${pip_VERSION}")
set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${pip_VERSION}\"")
set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${pip_VERSION}\"")
set(DOXY_EXAMPLE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/examples\"")
set(DOXY_IMAGE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/images\"")
set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd\"")
set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd\"")
if(DOXYGEN_DOT_EXECUTABLE)
string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}")
set(DOXY_DOT_PATH "\"${_DOT_PATH}\"")
@@ -623,7 +563,7 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
foreach(F ${PIP_MAIN_FOLDERS})
list(APPEND DOXY_INPUT "\"${F}\"")
endforeach(F)
string(REPLACE ";" " " DOXY_INPUT "\"${CMAKE_CURRENT_SOURCE_DIR}/lib\"")
string(REPLACE ";" " " DOXY_INPUT "\"${CMAKE_CURRENT_SOURCE_DIR}/libs\"")
string(REPLACE ";" " " DOXY_INCLUDE_PATH "${DOXY_INPUT}")
string(REPLACE ";" " " DOXY_DEFINES "${PIP_EXPORTS};DOXYGEN;PIOBJECT;PIOBJECT_SUBCLASS")
add_documentation(doc doc/Doxyfile.in)
@@ -632,13 +572,30 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
endif()
set(_max_len 0)
foreach(_m ${PIP_SRC_MODULES})
string(LENGTH "${_m}" _clen)
if (_clen GREATER _max_len)
set(_max_len ${_clen})
endif()
endforeach()
macro(expand_to_length _out _str _len)
set(${_out} "${_str}")
while(TRUE)
string(LENGTH "${${_out}}" _clen)
if (_clen GREATER_EQUAL ${_len})
break()
endif()
string(APPEND ${_out} " ")
endwhile()
endmacro()
list(REMOVE_ITEM LIBS_STATUS ${PIP_MODULES})
message("----------PIP----------")
message(" Version: ${PIP_VERSION} ")
message(" Linkage: ${PIP_LIB_TYPE_MSG}")
message(" Type : ${PIP_BUILD_TYPE}")
if(LIB)
message(" Version: ${pip_VERSION} ")
message(" Linkage: ${pip_LIB_TYPE_MSG}")
message(" Type : ${pip_BUILD_TYPE}")
if (NOT LOCAL)
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
else()
if(NOT PIP_FREERTOS)
@@ -651,13 +608,15 @@ message(" std::iostream: ${PIP_STD_IOSTREAM}")
message(" ICU strings : ${PIP_ICU}")
message(" Timer types : ${PIP_TIMERS}")
message(" Introspection: ${PIP_INTROSPECTION}")
message(" Coverage : ${PIP_COVERAGE}")
if(INTROSPECTION)
message(STATUS " Warning: Introspection reduces the performance!")
endif()
message("")
message(" Modules:")
foreach(_m ${PIP_SRC_MODULES})
message(" ${_m}: ${PIP_MSG_${_m}}")
expand_to_length(_m_e "${_m}" ${_max_len})
message(" ${_m_e}: ${PIP_MSG_${_m}}")
endforeach()
message("")
if (PIP_TESTS_LIST)

View File

@@ -1,1068 +0,0 @@
#[[
Important! You should include this file
in your top-level CMakeLists.txt
set_version(<target> [MAJOR <value>] [MINOR <value>] [REVISION <value>] [SUFFIX <value>] [BUILD <value>] [OUTPUT <file>])
Set target version, optionally creates file
Create variable <target>_VERSION with full version name
If OUTPUT then generate header <file> with
version macros - <target>_VERSION_<NAME>
Also create macro <target>_VERSION_NAME with full string version
Attention: macro <target>_VERSION is byte-packed integer version!
set_lang(<target> <lang> [<lang> [...] ])
Set target translations, e.g. "ru" "fr"
import_version(<target> <source_target>)
Copy all version components and languages from <source_target>
import_deploy_properties(<target> <source_target>)
Copy all deploy properties from <source_target>
set_deploy_property(<target> [SHARED | STATIC] NAME <value> [NAME <value> [...] ])
Set target deploy property, where NAME one of:
* LABEL - application icon name
* FULLNAME - package name in format "*.*.*"
* COMPANY - company name
* ICON - icon file path
* INFO - additional info
Specify SHARED or STATIC if your target is library
You can setup several properties in one command
make_rc(<target> <rc_out_file>)
Generate Windows *.rc file from deploy properties
and return file path to <rc_out_file>
On other platforms this variable set to empty
You should set version and deploy properties
before call this macro, see
"set_version()" and "set_deploy_property()"
deploy_target(<target> [DEPLOY_DIR <dir>]
[DESTINATION <dir>]
[RESOURCES <dir|file> [<dir|file> ...] ]
[PLUGINS <dir|file> [<dir|file> ...] ]
[FILES <dir|file> [<dir|file> ...] ]
[LIBS <dir|file> [<dir|file> ...] ]
[OPTIONS <flag> ...]
[VERBOSE]
[DMG_NO_ZIP]
[DEB_USR_DIR] [DEB_ADD_SERVICE])
Create make target "deploy_<target>", depends on target "deploy".
On this target create release package, containing all dependencies:
* .zip on Windows
* .deb on Linux
* .dmg[.zip] on MacOS
* .apk/.aab on Android
If not defined DMG_NO_ZIP then *.dmg.zip will be created on MacOS.
You should set version and deploy properties
before call this macro, see
"set_version()" and "set_deploy_property()".
Example:
deploy_target(my_app DESTINATION packages)
DEPLOY_DIR - dir where you install
* executable on Windows, Linux
* <T>.app directory with executable on MacOS
DESTINATION - dir where macro place package
RESOURCES, PLUGINS and FILES - list of directories and files, copied to:
| | Windows | Linux | Linux (DEB_USR_DIR) | MacOS |
|-----------|---------|-------------------------|---------------------------|---------------------|
| RESOURCES | root | /opt/COMPANY/target | /usr/share/COMPANY/target | Contents/Resources |
| PLUGINS | root | /opt/COMPANY/target | /usr/lib/COMPANY/target | Contents/PlugIns |
| FILES | root | /opt/COMPANY/target | /usr/bin | Contents/MacOS |
| LIBS | root | /opt/COMPANY/target/lib | /usr/lib | Contents/Frameworks |
Relative paths are taken from DEPLOY_DIR
Also check library dependencies from PLUGINS and FILES
Important! RESOURCES, PLUGINS, FILES and LIBS lists check
at cmake-time, so if entry ends with "/" it treat
as directory, else - file
This macro using "deploy_tool" from PIP,
so make sure it can be executed from shell
OPTIONS allow you to pass custom flags to "deploy_tool"
You can see flags by launch "deploy_tool" without arguments
Using CMAKE_LDD, CMAKE_OTOOL or CMAKE_OBJDUMP variable,
depends on target platform
DEPLOY_ADD_LIBPATH variable used as additional
library search path
If DEB_ADD_SERVICE then <T>-service.deb package will be created.
This package use contents of CMAKE_CURRENT_SOURCE_DIR/debian-service directory:
* CMAKE_CURRENT_SOURCE_DIR/debian-service/DEBIAN/
* CMAKE_CURRENT_SOURCE_DIR/debian-service/*.service
.service file placed in /opt/COMPANY/target, you should copy it to system with script
You can use "postinst,postrm,preinst,prerm,config" files to configure service
]]
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
if (POLICY CMP0057)
cmake_policy(SET CMP0057 NEW) # Support if() IN_LIST
endif()
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif()
set(__prop_names "LABEL;FULLNAME;COMPANY;ICON;INFO")
list(APPEND __prop_names "ANDROID_TARGET_SDK;ANDROID_STORE_FILE;ANDROID_STORE_PASSWORD;ANDROID_KEY_PASSWORD;ANDROID_KEY_ALIAS;ANDROID_NEW_LOADER")
set(__version_names "MAJOR;MINOR;REVISION;BUILD;SUFFIX")
include(TargetArch)
if (NOT MY_ARCH)
target_architecture(MY_ARCH)
endif()
if (NOT _dep_exists)
set(_dep_exists 1)
add_custom_target(deploy COMMENT "Deploy")
endif()
set(_modules_dir "${CMAKE_ROOT}/Modules")
if (LIBPROJECT)
set(_modules_dir ${PIP_CMAKE_MODULE_PATH})
endif()
set(_dt_delim "::")
macro(set_version _T)
set(_VERSION_ 1) # macro version
set(_name)
set(_is_name 1)
set(_is_out 0)
set(_out)
foreach(_i ${ARGN})
if (_is_out)
set(_is_out 0)
set(_out "${_i}")
elseif ("x${_i}" STREQUAL "xOUTPUT")
set(_is_out 1)
elseif(_is_name)
set(_is_name 0)
if (_i IN_LIST __version_names)
else()
message(FATAL_ERROR "Invalid version component \"${_i}\"!")
endif()
set(_name ${_i})
else()
set(_is_name 1)
set(${_T}_VERSION_${_name} ${_i})
endif()
endforeach()
set(${_T}_VERSION_FULLSUFFIX "${${_T}_VERSION_SUFFIX}")
if (NOT ("x${${_T}_VERSION_FULLSUFFIX}" STREQUAL "x"))
if(NOT ("${${_T}_VERSION_FULLSUFFIX}" MATCHES "_.*"))
set(${_T}_VERSION_FULLSUFFIX "_${${_T}_VERSION_FULLSUFFIX}")
endif()
endif()
if ("x${${_T}_VERSION_MAJOR}" STREQUAL "x")
set(${_T}_VERSION_MAJOR "0")
endif()
if ("x${${_T}_VERSION_MINOR}" STREQUAL "x")
set(${_T}_VERSION_MINOR "0")
endif()
if ("x${${_T}_VERSION_REVISION}" STREQUAL "x")
set(${_T}_VERSION_REVISION "0")
endif()
if ("x${${_T}_VERSION_BUILD}" STREQUAL "x")
set(${_T}_VERSION_BUILD "0")
endif()
set(${_T}_VERSION "${${_T}_VERSION_MAJOR}.${${_T}_VERSION_MINOR}.${${_T}_VERSION_REVISION}${${_T}_VERSION_FULLSUFFIX}")
set(_${_T}_VERSION_WB "${${_T}_VERSION}-${${_T}_VERSION_BUILD}")
if (_out)
set(_${_T}_VERSION_CHANGED 0)
if ((NOT _${_T}_CACHED_VERSION) OR (NOT ("x${_${_T}_CACHED_VERSION}" STREQUAL "x${_${_T}_VERSION_WB}")))
set(_${_T}_CACHED_VERSION "${_${_T}_VERSION_WB}" CACHE STRING "" FORCE)
set(_${_T}_VERSION_CHANGED 1)
endif()
if ((NOT _${_T}_CACHED_VERSION_VER) OR (NOT ("x${_${_T}_CACHED_VERSION_VER}" STREQUAL "x${_VERSION_}")))
set(_${_T}_CACHED_VERSION_VER "${_VERSION_}" CACHE STRING "" FORCE)
set(_${_T}_VERSION_CHANGED 1)
endif()
if ((NOT EXISTS "${_out}") OR _${_T}_VERSION_CHANGED)
get_filename_component(_def "${_out}" NAME)
string(MAKE_C_IDENTIFIER "${_T}_${_def}" _def)
string(TOUPPER "${_def}" _def)
string(TOUPPER "${_T}" _TN)
string(TIMESTAMP _cur_date "%d.%m.%Y %H:%M")
file(WRITE "${_out}"
"// This file generated by CMake set_version() version ${_VERSION_}
#ifndef ${_def}
#define ${_def}
// Project
#define ${_TN}_VERSION_MAJOR ${${_T}_VERSION_MAJOR}
#define ${_TN}_VERSION_MINOR ${${_T}_VERSION_MINOR}
#define ${_TN}_VERSION_REVISION ${${_T}_VERSION_REVISION}
#define ${_TN}_VERSION_BUILD ${${_T}_VERSION_BUILD}
#define ${_TN}_VERSION_SUFFIX \"${${_T}_VERSION_SUFFIX}\"
#define ${_TN}_VERSION_NAME \"${${_T}_VERSION}\"
#define ${_TN}_VERSION ((${_TN}_VERSION_MAJOR << 16) | (${_TN}_VERSION_MINOR << 8) | ${_TN}_VERSION_REVISION)
// Tools
#define ${_TN}_CMAKE_VERSION \"${CMAKE_VERSION}\"
#define ${_TN}_CXX_COMPILER \"${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}\"
#define ${_TN}_BUILD_DATE \"${_cur_date}\"
#define ${_TN}_ARCH \"${MY_ARCH}\"
#endif // ${_def}
")
endif()
endif()
endmacro()
macro(set_lang _T)
set(${_T}_LANG)
foreach(_i ${ARGN})
list(APPEND ${_T}_LANG "${_i}")
endforeach()
endmacro()
macro(import_version _T _F)
set(_names "${__version_names};FULLSUFFIX")
foreach(_i ${_names})
set(${_T}_VERSION_${_i} "${${_F}_VERSION_${_i}}")
endforeach()
set(${_T}_VERSION "${${_F}_VERSION}")
set(${_T}_LANG "${${_F}_LANG}")
endmacro()
macro(import_deploy_properties _T _F)
foreach(_i ${__prop_names})
set(${_T}_${_i} "${${_F}_${_i}}")
endforeach()
endmacro()
macro(set_deploy_property _T)
set(_name)
set(_is_name 1)
foreach(_i ${ARGN})
if (("x${_i}" STREQUAL "xSHARED") OR ("x${_i}" STREQUAL "xSTATIC"))
set(${_T}_TYPE "${_i}")
elseif(_is_name)
set(_is_name 0)
if (_i IN_LIST __prop_names)
else()
message(FATAL_ERROR "Invalid property name \"${_i}\"!")
endif()
set(_name ${_i})
else()
set(_is_name 1)
set(${_T}_${_name} ${_i})
endif()
endforeach()
endmacro()
macro(make_rc _T _out)
if (WIN32)
if ("x${${_T}_VERSION_MAJOR}" STREQUAL "x")
message(FATAL_ERROR "Version for \"${_T}\" not set, use set_version()!")
endif()
string(REPLACE "\"" "\"\"" WINDOWS_RC_FULLNAME "${${_T}_FULLNAME}")
string(REPLACE "\"" "\"\"" WINDOWS_RC_VERSION "${${_T}_VERSION}" )
string(REPLACE "\"" "\"\"" WINDOWS_RC_LABEL "${${_T}_LABEL}" )
string(REPLACE "\"" "\"\"" WINDOWS_RC_COMPANY "${${_T}_COMPANY}" )
string(REPLACE "\"" "\"\"" WINDOWS_RC_INFO "${${_T}_INFO}" )
if (("x${${_T}_TYPE}" STREQUAL "x") OR ("x${${_T}_TYPE}" STREQUAL "xEXECUTABLE"))
set(WINDOWS_RC_FILETYPE "0x1L")
set(_rc_prefix "")
set(_rc_ext "exe")
elseif ("x${${_T}_TYPE}" STREQUAL "xSHARED")
set(WINDOWS_RC_FILETYPE "0x2L")
set(_rc_prefix "lib")
set(_rc_ext "dll")
elseif ("x${${_T}_TYPE}" STREQUAL "xSTATIC")
set(WINDOWS_RC_FILETYPE "0x7L")
set(_rc_prefix "lib")
set(_rc_ext "a")
endif()
set(_rc_version "${${_T}_VERSION_MAJOR},${${_T}_VERSION_MINOR},${${_T}_VERSION_REVISION},${${_T}_VERSION_BUILD}")
set(_icon)
if (NOT ("x${${_T}_ICON}" STREQUAL "x"))
get_filename_component(WINDOWS_RC_ICON "${${_T}_ICON}" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(_icon "1 ICON \"${WINDOWS_RC_ICON}\"")
endif()
set(_rc_file "${CMAKE_CURRENT_BINARY_DIR}/${_T}_winres.rc")
file(WRITE "${_rc_file}"
"# if defined(UNDER_CE)
# include <winbase.h>
# else
# include <winver.h>
# endif
#pragma code_page(65001)
${_icon}
VS_VERSION_INFO VERSIONINFO
FILEVERSION ${_rc_version}
PRODUCTVERSION ${_rc_version}
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
FILETYPE ${WINDOWS_RC_FILETYPE}
FILESUBTYPE 0x0L
BEGIN
BLOCK \"StringFileInfo\"
BEGIN
BLOCK \"041904B0\"
BEGIN
VALUE \"Comments\", \"\\0\"
VALUE \"CompanyName\", \"${WINDOWS_RC_COMPANY}\\0\"
VALUE \"FileDescription\", \"${WINDOWS_RC_INFO}\\0\"
VALUE \"FileVersion\", \"${WINDOWS_RC_VERSION}\\0\"
VALUE \"InternalName\", \"${WINDOWS_RC_FULLNAME}\\0\"
VALUE \"LegalTrademarks\", \"\\0\"
VALUE \"LegalCopyright\", \"${WINDOWS_RC_COMPANY}\\0\"
VALUE \"OriginalFilename\", \"${_rc_prefix}${_T}.${_rc_ext}\\0\"
VALUE \"ProductName\", \"${WINDOWS_RC_LABEL}\\0\"
VALUE \"ProductVersion\", \"${WINDOWS_RC_VERSION}\\0\"
END
END
BLOCK \"VarFileInfo\"
BEGIN
VALUE \"Translation\", 0x0419, 0x04B0, 0x0409, 0x04B0
END
END
")
set(${_out} ${_rc_file})
else()
set(${_out})
endif()
endmacro()
# Help macros begin
macro(__add_file_or_dir _DIR_VAR _FILE_VAR _PATH _RELPATH)
set(_p)
set(_abs 0)
if (IS_ABSOLUTE "${_PATH}")
set(_abs 1)
endif()
if ("${_PATH}" MATCHES "^\$<")
set(_abs 1)
endif()
if (_abs)
set(_p "${_PATH}")
else()
set(_p "${_RELPATH}/${_PATH}")
endif()
if ("${_p}" MATCHES ".*/$")
string(LENGTH "${_p}" __sl)
math(EXPR __sl ${__sl}-1)
string(SUBSTRING "${_p}" 0 ${__sl} _p)
list(APPEND ${_DIR_VAR} "${_p}")
else()
list(APPEND ${_FILE_VAR} "${_p}")
endif()
endmacro()
set(__win_host 0)
set(__mac_host 0)
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows")
set(__win_host 1)
endif()
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xDarwin")
set(__mac_host 1)
endif()
macro(__make_win_path _in_path _out_var _is_dir _out_dir)
set(_add "")
if (${_is_dir})
set(_add "/")
endif()
file(TO_NATIVE_PATH "${_in_path}" ${_out_var})
string(REPLACE "//" "/" ${_out_var} "${${_out_var}}${_add}")
if (NOT "x${_out_dir}" STREQUAL "x")
string(LENGTH "${${_out_var}}" __sl)
math(EXPR __sl ${__sl}-1)
string(SUBSTRING "${${_out_var}}" 0 ${__sl} __substr)
get_filename_component(${_out_dir} "${__substr}" NAME)
#message("dirname src=\"${${_out_var}}\", len=${__sl} \"${__substr}\" = \"${${_out_dir}}\"")
endif()
string(REPLACE "/" "\\" ${_out_var} "${${_out_var}}")
endmacro()
macro(__make_dir _cmd _dest)
if (__win_host)
__make_win_path("${_dest}" __d 1 "")
set(${_cmd} ${${_cmd}} COMMAND if not exist "\"${__d}\"" mkdir "\"${__d}\"")
else()
set(${_cmd} ${${_cmd}} COMMAND mkdir ${_VERB} -p "${_dest}")
endif()
endmacro()
macro(__make_copy _cmd _dirs _files _dest)
if (${_dirs} OR ${_files})
__make_dir(${_cmd} "${_dest}")
endif()
if (__win_host)
__make_win_path("${_dest}" _wdest 1 "")
foreach(_d ${${_dirs}})
__make_win_path("${_d}" _wsrc 1 _dirname)
__make_dir(${_cmd} "${_dest}/${_dirname}")
set(${_cmd} ${${_cmd}} COMMAND xcopy /y /r /e "${_wsrc}*" "\"${_wdest}${_dirname}\\\"" ${_WVERB})
endforeach()
foreach(_f ${${_files}})
__make_win_path("${_f}" _wsrc 0 "")
set(${_cmd} ${${_cmd}} COMMAND xcopy /y /r "\"${_wsrc}\"" "\"${_wdest}\"" ${_WVERB})
endforeach()
else()
foreach(_d ${${_dirs}})
set(${_cmd} ${${_cmd}} COMMAND cp ${_VERB} -rf "${_d}" "${_dest}/")
endforeach()
foreach(_f ${${_files}})
set(${_cmd} ${${_cmd}} COMMAND cp ${_VERB} -f "${_f}" "${_dest}/")
endforeach()
endif()
endmacro()
macro(__gather_deps _T _search_path_var _dep_libs_var _dep_libs_cs_var _added_)
get_target_property(_LL${_T} ${_T} LINK_LIBRARIES)
foreach (_L${_T} ${_LL${_T}})
if (TARGET ${_L${_T}})
get_target_property(_II${_T} ${_L${_T}} IMPORTED)
if (NOT _II${_T})
#message("depend on ${_L${_T}}")
get_target_property(_LT${_T} ${_L${_T}} TYPE)
if (("x${_LT${_T}}" STREQUAL "xSHARED_LIBRARY") OR ("x${_LT${_T}}" STREQUAL "xSTATIC_LIBRARY"))
if (NOT _L${_T} IN_LIST ${_added_})
list(APPEND ${_added_} ${_L${_T}})
__gather_deps(${_L${_T}} ${_search_path_var} ${_dep_libs_var} ${_dep_libs_cs_var} ${_added_})
if ("x${_LT${_T}}" STREQUAL "xSHARED_LIBRARY")
if (NOT DEFINED ANDROID_PLATFORM)
set(${_search_path_var} "${${_search_path_var}}${_dt_delim}$<TARGET_FILE_DIR:${_L${_T}}>")
endif()
set(${_dep_libs_cs_var} "${${_dep_libs_cs_var}}${_dt_delim}$<TARGET_FILE_DIR:${_L${_T}}>/$<TARGET_FILE_NAME:${_L${_T}}>")
set(${_dep_libs_var} "${${_dep_libs_var}}" "$<TARGET_FILE_DIR:${_L${_T}}>/$<TARGET_FILE_NAME:${_L${_T}}>")
endif()
endif()
endif()
endif()
endif()
endforeach()
endmacro()
set(__macos_privacy_text "Application request permission")
set(__macos_privacies
"<key>NFCReaderUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSAppleMusicUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSCalendarsUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSCameraUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSContactsUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSFaceIDUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSHealthShareUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSHealthUpdateUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSHomeKitUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSMicrophoneUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSMotionUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSRemindersUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSVideoSubscriberAccountUsageDescription</key>
<string>${__macos_privacy_text}</string>"
)
set(__gradle_lang_start
" defaultConfig {
resConfigs ")
set(__gradle_sign
" signingConfigs {
debug {
storeFile file(DEBUG_STORE_FILE)
}
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyPassword RELEASE_KEY_PASSWORD
keyAlias RELEASE_KEY_ALIAS
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}")
# Help macros end
macro(deploy_target _T)
set(_DESTINATION "${CMAKE_INSTALL_PREFIX}")
set(_DEPLOY_DIR "${CMAKE_INSTALL_PREFIX}")
set(_RES_DIRS)
set(_RES_FILES)
set(_PLUG_DIRS)
set(_PLUG_FILES)
set(_FILE_DIRS)
set(_FILE_FILES)
set(_LIBS_DIRS)
set(_LIBS_FILES)
set(_VERB)
set(_WVERB 1> NUL)
set(_OPTIONS)
set(_ZIP_DMG 1)
set(_DEB_OPT 1)
set(_DEB_SERVICE 0)
set(_cur_arg)
set(__args "DESTINATION;DEPLOY_DIR;RESOURCES;PLUGINS;FILES;LIBS;OPTIONS;VERBOSE;DMG_NO_ZIP;DEB_USR_DIR;DEB_ADD_SERVICE")
foreach(_i ${ARGN})
if (_i IN_LIST __args)
set(_cur_arg "${_i}")
if ("${_cur_arg}" STREQUAL "VERBOSE")
set(_VERB -v)
set(_WVERB)
elseif("${_cur_arg}" STREQUAL "DMG_NO_ZIP")
set(_ZIP_DMG 0)
elseif("${_cur_arg}" STREQUAL "DEB_USR_DIR")
set(_DEB_OPT 0)
elseif("${_cur_arg}" STREQUAL "DEB_ADD_SERVICE")
set(_DEB_SERVICE 1)
endif()
elseif ("${_cur_arg}" STREQUAL "DESTINATION")
set(_cur_arg)
set(_DESTINATION "${_i}/")
elseif ("${_cur_arg}" STREQUAL "DEPLOY_DIR")
set(_cur_arg)
set(_DEPLOY_DIR "${_i}/")
elseif ("${_cur_arg}" STREQUAL "RESOURCES")
__add_file_or_dir(_RES_DIRS _RES_FILES "${_i}" "${_DEPLOY_DIR}")
elseif ("${_cur_arg}" STREQUAL "PLUGINS")
__add_file_or_dir(_PLUG_DIRS _PLUG_FILES "${_i}" "${_DEPLOY_DIR}")
elseif ("${_cur_arg}" STREQUAL "FILES")
__add_file_or_dir(_FILE_DIRS _FILE_FILES "${_i}" "${_DEPLOY_DIR}")
elseif ("${_cur_arg}" STREQUAL "LIBS")
__add_file_or_dir(_LIBS_DIRS _LIBS_FILES "${_i}" "${_DEPLOY_DIR}")
elseif ("${_cur_arg}" STREQUAL "OPTIONS")
list(APPEND _OPTIONS "${_i}")
endif()
#message("-i = ${_i}")
endforeach()
get_filename_component(_ICON_NAME "${${_T}_ICON}" NAME)
get_filename_component(_ICON_FN "${${_T}_ICON}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(_TV "${_T}_${${_T}_VERSION}")
set(_DEP_LIBPATH)
set(_DEP_LIBS_CS)
set(_DEP_LIBS)
set(_add_search_path)
set(_added_)
set(_ADD_DEPS ${_PLUG_DIRS} ${_PLUG_FILES} ${_FILE_DIRS} ${_FILE_FILES} ${_LIBS_DIRS} ${_LIBS_FILES})
__gather_deps(${_T} _add_search_path _DEP_LIBS _DEP_LIBS_CS _added_)
foreach (_L ${DEPLOY_ADD_LIBPATH})
set(_add_search_path "${_add_search_path}${_dt_delim}${_L}")
endforeach()
#message("app depend ${_T} libpath ${_add_search_path}")
set(_CMD_)
set(_deployed)
if ("x${CMAKE_SYSTEM_NAME}" STREQUAL "xLinux")
set(_os_id "")
set(_os_ver "")
set(_paths "/usr/lib" "/etc")
if (CMAKE_CROSSCOMPILING)
set(_paths "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/../etc")
endif()
find_file(_release_file NAMES os-release lsb-release PATHS ${_paths} NO_DEFAULT_PATH)
if (NOT "x${_release_file}" STREQUAL "x")
file(STRINGS "${_release_file}" _lines)
foreach(_l ${_lines})
if ("${_l}" MATCHES "VERSION_ID=.*")
string(SUBSTRING "${_l}" 11 -1 _os_ver)
string(REPLACE "\"" "" _os_ver "${_os_ver}")
#message("VERSION_ID ${_os_ver}")
elseif ("${_l}" MATCHES "ID=.*")
string(SUBSTRING "${_l}" 3 -1 _os_id)
string(REPLACE "\"" "" _os_id "${_os_id}")
#message("ID ${_os_id}")
endif()
endforeach()
endif()
set(_build "${${_T}_VERSION_BUILD}")
if (NOT "x${_build}" STREQUAL "x")
set(_build "-${_build}")
endif()
string(TOLOWER "${_os_id}${_os_ver}" _TARGET_OS)
if ("x${_TARGET_OS}" STREQUAL "x")
set(_TARGET_OS "linux")
endif()
string(REPLACE "_" "-" _DEBNAME "${_T}")
string(REPLACE "_" "-" _DEBVERSION "${${_T}_VERSION}${_build}+${_TARGET_OS}")
string(TOLOWER "${_DEBNAME}" _DEBNAME)
set(_DEB_ARCH)
if("_${MY_ARCH}" STREQUAL "_arm64")
set(_DEB_ARCH "arm64")
elseif("_${MY_ARCH}" STREQUAL "_armv7")
set(_DEB_ARCH "armhf")
elseif("_${MY_ARCH}" STREQUAL "_i386")
set(_DEB_ARCH "i386")
elseif("_${MY_ARCH}" STREQUAL "_x86_64")
set(_DEB_ARCH "amd64")
elseif("_${MY_ARCH}" STREQUAL "_ppc")
set(_DEB_ARCH "PowerPC")
elseif("_${MY_ARCH}" STREQUAL "_ppc64")
set(_DEB_ARCH "PPC64")
elseif("_${MY_ARCH}" STREQUAL "_ia64")
set(_DEB_ARCH "ia64")
endif()
set(_DEB "${_TV}_deb_${_DEB_ARCH}")
set(_AGD "${_DEPLOY_DIR}/${_DEB}")
set(_C_echof ">" "${_AGD}/DEBIAN/control")
set(_C_echo ">>" "${_AGD}/DEBIAN/control")
set(_D_echof ">" "${_AGD}/usr/share/applications/${_DEBNAME}.desktop")
set(_D_echo ">>" "${_AGD}/usr/share/applications/${_DEBNAME}.desktop")
set(_bin_path "${_AGD}/usr/bin")
set(_lib_path "${_AGD}/usr/lib")
set(_pli_path "${_AGD}/usr/lib/${${_T}_COMPANY}/${_T}")
set(_res_path "${_AGD}/usr/share/${${_T}_COMPANY}/${_T}")
set(_ico_path "${_AGD}/usr/share/pixmaps")
set(_app_bin_path "/usr/bin")
set(_app_ico_path "/usr/share/pixmaps")
if(_DEB_OPT)
set(_bin_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
set(_lib_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}/lib")
set(_pli_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
set(_res_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
set(_ico_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}/pixmaps")
set(_app_bin_path "/opt/${${_T}_COMPANY}/${_T}")
set(_app_ico_path "/opt/${${_T}_COMPANY}/${_T}/pixmaps")
endif()
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_bin_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_lib_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_pli_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_res_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_ico_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_AGD}/usr/share/applications")
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES ${_bin_path})
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES ${_pli_path})
__make_copy(_CMD_ _RES_DIRS _RES_FILES ${_res_path})
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES ${_lib_path})
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_DEPLOY_DIR}/${_T}" "${_bin_path}/")
if (_DEP_LIBS)
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_DEP_LIBS}" "${_lib_path}/")
endif()
if (_ICON_NAME)
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_ICON_FN}" "${_ico_path}/")
endif()
if(_DEB_OPT)
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_AGD}/usr/bin")
set(_CMD_ ${_CMD_} COMMAND ln -srf ${_VERB} "${_bin_path}/${_T}" "${_AGD}/usr/bin/${_T}")
endif()
file(GLOB _files "${CMAKE_CURRENT_SOURCE_DIR}/debian/DEBIAN/*")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_AGD}/DEBIAN/")
endforeach()
file(GLOB _files "${_AGD}/DEBIAN/p*inst" "${_AGD}/DEBIAN/p*rm" "${_AGD}/DEBIAN/config")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND chmod 0755 ${_VERB} "${_f}")
endforeach()
if (NOT CMAKE_LDD)
find_program(CMAKE_LDD ldd)
endif()
set(_dt_opts -l "${CMAKE_LDD}")
if (CMAKE_CROSSCOMPILING)
set(_dt_searchdirs "${CMAKE_PREFIX_PATH}/lib")
if (NOT "x${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "x")
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${CMAKE_PREFIX_PATH}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${CMAKE_PREFIX_PATH}/../lib/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()
set(_dt_opts -L "${CMAKE_READELF}" --dpkg-workdir "${CMAKE_DPKG_WORKDIR}" -s "${_dt_searchdirs}")
endif()
set(_deb_name "${_TV}_${_TARGET_OS}_${_DEB_ARCH}.deb")
#message("VER = \"${_DEBVERSION}\"")
#message("DEB = \"${_deb_name}\"")
list(APPEND _CMD_ COMMAND echo "Package: ${_DEBNAME}" ${_C_echof})
list(APPEND _CMD_ COMMAND echo "Version: ${_DEBVERSION}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Architecture: ${_DEB_ARCH}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Maintainer: ${${_T}_COMPANY} <>" ${_C_echo})
list(APPEND _CMD_ COMMAND ${PIP_DEPLOY_TOOL} ${_OPTIONS} --prefix "Depends: " --dependencies ${_dt_opts} -a "${_DEP_LIBS_CS}" -o "${_lib_path}" ${_DEPLOY_DIR}/${_T} ${_ADD_DEPS} ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Conflicts:" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Replaces:" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Section: misc" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Priority: optional" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Description: ${${_T}_INFO}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "[Desktop Entry]" ${_D_echof})
list(APPEND _CMD_ COMMAND echo "Encoding=UTF-8" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Type=Application" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Name=${${_T}_LABEL}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "GenericName=${${_T}_LABEL}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Comment=${${_T}_INFO}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Exec=${_app_bin_path}/${_T}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Icon=${_app_ico_path}/${_ICON_NAME}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Terminal=false" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "StartupNotify=true" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Categories=Utility;" ${_D_echo})
add_custom_target(deploy_${_T}
# gather deb dir
COMMAND rm -rf ${_VERB} "${_AGD}"
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
${_CMD_}
# generate deb
COMMAND cd ${_AGD} "&&" md5deep -rl opt usr ">" DEBIAN/md5sums
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
VERBATIM
COMMENT "Generating ${_deb_name}"
)
set(_deployed "deploy_${_T}")
if (_DEB_SERVICE)
set(_CMD_)
set(_DEB "${_TV}-service_deb_${_DEB_ARCH}")
set(_AGD "${_DEPLOY_DIR}/${_DEB}")
set(_C_echof ">" "${_AGD}/DEBIAN/control")
set(_C_echo ">>" "${_AGD}/DEBIAN/control")
set(_opt_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_opt_path}")
file(GLOB _files "${CMAKE_CURRENT_SOURCE_DIR}/debian-service/*.service")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_opt_path}/")
endforeach()
set(__deb_dir "${CMAKE_CURRENT_SOURCE_DIR}/debian-service/DEBIAN")
file(GLOB _files "${__deb_dir}/*")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_AGD}/DEBIAN/")
endforeach()
file(GLOB _files RELATIVE "${__deb_dir}" "${__deb_dir}/p*inst" "${__deb_dir}/p*rm" "${__deb_dir}/config")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND chmod 0755 ${_VERB} "${_AGD}/DEBIAN/${_f}")
endforeach()
set(_deb_name "${_TV}-service_${_TARGET_OS}_${_DEB_ARCH}.deb")
#message("VER = \"${_DEBVERSION}\"")
#message("DEB = \"${_deb_name}\"")
list(APPEND _CMD_ COMMAND echo "Package: ${_DEBNAME}-service" ${_C_echof})
list(APPEND _CMD_ COMMAND echo "Version: ${_DEBVERSION}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Architecture: ${_DEB_ARCH}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Maintainer: ${${_T}_COMPANY} <>" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Depends: ${_DEBNAME} (>= ${_DEBVERSION})" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Conflicts:" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Replaces:" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Section: misc" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Priority: optional" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Description: ${${_T}_LABEL} service" ${_C_echo})
add_custom_target(deploy_${_T}-service
# gather deb dir
COMMAND rm -rf ${_VERB} "${_AGD}"
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
${_CMD_}
# generate deb
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
VERBATIM
COMMENT "Generating ${_deb_name}"
)
list(APPEND _deployed "deploy_${_T}-service")
endif()
elseif(WIN32)
if (NOT CMAKE_OBJDUMP)
find_program(CMAKE_OBJDUMP objdump)
endif()
set(_AGD "${_DEPLOY_DIR}/${_TV}_win_${MY_ARCH}/")
if (__win_host)
string(REPLACE "/" "\\" CMAKE_OBJDUMP "${CMAKE_OBJDUMP}")
endif()
set(_var_exe "${_DEPLOY_DIR}/${_T}.exe")
set(_var_empty)
__make_dir(_CMD_ "${_AGD}")
__make_dir(_CMD_ "${_DESTINATION}")
__make_copy(_CMD_ _var_empty _var_exe "${_AGD}")
__make_copy(_CMD_ _RES_DIRS _RES_FILES "${_AGD}")
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}")
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES "${_AGD}")
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES "${_AGD}")
set(_zip_name "${_TV}_windows_${MY_ARCH}.zip")
add_custom_target(deploy_${_T}
# gather dir
${_CMD_}
COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -W "\"${CMAKE_OBJDUMP}\"" -P windows,minimal -S windows -q "\"${Qt5_ROOT}\"" -s "\"${CMAKE_PREFIX_PATH}/bin${_dt_delim}${MINGW_BIN}${_add_search_path}\"" -o ${_AGD} -p ${_AGD} "\"${_AGD}${_T}.exe\"" ${_ADD_DEPS}
# zip
COMMAND cd "\"${_DEPLOY_DIR}\"" "&&" zip -q -r "\"${_DESTINATION}/${_zip_name}\"" "\"${_TV}_win_${MY_ARCH}\""
COMMENT "Generating ${_zip_name}"
)
set(_deployed "deploy_${_T}")
elseif (APPLE)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "${${_T}_FULLNAME}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${${_T}_VERSION}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${${_T}_VERSION}")
set(MACOSX_BUNDLE_ICON_FILE "${_ICON_NAME}")
set(MACOSX_BUNDLE_BUNDLE_NAME "${${_T}_LABEL}")
set(MACOSX_BUNDLE_COPYRIGHT "${${_T}_COMPANY}")
set(MACOSX_BUNDLE_INFO_STRING "${${_T}_INFO}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "6.0")
set(MACOSX_BUNDLE_SIGNATURE "????")
set(MACOSX_BUNDLE_PRIVACIES "${__macos_privacies}")
set_target_properties(${_T} PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(${_T} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${_modules_dir}/PIMacOSBundle.plist.in")
set(_AGD "${_DEPLOY_DIR}/${_T}.app")
set(_DMG "${CMAKE_CURRENT_BINARY_DIR}/dmg")
__make_copy(_CMD_ _RES_DIRS _RES_FILES "${_AGD}/Contents/Resources")
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}/Contents/PlugIns")
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES "${_AGD}/Contents/MacOS")
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES "${_AGD}/Contents/Frameworks")
if (_ICON_NAME)
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f ${_ICON_FN} ${_AGD}/Contents/Resources)
endif()
if (NOT CMAKE_OTOOL)
set(CMAKE_OTOOL "otool")
endif()
if (NOT CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH "/usr/local")
endif()
set(_dmg_name "${_TV}_macosx_x64.dmg")
set(_cmd_gen_dmg COMMAND genisoimage -quiet -V "${MACOSX_BUNDLE_BUNDLE_NAME}" -D -R -apple -no-pad -o ${_DESTINATION}/${_dmg_name} ${_DMG})
if (__mac_host)
set(_cmd_gen_dmg COMMAND hdiutil create ${_DESTINATION}/${_dmg_name} -ov -volname "${MACOSX_BUNDLE_BUNDLE_NAME}" -fs HFS+ -srcfolder ${_DMG})
endif()
if (_ZIP_DMG)
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND zip -q -r "\"${_DESTINATION}/${_dmg_name}.zip\"" "\"${_DESTINATION}/${_dmg_name}\"")
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND rm "\"${_DESTINATION}/${_dmg_name}\"")
endif()
set(_comment "Generating ${_dmg_name}")
if (_ZIP_DMG)
set(_comment "${_comment}.zip")
endif()
add_custom_target(deploy_${_T}
# gather .app dir
COMMAND mkdir ${_VERB} -p ${_AGD}/Contents/Resources
COMMAND mkdir ${_VERB} -p ${_AGD}/Contents/Frameworks
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
${_CMD_}
COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -M "${CMAKE_OTOOL}" -P cocoa,minimal -S mac -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib${_add_search_path}\"" -o ${_AGD}/Contents/Frameworks -p ${_AGD}/Contents/PlugIns ${_AGD}/Contents/MacOS/${_T} ${_ADD_DEPS}
# prepare dmg dir
COMMAND rm -rf ${_DMG}
COMMAND mkdir ${_VERB} -p ${_DMG}
COMMAND cp -r ${_AGD} ${_DMG}
COMMAND ln ${_VERB} -s /Applications ${_DMG}
# generate dmg
${_cmd_gen_dmg}
COMMENT "${_comment}"
)
set(_deployed "deploy_${_T}")
elseif (DEFINED ANDROID_PLATFORM)
set(_res_files)
set(_res_files "${_res_files}\n <qresource prefix=\"/\">")
foreach (_f ${_RES_FILES})
set(_res_files "${_res_files}\n <file>${_f}</file>")
endforeach()
set(_res_files "${_res_files}\n </qresource>")
foreach (_d ${_RES_DIRS})
file(GLOB_RECURSE _df "${_d}/*")
#message("FILES ${_d} = ${_df}")
get_filename_component(_dn "${_d}" NAME)
set(_res_files "${_res_files}\n <qresource prefix=\"${_dn}\">")
foreach (_f ${_df})
get_filename_component(_fn "${_f}" NAME)
set(_res_files "${_res_files}\n <file alias=\"${_fn}\">${_f}</file>")
endforeach()
set(_res_files "${_res_files}\n </qresource>")
endforeach()
set(_res_qrc "${CMAKE_CURRENT_BINARY_DIR}/android_res.qrc")
file(WRITE "${_res_qrc}" "<RCC>${_res_files}\n</RCC>")
set(_AT ${_T}_lib)
set(_ATA ${_AT}_${ANDROID_ABI})
get_target_property(_sources ${_T} SOURCES)
get_target_property(_libs ${_T} LINK_LIBRARIES)
get_target_property(_incs ${_T} INCLUDE_DIRECTORIES)
get_target_property(_defs ${_T} COMPILE_DEFINITIONS)
qt5_add_resources(_res_out "${_res_qrc}")
add_library(${_ATA} SHARED ${_sources} ${_res_out})
target_link_libraries(${_ATA} ${_libs})
target_include_directories(${_ATA} PRIVATE ${_incs})
target_compile_definitions(${_ATA} PRIVATE ${_defs})
set_target_properties(${_T} PROPERTIES EXCLUDE_FROM_ALL 1)
#message("create new target ${_ATA} ${_sources} ${_libs}")
set(_AGD "${_DEPLOY_DIR}/${_T}.android")
__make_dir(_CMD_ "${_AGD}")
set(_file)
set(_dir "${CMAKE_BINARY_DIR}/android-build/libs" "${CMAKE_CURRENT_SOURCE_DIR}/android/res" "${CMAKE_CURRENT_SOURCE_DIR}/android/src")
__make_copy(_CMD_ _dir _file "${_AGD}")
set(_dir)
set(_file "${Qt5_ROOT}/src/android/templates/res/values/libs.xml")
__make_copy(_CMD_ _dir _file "${_AGD}/res/values")
set(_dir "${Qt5_ROOT}/src/3rdparty/gradle/gradle")
set(_file "${Qt5_ROOT}/src/3rdparty/gradle/gradlew"
"${Qt5_ROOT}/src/3rdparty/gradle/gradlew.bat")
__make_copy(_CMD_ _dir _file "${_AGD}")
#message("bindir = ${CMAKE_CURRENT_SOURCE_DIR}")
set(SDK_ROOT "$ENV{ANDROID_SDK_ROOT}")
if("x${SDK_ROOT}" STREQUAL "x")
set(SDK_ROOT "$ENV{ANDROID_HOME}")
endif()
set(__archs "armeabi-v7a" "arm64-v8a" "x86" "x86_64")
set(QT_ANDROID_ARCHITECTURES)
find_library(_lib_ c++_shared)
foreach (_a ${__archs})
set(_aname "${_a}")
if ("${_a}" STREQUAL "armeabi-v7a")
set(_aname "arm")
elseif ("${_a}" STREQUAL "arm64-v8a")
set(_aname "arm64")
endif()
set(_exist 0)
if ("${_a}" STREQUAL "${ANDROID_ABI}")
set(_exist 1)
elseif (EXISTS "${CMAKE_BINARY_DIR}/android-build/libs/${_a}")
set(_exist 1)
endif()
if (_exist)
string(REPLACE "${ANDROID_ABI}" "${_a}" _a_prefix "${CMAKE_PREFIX_PATH}")
string(REPLACE "arch-${ANDROID_ARCH_NAME}" "arch-${_aname}" _a_prefix "${_a_prefix}")
list(APPEND QT_ANDROID_ARCHITECTURES " \"${_a}\" : \"${ANDROID_SYSROOT_${_a}}\"")
string(REPLACE "${ANDROID_SYSROOT_${ANDROID_ABI}}" "${ANDROID_SYSROOT_${_a}}" _lib_${_a} "${_lib_}")
#message("search = ${_a_prefix}/lib")
__make_copy(_CMD_ _empty _lib_${_a} "${_AGD}/libs/${_a}")
set(_CMD_ ${_CMD_} COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -W "\"${CMAKE_OBJDUMP}\"" -s "${_a_prefix}/lib${_dt_delim}${Qt5_ROOT}/lib${_add_search_path}" -o "\"${_AGD}/libs/${_a}\"" --ignore "\"c${_dt_delim}m${_dt_delim}z${_dt_delim}dl${_dt_delim}log\"" "\"${_AGD}/libs/${_a}/lib${_AT}_${_a}.so\"" ${_ADD_DEPS})
#message("c++_${_a} -> ${_lib_${_a}}")
endif()
endforeach()
string(REPLACE ";" ",\n" QT_ANDROID_ARCHITECTURES "${QT_ANDROID_ARCHITECTURES}")
set(QT_ANDROID_APPLICATION_BINARY ${_AT})
set(ANDROID_LABEL "${${_T}_LABEL}")
set(ANDROID_ICON "${${_T}_ICON}")
set(ANDROID_VERSION "${${_T}_VERSION}")
set(ANDROID_BUILD "${${_T}_VERSION_BUILD}")
set(ANDROID_PACKAGE "${${_T}_FULLNAME}")
set(ANDROID_TARGET_SDK "${${_T}_ANDROID_TARGET_SDK}")
set(ANDROID_STORE_FILE "${${_T}_ANDROID_STORE_FILE}")
set(ANDROID_STORE_PASSWORD "${${_T}_ANDROID_STORE_PASSWORD}")
set(ANDROID_KEY_PASSWORD "${${_T}_ANDROID_KEY_PASSWORD}")
set(ANDROID_KEY_ALIAS "${${_T}_ANDROID_KEY_ALIAS}")
if (NOT IS_ABSOLUTE "${ANDROID_STORE_FILE}")
set(ANDROID_STORE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/android/${ANDROID_STORE_FILE}")
endif()
if (${_T}_ANDROID_NEW_LOADER)
set(ANDROID_NEW_LOADER "true")
else()
set(ANDROID_NEW_LOADER "false")
endif()
set(__ANDROID_DEBUG_KEYSTORE__ "${_modules_dir}/android_debug.keystore")
set(QT_DIR ${Qt5_ROOT})
set(_out_json "${CMAKE_CURRENT_BINARY_DIR}/${_T}_android_deployment_settings.json")
configure_file("${CMAKE_BINARY_DIR}/android_deployment_settings.json.in" "${_out_json}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android/AndroidManifest.xml.in" "${_AGD}/AndroidManifest.xml")
configure_file("${_modules_dir}/gradle.properties.in" "${_AGD}/gradle.properties")
set(_depstr)
foreach (_d ${ANDROID_GRADLE_DEPENDENCIES})
set(_depstr "${_depstr}\n ${_d}")
endforeach()
set(__gradle_lang)
foreach (_l ${${_T}_LANG})
if (NOT "x${__gradle_lang}" STREQUAL "x")
set(__gradle_lang "${__gradle_lang}, ")
endif()
set(__gradle_lang "${__gradle_lang}\"${_l}\"")
endforeach()
if ("x${__gradle_lang}" STREQUAL "x")
set(__gradle_lang "\"en\"")
endif()
file(READ "${Qt5_ROOT}/src/android/templates/build.gradle" _file)
string(REPLACE "\ndependencies {" "\ndependencies {${_depstr}" _file "${_file}")
string(REPLACE "\nandroid {" "\nandroid {\n${__gradle_sign}\n${__gradle_lang_start}${__gradle_lang}\n\t}\n" _file "${_file}")
string(REPLACE "['resources']" "['res']" _file "${_file}")
file(WRITE "${_AGD}/build.gradle" "${_file}")
set(_gradle_home)
if (NOT __win_host)
set(_gradle_home "-g" "${CMAKE_BINARY_DIR}")
endif()
set(_CMD_ ${_CMD_} COMMAND "${Qt5_BIN}/androiddeployqt" --aux-mode --android-platform ${ANDROID_PLATFORM} --output "\"${_AGD}\"" --input "\"${_out_json}\"")
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" assembleDebug)
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" bundleRelease)
set(_base_name "${_TV}_android_all")
set(_CMD_ ${_CMD_} COMMAND "${CMAKE_COMMAND}" -E copy "${_AGD}/build/outputs/apk/debug/${_T}.android-debug.apk" "${_DESTINATION}/${_base_name}.apk")
if (ANDROID_STORE_FILE)
set(_CMD_ ${_CMD_} COMMAND "${CMAKE_COMMAND}" -E copy "${_AGD}/build/outputs/bundle/release/${_T}.android-release.aab" "${_DESTINATION}/${_base_name}.aab")
endif()
add_custom_target(deploy_${_T}
# gather .app dir
${_CMD_}
COMMENT "Generating ${_base_name}.apk/aab"
)
set(_deployed "deploy_${_T}")
endif()
foreach (_d ${_deployed})
add_dependencies(deploy ${_d})
endforeach()
endmacro()

View File

@@ -1,31 +0,0 @@
# Download and unpack googletest at configure time
configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()
# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()

View File

@@ -1,24 +0,0 @@
if(${MINGW})
if(NOT DEFINED MINGW_DIR)
get_filename_component(MINGW_BIN ${CMAKE_CXX_COMPILER} PATH)
get_filename_component(MINGW_DIR ${MINGW_BIN} PATH)
find_path(MINGW_INCLUDE
windows.h
PATHS
ENV INCLUDE
${MINGW_DIR}
${MINGW_DIR}/i686-w64-mingw32
${MINGW_DIR}/x86_64-w64-mingw32
PATH_SUFFIXES
include)
#message(STATUS "Find MinGW = ${MINGW_INCLUDE}")
find_library(MINGW_LIB m HINTS ${MINGW_BIN}/../lib ${MINGW_INCLUDE}/../lib)
get_filename_component(MINGW_LIB ${MINGW_LIB} PATH)
if (NOT _MGW_MSG)
set(_MGW_MSG 1 CACHE BOOL "msg_mingw" FORCE)
message(STATUS "Found MinGW binary path = ${MINGW_BIN}")
message(STATUS "Found MinGW include path = ${MINGW_INCLUDE}")
message(STATUS "Found MinGW library path = ${MINGW_LIB}")
endif()
endif()
endif(${MINGW})

View File

@@ -1,6 +1,6 @@
#[[
Also create imported targets:
Create imported targets:
* PIP - main library
* PIP::USB
* PIP::Console
@@ -18,85 +18,64 @@ main library
]]
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
if(WIN32)
find_package(MinGW REQUIRED)
include(SHSTKMacros)
shstk_set_find_dirs(pip)
if(PIP_DIR)
list(APPEND pip_LIBDIR "${PIP_DIR}/lib")
list(APPEND pip_INCDIR "${PIP_DIR}/include/pip")
list(APPEND pip_BINDIR "${PIP_DIR}/bin")
endif()
set(_PIP_INCDIR "${PIP_DIR}/include/pip")
set(_PIP_LIBDIR "${PIP_DIR}/lib")
set(_PIP_BINDIR)
set(_PIP_FP_DP)
set(__libs "usb;crypt;console;fftw;compress;io_utils;opencl;cloud;lua")
if(MINGW_INCLUDE)
list(APPEND _PIP_INCDIR "${MINGW_INCLUDE}/pip")
list(APPEND _PIP_LIBDIR "${MINGW_LIB}")
endif()
if(CMAKE_CROSSCOMPILING)
list(APPEND _PIP_INCDIR "${CMAKE_PREFIX_PATH}/include/pip")
list(APPEND _PIP_LIBDIR "${CMAKE_PREFIX_PATH}/lib")
if (BUILDING_pip)
#set(_libs "pip;pip_usb;pip_console;pip_crypt;pip_fftw;pip_compress;pip_opencl;pip_io_utils;pip_cloud;pip_lua")
#set(_bins "pip_cmg;pip_rc;deploy_tool")
#get_target_property(_path pip BINARY_DIR)
#get_target_property(_path pip LIBRARY_OUTPUT_NAME)
#message("${_path}")
#set(PIP_LIBRARY "$<TARGET_FILE_DIR:pip>/$<TARGET_FILE_NAME:pip>" CACHE STRING "")
set(PIP_LIBRARY pip CACHE STRING "")
set(PIP_FOUND ON CACHE BOOL "")
else()
if(NOT WIN32)
list(APPEND _PIP_INCDIR "/usr/include/pip" "/usr/local/include/pip")
list(APPEND _PIP_LIBDIR "/usr/lib" "/usr/local/lib")
endif()
if(APPLE)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
find_library(PIP_LIBRARY pip HINTS ${pip_LIBDIR})
foreach (_l ${__libs})
find_library(PIP_LIBRARY_${_l} pip_${_l} HINTS ${pip_LIBDIR})
endforeach()
endif()
list(APPEND _PIP_LIBDIR "$ENV{SMSDK_DIR}/lib")
if(MINGW_INCLUDE)
list(APPEND _PIP_BINDIR "${MINGW_BIN}")
endif()
if(CMAKE_CROSSCOMPILING)
set(_PIP_FP_DP "NO_DEFAULT_PATH")
list(APPEND _PIP_BINDIR "/usr/bin" "/usr/local/bin")
if (BUILDING_pip AND (NOT CMAKE_CROSSCOMPILING))
set(PIP_CMG "$<TARGET_FILE_DIR:pip_cmg>/$<TARGET_FILE_NAME:pip_cmg>" CACHE STRING "")
set(PIP_RC "$<TARGET_FILE_DIR:pip_rc>/$<TARGET_FILE_NAME:pip_rc>" CACHE STRING "")
set(PIP_DEPLOY_TOOL "$<TARGET_FILE_DIR:deploy_tool>/$<TARGET_FILE_NAME:deploy_tool>" CACHE STRING "")
else()
list(APPEND _PIP_BINDIR "${CMAKE_PREFIX_PATH}/bin")
find_program(PIP_CMG pip_cmg${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
find_program(PIP_RC pip_rc${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
find_program(PIP_DEPLOY_TOOL deploy_tool${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
endif()
list(APPEND _PIP_BINDIR "${PIP_DIR}/bin")
set(_pip_suffix "")
find_library(PIP_LIBRARY pip${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_USB_LIBRARY pip_usb${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CONSOLE_LIBRARY pip_console${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CRYPT_LIBRARY pip_crypt${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_FFTW_LIBRARY pip_fftw${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_COMPRESS_LIBRARY pip_compress${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_OPENCL_LIBRARY pip_opencl${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_IO_UTILS_LIBRARY pip_io_utils${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CLOUD_LIBRARY pip_cloud HINTS${_pip_suffix} ${_PIP_LIBDIR})
find_library(PIP_LUA_LIBRARY pip_lua HINTS${_pip_suffix} ${_PIP_LIBDIR})
find_file(PIP_H_INCLUDE "pip.h" HINTS ${_PIP_INCDIR} $ENV{SMSDK_DIR}/include/pip)
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
set(__ext "")
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows")
set(__ext ".exe")
if (CMAKE_CROSSCOMPILING)
set(_PIP_FP_DP)
endif()
endif()
#message("FIND \"${__ext}\" -> ${_PIP_BINDIR}")
find_program(PIP_CMG pip_cmg${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
find_program(PIP_RC pip_rc${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
find_program(PIP_DEPLOY_TOOL deploy_tool${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
if (NOT PIP_LIBRARY)
message(FATAL_ERROR "Can`t find PIP library!")
if(PIP_FIND_REQUIRED)
message(FATAL_ERROR "Can`t find PIP library!")
endif()
return()
endif()
set(_PIP_LIBRARY_PATH_ "${PIP_LIBRARY}")
set(_PIP_ADD_LIBS_ "")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
find_library(DL_LIBRARY dl)
list(APPEND PIP_LIBRARY ${DL_LIBRARY})
if (NOT DEFINED ANDROID_PLATFORM)
find_library(PTHREAD_LIBRARY pthread)
find_library(UTIL_LIBRARY util)
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
if (NOT BUILDING_pip)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
find_library(DL_LIBRARY dl)
list(APPEND PIP_LIBRARY ${DL_LIBRARY})
if (NOT DEFINED ANDROID_PLATFORM)
find_library(PTHREAD_LIBRARY pthread)
find_library(UTIL_LIBRARY util)
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
endif()
endif()
endif()
if(PIP_LUA_LIBRARY)
if(PIP_LIBRARY_lua)
if (NOT LUA_FOUND)
if(MINGW)
set(LUA_INCLUDE_DIR ${MINGW_INCLUDE})
@@ -110,62 +89,81 @@ if(PIP_LUA_LIBRARY)
endif()
endif()
if(NOT PIP_VERSION)
include(CheckSymbolExists)
check_symbol_exists(PIP_VERSION_NAME "${PIP_INCLUDES}/piversion.h" HAVE_PIP_VERSION)
if (HAVE_PIP_VERSION)
file(STRINGS "${PIP_INCLUDES}/piversion.h" _VERSION REGEX "^[ \t]*#define[ \t]+PIP_VERSION_NAME+[ \t]+.*$")
string(REGEX MATCH "\".*\"" _VERSION ${_VERSION})
string(LENGTH ${_VERSION} SL)
math(EXPR SL ${SL}-2)
string(SUBSTRING ${_VERSION} 1 ${SL} _VERSION)
set(PIP_VERSION ${_VERSION} CACHE STRING "VERSION")
if (NOT _PIP_MSG)
set(_PIP_MSG 1 CACHE BOOL "msg_pip" FORCE)
message(STATUS "Found PIP: ${_PIP_LIBRARY_PATH_} (version \"${PIP_VERSION}\")")
endif()
else()
message(FATAL_ERROR "Can`t find PIP version file!")
endif()
if (NOT BUILDING_pip)
shstk_find_header(pip PIP "pip_version.h" "${_PIP_LIBRARY_PATH_}")
endif()
if(PIP_FIND_VERSION VERSION_GREATER PIP_VERSION)
message(FATAL_ERROR "PIP version ${PIP_VERSION} is available, but ${PIP_FIND_VERSION} requested!")
endif()
set(__modules "USB;Crypt;Console;FFTW;Compress;IOUtils;Cloud;Lua")
set(__module_USB "${PIP_USB_LIBRARY}" )
set(__module_Console "${PIP_CONSOLE_LIBRARY}" )
set(__module_Crypt "${PIP_CRYPT_LIBRARY}" )
set(__module_FFTW "${PIP_FFTW_LIBRARY}" )
set(__module_Compress "${PIP_COMPRESS_LIBRARY}" )
set(__module_OpenCL "${PIP_OPENCL_LIBRARY}" )
set(__module_IOUtils "${PIP_IO_UTILS_LIBRARY}" )
set(__module_Cloud "${PIP_CLOUD_LIBRARY}" )
set(__module_Lua "${PIP_LUA_LIBRARY}" )
if((NOT TARGET PIP) AND PIP_LIBRARY)
add_library(PIP UNKNOWN IMPORTED)
set_target_properties(PIP PROPERTIES
IMPORTED_LOCATION "${_PIP_LIBRARY_PATH_}"
INTERFACE_INCLUDE_DIRECTORIES "${PIP_INCLUDES}"
INTERFACE_LINK_LIBRARIES "${_PIP_ADD_LIBS_}")
endif()
foreach (_m ${__modules})
if((NOT TARGET PIP::${_m}) AND __module_${_m})
add_library(PIP::${_m} UNKNOWN IMPORTED)
set_target_properties(PIP::${_m} PROPERTIES
IMPORTED_LOCATION "${__module_${_m}}"
INTERFACE_LINK_LIBRARIES "PIP")
endif()
set(__module_usb USB )
set(__module_console Console )
set(__module_crypt Crypt )
set(__module_fftw FFTW )
set(__module_compress Compress )
set(__module_opencl OpenCL )
set(__module_io_utils IOUtils )
set(__module_cloud Cloud )
set(__module_lua Lua )
foreach (_l ${__libs})
set( __inc_${_l} "")
set(__deps_${_l} "")
set(__libs_${_l} "")
endforeach()
if(__module_IOUtils AND __module_Crypt)
set_target_properties(PIP::IOUtils PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::Crypt")
endif()
if(__module_Cloud AND __module_IOUtils)
set_target_properties(PIP::Cloud PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::IOUtils")
endif()
if(__module_Lua)
set_target_properties(PIP::Lua PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES "PIP;${LUA_LIBRARIES}")
set( __inc_lua "${LUA_INCLUDE_DIR}")
set(__deps_io_utils "PIP::Crypt")
set(__deps_cloud "PIP::IOUtils")
set(__libs_lua "${LUA_LIBRARIES}")
if (BUILDING_pip)
if (NOT SET_TARGETS_pip)
set(SET_TARGETS_pip ON CACHE BOOL "")
#message("create aliases")
if((NOT TARGET PIP) AND PIP_LIBRARY)
#message("alias PIP = pip")
add_library(PIP ALIAS pip)
endif()
foreach (_l ${__libs})
set(_m ${__module_${_l}})
if((NOT TARGET PIP::${_m}) AND TARGET pip_${_l})
#message("alias PIP::${_m} = pip_${_l}")
add_library(PIP::${_m} ALIAS pip_${_l})
endif()
endforeach()
endif()
else()
#message("create interfaces")
if((NOT TARGET PIP) AND PIP_LIBRARY)
add_library(PIP UNKNOWN IMPORTED)
set_target_properties(PIP PROPERTIES
IMPORTED_LOCATION "${_PIP_LIBRARY_PATH_}"
INTERFACE_INCLUDE_DIRECTORIES "${pip_INCLUDES}"
INTERFACE_LINK_LIBRARIES "${_PIP_ADD_LIBS_}")
#message("imported PIP = ${PIP_LIBRARY}")
endif()
foreach (_l ${__libs})
set(_m ${__module_${_l}})
if((NOT TARGET PIP::${_m}) AND PIP_LIBRARY_${_l})
add_library(PIP::${_m} UNKNOWN IMPORTED)
set_target_properties(PIP::${_m} PROPERTIES
IMPORTED_LOCATION "${PIP_LIBRARY_${_l}}"
INTERFACE_INCLUDE_DIRECTORIES "${__inc_${_l}}"
INTERFACE_LINK_LIBRARIES "PIP;${__deps_${_l}};${__libs_${_l}}")
#message("imported PIP::${_m} = ${PIP_LIBRARY_${_l}} ${__deps_${_l}} ${__libs_${_l}} ${__inc_${_l}}")
endif()
endforeach()
endif()
set(PIP_FOUND ON CACHE BOOL "")
include(PIPMacros)

View File

@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>${MACOSX_BUNDLE_SIGNATURE}</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
${MACOSX_BUNDLE_PRIVACIES}
</dict>
</plist>

View File

@@ -1,11 +1,11 @@
#[[
pip_code_model(<out_var> file0 [file1 ...] [OPTIONS opt0 [opt1 ...] ] [ABSOLUTE])
pip_code_model(<out_var> file0 [file1 ...] [OPTIONS opt0 [opt1 ...] ])
Generate code model files for source files file0 [file1 ...]
Options you can see by exec "pip_cmg -h"
If not ABSOLUTE source files will be prepended by CMAKE_CURRENT_SOURCE_DIR
Relative files pathes read from CMAKE_CURRENT_SOURCE_DIR
You should add ${<out_var>} to your target
@@ -53,15 +53,13 @@ macro(pip_code_model RESULT)
set(CCM_OUT ${CMAKE_CURRENT_BINARY_DIR}/ccm_${PROJECT_NAME}.cpp)
set(${RESULT} ${${RESULT}} ${CCM_OUT})
set(CCM_FILES)
if (ABS)
foreach(csrc ${CCM_SRC})
foreach(csrc ${CCM_SRC})
if (IS_ABSOLUTE "${csrc}")
list(APPEND CCM_FILES "${csrc}")
endforeach()
else()
foreach(csrc ${CCM_SRC})
else()
list(APPEND CCM_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${csrc}")
endforeach()
endif()
endif()
endforeach()
#message(STATUS "CCM = ${RESULT}")
if(NOT DEFINED PIP_DLL_DIR)
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR})
@@ -85,7 +83,6 @@ macro(pip_resources RESULT INPUT)
set(SRC_RC_OUT "${RC_OUT}")
set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE})
set(${RESULT} ${${RESULT}} ${RC_OUT})
set(CCM_FILES)
if(IS_ABSOLUTE "${INPUT}")
set(RC_FILES "${INPUT}")
else()
@@ -96,7 +93,7 @@ macro(pip_resources RESULT INPUT)
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
set(RC_DEPS ${RC_FILES})
if(NOT PIP_BUILD)
if(NOT BUILDING_pip)
execute_process(COMMAND "${PIP_RC}" -l -i "${RC_FILES}"
WORKING_DIRECTORY ${PIP_DLL_DIR}
OUTPUT_VARIABLE RC_LIST)

View File

@@ -1,136 +0,0 @@
# Based on the Qt 5 processor detection code, so should be very accurate
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
# Regarding POWER/PowerPC, just as is noted in the Qt source,
# "There are many more known variants/revisions that we do not handle/detect."
set(archdetect_c_code "
#if defined(__aarch64__)
#error cmake_ARCH arm64
#elif defined(__arm__) || defined(__TARGET_ARCH_ARM)
#if defined(__ARM_ARCH_7__) \\
|| defined(__ARM_ARCH_7A__) \\
|| defined(__ARM_ARCH_7R__) \\
|| defined(__ARM_ARCH_7M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
#error cmake_ARCH armv7
#elif defined(__ARM_ARCH_6__) \\
|| defined(__ARM_ARCH_6J__) \\
|| defined(__ARM_ARCH_6T2__) \\
|| defined(__ARM_ARCH_6Z__) \\
|| defined(__ARM_ARCH_6K__) \\
|| defined(__ARM_ARCH_6ZK__) \\
|| defined(__ARM_ARCH_6M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
#error cmake_ARCH armv6
#elif defined(__ARM_ARCH_5TEJ__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
#error cmake_ARCH armv5
#else
#error cmake_ARCH arm
#endif
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
#error cmake_ARCH i386
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
#error cmake_ARCH x86_64
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
#error cmake_ARCH ia64
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|| defined(_M_MPPC) || defined(_M_PPC)
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
#error cmake_ARCH ppc64
#else
#error cmake_ARCH ppc
#endif
#endif
#error cmake_ARCH unknown
")
# Set ppc_support to TRUE before including this file or ppc and ppc64
# will be treated as invalid architectures since they are no longer supported by Apple
function(target_architecture output_var)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
# First let's normalize the order of the values
# Note that it's not possible to compile PowerPC applications if you are using
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
# disable it by default
# See this page for more information:
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
set(osx_arch_ppc TRUE)
elseif("${osx_arch}" STREQUAL "i386")
set(osx_arch_i386 TRUE)
elseif("${osx_arch}" STREQUAL "x86_64")
set(osx_arch_x86_64 TRUE)
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
set(osx_arch_ppc64 TRUE)
else()
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
endif()
endforeach()
# Now add all the architectures in our normalized order
if(osx_arch_ppc)
list(APPEND ARCH ppc)
endif()
if(osx_arch_i386)
list(APPEND ARCH i386)
endif()
if(osx_arch_x86_64)
list(APPEND ARCH x86_64)
endif()
if(osx_arch_ppc64)
list(APPEND ARCH ppc64)
endif()
else()
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
enable_language(C)
# Detect the architecture in a rather creative way...
# This compiles a small C program which is a series of ifdefs that selects a
# particular #error preprocessor directive whose message string contains the
# target architecture. The program will always fail to compile (both because
# file is not a valid C program, and obviously because of the presence of the
# #error preprocessor directives... but by exploiting the preprocessor in this
# way, we can detect the correct target architecture even when cross-compiling,
# since the program itself never needs to be run (only the compiler/preprocessor)
try_run(
run_result_unused
compile_result_unused
"${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/arch.c"
COMPILE_OUTPUT_VARIABLE ARCH
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
)
# Parse the architecture name from the compiler output
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
# Get rid of the value marker leaving just the architecture name
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
# If we are compiling with an unknown architecture this variable should
# already be set to "unknown" but in the case that it's empty (i.e. due
# to a typo in the code), then set it to unknown
if (NOT ARCH)
set(ARCH unknown)
endif()
endif()
set(${output_var} "${ARCH}" PARENT_SCOPE)
endfunction()

Binary file not shown.

View File

@@ -1,10 +0,0 @@
androidBuildToolsVersion=
androidCompileSdkVersion=@ANDROID_TARGET_SDK@
android.bundle.enableUncompressedNativeLibs=@ANDROID_NEW_LOADER@
buildDir=build
qt5AndroidDir=@Qt5_ROOT@/src/android/java
DEBUG_STORE_FILE=@__ANDROID_DEBUG_KEYSTORE__@
RELEASE_STORE_FILE=@ANDROID_STORE_FILE@
RELEASE_STORE_PASSWORD=@ANDROID_STORE_PASSWORD@
RELEASE_KEY_PASSWORD=@ANDROID_KEY_PASSWORD@
RELEASE_KEY_ALIAS=@ANDROID_KEY_ALIAS@

View File

@@ -47,3 +47,21 @@ while (!cs2.atEnd()) {
}
piCout << i << str << f << s.i << s.f << s.s;
//! [read]
//! [write_new]
PIByteArray & operator <<(PIByteArray & s, const S & value) {
PIChunkStream cs;
cs.add(1, value.i).add(2, value.f).add(3, value.s);
s << cs.data();
return s;
}
//! [write_new]
//! [read_new]
PIByteArray & operator >>(PIByteArray & s, S & value) {
PIChunkStream cs;
if (!cs.extract(s)) return s;
cs.readAll();
cs.get(1, value.i).get(2, value.f).get(3, value.s);
return b;
}
//! [read_new]

View File

@@ -49,6 +49,9 @@ PIVector<char> vec(4u, 'p');
piForeachC (char i, vec)
cout << i << ", ";
// p, p, p, p,
piCout << PIVector<int>({1, 2, 3});
// 1, 2, 3
//! [PIVector::PIVector]
//! [PIVector::at_c]
PIVector<int> vec;

49
esp-pip/CMakeLists.txt Normal file
View File

@@ -0,0 +1,49 @@
set(COMPONENT_SRCS "main.cpp")
set(COMPONENT_ADD_INCLUDEDIRS "../libs/main")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/cloud")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/code")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/compress")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/console")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/containers")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/core")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/crypt")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/geo")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/io_devices")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/io_utils")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/math")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/resources")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/system")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/thread")
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spi_flash libsodium)
register_component()
set(PIP_FREERTOS ON)
set(LIB OFF)
set(INCLUDE_DIRS ${IDF_INCLUDE_DIRECTORIES})
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/newlib/platform_include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/newlib/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/libsodium/libsodium/src/libsodium/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/libsodium/port_include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/heap/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/esp_rom/include/esp32)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/driver/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/spi_flash/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/spiffs/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/soc/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/soc/esp32/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/freertos/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/lwip/lwip/src/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/lwip/port/esp32/include)
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/vfs/include)
include_directories(${INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/pip)
#message("IDF_COMPILE_DEFINITIONS = ${IDF_COMPILE_DEFINITIONS}")
#message("IDF_INCLUDE_DIRECTORIES = ${IDF_INCLUDE_DIRECTORIES}")
add_compile_options(${IDF_COMPILE_OPTIONS})
add_compile_options(${IDF_CXX_COMPILE_OPTIONS})
add_definitions(-DESP_PLATFORM)
add_definitions(-DGCC_NOT_5_2_0=0)
add_definitions(-DHAVE_CONFIG_H)
add_subdirectory(.. pip)
find_package(PIP REQUIRED)
target_link_libraries(${COMPONENT_TARGET} PIP::Crypt PIP::IOUtils PIP::Compress)
target_compile_definitions(${COMPONENT_TARGET} PRIVATE ESP_PLATFORM PIP_FREERTOS)

View File

@@ -1,49 +0,0 @@
set(COMPONENT_SRCS "main.cpp")
set(COMPONENT_ADD_INCLUDEDIRS "pip/lib/main")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/auxiliary")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/code")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/console")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/containers")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/core")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/crypt")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/geo")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/io_devices")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/io_utils")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/math")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/opencl")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/resources")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/system")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/thread")
list(APPEND COMPONENT_ADD_INCLUDEDIRS "pip/lib/main/introspection")
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spiffs)
register_component()
set(PIP_FREERTOS ON)
set(LIB OFF)
set(INCLUDE_DIRS ${IDF_INCLUDE_DIRECTORIES})
list(APPEND INCLUDE_DIRS "../newlib/platform_include")
list(APPEND INCLUDE_DIRS "../newlib/include")
list(APPEND INCLUDE_DIRS "../libsodium/libsodium/src/libsodium/include")
list(APPEND INCLUDE_DIRS "../libsodium/port_include")
list(APPEND INCLUDE_DIRS "../heap/include")
list(APPEND INCLUDE_DIRS "../esp_rom/include/esp32")
list(APPEND INCLUDE_DIRS "../driver/include")
list(APPEND INCLUDE_DIRS "../spi_flash/include")
list(APPEND INCLUDE_DIRS "../spiffs/include")
list(APPEND INCLUDE_DIRS "../soc/include")
list(APPEND INCLUDE_DIRS "../soc/esp32/include")
list(APPEND INCLUDE_DIRS "../freertos/include")
list(APPEND INCLUDE_DIRS "../lwip/lwip/src/include")
list(APPEND INCLUDE_DIRS "../lwip/port/esp32/include")
list(APPEND INCLUDE_DIRS "../vfs/include")
include_directories(${INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/pip)
#message("IDF_COMPILE_DEFINITIONS = ${IDF_COMPILE_DEFINITIONS}")
#message("IDF_INCLUDE_DIRECTORIES = ${IDF_INCLUDE_DIRECTORIES}")
add_compile_options(${IDF_COMPILE_OPTIONS})
add_compile_options(${IDF_CXX_COMPILE_OPTIONS})
add_definitions(-DESP_PLATFORM)
add_definitions(-DGCC_NOT_5_2_0=0)
add_definitions(-DHAVE_CONFIG_H)
add_subdirectory(pip)
target_link_libraries(${COMPONENT_TARGET} pip pip_crypt pip_io_utils pip_compress)

View File

@@ -1,40 +0,0 @@
/*! \file piccloudserver.h
* \brief PICloud Server
*/
/*
PIP - Platform Independent Primitives
PICloud Server
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PICCLOUDSERVER_H
#define PICCLOUDSERVER_H
#include "pip_cloud_export.h"
#include "piiodevice.h"
class PIP_CLOUD_EXPORT PICloudServer {
public:
//!
explicit PICloudServer();
private:
};
#endif // PICCLOUDSERVER_H

View File

@@ -1,330 +0,0 @@
/*! \file pibytearray.h
* \brief Byte array
*/
/*
PIP - Platform Independent Primitives
Byte array
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIBYTEARRAY_H
#define PIBYTEARRAY_H
#include "pichar.h"
#include "pibitarray.h"
#include "pimap.h"
#include "pivector2d.h"
__PICONTAINERS_SIMPLE_TYPE__(PIChar)
#define __PIBYTEARRAY_SIMPLE_TYPE__(T) \
template<> \
inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {s << int(v.size_s()); int os = s.size_s(); s.enlarge(v.size_s()*sizeof(T)); memcpy(s.data(os), v.data(), v.size_s()*sizeof(T)); return s;} \
template<> \
inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v._resizeRaw(sz); if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;} \
template<> \
inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {s << int(v.size_s()); int os = s.size_s(); s.enlarge(v.size_s()*sizeof(T)); memcpy(s.data(os), v.data(), v.size_s()*sizeof(T)); return s;} \
template<> \
inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v._resizeRaw(sz); if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;} \
template<> \
inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D<T> & v) {s << int(v.rows()) << int(v.cols()); int os = s.size_s(); s.enlarge(v.size_s()*sizeof(T)); memcpy(s.data(os), v.data(), v.size_s()*sizeof(T)); return s;} \
template<> \
inline PIByteArray & operator >>(PIByteArray & s, PIVector2D<T> & v) {assert(s.size_s() >= 8); int r, c; s >> r >> c; v._resizeRaw(r, c); int sz = r*c; if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;}
class PIString;
class PIByteArray;
class PIP_EXPORT PIByteArray: public PIDeque<uchar>
{
public:
//! Constructs an empty byte array
PIByteArray() {;}
PIByteArray(const PIByteArray & o): PIDeque<uchar>(o) {}
PIByteArray(PIByteArray && o): PIDeque<uchar>(std::move(o)) {}
//! Constructs 0-filled byte array with size "size"
PIByteArray(const uint size) {resize(size);}
//! Constructs byte array from data "data" and size "size"
PIByteArray(const void * data, const uint size): PIDeque<uchar>((const uchar*)data, size_t(size)) {}
//! Constructs byte array with size "size" filled by "t"
PIByteArray(const uint size, uchar t): PIDeque<uchar>(size, t) {}
//! Help struct to store/restore custom blocks of data to/from PIByteArray
struct RawData {
friend PIByteArray & operator <<(PIByteArray & s, const PIByteArray::RawData & v);
friend PIByteArray & operator >>(PIByteArray & s, PIByteArray::RawData v);
public:
//! Constructs data block
RawData(void * data = 0, int size = 0) {d = data; s = size;}
RawData(const RawData & o) {d = o.d; s = o.s;}
//! Constructs data block
RawData(const void * data, const int size) {d = const_cast<void * >(data); s = size;}
RawData & operator =(const RawData & o) {d = o.d; s = o.s; return *this;}
private:
void * d;
int s;
};
//! Return resized byte array
PIByteArray resized(uint new_size) const {PIByteArray ret(new_size); memcpy(ret.data(), data(), new_size); return ret;}
//! Convert data to Base 64 and return this byte array
PIByteArray & convertToBase64();
//! Convert data from Base 64 and return this byte array
PIByteArray & convertFromBase64();
//! Return converted to Base 64 data
PIByteArray toBase64() const;
//! Return converted from Base 64 data
PIByteArray & compressRLE(uchar threshold = 192);
PIByteArray & decompressRLE(uchar threshold = 192);
PIByteArray compressedRLE(uchar threshold = 192) {PIByteArray ba(*this); ba.compressRLE(threshold); return ba;}
PIByteArray decompressedRLE(uchar threshold = 192) {PIByteArray ba(*this); ba.decompressRLE(threshold); return ba;}
PIString toString(int base = 16) const;
PIString toHex() const;
//! Add to the end data "data" with size "size"
PIByteArray & append(const void * data_, int size_) {uint ps = size(); enlarge(size_); memcpy(data(ps), data_, size_); return *this;}
//! Add to the end byte array "data"
PIByteArray & append(const PIByteArray & data_) {uint ps = size(); enlarge(data_.size_s()); memcpy(data(ps), data_.data(), data_.size()); return *this;}
//! Add to the end "t"
PIByteArray & append(uchar t) {push_back(t); return *this;}
//! Returns plain 8-bit checksum
uchar checksumPlain8() const;
//! Returns plain 32-bit checksum
uint checksumPlain32() const;
//! Returns hash
uint hash() const;
void operator =(const PIDeque<uchar> & d) {resize(d.size()); memcpy(data(), d.data(), d.size());}
PIByteArray & operator =(const PIByteArray & o) {if (this == &o) return *this; clear(); append(o); return *this;}
PIByteArray & operator =(PIByteArray && o) {swap(o); return *this;}
static PIByteArray fromUserInput(PIString str);
static PIByteArray fromHex(PIString str);
static PIByteArray fromBase64(const PIByteArray & base64);
static PIByteArray fromBase64(const PIString & base64);
};
inline bool operator <(const PIByteArray & v0, const PIByteArray & v1) {if (v0.size() == v1.size()) {for (uint i = 0; i < v0.size(); ++i) if (v0[i] != v1[i]) return v0[i] < v1[i]; return false;} return v0.size() < v1.size();}
#ifdef PIP_STD_IOSTREAM
//! \relatesalso PIByteArray \brief Output to std::ostream operator
inline std::ostream & operator <<(std::ostream & s, const PIByteArray & ba);
#endif
//! \relatesalso PIByteArray \brief Output to PICout operator
PIP_EXPORT PICout operator <<(PICout s, const PIByteArray & ba);
#define PBA_OPERATOR_TO int os = s.size_s(); s.enlarge(sizeof(v)); memcpy(s.data(os), &v, sizeof(v));
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, bool v) {s.push_back(v); return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, char v) {s.push_back(v); return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, uchar v) {s.push_back(v); return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const short v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const int v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const long & v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const llong & v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const ushort v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const uint v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const ulong & v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const ullong & v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const float v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const double & v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const ldouble & v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator
template<typename T> inline PIByteArray & operator <<(PIByteArray & s, const PIFlags<T> & v) {PBA_OPERATOR_TO return s;}
//! \relatesalso PIByteArray \brief Store operator, see \ref PIByteArray_sec1 for details
inline PIByteArray & operator <<(PIByteArray & s, const PIByteArray & v) {s << int(v.size_s()); int os = s.size_s(); s.enlarge(v.size_s()); if (v.size_s() > 0) memcpy(s.data(os), v.data(), v.size()); return s;}
//! \relatesalso PIByteArray \brief Store operator, see \ref PIByteArray_sec1 for details
inline PIByteArray & operator <<(PIByteArray & s, const PIByteArray::RawData & v) {int os = s.size_s(); s.enlarge(v.s); if (v.s > 0) memcpy(s.data(os), v.d, v.s); return s;}
#undef PBA_OPERATOR_TO
#define PBA_OPERATOR_FROM memcpy((void*)(&v), s.data(), sizeof(v)); s.remove(0, sizeof(v));
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, bool & v) {assert(s.size() >= 1u); v = s.take_front(); return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, char & v) {assert(s.size() >= 1u); v = s.take_front(); return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, uchar & v) {assert(s.size() >= 1u); v = s.take_front(); return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, short & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, int & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, long & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, llong & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, ushort & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, uint & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, ulong & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, ullong & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, float & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, double & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, ldouble & v) {assert(s.size() >= sizeof(v)); PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator
template<typename T> inline PIByteArray & operator >>(PIByteArray & s, PIFlags<T> & v) {PBA_OPERATOR_FROM return s;}
//! \relatesalso PIByteArray \brief Restore operator, see \ref PIByteArray_sec1 for details
PIP_EXPORT PIByteArray & operator >>(PIByteArray & s, PIByteArray & v);
//! \relatesalso PIByteArray \brief Restore operator, see \ref PIByteArray_sec1 for details
inline PIByteArray & operator >>(PIByteArray & s, PIByteArray::RawData v) {assert(s.size_s() >= v.s); if (v.s > 0) memcpy((void*)(v.d), s.data(), v.s); s.remove(0, v.s); return s;}
#undef PBA_OPERATOR_FROM
template<typename Type0, typename Type1> inline PIByteArray & operator <<(PIByteArray & s, const PIPair<Type0, Type1> & v);
//! \relatesalso PIByteArray \brief Store operator
template<typename T> inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v);
//! \relatesalso PIByteArray \brief Store operator
template<typename T> inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v);
//! \relatesalso PIByteArray \brief Store operator
template <typename Key, typename T> inline PIByteArray & operator <<(PIByteArray & s, const PIMap<Key, T> & v);
//! Write operator to \c PIByteArray
inline PIByteArray & operator <<(PIByteArray & s, const PIChar & v) {s << v.ch; return s;}
//! \relatesalso PIByteArray \brief Restore operator
template<typename Type0, typename Type1> inline PIByteArray & operator >>(PIByteArray & s, PIPair<Type0, Type1> & v);
//! \relatesalso PIByteArray \brief Restore operator
template<typename T> inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v);
//! \relatesalso PIByteArray \brief Restore operator
template<typename T> inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v);
//! \relatesalso PIByteArray \brief Restore operator
template <typename Key, typename T> inline PIByteArray & operator >>(PIByteArray & s, PIMap<Key, T> & v);
//! Read operator from \c PIByteArray
inline PIByteArray & operator >>(PIByteArray & s, PIChar & v) {s >> v.ch; return s;}
//! \relatesalso PIByteArray \brief Store operator
inline PIByteArray & operator <<(PIByteArray & s, const PIBitArray & v) {s << v.size_ << v.data_; return s;}
template<typename Type0, typename Type1>
inline PIByteArray & operator <<(PIByteArray & s, const PIPair<Type0, Type1> & v) {s << v.first << v.second; return s;}
template<typename T>
inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {s << int(v.size_s()); for (uint i = 0; i < v.size(); ++i) s << v[i]; return s;}
template<typename T>
inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {s << int(v.size_s()); for (uint i = 0; i < v.size(); ++i) s << v[i]; return s;}
template <typename Key, typename T>
inline PIByteArray & operator <<(PIByteArray & s, const PIMap<Key, T> & v) {
s << int(v.pim_index.size_s());
for (uint i = 0; i < v.size(); ++i)
s << int(v.pim_index[i].index) << v.pim_index[i].key;
s << v.pim_content;
return s;
}
template<typename T>
inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D<T> & v) {s << int(v.rows()) << int(v.cols()) << v.toPlainVector(); return s;}
//! \relatesalso PIByteArray \brief Restore operator
inline PIByteArray & operator >>(PIByteArray & s, PIBitArray & v) {assert(s.size_s() >= 8); s >> v.size_ >> v.data_; return s;}
template<typename Type0, typename Type1>
inline PIByteArray & operator >>(PIByteArray & s, PIPair<Type0, Type1> & v) {s >> v.first >> v.second; return s;}
template<typename T>
inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
template<typename T>
inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
template <typename Key, typename T>
inline PIByteArray & operator >>(PIByteArray & s, PIMap<Key, T> & v) {
assert(s.size_s() >= 4);
int sz; s >> sz; v.pim_index.resize(sz);
int ind = 0;
for (int i = 0; i < sz; ++i) {
s >> ind >> v.pim_index[i].key;
v.pim_index[i].index = ind;
}
s >> v.pim_content;
if (v.pim_content.size_s() != v.pim_index.size_s()) {
piCout << "Warning: loaded invalid PIMap, clear";
v.clear();
}
return s;
}
template<typename T>
inline PIByteArray & operator >>(PIByteArray & s, PIVector2D<T> & v) {assert(s.size_s() >= 8); int r,c; PIVector<T> tmp; s >> r >> c >> tmp; v = PIVector2D<T>(r, c, tmp); return s;}
template<typename T>
inline PIByteArray & operator <<(PIByteArray & s, const T & ) {piCout << "[PIByteArray] Warning: using undeclared operator <<!"; return s;}
template<typename T>
inline PIByteArray & operator >>(PIByteArray & s, T & ) {piCout << "[PIByteArray] Warning: using undeclared operator >>!"; return s;}
//! \relatesalso PIByteArray \brief Byte arrays compare operator
inline bool operator ==(PIByteArray & f, PIByteArray & s) {if (f.size_s() != s.size_s()) return false; for (int i = 0; i < f.size_s(); ++i) if (f[i] != s[i]) return false; return true;}
//! \relatesalso PIByteArray \brief Byte arrays compare operator
inline bool operator !=(PIByteArray & f, PIByteArray & s) {if (f.size_s() != s.size_s()) return true; for (int i = 0; i < f.size_s(); ++i) if (f[i] != s[i]) return true; return false;}
__PIBYTEARRAY_SIMPLE_TYPE__(bool)
__PIBYTEARRAY_SIMPLE_TYPE__(char)
__PIBYTEARRAY_SIMPLE_TYPE__(short)
__PIBYTEARRAY_SIMPLE_TYPE__(ushort)
__PIBYTEARRAY_SIMPLE_TYPE__(int)
__PIBYTEARRAY_SIMPLE_TYPE__(uint)
__PIBYTEARRAY_SIMPLE_TYPE__(long)
__PIBYTEARRAY_SIMPLE_TYPE__(ulong)
__PIBYTEARRAY_SIMPLE_TYPE__(llong)
__PIBYTEARRAY_SIMPLE_TYPE__(ullong)
__PIBYTEARRAY_SIMPLE_TYPE__(float)
__PIBYTEARRAY_SIMPLE_TYPE__(double)
__PIBYTEARRAY_SIMPLE_TYPE__(ldouble)
__PIBYTEARRAY_SIMPLE_TYPE__(PIChar)
template<> inline uint piHash(const PIByteArray & ba) {return ba.hash();}
template<> inline void piSwap(PIByteArray & f, PIByteArray & s) {f.swap(s);}
#endif // PIBYTEARRAY_H

View File

@@ -1,925 +0,0 @@
/*! \file piobject.h
* \brief Base object
*
* This file declare PIObject class and associated macros
*/
/*
PIP - Platform Independent Primitives
Object, base class of some PIP classes, provide EVENT -> EVENT_HANDLER mechanism
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIOBJECT_H
#define PIOBJECT_H
#include "piinit.h"
#include "pivariant.h"
#include "pimutex.h"
#include "piset.h"
#include "piqueue.h"
#ifdef DOXYGEN
/// \relatesalso PIObject \brief you should use this macro after class declaration to use EVENT and EVENT_HANDLER and correct piCoutObj output
#define PIOBJECT(name)
/// \relatesalso PIObject \brief you should use this macro after class declaration to use EVENT and EVENT_HANDLER of parent class, and \a scopeList()
#define PIOBJECT_SUBCLASS(name, parent)
/// \relatesalso PIObject \brief declare event handler \"event\" with name \"name\" and return type \"ret\", ret name()
#define EVENT_HANDLER0(ret, name) ret name()
/// \relatesalso PIObject \brief declare event handler \"event\" with name \"name\" and return type \"ret\", ret name(type0 var0)
#define EVENT_HANDLER1(ret, name, type0, var0) ret name(type0 var0)
/// \relatesalso PIObject \brief declare event handler \"event\" with name \"name\" and return type \"ret\", ret name(type0 var0, type1 var1)
#define EVENT_HANDLER2(ret, name, type0, var0, type1, var1) ret name(type0 var0, type1 var1)
/// \relatesalso PIObject \brief declare event handler \"event\" with name \"name\" and return type \"ret\", ret name(type0 var0, type1 var1, type2 var2)
#define EVENT_HANDLER3(ret, name, type0, var0, type1, var1, type2, var2) ret name(type0 var0, type1 var1, type2 var2)
/// \relatesalso PIObject \brief declare event handler \"event\" with name \"name\" and return type \"ret\", ret name(type0 var0, type1 var1, type2 var2, type3 var3)
#define EVENT_HANDLER4(ret, name, type0, var0, type1, var1, type2, var2, type3, var3) ret name(type0 var0, type1 var1, type2 var2, type3 var3)
/// \relatesalso PIObject \brief EVENT_HANDLER is synonym of EVENT_HANDLER0
#define EVENT_HANDLER EVENT_HANDLER0
/// \relatesalso PIObject \brief declare virtual event handler \"event\" with name \"name\" and return type \"ret\", virtual ret name()
#define EVENT_VHANDLER0(ret, name) virtual ret name()
/// \relatesalso PIObject \brief declare virtual event handler \"event\" with name \"name\" and return type \"ret\", virtual ret name(type0 var0)
#define EVENT_VHANDLER1(ret, name, type0, var0) virtual ret name(type0 var0)
/// \relatesalso PIObject \brief declare virtual event handler \"event\" with name \"name\" and return type \"ret\", virtual ret name(type0 var0, type1 var1)
#define EVENT_VHANDLER2(ret, name, type0, var0, type1, var1) virtual ret name(type0 var0, type1 var1)
/// \relatesalso PIObject \brief declare virtual event handler \"event\" with name \"name\" and return type \"ret\", virtual ret name(type0 var0, type1 var1, type2 var2)
#define EVENT_VHANDLER3(ret, name, type0, var0, type1, var1, type2, var2) virtual ret name(type0 var0, type1 var1, type2 var2)
/// \relatesalso PIObject \brief declare virtual event handler \"event\" with name \"name\" and return type \"ret\", virtual ret name(type0 var0, type1 var1, type2 var2, type3 var3)
#define EVENT_VHANDLER4(ret, name, type0, var0, type1, var1, type2, var2, type3, var3) virtual ret name(type0 var0, type1 var1, type2 var2, type3 var3)
/// \relatesalso PIObject \brief EVENT_VHANDLER is synonym of EVENT_VHANDLER0
#define EVENT_VHANDLER EVENT_VHANDLER0
/// \relatesalso PIObject \brief declare event \"event\" with name \"name\", void name();
#define EVENT0(name) void name();
/// \relatesalso PIObject \brief declare event \"event\" with name \"name\", void name(type0 var0);
#define EVENT1(name, type0, var0) void name(type0 var0);
/// \relatesalso PIObject \brief declare event \"event\" with name \"name\", void name(type0 var0, type1 var1);
#define EVENT2(name, type0, var0, type1, var1) void name(type0 var0, type1 var1);
/// \relatesalso PIObject \brief declare event \"event\" with name \"name\", void name(type0 var0, type1 var1, type2 var2);
#define EVENT3(name, type0, var0, type1, var1, type2, var2) void name(type0 var0, type1 var1, type2 var2);
/// \relatesalso PIObject \brief declare event \"event\" with name \"name\", void name(type0 var0, type1 var1, type2 var2, type3 var3);
#define EVENT4(name, type0, var0, type1, var1, type2, var2, type3, var3) void name(type0 var0, type1 var1, type2 var2, type3 var3);
/// \relatesalso PIObject \brief EVENT is synonym of EVENT0
#define EVENT EVENT0
#define RAISE_EVENT0(src, event)
#define RAISE_EVENT1(src, event, v0)
#define RAISE_EVENT2(src, event, v0, v1)
#define RAISE_EVENT3(src, event, v0, v1, v2)
#define RAISE_EVENT4(src, event, v0, v1, v2, v3)
#define RAISE_EVENT RAISE_EVENT0
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\". \"Event\" and \"handler\" must has equal argument lists.
#define CONNECTU(src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\".
/// Event handler will be executed by \"performer\". \"Event\" and \"handler\" must has equal argument lists.
#define CONNECTU_QUEUED(src, event, dest, handler, performer)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to lambda-expression \"functor\". \"Event\" and \"functor\" must has equal argument lists.
#define CONNECTL(src, event, functor)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" with check of event and handler exists
#define CONNECT0(ret, src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" with check of event and handler exists
#define CONNECT1(ret, type0, src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" with check of event and handler exists
#define CONNECT2(ret, type0, type1, src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" with check of event and handler exists
#define CONNECT3(ret, type0, type1, type2, src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" with check of event and handler exists
#define CONNECT4(ret, type0, type1, type2, type3, src, event, dest, handler)
/// \relatesalso PIObject \brief CONNECT is synonym of CONNECT0
#define CONNECT CONNECT0
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" without check of event exists
#define WEAK_CONNECT0(ret, src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" without check of event exists
#define WEAK_CONNECT1(ret, type0, src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" without check of event exists
#define WEAK_CONNECT2(ret, type0, type1, src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" without check of event exists
#define WEAK_CONNECT3(ret, type0, type1, type2, src, event, dest, handler)
/// \relatesalso PIObject \brief connect event \"event\" from object \"src\" to event handler \"handler\" with return type \"ret\" from object \"dest\" without check of event exists
#define WEAK_CONNECT4(ret, type0, type1, type2, type3, src, event, dest, handler)
/// \relatesalso PIObject \brief WEAK_CONNECT is synonym of WEAK_CONNECT0
#define WEAK_CONNECT WEAK_CONNECT0
/// \relatesalso PIObject \brief piDisconnect event \"event\" from object \"src\" from event handler \"handler\" with return type \"ret\" from object \"dest\"
#define DISCONNECT0(ret, src, event, dest, handler)
/// \relatesalso PIObject \brief piDisconnect event \"event\" from object \"src\" from event handler \"handler\" with return type \"ret\" from object \"dest\"
#define DISCONNECT1(ret, type0, src, event, dest, handler)
/// \relatesalso PIObject \brief piDisconnect event \"event\" from object \"src\" from event handler \"handler\" with return type \"ret\" from object \"dest\"
#define DISCONNECT2(ret, type0, type1, src, event, dest, handler)
/// \relatesalso PIObject \brief piDisconnect event \"event\" from object \"src\" from event handler \"handler\" with return type \"ret\" from object \"dest\"
#define DISCONNECT3(ret, type0, type1, type2, src, event, dest, handler)
/// \relatesalso PIObject \brief piDisconnect event \"event\" from object \"src\" from event handler \"handler\" with return type \"ret\" from object \"dest\"
#define DISCONNECT4(ret, type0, type1, type2, type3, src, event, dest, handler)
/// \relatesalso PIObject \brief DISCONNECT is synonym of DISCONNECT0
#define DISCONNECT DISCONNECT0
/// \relatesalso PIObject \brief Returns pointer to events handler \"handler\"
#define HANDLER(handler)
#define PIOBJECT(name)
#define PIOBJECT_SUBCLASS(name)
#else
#define _PI_STR(x) #x
#define _PI_SSTR(x) _PI_STR(x)
#define LOCATION __FILE__ ":" _PI_SSTR(__LINE__)
#ifdef CC_GCC
# define __PTYPE(t) typename __PIVariantTypeInfo__<t>::PureType
#else
# define __PTYPE(t) __PIVariantTypeInfo__<t>::PureType
#endif
#define __VVALUE(t, v) v.value< __PTYPE(t) >()
//printf("base_init %s id=%d (%d) pid=%d (%d) ...\n", #name, id, eh.eh_func.size(), pid, ehp.eh_func.size());
//printf("base_init %s id=%d (%d) pid=%d (%d) ok\n", #name, id, eh.eh_func.size(), pid, ehp.eh_func.size());
//printf("parent_init %s::%s id=%d (%d) pid=%d (%d) ...\n", __classNameS().dataAscii(), #name, id, eh.eh_func.size(), pid, ehp.eh_func.size());
//printf("parent_init %s::%s id=%d (%d) pid=%d (%d) ok\n", __classNameS().dataAscii(), #name, id, eh.eh_func.size(), pid, ehp.eh_func.size());
#define PIOBJECT(name) \
protected: \
typedef name __PIObject__; \
public: \
static const PIString __classNameS() {static PIString ret = PIStringAscii(#name); return ret;} \
static uint __classNameIDS() {static uint ret = PIStringAscii(#name).hash(); return ret;} \
virtual const char * className() const {return #name;} \
virtual uint classNameID() const {static uint ret = PIStringAscii(#name).hash(); return ret;} \
private: \
virtual int ptrOffset() const {name * o = (name*)100; return int(llong((PIObject*)o) - llong(o));} \
class __BaseInitializer__ { \
public: \
__BaseInitializer__() { \
uint pid = PIObject::__classNameIDS(); \
if (pid == 0) return; \
uint id = __classNameIDS(); \
PIMutexLocker ml(__meta_mutex()); \
if (__meta_data().contains(id)) return; \
__meta_data()[pid]; \
__meta_data()[id]; \
__MetaData & ehp(__meta_data()[pid]); \
__MetaData & eh(__meta_data()[id]); \
eh.eh_set << ehp.eh_set; \
eh.eh_func << ehp.eh_func; \
eh.addScope(__classNameS(), id); \
} \
}; \
__BaseInitializer__ __base_init__;
#define PIOBJECT_PARENT(name) \
class __ParentInitializer__ { \
public: \
__ParentInitializer__() { \
uint pid = name::__classNameIDS(); \
if (pid == 0) return; \
uint id = __classNameIDS(); \
PIMutexLocker ml(__meta_mutex()); \
__MetaData & eh(__meta_data()[id]); \
if (eh.scope_id.contains(pid)) return; \
__MetaData ehp(__meta_data().value(pid)); \
eh.eh_set << ehp.eh_set; \
eh.eh_func << ehp.eh_func; \
eh.scope_id = ehp.scope_id; \
eh.scope_list = ehp.scope_list; \
eh.addScope(__classNameS(), id); \
} \
}; \
__ParentInitializer__ __parent_init__; \
public: \
virtual const char * parentClassName() const {return #name;} \
typedef name __Parent__; \
private:
#define PIOBJECT_SUBCLASS(name, parent) PIOBJECT(name) PIOBJECT_PARENT(parent)
#define EH_INIT0(ret, name) \
class __##name##0_Initializer__ { \
public: \
__##name##0_Initializer__() { \
PIMutexLocker ml(__meta_mutex()); \
__MetaData & eh(__meta_data()[__classNameIDS()]); \
void * fp = (void*)(ret(*)(void*))__stat_eh_##name##__; \
void * fpV = fp; \
if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \
__MetaFunc & f(eh.eh_func[fp]); \
f.scope = __classNameS(); \
f.func_name = PIStringAscii(#name); \
f.addr = fp; \
f.addrV = fpV; \
f.type_ret = PIStringAscii(#ret); \
} \
}; \
__##name##0_Initializer__ __##name##0_init__; \
#define EH_INIT1(ret, name, a0, n0) \
class __##name##1##n0##_Initializer__ { \
public: \
__##name##1##n0##_Initializer__() { \
PIMutexLocker ml(__meta_mutex()); \
__MetaData & eh(__meta_data()[__classNameIDS()]); \
void * fp = (void*)(ret(*)(void*, a0))__stat_eh_##name##__; \
void * fpV = (void*)(ret(*)(void*, const PIVariant &))__stat_eh_v_##name##__; \
if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \
__MetaFunc & f(eh.eh_func[fp]); \
f.scope = __classNameS(); \
f.func_name = PIStringAscii(#name); \
f.addr = fp; \
f.addrV = fpV; \
f.type_ret = PIStringAscii(#ret); \
f.types << PIObject::simplifyType(#a0); \
f.names << PIStringAscii(#n0); \
} \
}; \
__##name##1##n0##_Initializer__ __##name##1##n0##_init__; \
#define EH_INIT2(ret, name, a0, n0, a1, n1) \
class __##name##2##n0##n1##_Initializer__ { \
public: \
__##name##2##n0##n1##_Initializer__() { \
PIMutexLocker ml(__meta_mutex()); \
__MetaData & eh(__meta_data()[__classNameIDS()]); \
void * fp = (void*)(ret(*)(void*, a0, a1))__stat_eh_##name##__; \
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \
__MetaFunc & f(eh.eh_func[fp]); \
f.scope = __classNameS(); \
f.func_name = PIStringAscii(#name); \
f.addr = fp; \
f.addrV = fpV; \
f.type_ret = PIStringAscii(#ret); \
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1); \
f.names << PIStringAscii(#n0) << PIStringAscii(#n1); \
} \
}; \
__##name##2##n0##n1##_Initializer__ __##name##2##n0##n1##_init__; \
#define EH_INIT3(ret, name, a0, n0, a1, n1, a2, n2) \
class __##name##3##n0##n1##n2##_Initializer__ { \
public: \
__##name##3##n0##n1##n2##_Initializer__() { \
PIMutexLocker ml(__meta_mutex()); \
__MetaData & eh(__meta_data()[__classNameIDS()]); \
void * fp = (void*)(ret(*)(void*, a0, a1, a2))__stat_eh_##name##__; \
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \
__MetaFunc & f(eh.eh_func[fp]); \
f.scope = __classNameS(); \
f.func_name = PIStringAscii(#name); \
f.addr = fp; \
f.addrV = fpV; \
f.type_ret = PIStringAscii(#ret); \
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1) << PIObject::simplifyType(#a2); \
f.names << PIStringAscii(#n0) << PIStringAscii(#n1) << PIStringAscii(#n2); \
} \
}; \
__##name##3##n0##n1##n2##_Initializer__ __##name##3##n0##n1##n2##_init__; \
#define EH_INIT4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \
class __##name##4##n0##n1##n2##n3##_Initializer__ { \
public: \
__##name##4##n0##n1##n2##n3##_Initializer__() { \
PIMutexLocker ml(__meta_mutex()); \
__MetaData & eh(__meta_data()[__classNameIDS()]); \
void * fp = (void*)(ret(*)(void*, a0, a1, a2, a3))__stat_eh_##name##__; \
void * fpV = (void*)(ret(*)(void*, const PIVariant &, const PIVariant &, const PIVariant &, const PIVariant &))__stat_eh_v_##name##__; \
if (eh.eh_set[fp]) return; \
eh.eh_set << fp; \
__MetaFunc & f(eh.eh_func[fp]); \
f.scope = __classNameS(); \
f.func_name = PIStringAscii(#name); \
f.addr = fp; \
f.addrV = fpV; \
f.type_ret = PIStringAscii(#ret); \
f.types << PIObject::simplifyType(#a0) << PIObject::simplifyType(#a1) << PIObject::simplifyType(#a2) << PIObject::simplifyType(#a3); \
f.names << PIStringAscii(#n0) << PIStringAscii(#n1) << PIStringAscii(#n2) << PIStringAscii(#n3); \
} \
}; \
__##name##4##n0##n1##n2##n3##_Initializer__ __##name##4##n0##n1##n2##n3##_init__; \
#define EVENT_HANDLER0(ret, name) \
EH_INIT0(ret, name) \
static ret __stat_eh_##name##__(void * __o__) {return ((__PIObject__*)__o__)->name();} \
ret name()
#define EVENT_HANDLER1(ret, name, a0, n0) \
EH_INIT1(ret, name, a0, n0) \
static ret __stat_eh_##name##__(void * __o__, a0 n0) {return ((__PIObject__*)__o__)->name(n0);} \
static ret __stat_eh_v_##name##__(void * __o__, const PIVariant & v0) { \
__PTYPE(a0) tv0 = __VVALUE(a0, v0); \
return ((__PIObject__*)__o__)->name(tv0);} \
ret name(a0 n0)
#define EVENT_HANDLER2(ret, name, a0, n0, a1, n1) \
EH_INIT2(ret, name, a0, n0, a1, n1) \
static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1) {return ((__PIObject__*)__o__)->name(n0, n1);} \
static ret __stat_eh_v_##name##__(void * __o__, const PIVariant & v0, const PIVariant & v1) { \
__PTYPE(a0) tv0 = __VVALUE(a0, v0); \
__PTYPE(a1) tv1 = __VVALUE(a1, v1); \
return ((__PIObject__*)__o__)->name(tv0, tv1);} \
ret name(a0 n0, a1 n1)
#define EVENT_HANDLER3(ret, name, a0, n0, a1, n1, a2, n2) \
EH_INIT3(ret, name, a0, n0, a1, n1, a2, n2) \
static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1, a2 n2) {return ((__PIObject__*)__o__)->name(n0, n1, n2);} \
static ret __stat_eh_v_##name##__(void * __o__, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2) { \
__PTYPE(a0) tv0 = __VVALUE(a0, v0); \
__PTYPE(a1) tv1 = __VVALUE(a1, v1); \
__PTYPE(a2) tv2 = __VVALUE(a2, v2); \
return ((__PIObject__*)__o__)->name(tv0, tv1, tv2);} \
ret name(a0 n0, a1 n1, a2 n2)
#define EVENT_HANDLER4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \
EH_INIT4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \
static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1, a2 n2, a3 n3) {return ((__PIObject__*)__o__)->name(n0, n1, n2, n3);} \
static ret __stat_eh_v_##name##__(void * __o__, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2, const PIVariant & v3) { \
__PTYPE(a0) tv0 = __VVALUE(a0, v0); \
__PTYPE(a1) tv1 = __VVALUE(a1, v1); \
__PTYPE(a2) tv2 = __VVALUE(a2, v2); \
__PTYPE(a3) tv3 = __VVALUE(a3, v3); \
return ((__PIObject__*)__o__)->name(tv0, tv1, tv2, tv3);} \
ret name(a0 n0, a1 n1, a2 n2, a3 n3)
#define EVENT_HANDLER EVENT_HANDLER0
#define EVENT_VHANDLER0(ret, name) \
EH_INIT0(ret, name) \
static ret __stat_eh_##name##__(void * __o__) {return ((__PIObject__*)__o__)->name();} \
virtual ret name()
#define EVENT_VHANDLER1(ret, name, a0, n0) \
EH_INIT1(ret, name, a0, n0) \
static ret __stat_eh_##name##__(void * __o__, a0 n0) {return ((__PIObject__*)__o__)->name(n0);} \
static ret __stat_eh_v_##name##__(void * __o__, const PIVariant & v0) {return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0));} \
virtual ret name(a0 n0)
#define EVENT_VHANDLER2(ret, name, a0, n0, a1, n1) \
EH_INIT2(ret, name, a0, n0, a1, n1) \
static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1) {return ((__PIObject__*)__o__)->name(n0, n1);} \
static ret __stat_eh_v_##name##__(void * __o__, const PIVariant & v0, const PIVariant & v1) {return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1));} \
virtual ret name(a0 n0, a1 n1)
#define EVENT_VHANDLER3(ret, name, a0, n0, a1, n1, a2, n2) \
EH_INIT3(ret, name, a0, n0, a1, n1, a2, n2) \
static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1, a2 n2) {return ((__PIObject__*)__o__)->name(n0, n1, n2);} \
static ret __stat_eh_v_##name##__(void * __o__, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2) {return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1), __VVALUE(a2, v2));} \
virtual ret name(a0 n0, a1 n1, a2 n2)
#define EVENT_VHANDLER4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \
EH_INIT4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \
static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1, a2 n2, a3 n3) {return ((__PIObject__*)__o__)->name(n0, n1, n2, n3);} \
static ret __stat_eh_v_##name##__(void * __o__, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2, const PIVariant & v3) {return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1), __VVALUE(a2, v2), __VVALUE(a3, v3));} \
virtual ret name(a0 n0, a1 n1, a2 n2, a3 n3)
#define EVENT_VHANDLER EVENT_VHANDLER0
#define EVENT0(name) EVENT_HANDLER0(void, name) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid);}
#define EVENT1(name, a0, n0) EVENT_HANDLER1(void, name, a0, n0) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0);}
#define EVENT2(name, a0, n0, a1, n1) EVENT_HANDLER2(void, name, a0, n0, a1, n1) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1);}
#define EVENT3(name, a0, n0, a1, n1, a2, n2) EVENT_HANDLER3(void, name, a0, n0, a1, n1, a2, n2) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1, n2);}
#define EVENT4(name, a0, n0, a1, n1, a2, n2, a3, n3) EVENT_HANDLER4(void, name, a0, n0, a1, n1, a2, n2, a3, n3) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1, n2, n3);}
#define EVENT EVENT0
#define RAISE_EVENT0(src, event) (src)->event();
#define RAISE_EVENT1(src, event, v0) (src)->event(v0);
#define RAISE_EVENT2(src, event, v0, v1) (src)->event(v0, v1);
#define RAISE_EVENT3(src, event, v0, v1, v2) (src)->event(v0, v1, v2);
#define RAISE_EVENT4(src, event, v0, v1, v2, v3) (src)->event(v0, v1, v2, v3);
#define RAISE_EVENT RAISE_EVENT0
#define CONNECTU(src, event, dest, handler) PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION);
#define CONNECTU_QUEUED(src, event, dest, handler, performer) PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION, performer);
#define CONNECTL(src, event, functor) PIObject::piConnectLS(src, PIStringAscii(#event), PIObject::__newFunctor(&(src)->__stat_eh_##event##__, functor), LOCATION);
#define CONNECT0(ret, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*))(&(src)->__stat_eh_##event##__), 0, LOCATION);
#define CONNECT1(ret, a0, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0))(&(src)->__stat_eh_##event##__), 1, LOCATION);
#define CONNECT2(ret, a0, a1, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0, a1))(&(src)->__stat_eh_##event##__), 2, LOCATION);
#define CONNECT3(ret, a0, a1, a2, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0, a1, a2))(&(src)->__stat_eh_##event##__), 3, LOCATION);
#define CONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0, a1, a2, a3))(&(src)->__stat_eh_##event##__), 4, LOCATION);
#define CONNECT CONNECT0
#define WEAK_CONNECT0(ret, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__), 0, 0, LOCATION);
#define WEAK_CONNECT1(ret, a0, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__), 0, 1, LOCATION);
#define WEAK_CONNECT2(ret, a0, a1, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__), 0, 2, LOCATION);
#define WEAK_CONNECT3(ret, a0, a1, a2, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__), 0, 3, LOCATION);
#define WEAK_CONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__), 0, 4, LOCATION);
#define WEAK_CONNECT WEAK_CONNECT0
#define DISCONNECT0(ret, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__));
#define DISCONNECT1(ret, a0, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__));
#define DISCONNECT2(ret, a0, a1, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__));
#define DISCONNECT3(ret, a0, a1, a2, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__));
#define DISCONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__));
#define DISCONNECT DISCONNECT0
#define HANDLER(handler) __stat_eh_##handler##__
#define __PIOBJECT_SIGNATURE__ 0xabcdbadc
#endif
typedef void (*Handler)(void * );
class PIP_EXPORT PIObject {
friend class PIObjectManager;
friend void dumpApplication();
typedef PIObject __PIObject__;
typedef void __Parent__;
friend class PIIntrospection;
public:
NO_COPY_CLASS(PIObject)
//! Contructs PIObject with name "name"
explicit PIObject(const PIString & name = PIString());
virtual ~PIObject();
private:
uint _signature_;
public:
//! Returns object name
PIString name() const {return property(PIStringAscii("name")).toString();}
//! Returns object class name
virtual const char * className() const {return "PIObject";}
virtual uint classNameID() const {static uint ret = PIStringAscii("PIObject").hash(); return ret;}
static const PIString __classNameS() {return PIStringAscii("PIObject");}
static uint __classNameIDS() {static uint ret = PIStringAscii("PIObject").hash(); return ret;}
//! Returns parent object class name
virtual const char * parentClassName() const {return "";}
//! Return if debug of this object is active
bool debug() const {return property(PIStringAscii("debug")).toBool();}
//! Set object name
void setName(const PIString & name) {setProperty(PIStringAscii("name"), name);}
void setName(const char * name) {setName(PIStringAscii(name));}
//! Set object debug active
void setDebug(bool debug) {setProperty(PIStringAscii("debug"), debug);}
//! Returns properties of the object
PIMap<PIString, PIVariant> properties() const;
//! Returns properties count of the object
int propertiesCount() const {return properties_.size_s();}
//! Returns property with name "name"
PIVariant property(const PIString & name) const {return properties_.value(name.hash(), Property(PIString(), PIVariant())).second;}
PIVariant property(const char * name) const {return property(PIStringAscii(name));}
//! Set property with name "name" to "value". If there is no such property in object it will be added
void setProperty(const PIString & name, const PIVariant & value) {properties_[name.hash()] = Property(name, value); propertyChanged(name);}
void setProperty(const char * name, const PIVariant & value) {setProperty(PIStringAscii(name), value);}
//! Returns if property with name "name" exists
bool isPropertyExists(const PIString & name) const {return properties_.contains(name.hash());}
bool isPropertyExists(const char * name) const {return isPropertyExists(PIStringAscii(name));}
void setThreadSafe(bool yes) {thread_safe_ = yes;}
bool isThreadSafe() const {return thread_safe_;}
bool execute(const PIString & method, const PIVector<PIVariant> & vl);
bool execute(const PIString & method) {return execute(method, PIVector<PIVariant>());}
bool execute(const PIString & method, const PIVariant & v0) {return execute(method, PIVector<PIVariant>() << v0);}
bool execute(const PIString & method, const PIVariant & v0, const PIVariant & v1) {return execute(method, PIVector<PIVariant>() << v0 << v1);}
bool execute(const PIString & method, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2) {return execute(method, PIVector<PIVariant>() << v0 << v1 << v2);}
bool execute(const PIString & method, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2, const PIVariant & v3) {return execute(method, PIVector<PIVariant>() << v0 << v1 << v2 << v3);}
bool executeQueued(PIObject * performer, const PIString & method, const PIVector<PIVariant> & vl);
bool executeQueued(PIObject * performer, const PIString & method) {return executeQueued(performer, method, PIVector<PIVariant>());}
bool executeQueued(PIObject * performer, const PIString & method, const PIVariant & v0) {return executeQueued(performer, method, PIVector<PIVariant>() << v0);}
bool executeQueued(PIObject * performer, const PIString & method, const PIVariant & v0, const PIVariant & v1) {return executeQueued(performer, method, PIVector<PIVariant>() << v0 << v1);}
bool executeQueued(PIObject * performer, const PIString & method, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2) {return executeQueued(performer, method, PIVector<PIVariant>() << v0 << v1 << v2);}
bool executeQueued(PIObject * performer, const PIString & method, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2, const PIVariant & v3) {return executeQueued(performer, method, PIVector<PIVariant>() << v0 << v1 << v2 << v3);}
static bool execute(PIObject * o, const PIString & method, const PIVector<PIVariant> & vl) {return o->execute(method, vl);}
static bool execute(PIObject * o, const PIString & method) {return execute(o, method, PIVector<PIVariant>());}
static bool execute(PIObject * o, const PIString & method, const PIVariant & v0) {return execute(o, method, PIVector<PIVariant>() << v0);}
static bool execute(PIObject * o, const PIString & method, const PIVariant & v0, const PIVariant & v1) {return execute(o, method, PIVector<PIVariant>() << v0 << v1);}
static bool execute(PIObject * o, const PIString & method, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2) {return execute(o, method, PIVector<PIVariant>() << v0 << v1 << v2);}
static bool execute(PIObject * o, const PIString & method, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2, const PIVariant & v3) {return execute(o, method, PIVector<PIVariant>() << v0 << v1 << v2 << v3);}
static bool executeQueued(PIObject * o, PIObject * performer, const PIString & method, const PIVector<PIVariant> & vl) {return o->executeQueued(performer, method, vl);}
static bool executeQueued(PIObject * o, PIObject * performer, const PIString & method) {return executeQueued(o, performer, method, PIVector<PIVariant>());}
static bool executeQueued(PIObject * o, PIObject * performer, const PIString & method, const PIVariant & v0) {return executeQueued(o, performer, method, PIVector<PIVariant>() << v0);}
static bool executeQueued(PIObject * o, PIObject * performer, const PIString & method, const PIVariant & v0, const PIVariant & v1) {return executeQueued(o, performer, method, PIVector<PIVariant>() << v0 << v1);}
static bool executeQueued(PIObject * o, PIObject * performer, const PIString & method, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2) {return executeQueued(o, performer, method, PIVector<PIVariant>() << v0 << v1 << v2);}
static bool executeQueued(PIObject * o, PIObject * performer, const PIString & method, const PIVariant & v0, const PIVariant & v1, const PIVariant & v2, const PIVariant & v3) {return executeQueued(o, performer, method, PIVector<PIVariant>() << v0 << v1 << v2 << v3);}
void dump(const PIString & line_prefix = PIString()) const;
PIStringList scopeList() const;
PIStringList methodsEH() const;
bool isMethodEHContains(const PIString & name) const;
PIString methodEHArguments(const PIString & name) const;
PIString methodEHFullFormat(const PIString & name) const;
PIString methodEHFromAddr(const void * addr) const;
// / Direct connect
static void piConnect(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, void * ev_h, void * e_h, int args, const char * loc);
static bool piConnectU(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, const PIString & hname, const char * loc, PIObject * performer = 0);
static bool piConnectLS(PIObject * src, const PIString & sig, std::function<void()> * f, const char * loc);
template <typename INPUT, typename... TYPES>
static std::function<void()> * __newFunctor(void(*stat_handler)(void*,TYPES...), INPUT functor) {
return (std::function<void()>*)(new std::function<void(TYPES...)>(functor));
}
// / Through names and mixed
static void piConnect(const PIString & src, const PIString & sig, void * dest, void * ev_h);
static void piConnect(PIObject * src, const PIString & sig, const PIString & dest, void * ev_h);
static void piConnect(const PIString & src, const PIString & sig, const PIString & dest, void * ev_h);
static void piDisconnect(PIObject * src, const PIString & sig, PIObject * dest, void * ev_h);
static void piDisconnect(PIObject * src, const PIString & sig, PIObject * dest);
//! Disconnect object "src" from all connections with event name "sig"
static void piDisconnect(PIObject * src, const PIString & sig);
//! Disconnect object "src" from all connections, i.e. all connections where object "src" is emitter
static void piDisconnect(PIObject * src);
// / Raise events
static void raiseEvent(PIObject * sender, const uint eventID) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
__Connection i(sender->connections[j]);
if (i.eventID != eventID) continue;
if (i.functor) {
(*(i.functor))();
} else {
if (i.performer) {
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender));
} else {
bool ts = sender->thread_safe_;
if (ts) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
((void( *)(void * ))i.slot)(i.dest);
if (i.dest_o->isPIObject()) {
i.dest_o->emitter_ = 0;
if (ts) i.dest_o->mutex_.unlock();
}
}
}
if (!sender->isPIObject()) break;
}
}
template <typename T0>
static void raiseEvent(PIObject * sender, const uint eventID, const T0 & v0 = T0()) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
__Connection i(sender->connections[j]);
if (i.eventID != eventID) continue;
if (i.functor) {
(*((std::function<void(T0)>*)i.functor))(v0);
} else {
if (i.performer) {
PIVector<PIVariant> vl;
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
} else {
bool ts = sender->thread_safe_;
if (ts) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
if (i.args_count == 0) ((void(*)(void *))i.slot)(i.dest);
else ((void(*)(void * , T0))i.slot)(i.dest, v0);
if (i.dest_o->isPIObject()) {
i.dest_o->emitter_ = 0;
if (ts) i.dest_o->mutex_.unlock();
}
}
}
if (!sender->isPIObject()) break;
}
}
template <typename T0, typename T1>
static void raiseEvent(PIObject * sender, const uint eventID, const T0 & v0 = T0(), const T1 & v1 = T1()) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
__Connection i(sender->connections[j]);
if (i.eventID != eventID) continue;
if (i.functor) {
(*((std::function<void(T0, T1)>*)i.functor))(v0, v1);
} else {
if (i.performer) {
PIVector<PIVariant> vl;
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
if (i.args_count > 1) vl << PIVariant::fromValue(v1);
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
} else {
bool ts = sender->thread_safe_;
if (ts) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
switch (i.args_count) {
case 0: ((void(*)(void *))i.slot)(i.dest); break;
case 1: ((void(*)(void * , T0))i.slot)(i.dest, v0); break;
default: ((void(*)(void * , T0, T1))i.slot)(i.dest, v0, v1); break;
}
if (i.dest_o->isPIObject()) {
i.dest_o->emitter_ = 0;
if (ts) i.dest_o->mutex_.unlock();
}
}
}
if (!sender->isPIObject()) break;
}
}
template <typename T0, typename T1, typename T2>
static void raiseEvent(PIObject * sender, const uint eventID, const T0 & v0 = T0(), const T1 & v1 = T1(), const T2 & v2 = T2()) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
__Connection i(sender->connections[j]);
if (i.eventID != eventID) continue;
if (i.functor) {
(*((std::function<void(T0, T1, T2)>*)i.functor))(v0, v1, v2);
} else {
if (i.performer) {
PIVector<PIVariant> vl;
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
if (i.args_count > 1) vl << PIVariant::fromValue(v1);
if (i.args_count > 2) vl << PIVariant::fromValue(v2);
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
} else {
bool ts = sender->thread_safe_;
if (ts) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
switch (i.args_count) {
case 0: ((void(*)(void *))i.slot)(i.dest); break;
case 1: ((void(*)(void * , T0))i.slot)(i.dest, v0); break;
case 2: ((void(*)(void * , T0, T1))i.slot)(i.dest, v0, v1); break;
default: ((void(*)(void * , T0, T1, T2))i.slot)(i.dest, v0, v1, v2); break;
}
if (i.dest_o->isPIObject()) {
i.dest_o->emitter_ = 0;
if (ts) i.dest_o->mutex_.unlock();
}
}
}
if (!sender->isPIObject()) break;
}
}
template <typename T0, typename T1, typename T2, typename T3>
static void raiseEvent(PIObject * sender, const uint eventID, const T0 & v0 = T0(), const T1 & v1 = T1(), const T2 & v2 = T2(), const T3 & v3 = T3()) {
for (int j = 0; j < sender->connections.size_s(); ++j) {
__Connection i(sender->connections[j]);
if (i.eventID != eventID) continue;
if (i.functor) {
(*((std::function<void(T0, T1, T2, T3)>*)i.functor))(v0, v1, v2, v3);
} else {
if (i.performer) {
PIVector<PIVariant> vl;
if (i.args_count > 0) vl << PIVariant::fromValue(v0);
if (i.args_count > 1) vl << PIVariant::fromValue(v1);
if (i.args_count > 2) vl << PIVariant::fromValue(v2);
if (i.args_count > 3) vl << PIVariant::fromValue(v3);
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
} else {
bool ts = sender->thread_safe_;
if (ts) i.dest_o->mutex_.lock();
i.dest_o->emitter_ = sender;
switch (i.args_count) {
case 0: ((void(*)(void *))i.slot)(i.dest); break;
case 1: ((void(*)(void * , T0))i.slot)(i.dest, v0); break;
case 2: ((void(*)(void * , T0, T1))i.slot)(i.dest, v0, v1); break;
case 3: ((void(*)(void * , T0, T1, T2))i.slot)(i.dest, v0, v1, v2); break;
default: ((void(*)(void * , T0, T1, T2, T3))i.slot)(i.dest, v0, v1, v2, v3); break;
}
if (i.dest_o->isPIObject()) {
i.dest_o->emitter_ = 0;
if (ts) i.dest_o->mutex_.unlock();
}
}
}
if (!sender->isPIObject()) break;
}
}
//! Returns PIObject* with name "name" or 0, if there is no object found
static PIObject * findByName(const PIString & name) {
PIMutexLocker _ml(mutexObjects());
piForeach (PIObject * i, PIObject::objects()) {
if (i->name() != name) continue;
return i;
}
return 0;
}
bool isPIObject() const {return isPIObject(this);}
template<typename T>
bool isTypeOf() const {
if (!isPIObject()) return false;
return scopeList().contains(T::__classNameS());
}
template<typename T>
T * cast() const {
if (!isTypeOf<T>()) return (T*)0;
return (T*)this;
}
static bool isPIObject(const PIObject * o);
static bool isPIObject(const void * o) {return isPIObject((PIObject*)o);}
template<typename T>
static bool isTypeOf(const PIObject * o) {return o->isTypeOf<T>();}
template<typename T>
static bool isTypeOf(const void * o) {return isTypeOf<T>((PIObject*)o);}
static PIString simplifyType(const char * a);
struct PIP_EXPORT __MetaFunc {
__MetaFunc(): addr(0), addrV(0) {;}
bool isNull() const {return addr == 0;}
PIString arguments() const;
PIString fullFormat() const;
void * addr;
void * addrV;
PIString func_name;
PIString type_ret;
PIString scope;
PIStringList types;
PIStringList names;
};
struct PIP_EXPORT __MetaData {
__MetaData() {scope_list << PIStringAscii("PIObject"); scope_id << PIStringAscii("PIObject").hash();}
void addScope(const PIString & s, uint shash);
PIStringList scope_list;
PISet<uint> scope_id;
PISet<const void * > eh_set;
PIMap<const void * , __MetaFunc> eh_func;
};
typedef PIPair<const void * , __MetaFunc> __EHPair;
static PIMutex & __meta_mutex();
static PIMap<uint, __MetaData> & __meta_data(); // [hash(classname)]=__MetaData
//! \brief Execute all posted events from CONNECTU_QUEUED connections
void callQueuedEvents();
//! \brief Check if any CONNECTU_QUEUED connections to this object and execute them.
//! \details This function is more optimized than \a callQueuedEvents() for objects that doesn`t
//! appears as \"performer\" target at CONNECTU_QUEUED
bool maybeCallQueuedEvents() {if (proc_event_queue) callQueuedEvents(); return proc_event_queue;}
protected:
//! Returns PIObject* which has raised an event. This value is correct only in definition of some event handler
PIObject * emitter() const {return emitter_;}
//! Virtual function executes after property with name "name" has been changed
virtual void propertyChanged(const PIString & name) {}
EVENT(deleted)
//! \events
//! \{
/** \fn void deleted()
* \brief Raise before object delete
* \note This event raised from destructor, so use only emitter() value,
* don`t try to cast deleted object to some subclass! */
//! \}
private:
struct __Connection {
__Connection(void * sl = 0, void * si = 0, const PIString & e = PIString(), PIObject * d_o = 0, void * d = 0, int ac = 0, PIObject * p = 0) {
slot = sl;
signal = si;
event = e;
eventID = e.hash();
dest_o = d_o;
dest = d;
args_count = ac;
performer = p;
functor = 0;
}
void destroy();
void * slot;
void * signal;
std::function<void()> * functor;
PIString event;
uint eventID;
PIObject * dest_o;
PIObject * performer;
void * dest;
int args_count;
};
struct __QueuedEvent {
__QueuedEvent(void * sl = 0, void * d = 0, PIObject * d_o = 0, PIObject * s = 0, const PIVector<PIVariant> & v = PIVector<PIVariant>()) {
slot = sl;
dest = d;
dest_o = d_o;
src = s;
values = v;
}
void * slot;
void * dest;
PIObject * dest_o;
PIObject * src;
PIVector<PIVariant> values;
};
typedef PIPair<PIString, PIVariant> Property;
typedef PIPair<uint, PIPair<PIString, PIVariant> > PropertyHash;
bool findSuitableMethodV(const PIString & method, int args, int & ret_args, __MetaFunc & ret);
PIVector<__MetaFunc> findEH(const PIString & name) const;
__MetaFunc methodEH(const void * addr) const;
void updateConnectors();
void postQueuedEvent(const __QueuedEvent & e);
void * toThis() const;
virtual int ptrOffset() const {return 0;}
static PIVector<PIObject * > & objects();
static PIMutex & mutexObjects();
static void callAddrV(void * slot, void * obj, int args, const PIVector<PIVariant> & vl);
PIVector<__Connection> connections;
PIMap<uint, PIPair<PIString, PIVariant> > properties_;
PISet<PIObject * > connectors;
PIVector<__QueuedEvent> events_queue;
PIMutex mutex_, mutex_connect, mutex_queue;
PIObject * emitter_;
bool thread_safe_, proc_event_queue;
};
PIP_EXPORT void dumpApplication();
PIP_EXPORT bool dumpApplicationToFile(const PIString & path);
#endif // PIOBJECT_H

View File

@@ -1,574 +0,0 @@
/*! \file pimathmatrix.h
* \brief PIMathMatrix
*/
/*
PIP - Platform Independent Primitives
PIMathMatrix
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIMATHMATRIX_H
#define PIMATHMATRIX_H
#include "pimathvector.h"
#include "pimathcomplex.h"
template<typename T>
inline bool _PIMathMatrixNullCompare(const T v) {
return (piAbs(v) < T(1E-200));
}
template<>
inline bool _PIMathMatrixNullCompare<complexf >(const complexf v) {
return (abs(v) < float(1E-200));
}
template<>
inline bool _PIMathMatrixNullCompare<complexd >(const complexd v) {
return (abs(v) < double(1E-200));
}
/// Matrix templated
#define PIMM_FOR(r, c) for (uint c = 0; c < Cols; ++c) { for (uint r = 0; r < Rows; ++r) {
#define PIMM_FOR_WB(r, c) for (uint c = 0; c < Cols; ++c) for (uint r = 0; r < Rows; ++r) // without brakes
#define PIMM_FOR_I(r, c) for (uint r = 0; r < Rows; ++r) { for (uint c = 0; c < Cols; ++c) {
#define PIMM_FOR_I_WB(r, c) for (uint r = 0; r < Rows; ++r) for (uint c = 0; c < Cols; ++c) // without brakes
#define PIMM_FOR_C(v) for (uint v = 0; v < Cols; ++v)
#define PIMM_FOR_R(v) for (uint v = 0; v < Rows; ++v)
#pragma pack(push, 1)
template<uint Rows, uint Cols = Rows, typename Type = double>
class PIP_EXPORT PIMathMatrixT {
typedef PIMathMatrixT<Rows, Cols, Type> _CMatrix;
typedef PIMathMatrixT<Cols, Rows, Type> _CMatrixI;
typedef PIMathVectorT<Rows, Type> _CMCol;
typedef PIMathVectorT<Cols, Type> _CMRow;
public:
PIMathMatrixT() {resize(Rows, Cols);}
PIMathMatrixT(const PIVector<Type> & val) {resize(Rows, Cols); int i = 0; PIMM_FOR_I_WB(r, c) m[r][c] = val[i++];}
static _CMatrix identity() {_CMatrix tm = _CMatrix(); PIMM_FOR_WB(r, c) tm.m[r][c] = (c == r ? Type(1) : Type(0)); return tm;}
static _CMatrix filled(const Type & v) {_CMatrix tm; PIMM_FOR_WB(r, c) tm.m[r][c] = v; return tm;}
static _CMatrix rotation(double angle) {return _CMatrix();}
static _CMatrix rotationX(double angle) {return _CMatrix();}
static _CMatrix rotationY(double angle) {return _CMatrix();}
static _CMatrix rotationZ(double angle) {return _CMatrix();}
static _CMatrix scaleX(double factor) {return _CMatrix();}
static _CMatrix scaleY(double factor) {return _CMatrix();}
static _CMatrix scaleZ(double factor) {return _CMatrix();}
uint cols() const {return Cols;}
uint rows() const {return Rows;}
_CMCol col(uint index) {_CMCol tv; PIMM_FOR_R(i) tv[i] = m[i][index]; return tv;}
_CMRow row(uint index) {_CMRow tv; PIMM_FOR_C(i) tv[i] = m[index][i]; return tv;}
_CMatrix & setCol(uint index, const _CMCol & v) {PIMM_FOR_R(i) m[i][index] = v[i]; return *this;}
_CMatrix & setRow(uint index, const _CMRow & v) {PIMM_FOR_C(i) m[index][i] = v[i]; return *this;}
_CMatrix & swapRows(uint r0, uint r1) {Type t; PIMM_FOR_C(i) {t = m[r0][i]; m[r0][i] = m[r1][i]; m[r1][i] = t;} return *this;}
_CMatrix & swapCols(uint c0, uint c1) {Type t; PIMM_FOR_R(i) {t = m[i][c0]; m[i][c0] = m[i][c1]; m[i][c1] = t;} return *this;}
_CMatrix & fill(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] = v; return *this;}
bool isSquare() const {return cols() == rows();}
bool isIdentity() const {PIMM_FOR_WB(r, c) if ((c == r) ? m[r][c] != Type(1) : m[r][c] != Type(0)) return false; return true;}
bool isNull() const {PIMM_FOR_WB(r, c) if (m[r][c] != Type(0)) return false; return true;}
Type & at(uint row, uint col) {return m[row][col];}
Type at(uint row, uint col) const {return m[row][col];}
Type * operator [](uint row) {return m[row];}
const Type * operator [](uint row) const {return m[row];}
_CMatrix & operator =(const _CMatrix & sm) {memcpy(m, sm.m, sizeof(Type) * Cols * Rows); return *this;}
bool operator ==(const _CMatrix & sm) const {PIMM_FOR_WB(r, c) if (m[r][c] != sm.m[r][c]) return false; return true;}
bool operator !=(const _CMatrix & sm) const {return !(*this == sm);}
void operator +=(const _CMatrix & sm) {PIMM_FOR_WB(r, c) m[r][c] += sm.m[r][c];}
void operator -=(const _CMatrix & sm) {PIMM_FOR_WB(r, c) m[r][c] -= sm.m[r][c];}
void operator *=(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] *= v;}
void operator /=(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] /= v;}
_CMatrix operator -() const {_CMatrix tm; PIMM_FOR_WB(r, c) tm.m[r][c] = -m[r][c]; return tm;}
_CMatrix operator +(const _CMatrix & sm) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] += sm.m[r][c]; return tm;}
_CMatrix operator -(const _CMatrix & sm) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] -= sm.m[r][c]; return tm;}
_CMatrix operator *(const Type & v) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] *= v; return tm;}
_CMatrix operator /(const Type & v) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] /= v; return tm;}
Type determinant(bool * ok = 0) const {
_CMatrix m(*this);
bool k;
Type ret = Type(0);
m.toUpperTriangular(&k);
if (ok) *ok = k;
if (!k) return ret;
ret = Type(1);
for (uint c = 0; c < Cols; ++c)
for (uint r = 0; r < Rows; ++r)
if (r == c)
ret *= m[r][c];
return ret;
}
_CMatrix & toUpperTriangular(bool * ok = 0) {
if (Cols != Rows) {
if (ok != 0) *ok = false;
return *this;
}
_CMatrix smat(*this);
bool ndet;
uint crow;
Type mul;
for (uint i = 0; i < Cols; ++i) {
ndet = true;
for (uint j = 0; j < Rows; ++j) if (smat.m[i][j] != 0) ndet = false;
if (ndet) {
if (ok != 0) *ok = false;
return *this;
}
}
for (uint i = 0; i < Cols; ++i) {
crow = i;
while (smat.m[i][i] == Type(0))
smat.swapRows(i, ++crow);
for (uint j = i + 1; j < Rows; ++j) {
mul = smat.m[i][j] / smat.m[i][i];
for (uint k = i; k < Cols; ++k) smat.m[k][j] -= mul * smat.m[k][i];
}
if (i < Cols - 1) {
if (fabs(smat.m[i+1][i+1]) < Type(1E-200)) {
if (ok != 0) *ok = false;
return *this;
}
}
}
if (ok != 0) *ok = true;
memcpy(m, smat.m, sizeof(Type) * Cols * Rows);
return *this;
}
_CMatrix & invert(bool * ok = 0) {
if (Cols != Rows) {
if (ok != 0) *ok = false;
return *this;
}
_CMatrix mtmp = _CMatrix::identity(), smat(*this);
bool ndet;
uint crow;
Type mul, iddiv;
for (uint i = 0; i < Cols; ++i) {
ndet = true;
for (uint j = 0; j < Rows; ++j) if (smat.m[i][j] != 0) ndet = false;
if (ndet) {
if (ok != 0) *ok = false;
return *this;
}
}
for (uint i = 0; i < Cols; ++i) {
crow = i;
while (smat.m[i][i] == Type(0)) {
++crow;
smat.swapRows(i, crow);
mtmp.swapRows(i, crow);
}
for (uint j = i + 1; j < Rows; ++j) {
mul = smat.m[i][j] / smat.m[i][i];
for (uint k = i; k < Cols; ++k) smat.m[k][j] -= mul * smat.m[k][i];
for (uint k = 0; k < Cols; ++k) mtmp.m[k][j] -= mul * mtmp.m[k][i];
}
if (i < Cols - 1) {
if (fabs(smat.m[i+1][i+1]) < Type(1E-200)) {
if (ok != 0) *ok = false;
return *this;
}
}
iddiv = smat.m[i][i];
for (uint j = i; j < Cols; ++j) smat.m[j][i] /= iddiv;
for (uint j = 0; j < Cols; ++j) mtmp.m[j][i] /= iddiv;
}
for (uint i = Cols - 1; i > 0; --i) {
for (uint j = 0; j < i; ++j) {
mul = smat.m[i][j];
smat.m[i][j] -= mul;
for (uint k = 0; k < Cols; ++k) mtmp.m[k][j] -= mtmp.m[k][i] * mul;
}
}
if (ok != 0) *ok = true;
memcpy(m, mtmp.m, sizeof(Type) * Cols * Rows);
return *this;
}
_CMatrix inverted(bool * ok = 0) const {_CMatrix tm(*this); tm.invert(ok); return tm;}
_CMatrixI transposed() const {_CMatrixI tm; PIMM_FOR_WB(r, c) tm[c][r] = m[r][c]; return tm;}
private:
void resize(uint rows_, uint cols_, const Type & new_value = Type()) {r_ = rows_; c_ = cols_; PIMM_FOR_WB(r, c) m[r][c] = new_value;}
int c_, r_;
Type m[Rows][Cols];
};
#pragma pack(pop)
template<> inline PIMathMatrixT<2u, 2u> PIMathMatrixT<2u, 2u>::rotation(double angle) {double c = cos(angle), s = sin(angle); PIMathMatrixT<2u, 2u> tm; tm[0][0] = tm[1][1] = c; tm[0][1] = -s; tm[1][0] = s; return tm;}
template<> inline PIMathMatrixT<2u, 2u> PIMathMatrixT<2u, 2u>::scaleX(double factor) {PIMathMatrixT<2u, 2u> tm; tm[0][0] = factor; tm[1][1] = 1.; return tm;}
template<> inline PIMathMatrixT<2u, 2u> PIMathMatrixT<2u, 2u>::scaleY(double factor) {PIMathMatrixT<2u, 2u> tm; tm[0][0] = 1.; tm[1][1] = factor; return tm;}
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::rotationX(double angle) {double c = cos(angle), s = sin(angle); PIMathMatrixT<3u, 3u> tm; tm[0][0] = 1.; tm[1][1] = tm[2][2] = c; tm[2][1] = s; tm[1][2] = -s; return tm;}
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::rotationY(double angle) {double c = cos(angle), s = sin(angle); PIMathMatrixT<3u, 3u> tm; tm[1][1] = 1.; tm[0][0] = tm[2][2] = c; tm[2][0] = -s; tm[0][2] = s; return tm;}
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::rotationZ(double angle) {double c = cos(angle), s = sin(angle); PIMathMatrixT<3u, 3u> tm; tm[2][2] = 1.; tm[0][0] = tm[1][1] = c; tm[1][0] = s; tm[0][1] = -s; return tm;}
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::scaleX(double factor) {PIMathMatrixT<3u, 3u> tm; tm[1][1] = tm[2][2] = 1.; tm[0][0] = factor; return tm;}
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::scaleY(double factor) {PIMathMatrixT<3u, 3u> tm; tm[0][0] = tm[2][2] = 1.; tm[1][1] = factor; return tm;}
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::scaleZ(double factor) {PIMathMatrixT<3u, 3u> tm; tm[0][0] = tm[1][1] = 1.; tm[2][2] = factor; return tm;}
#ifdef PIP_STD_IOSTREAM
template<uint Rows, uint Cols, typename Type>
inline std::ostream & operator <<(std::ostream & s, const PIMathMatrixT<Rows, Cols, Type> & m) {s << "{"; PIMM_FOR_I(r, c) s << m[r][c]; if (c < Cols - 1 || r < Rows - 1) s << ", ";} if (r < Rows - 1) s << std::endl << " ";} s << "}"; return s;}
#endif
template<uint Rows, uint Cols, typename Type>
inline PICout operator <<(PICout s, const PIMathMatrixT<Rows, Cols, Type> & m) {s << "{"; PIMM_FOR_I(r, c) s << m[r][c]; if (c < Cols - 1 || r < Rows - 1) s << ", ";} if (r < Rows - 1) s << PICoutManipulators::NewLine << " ";} s << "}"; return s;}
/// Multiply matrices {Rows0 x CR} on {CR x Cols1}, result is {Rows0 x Cols1}
template<uint CR, uint Rows0, uint Cols1, typename Type>
inline PIMathMatrixT<Rows0, Cols1, Type> operator *(const PIMathMatrixT<Rows0, CR, Type> & fm,
const PIMathMatrixT<CR, Cols1, Type> & sm) {
PIMathMatrixT<Rows0, Cols1, Type> tm;
Type t;
for (uint j = 0; j < Rows0; ++j) {
for (uint i = 0; i < Cols1; ++i) {
t = Type(0);
for (uint k = 0; k < CR; ++k)
t += fm[j][k] * sm[k][i];
tm[j][i] = t;
}
}
return tm;
}
/// Multiply matrix {Rows x Cols} on vector {Cols}, result is vector {Rows}
template<uint Cols, uint Rows, typename Type>
inline PIMathVectorT<Rows, Type> operator *(const PIMathMatrixT<Rows, Cols, Type> & fm,
const PIMathVectorT<Cols, Type> & sv) {
PIMathVectorT<Rows, Type> tv;
Type t;
for (uint j = 0; j < Rows; ++j) {
t = Type(0);
for (uint i = 0; i < Cols; ++i)
t += fm[j][i] * sv[i];
tv[j] = t;
}
return tv;
}
/// Multiply vector {Rows} on matrix {Rows x Cols}, result is vector {Cols}
template<uint Cols, uint Rows, typename Type>
inline PIMathVectorT<Cols, Type> operator *(const PIMathVectorT<Rows, Type> & sv,
const PIMathMatrixT<Rows, Cols, Type> & fm) {
PIMathVectorT<Cols, Type> tv;
Type t;
for (uint j = 0; j < Cols; ++j) {
t = Type(0);
for (uint i = 0; i < Rows; ++i)
t += fm[i][j] * sv[i];
tv[j] = t;
}
return tv;
}
/// Multiply value(T) on matrix {Rows x Cols}, result is vector {Rows}
template<uint Cols, uint Rows, typename Type>
inline PIMathMatrixT<Rows, Cols, Type> operator *(const Type & x, const PIMathMatrixT<Rows, Cols, Type> & v) {
return v * x;
}
typedef PIMathMatrixT<2u, 2u, int> PIMathMatrixT22i;
typedef PIMathMatrixT<3u, 3u, int> PIMathMatrixT33i;
typedef PIMathMatrixT<4u, 4u, int> PIMathMatrixT44i;
typedef PIMathMatrixT<2u, 2u, double> PIMathMatrixT22d;
typedef PIMathMatrixT<3u, 3u, double> PIMathMatrixT33d;
typedef PIMathMatrixT<4u, 4u, double> PIMathMatrixT44d;
template<typename Type>
class PIMathMatrix;
#undef PIMM_FOR
#undef PIMM_FOR_WB
#undef PIMM_FOR_I
#undef PIMM_FOR_I_WB
#undef PIMM_FOR_C
#undef PIMM_FOR_R
/// Matrix
#define PIMM_FOR(c, r) for (uint c = 0; c < _V2D::cols_; ++c) for (uint r = 0; r < _V2D::rows_; ++r)
#define PIMM_FOR_I(c, r) for (uint r = 0; r < _V2D::rows_; ++r) for (uint c = 0; c < _V2D::cols_; ++c)
#define PIMM_FOR_A(v) for (uint v = 0; v < _V2D::mat.size(); ++v)
#define PIMM_FOR_C(v) for (uint v = 0; v < _V2D::cols_; ++v)
#define PIMM_FOR_R(v) for (uint v = 0; v < _V2D::rows_; ++v)
template<typename Type>
class PIP_EXPORT PIMathMatrix : public PIVector2D<Type> {
typedef PIVector2D<Type> _V2D;
typedef PIMathMatrix<Type> _CMatrix;
typedef PIMathVector<Type> _CMCol;
public:
PIMathMatrix(const uint cols = 0, const uint rows = 0, const Type & f = Type()) {_V2D::resize(rows, cols, f);}
PIMathMatrix(const uint cols, const uint rows, const PIVector<Type> & val) {_V2D::resize(rows, cols); int i=0; PIMM_FOR_I(c, r) _V2D::element(r, c) = val[i++];}
PIMathMatrix(const PIVector<PIVector<Type> > & val) {if(!val.isEmpty()) {_V2D::resize(val.size(), val[0].size()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val[r][c];}}
PIMathMatrix(const PIVector2D<Type> & val) {if(!val.isEmpty()) {_V2D::resize(val.rows(), val.cols()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val.element(r, c);}}
static _CMatrix identity(const uint cols, const uint rows) {_CMatrix tm(cols, rows); for (uint r = 0; r < rows; ++r) for (uint c = 0; c < cols; ++c) tm.element(r, c) = (c == r ? Type(1) : Type(0)); return tm;}
static _CMatrix matrixRow(const PIMathVector<Type> & val) {return _CMatrix(val.size(), 1, val.toVector());}
static _CMatrix matrixCol(const PIMathVector<Type> & val) {return _CMatrix(1, val.size(), val.toVector());}
_CMatrix & setCol(uint index, const _CMCol & v) {PIMM_FOR_R(i) _V2D::element(i, index) = v[i]; return *this;}
_CMatrix & setRow(uint index, const _CMCol & v) {PIMM_FOR_C(i) _V2D::element(index, i) = v[i]; return *this;}
_CMatrix & swapCols(uint r0, uint r1) {PIMM_FOR_C(i) {piSwap(_V2D::element(i, r0), _V2D::element(i, r1));} return *this;}
_CMatrix & swapRows(uint c0, uint c1) {PIMM_FOR_R(i) {piSwap(_V2D::element(c0, i), _V2D::element(c1, i));} return *this;}
_CMatrix & fill(const Type & v) {PIMM_FOR_A(i) _V2D::mat[i] = v; return *this;}
bool isSquare() const {return _V2D::cols_ == _V2D::rows_;}
bool isIdentity() const {PIMM_FOR(c, r) if ((c == r) ? _V2D::element(r, c) != Type(1) : _V2D::element(r, c) != Type(0)) return false; return true;}
bool isNull() const {PIMM_FOR_A(i) if (_V2D::mat[i] != Type(0)) return false; return true;}
bool isValid() const {return !PIVector2D<Type>::isEmpty();}
_CMatrix & operator =(const PIVector<PIVector<Type> > & v) {*this = _CMatrix(v); return *this;}
bool operator ==(const _CMatrix & sm) const {PIMM_FOR_A(i) if (_V2D::mat[i] != sm.mat[i]) return false; return true;}
bool operator !=(const _CMatrix & sm) const {return !(*this == sm);}
void operator +=(const _CMatrix & sm) {PIMM_FOR_A(i) _V2D::mat[i] += sm.mat[i];}
void operator -=(const _CMatrix & sm) {PIMM_FOR_A(i) _V2D::mat[i] -= sm.mat[i];}
void operator *=(const Type & v) {PIMM_FOR_A(i) _V2D::mat[i] *= v;}
void operator /=(const Type & v) {PIMM_FOR_A(i) _V2D::mat[i] /= v;}
_CMatrix operator -() const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] = -_V2D::mat[i]; return tm;}
_CMatrix operator +(const _CMatrix & sm) const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] += sm.mat[i]; return tm;}
_CMatrix operator -(const _CMatrix & sm) const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] -= sm.mat[i]; return tm;}
_CMatrix operator *(const Type & v) const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] *= v; return tm;}
_CMatrix operator /(const Type & v) const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] /= v; return tm;}
Type determinant(bool * ok = 0) const {
_CMatrix m(*this);
bool k;
Type ret = Type(0);
m.toUpperTriangular(&k);
if (ok) *ok = k;
if (!k) return ret;
ret = Type(1);
for (uint c = 0; c < _V2D::cols_; ++c)
for (uint r = 0; r < _V2D::rows_; ++r)
if (r == c)
ret *= m.element(r, c);
return ret;
}
Type trace(bool * ok = 0) const {
Type ret = Type(0);
if (!isSquare()) {
if (ok != 0) *ok = false;
return ret;
}
for (uint i = 0; i < _V2D::cols_; ++i) {
ret += _V2D::element(i, i);
}
if (ok != 0) *ok = true;
return ret;
}
_CMatrix & toUpperTriangular(bool * ok = 0) {
if (!isSquare()) {
if (ok != 0) *ok = false;
return *this;
}
_CMatrix smat(*this);
bool ndet;
uint crow;
Type mul;
for (uint i = 0; i < _V2D::cols_; ++i) {
ndet = true;
for (uint j = 0; j < _V2D::rows_; ++j) if (smat.element(i, j) != 0) ndet = false;
if (ndet) {
if (ok != 0) *ok = false;
return *this;
}
}
for (uint i = 0; i < _V2D::cols_; ++i) {
crow = i;
while (smat.element(i, i) == Type(0))
smat.swapRows(i, ++crow);
for (uint j = i + 1; j < _V2D::rows_; ++j) {
mul = smat.element(i, j) / smat.element(i, i);
for (uint k = i; k < _V2D::cols_; ++k) smat.element(k, j) -= mul * smat.element(k, i);
}
if (i < _V2D::cols_ - 1) {
if (_PIMathMatrixNullCompare(smat.element(i+1, i+1))) {
if (ok != 0) *ok = false;
return *this;
}
}
}
if (ok != 0) *ok = true;
_V2D::mat.swap(smat.mat);
return *this;
}
_CMatrix & invert(bool * ok = 0, _CMCol * sv = 0) {
if (!isSquare()) {
if (ok != 0) *ok = false;
return *this;
}
_CMatrix mtmp = _CMatrix::identity(_V2D::cols_, _V2D::rows_), smat(*this);
bool ndet;
uint crow;
Type mul, iddiv;
for (uint i = 0; i < _V2D::cols_; ++i) {
ndet = true;
for (uint j = 0; j < _V2D::rows_; ++j) if (smat.element(i, j) != Type(0)) ndet = false;
if (ndet) {
if (ok != 0) *ok = false;
return *this;
}
}
for (uint i = 0; i < _V2D::cols_; ++i) {
crow = i;
while (smat.element(i, i) == Type(0)) {
++crow;
smat.swapRows(i, crow);
mtmp.swapRows(i, crow);
if (sv != 0) sv->swap(i, crow);
}
for (uint j = i + 1; j < _V2D::rows_; ++j) {
mul = smat.element(i, j) / smat.element(i, i);
for (uint k = i; k < _V2D::cols_; ++k) smat.element(k, j) -= mul * smat.element(k, i);
for (uint k = 0; k < _V2D::cols_; ++k) mtmp.element(k, j) -= mul * mtmp.element(k, i);
if (sv != 0) (*sv)[j] -= mul * (*sv)[i];
}
if (i < _V2D::cols_ - 1) {
if (_PIMathMatrixNullCompare(smat.element(i+1, i+1))) {
if (ok != 0) *ok = false;
return *this;
}
}
iddiv = smat.element(i, i);
for (uint j = i; j < _V2D::cols_; ++j) smat.element(j, i) /= iddiv;
for (uint j = 0; j < _V2D::cols_; ++j) mtmp.element(j, i) /= iddiv;
if (sv != 0) (*sv)[i] /= iddiv;
}
for (uint i = _V2D::cols_ - 1; i > 0; --i) {
for (uint j = 0; j < i; ++j) {
mul = smat.element(i, j);
smat.element(i, j) -= mul;
for (uint k = 0; k < _V2D::cols_; ++k) mtmp.element(k, j) -= mul * mtmp.element(k, i);
if (sv != 0) (*sv)[j] -= mul * (*sv)[i];
}
}
if (ok != 0) *ok = true;
PIVector2D<Type>::swap(mtmp);
return *this;
}
_CMatrix inverted(bool * ok = 0) const {_CMatrix tm(*this); tm.invert(ok); return tm;}
_CMatrix transposed() const {_CMatrix tm(_V2D::rows_, _V2D::cols_); PIMM_FOR(c, r) tm.element(c, r) = _V2D::element(r, c); return tm;}
};
#ifdef PIP_STD_IOSTREAM
template<typename Type>
inline std::ostream & operator <<(std::ostream & s, const PIMathMatrix<Type> & m) {s << "{"; for (uint r = 0; r < m.rows(); ++r) { for (uint c = 0; c < m.cols(); ++c) { s << m.element(r, c); if (c < m.cols() - 1 || r < m.rows() - 1) s << ", ";} if (r < m.rows() - 1) s << std::endl << " ";} s << "}"; return s;}
#endif
template<typename Type>
inline PICout operator <<(PICout s, const PIMathMatrix<Type> & m) {s << "Matrix{"; for (uint r = 0; r < m.rows(); ++r) { for (uint c = 0; c < m.cols(); ++c) { s << m.element(r, c); if (c < m.cols() - 1 || r < m.rows() - 1) s << ", ";} if (r < m.rows() - 1) s << PICoutManipulators::NewLine << " ";} s << "}"; return s;}
template<typename Type>
inline PIByteArray & operator <<(PIByteArray & s, const PIMathMatrix<Type> & v) {s << (const PIVector2D<Type> &)v; return s;}
template<typename Type>
inline PIByteArray & operator >>(PIByteArray & s, PIMathMatrix<Type> & v) {s >> (PIVector2D<Type> &)v; return s;}
/// Multiply matrices {CR x Rows0} on {Cols1 x CR}, result is {Cols1 x Rows0}
template<typename Type>
inline PIMathMatrix<Type> operator *(const PIMathMatrix<Type> & fm,
const PIMathMatrix<Type> & sm) {
uint cr = fm.cols(), rows0 = fm.rows(), cols1 = sm.cols();
PIMathMatrix<Type> tm(cols1, rows0);
if (fm.cols() != sm.rows()) return tm;
Type t;
for (uint j = 0; j < rows0; ++j) {
for (uint i = 0; i < cols1; ++i) {
t = Type(0);
for (uint k = 0; k < cr; ++k)
t += fm.element(j, k) * sm.element(k, i);
tm.element(j, i) = t;
}
}
return tm;
}
/// Multiply matrix {Cols x Rows} on vector {Cols}, result is vector {Rows}
template<typename Type>
inline PIMathVector<Type> operator *(const PIMathMatrix<Type> & fm,
const PIMathVector<Type> & sv) {
uint c = fm.cols(), r = fm.rows();
PIMathVector<Type> tv(r);
if (c != sv.size()) return tv;
Type t;
for (uint j = 0; j < r; ++j) {
t = Type(0);
for (uint i = 0; i < c; ++i)
t += fm.element(j, i) * sv[i];
tv[j] = t;
}
return tv;
}
/// Multiply vector {Rows} on matrix {Rows x Cols}, result is vector {Cols}
template<typename Type>
inline PIMathVector<Type> operator *(const PIMathVector<Type> & sv,
const PIMathMatrix<Type> & fm) {
uint c = fm.cols(), r = fm.rows();
PIMathVector<Type> tv(c);
Type t;
for (uint j = 0; j < c; ++j) {
t = Type(0);
for (uint i = 0; i < r; ++i)
t += fm.element(i, j) * sv[i];
tv[j] = t;
}
return tv;
}
/// Multiply value(T) on matrix {Rows x Cols}, result is vector {Rows}
template<typename Type>
inline PIMathMatrix<Type> operator *(const Type & x, const PIMathMatrix<Type> & v) {
return v * x;
}
typedef PIMathMatrix<int> PIMathMatrixi;
typedef PIMathMatrix<double> PIMathMatrixd;
template<typename T>
PIMathMatrix<complex<T> > hermitian(const PIMathMatrix<complex<T> > & m) {
PIMathMatrix<complex<T> > ret(m);
for (uint r = 0; r < ret.rows(); ++r) for (uint c = 0; c < ret.cols(); ++c) ret.element(r, c).imag(-(ret.element(r, c).imag()));
return ret.transposed();
}
#undef PIMM_FOR
#undef PIMM_FOR_I
#undef PIMM_FOR_A
#undef PIMM_FOR_C
#undef PIMM_FOR_R
#endif // PIMATHMATRIX_H

View File

@@ -1,252 +0,0 @@
/*! \file pimathvector.h
* \brief PIMathVector
*/
/*
PIP - Platform Independent Primitives
PIMathVector
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIMATHVECTOR_H
#define PIMATHVECTOR_H
#include "pimathbase.h"
template<uint Cols, uint Rows, typename Type>
class PIMathMatrixT;
/// Vector templated
#define PIMV_FOR(v, s) for (uint v = s; v < Size; ++v)
template<uint Size, typename Type = double>
class PIP_EXPORT PIMathVectorT {
typedef PIMathVectorT<Size, Type> _CVector;
public:
PIMathVectorT() {resize();}
PIMathVectorT(const PIVector<Type> & val) {resize(); PIMV_FOR(i, 0) c[i] = val[i];}
PIMathVectorT(const _CVector & st, const _CVector & fn) {resize(); set(st, fn);}
uint size() const {return Size;}
_CVector & fill(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}
_CVector & set(const _CVector & st, const _CVector & fn) {PIMV_FOR(i, 0) c[i] = fn[i] - st[i]; return *this;}
_CVector & move(const Type & v) {PIMV_FOR(i, 0) c[i] += v; return *this;}
_CVector & move(const _CVector & v) {PIMV_FOR(i, 0) c[i] += v[i]; return *this;}
Type lengthSqr() const {Type tv(0); PIMV_FOR(i, 0) tv += (c[i] * c[i]); return tv;}
Type length() const {return sqrt(lengthSqr());}
Type manhattanLength() const {Type tv(0); PIMV_FOR(i, 0) tv += fabs(c[i]); return tv;}
Type angleCos(const _CVector & v) const {Type tv = v.length() * length(); return (tv == Type(0) ? Type(0) : ((*this) ^ v) / tv);}
Type angleSin(const _CVector & v) const {Type tv = angleCos(v); return sqrt(Type(1) - tv * tv);}
Type angleRad(const _CVector & v) const {return acos(angleCos(v));}
Type angleDeg(const _CVector & v) const {return toDeg(acos(angleCos(v)));}
Type angleElevation(const _CVector & v) const {_CVector z = v - *this; double c = z.angleCos(*this); return 90.0 - acos(c) * rad2deg;}
_CVector projection(const _CVector & v) {Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));}
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
_CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;}
_CVector cross(const _CVector & v) {return (*this) * v;}
Type dot(const _CVector & v) const {return (*this) ^ v;}
bool isNull() const {PIMV_FOR(i, 0) if (c[i] != Type(0)) return false; return true;}
bool isOrtho(const _CVector & v) const {return ((*this) ^ v) == Type(0);}
Type & at(uint index) {return c[index];}
Type at(uint index) const {return c[index];}
Type & operator [](uint index) {return c[index];}
Type operator [](uint index) const {return c[index];}
_CVector & operator =(const _CVector & v) {memcpy(c, v.c, sizeof(Type) * Size); return *this;}
_CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}
bool operator ==(const _CVector & v) const {PIMV_FOR(i, 0) if (c[i] != v[i]) return false; return true;}
bool operator !=(const _CVector & v) const {return !(*this == c);}
void operator +=(const _CVector & v) {PIMV_FOR(i, 0) c[i] += v[i];}
void operator -=(const _CVector & v) {PIMV_FOR(i, 0) c[i] -= v[i];}
void operator *=(const Type & v) {PIMV_FOR(i, 0) c[i] *= v;}
void operator *=(const _CVector & v) {PIMV_FOR(i, 0) c[i] *= v[i];}
void operator /=(const Type & v) {PIMV_FOR(i, 0) c[i] /= v;}
void operator /=(const _CVector & v) {PIMV_FOR(i, 0) c[i] /= v[i];}
_CVector operator -() const {_CVector tv; PIMV_FOR(i, 0) tv[i] = -c[i]; return tv;}
_CVector operator +(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] += v[i]; return tv;}
_CVector operator -(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] -= v[i]; return tv;}
_CVector operator *(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v; return tv;}
_CVector operator /(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] /= v; return tv;}
_CVector operator /(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] /= v[i]; return tv;}
_CVector operator *(const _CVector & v) const {if (Size != 3) return _CVector(); _CVector tv; tv.fill(Type(1)); tv[0] = c[1]*v[2] - v[1]*c[2]; tv[1] = v[0]*c[2] - c[0]*v[2]; tv[2] = c[0]*v[1] - v[0]*c[1]; return tv;}
_CVector operator &(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v[i]; return tv;}
Type operator ^(const _CVector & v) const {Type tv(0); PIMV_FOR(i, 0) tv += c[i] * v[i]; return tv;}
PIMathMatrixT<1, Size, Type> transposed() const {
PIMathMatrixT<1, Size, Type> ret;
PIMV_FOR(i, 0) ret[0][i] = c[i];
return ret;
}
Type distToLine(const _CVector & lp0, const _CVector & lp1) {
_CVector a(lp0, lp1), b(lp0, *this), c(lp1, *this);
Type f = fabs(a[0]*b[1] - a[1]*b[0]) / a.length();
return f;}
template<uint Size1, typename Type1> /// vector {Size, Type} to vector {Size1, Type1}
PIMathVectorT<Size1, Type1> turnTo() const {PIMathVectorT<Size1, Type1> tv; uint sz = piMin<uint>(Size, Size1); for (uint i = 0; i < sz; ++i) tv[i] = c[i]; return tv;}
static _CVector filled(const Type & v) {_CVector vv; PIMV_FOR(i, 0) vv[i] = v; return vv;}
private:
void resize(const Type & new_value = Type()) {for (uint i = 0; i < Size; ++i) c[i] = new_value;}
Type c[Size];
};
template<uint Size, typename Type>
inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<Size, Type> & v) {
return v * x;
}
template<uint Size, typename Type>
inline PICout operator <<(PICout s, const PIMathVectorT<Size, Type> & v) {s << "{"; PIMV_FOR(i, 0) {s << v[i]; if (i < Size - 1) s << ", ";} s << "}"; return s;}
template<uint Size, typename Type>
inline bool operator ||(const PIMathVectorT<Size, Type> & f, const PIMathVectorT<Size, Type> & s) {return (f * s).isNull();}
template<uint Size, typename Type>
inline PIMathVectorT<Size, Type> sqrt(const PIMathVectorT<Size, Type> & v) {PIMathVectorT<Size, Type> ret; PIMV_FOR(i, 0) {ret[i] = sqrt(v[i]);} return ret;}
template<uint Size, typename Type>
inline PIMathVectorT<Size, Type> sqr(const PIMathVectorT<Size, Type> & v) {PIMathVectorT<Size, Type> ret; PIMV_FOR(i, 0) {ret[i] = sqr(v[i]);} return ret;}
template<uint Size, typename Type>
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVectorT<Size, Type> & v) {for (uint i = 0; i < Size; ++i) s << v[i]; return s;}
template<uint Size, typename Type>
inline PIByteArray & operator >>(PIByteArray & s, PIMathVectorT<Size, Type> & v) {for (uint i = 0; i < Size; ++i) s >> v[i]; return s;}
template<typename T>
inline PIMathVectorT<2u, T> createVectorT2(T x, T y) {return PIMathVectorT<2u, T>(PIVector<T>() << x << y);}
template<typename T>
inline PIMathVectorT<3u, T> createVectorT3(T x, T y, T z) {return PIMathVectorT<3u, T>(PIVector<T>() << x << y << z);}
template<typename T>
inline PIMathVectorT<4u, T> createVectorT4(T x, T y, T z, T w) {return PIMathVectorT<4u, T>(PIVector<T>() << x << y << z << w);}
typedef PIMathVectorT<2u, int> PIMathVectorT2i;
typedef PIMathVectorT<3u, int> PIMathVectorT3i;
typedef PIMathVectorT<4u, int> PIMathVectorT4i;
typedef PIMathVectorT<2u, double> PIMathVectorT2d;
typedef PIMathVectorT<3u, double> PIMathVectorT3d;
typedef PIMathVectorT<4u, double> PIMathVectorT4d;
#define createVectorT2i createVectorT2<int>
#define createVectorT3i createVectorT3<int>
#define createVectorT4i createVectorT4<int>
#define createVectorT2f createVectorT2<float>
#define createVectorT3f createVectorT3<float>
#define createVectorT4f createVectorT4<float>
#define createVectorT2d createVectorT2<double>
#define createVectorT3d createVectorT3<double>
#define createVectorT4d createVectorT4<double>
#undef PIMV_FOR
/// Vector
#define PIMV_FOR(v, s) for (uint v = s; v < c.size(); ++v)
template<typename Type>
class PIP_EXPORT PIMathVector {
typedef PIMathVector<Type> _CVector;
template<typename TypeOp> friend PIByteArray & operator <<(PIByteArray & s, const PIMathVector<TypeOp> & v);
template<typename TypeOp> friend PIByteArray & operator >>(PIByteArray & s, PIMathVector<TypeOp> & v);
public:
PIMathVector(const uint size = 0) {c.resize(size);}
PIMathVector(const PIVector<Type> & val) {c.resize(val.size()); PIMV_FOR(i, 0) c[i] = val[i];}
PIMathVector(const _CVector & st, const _CVector & fn) {c.resize(st.size()); PIMV_FOR(i, 0) c[i] = fn[i] - st[i];}
uint size() const {return c.size();}
_CVector & resize(uint size, const Type & new_value = Type()) {c.resize(size, new_value); return *this;}
_CVector resized(uint size, const Type & new_value = Type()) {_CVector tv = _CVector(*this); tv.resize(size, new_value); return tv;}
_CVector & fill(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}
_CVector & move(const Type & v) {PIMV_FOR(i, 0) c[i] += v; return *this;}
_CVector & move(const _CVector & v) {PIMV_FOR(i, 0) c[i] += v[i]; return *this;}
_CVector & swap(uint fe, uint se) {piSwap<Type>(c[fe], c[se]); return *this;}
Type lengthSqr() const {Type tv(0); PIMV_FOR(i, 0) tv += (c[i] * c[i]); return tv;}
Type length() const {return sqrt(lengthSqr());}
Type manhattanLength() const {Type tv(0); PIMV_FOR(i, 0) tv += fabs(c[i]); return tv;}
Type angleCos(const _CVector & v) const {Type tv = v.length() * length(); return (tv == Type(0) ? Type(0) : ((*this) ^ v) / tv);}
Type angleSin(const _CVector & v) const {Type tv = angleCos(v); return sqrt(Type(1) - tv * tv);}
Type angleRad(const _CVector & v) const {return acos(angleCos(v));}
Type angleDeg(const _CVector & v) const {return toDeg(acos(angleCos(v)));}
_CVector projection(const _CVector & v) {Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));}
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
_CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;}
bool isNull() const {PIMV_FOR(i, 0) if (c[i] != Type(0)) return false; return true;}
bool isValid() const {return !c.isEmpty();}
bool isOrtho(const _CVector & v) const {return ((*this) ^ v) == Type(0);}
Type & at(uint index) {return c[index];}
Type at(uint index) const {return c[index];}
Type & operator [](uint index) {return c[index];}
Type operator [](uint index) const {return c[index];}
_CVector & operator =(const _CVector & v) {c = v.c; return *this;}
_CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}
bool operator ==(const _CVector & v) const {PIMV_FOR(i, 0) if (c[i] != v[i]) return false; return true;}
bool operator !=(const _CVector & v) const {return !(*this == c);}
void operator +=(const _CVector & v) {PIMV_FOR(i, 0) c[i] += v[i];}
void operator -=(const _CVector & v) {PIMV_FOR(i, 0) c[i] -= v[i];}
void operator *=(const Type & v) {PIMV_FOR(i, 0) c[i] *= v;}
void operator *=(const _CVector & v) {PIMV_FOR(i, 0) c[i] *= v[i];}
void operator /=(const Type & v) {PIMV_FOR(i, 0) c[i] /= v;}
void operator /=(const _CVector & v) {PIMV_FOR(i, 0) c[i] /= v[i];}
_CVector operator -() const {_CVector tv; PIMV_FOR(i, 0) tv[i] = -c[i]; return tv;}
_CVector operator +(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] += v[i]; return tv;}
_CVector operator -(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] -= v[i]; return tv;}
_CVector operator *(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v; return tv;}
_CVector operator /(const Type & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] /= v; return tv;}
_CVector operator *(const _CVector & v) const {if (c.size() < 3) return _CVector(); _CVector tv; tv.fill(Type(1)); tv[0] = c[1]*v[2] - v[1]*c[2]; tv[1] = v[0]*c[2] - c[0]*v[2]; tv[2] = c[0]*v[1] - v[0]*c[1]; return tv;}
_CVector operator &(const _CVector & v) const {_CVector tv = _CVector(*this); PIMV_FOR(i, 0) tv[i] *= v[i]; return tv;}
Type operator ^(const _CVector & v) const {Type tv(0); PIMV_FOR(i, 0) tv += c[i] * v[i]; return tv;}
Type distToLine(const _CVector & lp0, const _CVector & lp1) {
_CVector a(lp0, lp1), b(lp0, *this), c(lp1, *this);
Type f = fabs(a[0]*b[1] - a[1]*b[0]) / a.length();
return f;
}
template<typename Type1>
PIMathVector turnTo(uint size) const {PIMathVector<Type1> tv; uint sz = piMin<uint>(c.size(), size); for (uint i = 0; i < sz; ++i) tv[i] = c[i]; return tv;}
PIVector<Type> toVector() const {return c;}
inline Type * data() {return c.data();}
inline const Type * data() const {return c.data();}
private:
PIVector<Type> c;
};
#undef PIMV_FOR
#ifdef PIP_STD_IOSTREAM
template<typename Type>
inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v) {s << "{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
#endif
template<typename Type>
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << "Vector{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
template<typename Type>
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVector<Type> & v) {s << v.c; return s;}
template<typename Type>
inline PIByteArray & operator >>(PIByteArray & s, PIMathVector<Type> & v) {s >> v.c; return s;}
typedef PIMathVector<int> PIMathVectori;
typedef PIMathVector<double> PIMathVectord;
#endif // PIMATHVECTOR_H

View File

@@ -1,200 +0,0 @@
/*
PIP - Platform Independent Primitives
Stephan Fomenko
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIEXECUTOR_H
#define PIEXECUTOR_H
#include "piblockingdequeue.h"
#include <atomic>
#include <future>
/**
* @brief Wrapper for custom invoke operator available function types.
* @note Source from: "Энтони Уильямс, Параллельное программирование на С++ в действии. Практика разработки многопоточных
* программ. Пер. с англ. Слинкин А. А. - M.: ДМК Пресс, 2012 - 672c.: ил." (page 387)
*/
class FunctionWrapper {
struct ImplBase {
virtual void call() = 0;
virtual ~ImplBase() = default;
};
std::unique_ptr<ImplBase> impl;
template<typename F>
struct ImplType: ImplBase {
F f;
explicit ImplType(F&& f): f(std::forward<F>(f)) {}
void call() final { f(); }
};
public:
template<typename F, typename = std::enable_if<!std::is_same<F, FunctionWrapper>::value> >
explicit FunctionWrapper(F&& f): impl(new ImplType<F>(std::forward<F>(f))) {}
void operator()() { impl->call(); }
explicit operator bool() const noexcept { return static_cast<bool>(impl); }
FunctionWrapper() = default;
FunctionWrapper(FunctionWrapper&& other) noexcept : impl(std::move(other.impl)) {}
FunctionWrapper& operator=(FunctionWrapper&& other) noexcept {
impl = std::move(other.impl);
return *this;
}
FunctionWrapper(const FunctionWrapper& other) = delete;
FunctionWrapper& operator=(const FunctionWrapper&) = delete;
};
template <typename Thread_ = PIThread, typename Dequeue_ = PIBlockingDequeue<FunctionWrapper>>
class PIThreadPoolExecutorTemplate {
public:
NO_COPY_CLASS(PIThreadPoolExecutorTemplate)
explicit PIThreadPoolExecutorTemplate(size_t corePoolSize = 1) : isShutdown_(false) { makePool(corePoolSize); }
virtual ~PIThreadPoolExecutorTemplate() {
shutdownNow();
while (threadPool.size() > 0) delete threadPool.take_back();
}
template<typename FunctionType>
std::future<typename std::result_of<FunctionType()>::type> submit(FunctionType&& callable) {
typedef typename std::result_of<FunctionType()>::type ResultType;
if (!isShutdown_) {
std::packaged_task<ResultType()> callable_task(std::forward<FunctionType>(callable));
auto future = callable_task.get_future();
FunctionWrapper functionWrapper(callable_task);
taskQueue.offer(std::move(functionWrapper));
return future;
} else {
return std::future<ResultType>();
}
}
template<typename FunctionType>
void execute(FunctionType&& runnable) {
if (!isShutdown_) {
FunctionWrapper function_wrapper(std::forward<FunctionType>(runnable));
taskQueue.offer(std::move(function_wrapper));
}
}
void shutdown() {
isShutdown_ = true;
}
void shutdownNow() {
isShutdown_ = true;
for (size_t i = 0; i < threadPool.size(); ++i) threadPool[i]->stop();
}
bool isShutdown() const {
return isShutdown_;
}
bool awaitTermination(int timeoutMs) {
PITimeMeasurer measurer;
for (size_t i = 0; i < threadPool.size(); ++i) {
int dif = timeoutMs - (int)measurer.elapsed_m();
if (dif < 0) return false;
if (!threadPool[i]->waitForFinish(dif)) return false;
}
return true;
}
protected:
std::atomic_bool isShutdown_;
Dequeue_ taskQueue;
PIVector<Thread_*> threadPool;
template<typename Function>
PIThreadPoolExecutorTemplate(size_t corePoolSize, Function&& onBeforeStart) : isShutdown_(false) {
makePool(corePoolSize, std::forward<Function>(onBeforeStart));
}
void makePool(size_t corePoolSize, std::function<void(Thread_*)>&& onBeforeStart = [](Thread_*){}) {
for (size_t i = 0; i < corePoolSize; ++i) {
auto* thread = new Thread_([&, i](){
auto runnable = taskQueue.poll(100);
if (runnable) {
runnable();
}
if (isShutdown_ && taskQueue.size() == 0) threadPool[i]->stop();
});
threadPool.push_back(thread);
onBeforeStart(thread);
thread->start();
}
}
};
typedef PIThreadPoolExecutorTemplate<> PIThreadPoolExecutor;
#ifdef DOXYGEN
/**
* @brief Thread pools address two different problems: they usually provide improved performance when executing large
* numbers of asynchronous tasks, due to reduced per-task invocation overhead, and they provide a means of bounding and
* managing the resources, including threads, consumed when executing a collection of tasks.
*/
class PIThreadPoolExecutor {
public:
explicit PIThreadPoolExecutor(size_t corePoolSize);
virtual ~PIThreadPoolExecutor();
/**
* @brief Submits a Runnable task for execution and returns a Future representing that task. The Future's get method
* will return null upon successful completion.
*
* @tparam FunctionType - custom type of function with operator() and return type
* @tparam R - derived from FunctionType return type
*
* @param callable - the task to submit
* @return a future representing pending completion of the task
*/
std::future<R> submit(FunctionType&& callable);
/**
* @brief Executes the given task sometime in the future. The task execute in an existing pooled thread. If the task
* cannot be submitted for execution, either because this executor has been shutdown or because its capacity has been
* reached.
*
* @tparam FunctionType - custom type of function with operator() and return type
*
* @param runnable not empty function for thread pool execution
*/
void execute(FunctionType&& runnable);
/**
* @brief Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be
* accepted. Invocation has no additional effect if already shut down. This method does not wait for previously
* submitted tasks to complete execution. Use awaitTermination to do that.
*/
void shutdown();
void shutdownNow();
bool isShutdown() const;
bool awaitTermination(int timeoutMs);
};
#endif //DOXYGEN
#endif //PIEXECUTOR_H

View File

@@ -17,24 +17,33 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "piccloudclient.h"
#include "picloudclient.h"
PICloudClient::PICloudClient() {
PICloudClient::PICloudClient(const PIString & path, PIIODevice::DeviceMode mode) : PIIODevice(path, mode), eth(PIEthernet::TCP_Client) {
}
PICloudClient::~PICloudClient() {
stop();
close();
}
bool PICloudClient::openDevice() {
return false;
}
bool PICloudClient::closeDevice() {
return false;
}
int PICloudClient::readDevice(void * read_to, int max_size) {
return eth.read(read_to, max_size);
}
int PICloudClient::writeDevice(const void * data, int max_size) {
return eth.write(data, max_size);
}

View File

@@ -0,0 +1,81 @@
/*
PIP - Platform Independent Primitives
PICloud Server
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "picloudserver.h"
PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode) : PIIODevice(path, mode), eth(PIEthernet::TCP_Client) {
}
PICloudServer::~PICloudServer() {
stop();
close();
}
bool PICloudServer::openDevice() {
piCout << "PICloudServer open device" << path();
bool op = eth.connect(path(), false);
if (op) {
CONNECTL(&eth, disconnected, [this](bool){opened_ = false;});
CONNECTU(&eth, threadedReadEvent, this, readed);
eth.startThreadedRead();
sendStart();
return true;
}
eth.close();
return false;
}
bool PICloudServer::closeDevice() {
return eth.close();
}
int PICloudServer::readDevice(void * read_to, int max_size) {
return -1;
}
int PICloudServer::writeDevice(const void * data, int max_size) {
return -1;
}
void PICloudServer::sendStart() {
}
PICloudServer::Client::Client(PICloudServer * srv) : server(srv) {
}
bool PICloudServer::Client::openDevice() {
return server;
}
void PICloudServer::readed(uchar *data, int size) {
}

View File

@@ -17,12 +17,26 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "piccloudtcp.h"
#include "picloudtcp.h"
#include "picrypt.h"
#include "pichunkstream.h"
const char hash_def_key[] = "_picrypt_";
PICloudTCP::PICloudTCP() {
PIByteArray & operator <<(PIByteArray & s, const PICloud::Header & v) {
s << v.version << v.type << v.sname;
return s;
}
PIByteArray & operator >>(PIByteArray & s, PICloud::Header & v) {
s >> v.version >> v.type >> v.sname;
return s;
}
PICloud::TCP::TCP() {
}

View File

@@ -20,7 +20,7 @@
#include "picompress.h"
#ifdef PIP_COMPRESS
# ifdef FREERTOS
# include "rom/miniz.h"
# include "esp32/rom/miniz.h"
# define compress2 mz_compress2
# define Z_OK MZ_OK
# define uncompress mz_uncompress

View File

@@ -409,6 +409,8 @@ bool PICrypt::init() {
if (inited) return true;
//piCout << "[PICrypt]" << "init ...";
inited = sodium_init();
if (!inited)
inited = sodium_init();
//piCout << "[PICrypt]" << "init" << inited;
return inited;
#else

View File

@@ -1,4 +1,4 @@
/*! \file piccloudclient.h
/*! \file picloudclient.h
* \brief PICloud Client
*/
/*
@@ -20,13 +20,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PICCLOUDCLIENT_H
#define PICCLOUDCLIENT_H
#ifndef PICLOUDCLIENT_H
#define PICLOUDCLIENT_H
#include "pip_cloud_export.h"
#include "piiodevice.h"
class PIEthernet;
#include "piethernet.h"
class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice
@@ -34,7 +32,7 @@ class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice
PIIODEVICE(PICloudClient)
public:
//!
explicit PICloudClient();
explicit PICloudClient(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
virtual ~PICloudClient();
protected:
@@ -42,7 +40,10 @@ protected:
bool closeDevice();
private:
PIEthernet * eth;
int readDevice(void * read_to, int max_size);
int writeDevice(const void * data, int max_size);
PIEthernet eth;
};
#endif // PICCLOUDCLIENT_H
#endif // PICLOUDCLIENT_H

View File

@@ -20,8 +20,8 @@
#ifndef PICLOUDMODULE_H
#define PICLOUDMODULE_H
#include "piccloudtcp.h"
#include "piccloudclient.h"
#include "piccloudserver.h"
#include "picloudtcp.h"
#include "picloudclient.h"
#include "picloudserver.h"
#endif // PICLOUDMODULE_H

View File

@@ -0,0 +1,65 @@
/*! \file picloudserver.h
* \brief PICloud Server
*/
/*
PIP - Platform Independent Primitives
PICloud Server
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PICLOUDSERVER_H
#define PICLOUDSERVER_H
#include "pip_cloud_export.h"
#include "piethernet.h"
class PIP_CLOUD_EXPORT PICloudServer : public PIIODevice
{
PIIODEVICE(PICloudServer)
public:
//!
explicit PICloudServer(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
virtual ~PICloudServer();
class Client : public PIIODevice {
PIIODEVICE(PICloudServer::Client)
public:
Client(PICloudServer * srv = nullptr);
protected:
bool openDevice();
private:
PICloudServer * server;
};
EVENT1(newConnection, PICloudServer::Client * , client)
protected:
bool openDevice();
bool closeDevice();
int readDevice(void * read_to, int max_size);
int writeDevice(const void * data, int max_size);
private:
EVENT_HANDLER2(void, readed, uchar * , data, int, size);
void sendStart();
PIEthernet eth;
PIVector<Client> clients;
};
#endif // PICLOUDSERVER_H

View File

@@ -1,4 +1,4 @@
/*! \file piccloudtcp.h
/*! \file picloudtcp.h
* \brief PICloud TCP transport
*/
/*
@@ -20,20 +20,45 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PICCLOUDTCP_H
#define PICCLOUDTCP_H
#ifndef PICLOUDTCP_H
#define PICLOUDTCP_H
#include "pip_cloud_export.h"
#include "pistring.h"
class PIP_CLOUD_EXPORT PICloudTCP {
public:
//!
PICloudTCP();
namespace PICloud {
enum Version {
Version_1 = 1,
};
enum HeaderType {
Server = 1,
Client = 2,
};
struct PIP_CLOUD_EXPORT Header {
Header() {
version = Version_1;
}
uchar version; // PICloud::Version
uchar type; // PICloud::HeaderType
PIString sname; // server name
};
class PIP_CLOUD_EXPORT TCP {
public:
TCP();
private:
};
#endif // PICCLOUDTCP_H
}
PIP_CLOUD_EXPORT PIByteArray & operator <<(PIByteArray & s, const PICloud::Header & v);
PIP_CLOUD_EXPORT PIByteArray & operator >>(PIByteArray & s, PICloud::Header & v);
#endif // PICLOUDTCP_H

View File

@@ -174,6 +174,13 @@ inline const char * getMemberType(const char * class_name, const char * member_n
PIP_EXPORT PIVariant getMemberAsVariant(const void * p, const char * class_name, const char * member_name);
template<typename T, typename std::enable_if< std::is_assignable<T&, const T&>::value, int>::type = 0>
void serialize(PIByteArray & ret, const T & v) {ret << v;}
template<typename T, typename std::enable_if<!std::is_assignable<T&, const T&>::value, int>::type = 0>
void serialize(PIByteArray & ret, const T & v) {}
}
class PIP_EXPORT __PICodeInfoInitializer__ {

View File

@@ -252,5 +252,8 @@ inline PIByteArray & operator >>(PIByteArray & s, PIKbdListener::KeyEvent & v) {
inline PIByteArray & operator >>(PIByteArray & s, PIKbdListener::MouseEvent & v) {int a(0); s >> v.x >> v.y >> a >> v.buttons >> v.modifiers; v.action = (PIKbdListener::MouseAction)a; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PIKbdListener::WheelEvent & v) {uchar d(0); s >> (*(PIKbdListener::MouseEvent*)&v) >> d; v.direction = d; return s;}
REGISTER_PIVARIANTSIMPLE(PIKbdListener::KeyEvent)
REGISTER_PIVARIANTSIMPLE(PIKbdListener::MouseEvent)
REGISTER_PIVARIANTSIMPLE(PIKbdListener::WheelEvent)
#endif // PIKBDLISTENER_H

View File

@@ -25,6 +25,7 @@
#include "pip_console_export.h"
#include "pivariant.h"
#include "pivariantsimple.h"
class PIScreenTile;
@@ -140,8 +141,11 @@ namespace PIScreenTypes {
inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::Cell & v) {s << v.format.raw_format << v.symbol; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::Cell & v) {s >> v.format.raw_format >> v.symbol; return s;}
inline PIByteArray & operator <<(PIByteArray & s, const PIScreenTypes::TileEvent & v) {s << v.type << v.data; return s;}
inline PIByteArray & operator >>(PIByteArray & s, PIScreenTypes::TileEvent & v) {s >> v.type >> v.data; return s;}
REGISTER_PIVARIANTSIMPLE(PIScreenTypes::TileEvent)
#endif // PISCREENTYPES_H

View File

@@ -32,6 +32,10 @@
* \brief Contructs vector with size "size" filled elements "value"
* \details Example: \snippet picontainers.cpp PIVector::PIVector
* \fn PIVector::PIVector(std::initializer_list list);
* \brief Contructs vector from C++11 initializer list
* \details Example: \snippet picontainers.cpp PIVector::PIVector
* \fn const T & PIVector::at(size_t index) const;
* \brief Read-only access to element by index "index"
* \details Example: \snippet picontainers.cpp PIVector::at_c
@@ -371,4 +375,7 @@
* \fn bool PIMapIterator::next()
* \brief Jump to next entry and return if new position is valid.
* \fn void PIMapIterator::reset()
* \brief Reset iterator to initial position.
* */

View File

@@ -28,20 +28,13 @@
#include "picout.h"
#include "piintrospection_containers.h"
#ifdef PIP_DEBUG
# ifdef NDEBUG
# undef NDEBUG
# endif
# include <cassert>
#endif
#ifndef assert
# define assert(x)
#endif
#ifdef MAC_OS
# include <stdlib.h>
#else
# include <malloc.h>
#endif
#include <initializer_list>
#include <type_traits>
#include <string.h>
#include <new>
#ifndef PIP_MEMALIGN_BYTES

View File

@@ -39,6 +39,11 @@ public:
alloc(other.pid_size, true);
newT(pid_data + pid_start, other.pid_data + other.pid_start, pid_size);
}
inline PIDeque(std::initializer_list<T> init_list): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(init_list.size(), true);
newT(pid_data, init_list.begin(), init_list.size());
}
inline PIDeque(const T * data, size_t size): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(size, true);
@@ -49,6 +54,7 @@ public:
resize(pid_size, f);
}
inline PIDeque(PIDeque<T> && other): pid_data(other.pid_data), pid_size(other.pid_size), pid_rsize(other.pid_rsize), pid_start(other.pid_start) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
other._reset();
}
inline virtual ~PIDeque() {
@@ -161,7 +167,6 @@ public:
inline bool isEmpty() const {return (pid_size == 0);}
inline T & operator [](size_t index) {return pid_data[pid_start + index];}
inline T & at(size_t index) {return pid_data[pid_start + index];}
inline const T & operator [](size_t index) const {return pid_data[pid_start + index];}
inline const T & at(size_t index) const {return pid_data[pid_start + index];}
inline T & back() {return pid_data[pid_start + pid_size - 1];}
@@ -204,7 +209,22 @@ public:
inline T * data(size_t index = 0) {return &(pid_data[pid_start + index]);}
inline const T * data(size_t index = 0) const {return &(pid_data[pid_start + index]);}
inline PIDeque<T> & clear() {resize(0); return *this;}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & clear() {
resize(0);
return *this;
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & clear() {
PIINTROSPECTION_CONTAINER_UNUSED(T, pid_size)
pid_size = 0;
return *this;
}
inline PIDeque<T> & fill(const T & f = T()) {
deleteT(pid_data + pid_start, pid_size);
PIINTROSPECTION_CONTAINER_USED(T, pid_size)
@@ -213,10 +233,20 @@ public:
return *this;
}
inline PIDeque<T> & assign(const T & f = T()) {return fill(f);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & assign(size_t new_size, const T & f) {
resize(new_size);
return fill(f);
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & assign(size_t new_size, const T & f) {
_resizeRaw(new_size);
return fill(f);
}
inline PIDeque<T> & resize(size_t new_size, const T & f = T()) {
if (new_size < pid_size) {
@@ -231,9 +261,18 @@ public:
}
return *this;
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIDeque<T> & _resizeRaw(size_t new_size) {
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIDEQUE_SIMPLE_TYPE__ macro!";
assert(0);
if (new_size > pid_size) {
PIINTROSPECTION_CONTAINER_USED(T, (new_size-pid_size));
}
if (new_size < pid_size) {
PIINTROSPECTION_CONTAINER_UNUSED(T, (pid_size-new_size));
}
alloc(new_size, true);
return *this;
}
@@ -432,11 +471,24 @@ private:
++t;
return (1 << t);
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void newT(T * dst, const T * src, size_t s) {
PIINTROSPECTION_CONTAINER_USED(T, s)
for (size_t i = 0; i < s; ++i)
elementNew(dst + i, src[i]);
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void newT(T * dst, const T * src, size_t s) {
PIINTROSPECTION_CONTAINER_USED(T, s)
memcpy((void*)(dst), (const void*)(src), s * sizeof(T));
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void deleteT(T * d, size_t sz) {
PIINTROSPECTION_CONTAINER_UNUSED(T, sz)
if ((uchar*)d != 0) {
@@ -444,9 +496,36 @@ private:
elementDelete(d[i]);
}
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void deleteT(T * d, size_t sz) {
PIINTROSPECTION_CONTAINER_UNUSED(T, sz)
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, const T & from) {new(to)T(from);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, T && from) {new(to)T(std::move(from));}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T1 * to, const T & from) {(*to) = from;}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, T && from) {(*to) = std::move(from);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementDelete(T & from) {from.~T();}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementDelete(T & from) {}
inline void dealloc() {
if ((uchar*)pid_data != 0) free((uchar*)pid_data);
pid_data = 0;
@@ -515,41 +594,6 @@ private:
ssize_t pid_start;
};
#define __PIDEQUE_SIMPLE_TYPE__(T) \
template<> inline void PIDeque<T>::newT(T * dst, const T * src, size_t s) {PIINTROSPECTION_CONTAINER_USED(T, s); memcpy((void*)(dst), (const void*)(src), s * sizeof(T));} \
template<> inline void PIDeque<T>::deleteT(T *, size_t sz) {PIINTROSPECTION_CONTAINER_UNUSED(T, sz);} \
template<> inline void PIDeque<T>::elementNew(T * to, const T & from) {(*to) = from;} \
template<> inline void PIDeque<T>::elementNew(T * to, T && from) {(*to) = std::move(from);} \
template<> inline void PIDeque<T>::elementDelete(T &) {;} \
template<> inline PIDeque<T> & PIDeque<T>::_resizeRaw(size_t new_size) { \
if (new_size > pid_size) { \
PIINTROSPECTION_CONTAINER_USED(T, (new_size-pid_size)); \
} \
if (new_size < pid_size) { \
PIINTROSPECTION_CONTAINER_UNUSED(T, (pid_size-new_size)); \
} \
alloc(new_size, true); \
return *this; \
} \
template<> inline PIDeque<T> & PIDeque<T>::clear() {PIINTROSPECTION_CONTAINER_UNUSED(T, pid_size); pid_size = 0; return *this;} \
template<> inline PIDeque<T> & PIDeque<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
__PIDEQUE_SIMPLE_TYPE__(bool)
__PIDEQUE_SIMPLE_TYPE__(char)
__PIDEQUE_SIMPLE_TYPE__(uchar)
__PIDEQUE_SIMPLE_TYPE__(short)
__PIDEQUE_SIMPLE_TYPE__(ushort)
__PIDEQUE_SIMPLE_TYPE__(int)
__PIDEQUE_SIMPLE_TYPE__(uint)
__PIDEQUE_SIMPLE_TYPE__(long)
__PIDEQUE_SIMPLE_TYPE__(ulong)
__PIDEQUE_SIMPLE_TYPE__(llong)
__PIDEQUE_SIMPLE_TYPE__(ullong)
__PIDEQUE_SIMPLE_TYPE__(float)
__PIDEQUE_SIMPLE_TYPE__(double)
__PIDEQUE_SIMPLE_TYPE__(ldouble)
#ifdef PIP_STD_IOSTREAM
template<typename T>

View File

@@ -28,9 +28,6 @@
#include "pivector.h"
#include "pideque.h"
#include "pipair.h"
# define __PICONTAINERS_SIMPLE_TYPE__(T) \
__PIDEQUE_SIMPLE_TYPE__(T)\
__PIVECTOR_SIMPLE_TYPE__(T)
template<class T>
@@ -206,7 +203,6 @@ public:
return pim_content.back();
}
const T operator [](const Key & key) const {bool f(false); ssize_t i = _find(key, f); if (f) return pim_content[pim_index[i].index]; return T();}
T & at(const Key & key) {return (*this)[key];}
const T at(const Key & key) const {return (*this)[key];}
PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) {
@@ -364,6 +360,13 @@ public:
}
return false;
}
inline void reset() {
if (rev) {
pos = m.size_s();
} else {
pos = -1;
}
}
private:
const MapType & m;
ssize_t pos;

View File

@@ -44,11 +44,17 @@ public:
alloc(other.piv_size);
newT(piv_data, other.piv_data, piv_size);
}
inline PIVector(std::initializer_list<T> init_list): piv_data(0), piv_size(0), piv_rsize(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(init_list.size());
newT(piv_data, init_list.begin(), init_list.size());
}
inline PIVector(size_t piv_size, const T & f = T()): piv_data(0), piv_size(0), piv_rsize(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
resize(piv_size, f);
}
inline PIVector(PIVector<T> && other): piv_data(other.piv_data), piv_size(other.piv_size), piv_rsize(other.piv_rsize) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
other._reset();
}
inline virtual ~PIVector() {
@@ -161,7 +167,6 @@ public:
inline bool isEmpty() const {return (piv_size == 0);}
inline T & operator [](size_t index) {return piv_data[index];}
inline T & at(size_t index) {return piv_data[index];}
inline const T & operator [](size_t index) const {return piv_data[index];}
inline const T & at(size_t index) const {return piv_data[index];}
inline T & back() {return piv_data[piv_size - 1];}
@@ -205,7 +210,22 @@ public:
inline T * data(size_t index = 0) {return &(piv_data[index]);}
inline const T * data(size_t index = 0) const {return &(piv_data[index]);}
inline PIVector<T> & clear() {resize(0); return *this;}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & clear() {
resize(0);
return *this;
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & clear() {
PIINTROSPECTION_CONTAINER_UNUSED(T, piv_size)
piv_size = 0;
return *this;
}
inline PIVector<T> & fill(const T & f = T()) {
deleteT(piv_data, piv_size);
PIINTROSPECTION_CONTAINER_USED(T, piv_size)
@@ -214,10 +234,20 @@ public:
return *this;
}
inline PIVector<T> & assign(const T & f = T()) {return fill(f);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & assign(size_t new_size, const T & f) {
resize(new_size);
return fill(f);
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & assign(size_t new_size, const T & f) {
_resizeRaw(new_size);
return fill(f);
}
inline PIVector<T> & resize(size_t new_size, const T & f = T()) {
if (new_size < piv_size) {
@@ -234,9 +264,17 @@ public:
}
return *this;
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector<T> & _resizeRaw(size_t new_size) {
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIVECTOR_SIMPLE_TYPE__ macro!";
assert(0);
if (new_size > piv_size) {
PIINTROSPECTION_CONTAINER_USED(T, (new_size-piv_size));
}
if (new_size < piv_size) {
PIINTROSPECTION_CONTAINER_UNUSED(T, (piv_size-new_size));
}
alloc(new_size);
return *this;
}
inline void _copyRaw(T * dst, const T * src, size_t size) {
@@ -420,11 +458,24 @@ private:
while (s_ >> t) ++t;
return (1 << t);
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void newT(T * dst, const T * src, size_t s) {
PIINTROSPECTION_CONTAINER_USED(T, s)
for (size_t i = 0; i < s; ++i)
elementNew(dst + i, src[i]);
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void newT(T * dst, const T * src, size_t s) {
PIINTROSPECTION_CONTAINER_USED(T, s)
memcpy((void*)(dst), (const void*)(src), s * sizeof(T));
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void deleteT(T * d, size_t sz) {
PIINTROSPECTION_CONTAINER_UNUSED(T, sz)
if ((uchar*)d != 0) {
@@ -432,9 +483,36 @@ private:
elementDelete(d[i]);
}
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void deleteT(T * d, size_t sz) {
PIINTROSPECTION_CONTAINER_UNUSED(T, sz)
}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, const T & from) {new(to)T(from);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, T && from) {new(to)T(std::move(from));}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T1 * to, const T & from) {(*to) = from;}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementNew(T * to, T && from) {(*to) = std::move(from);}
template<typename T1 = T, typename std::enable_if<
!std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementDelete(T & from) {from.~T();}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline void elementDelete(T & from) {}
inline void dealloc() {
if ((uchar*)piv_data != 0) free((uchar*)piv_data);
piv_data = 0;
@@ -459,41 +537,6 @@ private:
};
#define __PIVECTOR_SIMPLE_TYPE__(T) \
template<> inline void PIVector<T>::newT(T * dst, const T * src, size_t s) {PIINTROSPECTION_CONTAINER_USED(T, s); memcpy((void*)(dst), (const void*)(src), s * sizeof(T));} \
template<> inline void PIVector<T>::deleteT(T *, size_t sz) {PIINTROSPECTION_CONTAINER_UNUSED(T, sz);} \
template<> inline void PIVector<T>::elementNew(T * to, const T & from) {(*to) = from;} \
template<> inline void PIVector<T>::elementNew(T * to, T && from) {(*to) = std::move(from);} \
template<> inline void PIVector<T>::elementDelete(T &) {;} \
template<> inline PIVector<T> & PIVector<T>::_resizeRaw(size_t new_size) { \
if (new_size > piv_size) { \
PIINTROSPECTION_CONTAINER_USED(T, (new_size-piv_size)); \
} \
if (new_size < piv_size) { \
PIINTROSPECTION_CONTAINER_UNUSED(T, (piv_size-new_size)); \
} \
alloc(new_size); \
return *this; \
} \
template<> inline PIVector<T> & PIVector<T>::clear() {PIINTROSPECTION_CONTAINER_UNUSED(T, piv_size); piv_size = 0; return *this;} \
template<> inline PIVector<T> & PIVector<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
__PIVECTOR_SIMPLE_TYPE__(bool)
__PIVECTOR_SIMPLE_TYPE__(char)
__PIVECTOR_SIMPLE_TYPE__(uchar)
__PIVECTOR_SIMPLE_TYPE__(short)
__PIVECTOR_SIMPLE_TYPE__(ushort)
__PIVECTOR_SIMPLE_TYPE__(int)
__PIVECTOR_SIMPLE_TYPE__(uint)
__PIVECTOR_SIMPLE_TYPE__(long)
__PIVECTOR_SIMPLE_TYPE__(ulong)
__PIVECTOR_SIMPLE_TYPE__(llong)
__PIVECTOR_SIMPLE_TYPE__(ullong)
__PIVECTOR_SIMPLE_TYPE__(float)
__PIVECTOR_SIMPLE_TYPE__(double)
__PIVECTOR_SIMPLE_TYPE__(ldouble)
#ifdef PIP_STD_IOSTREAM
template<typename T>

View File

@@ -160,6 +160,7 @@ public:
inline T & element(size_t row, size_t col) {return mat[row * cols_ + col];}
inline const T & element(size_t row, size_t col) const {return mat[row * cols_ + col];}
inline const T & at(size_t row, size_t col) const {return mat[row * cols_ + col];}
inline Row operator[](size_t index) {return Row(this, index);}
inline RowConst operator[](size_t index) const {return RowConst(this, index);}
inline T * data(size_t index = 0) {return mat.data(index);}
@@ -218,7 +219,7 @@ public:
int cs = (cols - cols_);
if (cs < 0) {
for (size_t r=0; r<rows; ++r) {
mat.remove(r*cols_ + cols_, -cs);
mat.remove(r*cols + cols, -cs);
}
}
mat.resize(rows*cols, f);
@@ -234,6 +235,13 @@ public:
return *this;
}
inline bool operator ==(const PIVector2D<T> & t) const {
if (cols_ != t.cols_ || rows_ != t.rows_)
return false;
return mat == t.mat;
}
inline bool operator !=(const PIVector2D<T> & t) const {return !(*this == t);}
PIVector<PIVector<T> > toVectors() const {
PIVector<PIVector<T> > ret;
ret.reserve(rows_);
@@ -251,9 +259,13 @@ public:
piSwap<size_t>(cols_, other.cols_);
}
template<typename T1 = T, typename std::enable_if<
std::is_trivially_copyable<T1>::value
, int>::type = 0>
inline PIVector2D<T> & _resizeRaw(size_t r, size_t c) {
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIVECTOR_SIMPLE_TYPE__ macro!";
assert(0);
rows_ = r;
cols_ = c;
mat._resizeRaw(r*c);
return *this;
}
@@ -287,22 +299,5 @@ inline PICout operator <<(PICout s, const PIVector2D<T> & v) {
return s;
}
#define __PIVECTOR2D_SIMPLE_TYPE__(T) \
template<> inline PIVector2D<T> & PIVector2D<T>::_resizeRaw(size_t r, size_t c) {rows_ = r; cols_ = c; mat._resizeRaw(r*c); return *this;}
__PIVECTOR2D_SIMPLE_TYPE__(bool)
__PIVECTOR2D_SIMPLE_TYPE__(char)
__PIVECTOR2D_SIMPLE_TYPE__(uchar)
__PIVECTOR2D_SIMPLE_TYPE__(short)
__PIVECTOR2D_SIMPLE_TYPE__(ushort)
__PIVECTOR2D_SIMPLE_TYPE__(int)
__PIVECTOR2D_SIMPLE_TYPE__(uint)
__PIVECTOR2D_SIMPLE_TYPE__(long)
__PIVECTOR2D_SIMPLE_TYPE__(ulong)
__PIVECTOR2D_SIMPLE_TYPE__(llong)
__PIVECTOR2D_SIMPLE_TYPE__(ullong)
__PIVECTOR2D_SIMPLE_TYPE__(float)
__PIVECTOR2D_SIMPLE_TYPE__(double)
__PIVECTOR2D_SIMPLE_TYPE__(ldouble)
#endif // PIVECTOR2D_H

View File

@@ -26,7 +26,7 @@
#ifndef PIBASE_H
#define PIBASE_H
#include "piversion.h"
#include "pip_version.h"
#include "piplatform.h"
#include "pip_export.h"
#include "pip_defs.h"
@@ -94,6 +94,25 @@
//! Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation
# define PIP_TIMER_RT
//! Macro to declare private section, export is optional
# define PRIVATE_DECLARATION(export)
//! Macro to start definition of private section
# define PRIVATE_DEFINITION_START(Class)
//! Macro to end definition of private section
# define PRIVATE_DEFINITION_END(Class)
//! Macro to access private section by pointer
# define PRIVATE
//! Macro to start static initializer
# define STATIC_INITIALIZER_BEGIN
//! Macro to end static initializer
# define STATIC_INITIALIZER_END
#endif
#include <functional>
@@ -136,6 +155,16 @@
extern char ** environ;
#endif
#ifdef NDEBUG
# undef NDEBUG
#endif
#include <cassert>
#ifndef assert
# define assert(x)
# define assertm(exp, msg)
#else
# define assertm(exp, msg) assert(((void)msg, exp))
#endif
#ifdef CC_GCC
# undef DEPRECATED
@@ -217,10 +246,29 @@
#define PRIVATE (__privateinitializer__.p)
#define PRIVATEWB __privateinitializer__.p
#define NO_COPY_CLASS(name) \
name(const name&) = delete; \
name& operator=(const name&) = delete;
#define _PIP_ADD_COUNTER_WS(a, cnt) a##cnt
#define _PIP_ADD_COUNTER_WF(a, cnt) _PIP_ADD_COUNTER_WS(a, cnt)
#define _PIP_ADD_COUNTER(a) _PIP_ADD_COUNTER_WF(a, __COUNTER__)
#define STATIC_INITIALIZER_BEGIN \
class { \
class _Initializer_ { \
public: \
_Initializer_() {
#define STATIC_INITIALIZER_END \
} \
} _initializer_; \
} _PIP_ADD_COUNTER(_pip_initializer_);
#ifdef FREERTOS
# define PIP_MIN_MSLEEP 10.
#else
@@ -292,13 +340,6 @@ template<> inline void piSwapBinary(const void *& f, const void *& s) {
}
}
template<> inline void piSwap(double & f, double & s) {piSwapBinary<double>(f, s);}
template<> inline void piSwap(ldouble & f, ldouble & s) {piSwapBinary<ldouble>(f, s);}
#ifdef ARCH_BITS_32
template<> inline void piSwap(float & f, float & s) {piSwapBinary<float>(f, s);}
template<> inline void piSwap(llong & f, llong & s) {piSwapBinary<llong>(f, s);}
template<> inline void piSwap(ullong & f, ullong & s) {piSwapBinary<ullong>(f, s);}
#endif
/*! \brief Function for compare two values without "=" by raw content
* \details Example:\n \snippet piincludes.cpp compareBinary */
@@ -317,7 +358,7 @@ inline bool piCompareBinary(const void * f, const void * s, size_t size) {
*
* Example:
* \snippet piincludes.cpp round */
template<typename T> inline int piRound(const T & v) {return int(v >= T(0.) ? v + T(0.5) : v - T(0.5));}
template<typename T> inline constexpr int piRound(const T & v) {return int(v >= T(0.) ? v + T(0.5) : v - T(0.5));}
/*! \brief Templated function return floor of float falue
* \details Floor is the largest integer that is not greater than value \n
@@ -327,7 +368,7 @@ template<typename T> inline int piRound(const T & v) {return int(v >= T(0.) ? v
*
* Example:
* \snippet piincludes.cpp floor */
template<typename T> inline int piFloor(const T & v) {return v < T(0) ? int(v) - 1 : int(v);}
template<typename T> inline constexpr int piFloor(const T & v) {return v < T(0) ? int(v) - 1 : int(v);}
/*! \brief Templated function return ceil of float falue
* \details Ceil is the smallest integer that is not less than value \n
@@ -337,7 +378,7 @@ template<typename T> inline int piFloor(const T & v) {return v < T(0) ? int(v) -
*
* Example:
* \snippet piincludes.cpp ceil */
template<typename T> inline int piCeil(const T & v) {return v < T(0) ? int(v) : int(v) + 1;}
template<typename T> inline constexpr int piCeil(const T & v) {return v < T(0) ? int(v) : int(v) + 1;}
/*! \brief Templated function return absolute of numeric falue
* \details Absolute is the positive or equal 0 value \n
@@ -351,7 +392,7 @@ template<typename T> inline int piCeil(const T & v) {return v < T(0) ? int(v) :
*
* Example:
* \snippet piincludes.cpp abs */
template<typename T> inline T piAbs(const T & v) {return (v >= T(0) ? v : -v);}
template<typename T> inline constexpr T piAbs(const T & v) {return (v >= T(0) ? v : -v);}
/*! \brief Templated function return minimum of two values
* \details There are some macros:
@@ -364,7 +405,7 @@ template<typename T> inline T piAbs(const T & v) {return (v >= T(0) ? v : -v);}
*
* Example:
* \snippet piincludes.cpp min2 */
template<typename T> inline T piMin(const T & f, const T & s) {return ((f > s) ? s : f);}
template<typename T> inline constexpr T piMin(const T & f, const T & s) {return ((f > s) ? s : f);}
/*! \brief Templated function return minimum of tree values
* \details There are some macros:
@@ -377,7 +418,7 @@ template<typename T> inline T piMin(const T & f, const T & s) {return ((f > s) ?
*
* Example:
* \snippet piincludes.cpp min3 */
template<typename T> inline T piMin(const T & f, const T & s, const T & t) {return ((f < s && f < t) ? f : ((s < t) ? s : t));}
template<typename T> inline constexpr T piMin(const T & f, const T & s, const T & t) {return ((f < s && f < t) ? f : ((s < t) ? s : t));}
/*! \brief Templated function return maximum of two values
* \details There are some macros:
@@ -390,7 +431,7 @@ template<typename T> inline T piMin(const T & f, const T & s, const T & t) {retu
*
* Example:
* \snippet piincludes.cpp max2 */
template<typename T> inline T piMax(const T & f, const T & s) {return ((f < s) ? s : f);}
template<typename T> inline constexpr T piMax(const T & f, const T & s) {return ((f < s) ? s : f);}
/*! \brief Templated function return maximum of tree values
* \details There are some macros:
@@ -403,7 +444,7 @@ template<typename T> inline T piMax(const T & f, const T & s) {return ((f < s) ?
*
* Example:
* \snippet piincludes.cpp max3 */
template<typename T> inline T piMax(const T & f, const T & s, const T & t) {return ((f > s && f > t) ? f : ((s > t) ? s : t));}
template<typename T> inline constexpr T piMax(const T & f, const T & s, const T & t) {return ((f > s && f > t) ? f : ((s > t) ? s : t));}
/*! \brief Templated function return clamped value
* \details Clamped is the not greater than "max" and not lesser than "min" value \n
@@ -417,7 +458,7 @@ template<typename T> inline T piMax(const T & f, const T & s, const T & t) {retu
*
* Example:
* \snippet piincludes.cpp clamp */
template<typename T> inline T piClamp(const T & v, const T & min, const T & max) {return (v > max ? max : (v < min ? min : v));}
template<typename T> inline constexpr T piClamp(const T & v, const T & min, const T & max) {return (v > max ? max : (v < min ? min : v));}
/// Function inverse byte order in memory block
inline void piLetobe(void * data, int size) {
@@ -454,20 +495,7 @@ template<> inline float piLetobe(const float & v) {
return a.f;
}
DEPRECATED inline ushort letobe_s(const ushort & v) {return (v << 8) | (v >> 8);}
DEPRECATED inline uint letobe_i(const uint & v) {return (v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);}
#ifdef DOXYGEN
/// \deprecated \brief Use \a piLetobe() instead of this function
ushort letobe_s(ushort v) {return (v << 8) | (v >> 8);}
/// \deprecated \brief Use \a piLetobe() instead of this function
uint letobe_i(uint v) {return (v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);}
#endif
/// \brief Generic hash function, impements murmur3/32 algorithm
/// \brief Generic hash function, implements murmur3/32 algorithm
inline uint piHashData(const uchar * data, uint len, uint seed = 0) {
if (!data || len <= 0) return 0u;
uint h = seed;

View File

@@ -396,8 +396,19 @@ PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) {
}
v.resize(sz);
if (sz > 0) {
memcpy(v.data(), s.data(), v.size());
s.remove(0, v.size());
memcpy(v.data(), s.data(), sz);
s.remove(0, sz);
}
return s;
}
PIByteArray & operator <<(PIByteArray & s, const PIByteArray & v) {
s << int(v.size_s());
int os = s.size_s();
if (v.size_s() > 0) {
s.enlarge(v.size_s());
memcpy(s.data(os), v.data(), v.size());
}
return s;
}

Some files were not shown because too many files have changed in this diff Show More