Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
59ebd0d464 | |||
d9e889cf8a | |||
5594102482 | |||
7da790e3e4 | |||
85423b4823 | |||
37a1dce0b4 | |||
ab070be3f8 | |||
d6cc27ac31 | |||
44cba70919 | |||
9bab81a1ad | |||
b2155ff693 | |||
cad4f762e8 | |||
fd3887af17 | |||
421f338126 | |||
f8f5e6b15f | |||
602bb39ff2 | |||
5d8044756a | |||
69efe4f5b6 | |||
888a70d767 | |||
e103df58cd | |||
b64a3bfcb0 | |||
a2788997fd | |||
6ab7be7799 | |||
afca4fd646 | |||
31e74185c8 | |||
8b97705cb1 | |||
7f9b6b01c5 | |||
bf72807cef | |||
a2209a6a0e | |||
73f02160b5 | |||
ea6e306ee6 | |||
59ad3091d3 | |||
d03c58a66b | |||
6e7619a4e9 | |||
0ff8ca484a | |||
83d77a1ba9 | |||
3b41672f37 | |||
c3c833632b | |||
47ad66bc89 | |||
05cd1f5cd8 |
30
.travis.yml
30
.travis.yml
@@ -1,6 +1,7 @@
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
branches:
|
||||
only:
|
||||
@@ -14,24 +15,24 @@ addons:
|
||||
packages:
|
||||
- g++-4.9
|
||||
- expect
|
||||
#- binutils-mingw-w64-x86-64 # 64bit MinGW
|
||||
#- gcc-mingw-w64-x86-64
|
||||
#- g++-mingw-w64-x86-64
|
||||
- binutils-mingw-w64-x86-64 # 64bit MinGW
|
||||
- gcc-mingw-w64-x86-64
|
||||
- g++-mingw-w64-x86-64
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: CONF=debug BUILDER=gcc TARGET=Linux TAG=Linux COMPILATOR_OPTION="--compilator-version=4.9" GCOV=--gcov
|
||||
env: CONF=release BUILDER=gcc TARGET=Linux TAG=Linux COMPILATOR_OPTION="--compilator-version=4.9" GCOV=--gcov
|
||||
compiler: gcc
|
||||
- os: linux
|
||||
env: CONF=debug BUILDER=clang TARGET=Linux
|
||||
compiler: clang
|
||||
#- os: linux
|
||||
# env: CONF=release BUILDER=gcc TARGET=Windows TAG=Mingw
|
||||
# compiler: x86_64-w64-mingw32-gcc
|
||||
#- os: linux
|
||||
# env: CONF=release BUILDER=gcc TARGET=Android TAG=Android DISABLE_PACKAGE=-p
|
||||
# compiler: gcc
|
||||
- os: linux
|
||||
env: CONF=release BUILDER=gcc TARGET=Windows TAG=Mingw
|
||||
compiler: x86_64-w64-mingw32-gcc
|
||||
- os: linux
|
||||
env: CONF=release BUILDER=gcc TARGET=Android TAG=Android DISABLE_PACKAGE=-p
|
||||
compiler: gcc
|
||||
- os: osx
|
||||
env: CONF=release BUILDER=clang TARGET=MacOs TAG=MacOs
|
||||
compiler: clang
|
||||
@@ -39,7 +40,6 @@ matrix:
|
||||
env: CONF=release BUILDER=clang TARGET=IOs TAG=IOs
|
||||
compiler: clang
|
||||
|
||||
|
||||
install:
|
||||
- cd ..
|
||||
- pip install --user lutin
|
||||
@@ -52,7 +52,9 @@ install:
|
||||
|
||||
before_script:
|
||||
- cd ..
|
||||
- git clone https://github.com/atria-soft/elog.git -b $TRAVIS_BRANCH
|
||||
- git clone https://github.com/atria-soft/etk.git -b $TRAVIS_BRANCH
|
||||
- git clone https://github.com/atria-soft/ememory.git -b $TRAVIS_BRANCH
|
||||
- git clone https://github.com/generic-library/gtest-lutin.git --recursive
|
||||
- git clone https://github.com/generic-library/z-lutin.git --recursive
|
||||
- pwd
|
||||
@@ -63,14 +65,14 @@ before_script:
|
||||
- ./ci/build_send.py --tag=$TAG --status=START;
|
||||
|
||||
script:
|
||||
- lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE esignal-test; STATUS=$?
|
||||
- lutin -w -j4 -C -P -t $TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE esignal-*; STATUS=$?
|
||||
- ./ci/build_send.py --tag=$TAG --status="$STATUS";
|
||||
|
||||
after_script:
|
||||
- if [ "$GCOV" != "" ]; then
|
||||
./ci/warning_send.py --find-path ./out/Linux_x86_64/$CONF/build/$BUILDER/esignal/;
|
||||
fi
|
||||
- ./out/Linux_x86_64/$CONF/staging/$BUILDER/esignal-test/esignal-test.app/bin/esignal-test --etk-log-level=3 | tee out_test.txt
|
||||
- lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE esignal-test?run:--elog-level=3 | tee out_test.txt
|
||||
- if [ "$GCOV" != "" ]; then
|
||||
./ci/test_send.py --file=out_test.txt;
|
||||
lutin -C -P -t $TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF -p esignal?gcov;
|
||||
|
510
LICENSE
510
LICENSE
@@ -1,201 +1,373 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1. Definitions.
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
2.1. Grants
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
2.2. Effective Date
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
12
README.md
12
README.md
@@ -1,7 +1,7 @@
|
||||
e-signal
|
||||
========
|
||||
|
||||
`esignal` is c++ svg image parser and renderer.
|
||||
`esignal` is c++ simple direct signal manager.
|
||||
|
||||
Release (master)
|
||||
----------------
|
||||
@@ -49,6 +49,8 @@ download the software:
|
||||
mkdir WORKING_DIRECTORY
|
||||
cd WORKING_DIRECTORY
|
||||
git clone https://github.com/atria-soft/etk.git
|
||||
git clone https://github.com/atria-soft/elog.git
|
||||
git clone https://github.com/atria-soft/ememory.git
|
||||
git clone https://github.com/atria-soft/esignal.git
|
||||
git clone https://github.com/generic-library/gtest-lutin.git --recursive
|
||||
git clone https://github.com/generic-library/z-lutin.git --recursive
|
||||
@@ -57,18 +59,18 @@ Compile software:
|
||||
-----------------
|
||||
|
||||
cd WORKING_DIRECTORY
|
||||
lutin -C -P esignal-test
|
||||
lutin -C -P esignal-test esignal-sample
|
||||
|
||||
|
||||
License (APACHE v2.0)
|
||||
License (MPL v2.0)
|
||||
=====================
|
||||
Copyright esignal Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
https://www.mozilla.org/MPL/2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
1
authors.txt
Normal file
1
authors.txt
Normal file
@@ -0,0 +1 @@
|
||||
MR Edouard DUPIN <yui.heero@gmail.com>
|
72
doc/build.md
Normal file
72
doc/build.md
Normal file
@@ -0,0 +1,72 @@
|
||||
Build lib & build sample {#esignal_build}
|
||||
========================
|
||||
|
||||
@tableofcontents
|
||||
|
||||
Download: {#esignal_build_download}
|
||||
=========
|
||||
|
||||
esignal use some tools to manage source and build it:
|
||||
|
||||
lutin (build-system): {#esignal_build_download_lutin}
|
||||
---------------------
|
||||
|
||||
```{.sh}
|
||||
pip install lutin --user
|
||||
# optionnal dependency of lutin (manage image changing size for application release
|
||||
pip install pillow --user
|
||||
```
|
||||
|
||||
|
||||
dependency: {#esignal_build_download_dependency}
|
||||
-----------
|
||||
|
||||
```{.sh}
|
||||
mkdir framework
|
||||
cd framework
|
||||
git clone https://github.com/atria-soft/elog.git
|
||||
git clone https://github.com/atria-soft/etk.git
|
||||
git clone https://github.com/atria-soft/ememory.git
|
||||
cd ..
|
||||
```
|
||||
|
||||
sources: {#esignal_build_download_sources}
|
||||
--------
|
||||
|
||||
```{.sh}
|
||||
cd framework
|
||||
git clone https://github.com/atria-soft/esignal.git
|
||||
cd ..
|
||||
```
|
||||
|
||||
Build: {#esignal_build_build}
|
||||
======
|
||||
|
||||
|
||||
library: {#esignal_build_build_library}
|
||||
--------
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug esignal
|
||||
```
|
||||
|
||||
Sample: {#esignal_build_build_sample}
|
||||
-------
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug esignal-sample
|
||||
lutin -mdebug esignal-test
|
||||
```
|
||||
|
||||
Or simple:
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug esignal-*
|
||||
```
|
||||
|
||||
Run sample: {#esignal_build_run_sample}
|
||||
===========
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug esignal-sample?run
|
||||
```
|
54
doc/mainpage.md
Normal file
54
doc/mainpage.md
Normal file
@@ -0,0 +1,54 @@
|
||||
ESIGNAL library {#mainpage}
|
||||
===============
|
||||
|
||||
@tableofcontents
|
||||
|
||||
What is ESIGNAL, and how can I use it? {#esignal_mainpage_what}
|
||||
======================================
|
||||
|
||||
ESIGNAL, or Ewol signal engine is a simple messaging layer, managing multiple connection and manage disconnection
|
||||
|
||||
ESIGNAL is designed for
|
||||
- Expose signal
|
||||
- Emit synchronous signal (not send through an event loop but directly)
|
||||
- Manage versatil connection/disconnection
|
||||
|
||||
|
||||
What languages are supported? {#esignal_mainpage_language}
|
||||
=============================
|
||||
|
||||
ESIGNAL is written in C++.
|
||||
|
||||
|
||||
Are there any licensing restrictions? {#esignal_mainpage_restriction}
|
||||
=====================================
|
||||
|
||||
ESIGNAL is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
|
||||
|
||||
|
||||
License (MPL v2.0) {#esignal_mainpage_license}
|
||||
==================
|
||||
|
||||
Copyright esignal Edouard DUPIN
|
||||
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
<https://www.mozilla.org/MPL/2.0>
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
Other pages {#eproperty_mainpage_sub_page}
|
||||
===========
|
||||
|
||||
- @ref esignal_build
|
||||
- @ref esignal_tutorial
|
||||
- [**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html)
|
||||
|
||||
|
112
doc/tutorial.md
Normal file
112
doc/tutorial.md
Normal file
@@ -0,0 +1,112 @@
|
||||
Tutorial {#esignal_tutorial}
|
||||
========
|
||||
|
||||
@tableofcontents
|
||||
|
||||
Declare a Signal: {#esignal_declare}
|
||||
=================
|
||||
|
||||
Declaring a signal is really simple, just include the esignal file:
|
||||
|
||||
@snippet sampleAll.cpp esignal_sample_declare
|
||||
|
||||
You can now declare your signals. We have basicly declare some basic signal type:
|
||||
- void
|
||||
- bool
|
||||
- etk::String / etk::UString
|
||||
- int8_t / int16_t / int32_t / int64_t
|
||||
- uint8_t / uint16_t / uint32_t / uint64_t
|
||||
- float / double
|
||||
- vec2 / bvec2 / ivec2 / uivec2
|
||||
- vec3 / bvec3 / ivec3 / uivec3
|
||||
- etk::Color<unsigned char,4>
|
||||
- etk::Color<unsigned char,3>
|
||||
- etk::Color<float,4>
|
||||
- etk::Color<float,3>
|
||||
|
||||
To declare a signal with 'void' type:
|
||||
@snippet sampleAll.cpp esignal_sample_declare_void
|
||||
|
||||
To declare a signal with 'int32_t' type:
|
||||
@snippet sampleAll.cpp esignal_sample_declare_int
|
||||
|
||||
To declare a signal with 'string' type:
|
||||
@snippet sampleAll.cpp esignal_sample_declare_string
|
||||
|
||||
|
||||
Connecting on a signal {#esignal_connection}
|
||||
======================
|
||||
|
||||
We have some way to connect on a signals depending on where we do the connection.
|
||||
|
||||
Connection and basic emition {#esignal_connection_base}
|
||||
----------------------------
|
||||
|
||||
Declare the signal:
|
||||
@snippet sampleAll.cpp esignal_sample_connection_simple_connection_declare
|
||||
|
||||
Declare a generic fuction:
|
||||
@snippet sampleAll.cpp esignal_sample_connection_simple_extern_function
|
||||
|
||||
Connect a generic function:
|
||||
@snippet sampleAll.cpp esignal_sample_connection_simple_connection_function
|
||||
|
||||
Or simply connect a lambda function:
|
||||
@snippet sampleAll.cpp esignal_sample_connection_simple_connection_lambda
|
||||
|
||||
And now, we can emit a simple signal:
|
||||
@snippet sampleAll.cpp esignal_sample_connection_simple_emit
|
||||
|
||||
You can see that all connection return a esignal::Connection value. This is an handle that can not be copiable, but only movable, While this handle is alive, the connection is allive too.
|
||||
The to remove a connection, we only need to remive the handle or call the esignal::Connection::disconnect fucntion.
|
||||
|
||||
To disconnect a signal, it is very simple:
|
||||
@snippet sampleAll.cpp esignal_sample_connection_simple_disconnect
|
||||
|
||||
|
||||
This Will generate this simple sample code:
|
||||
@snippet sampleAll.cpp esignal_sample_connection_simple
|
||||
|
||||
|
||||
Connection on class member function {#esignal_connection_class}
|
||||
-----------------------------------
|
||||
|
||||
Declare class fuction:
|
||||
@snippet sampleAll.cpp esignal_sample_class_connection_callback
|
||||
|
||||
For direct connection, you need to have a 'const ref' on the parameter (internal helper design) to bind on the signal
|
||||
|
||||
Now you can nonnect the functions:
|
||||
@snippet sampleAll.cpp esignal_sample_class_connection_callback_connect
|
||||
|
||||
This Will generate this simple sample code:
|
||||
@snippet sampleAll.cpp esignal_sample_class_connection
|
||||
|
||||
Connection on ememory::SharedPtr<class> member function {#esignal_connection_shared}
|
||||
----------------------------------------------------
|
||||
|
||||
ememory::SharedPtr have intrinsec knowledge of alive pointer, then, if you do not need to remove connection while the ememory::SharedPtr is alive, just connect it like:
|
||||
@snippet sampleAll.cpp esignal_sample_shared_connection
|
||||
|
||||
Create new Signal {#esignal_create}
|
||||
=================
|
||||
|
||||
If the signal is not in the list: @ref esignal_declare, you need to declare it yourself. This is due to optimise the compilation time,
|
||||
in C++ when we inserte many template with all the implementation, the compilation time increase, the we decide to optimise the build time.
|
||||
|
||||
Create a new custum signal:
|
||||
@snippet sampleAll.cpp esignal_sample_new_declare
|
||||
|
||||
Connect on the Signal:
|
||||
@snippet sampleAll.cpp esignal_sample_new_lambda
|
||||
|
||||
Emit a Signal:
|
||||
@snippet sampleAll.cpp esignal_sample_new_emit
|
||||
|
||||
This might work good, but at this point the compilation is OK, but not the linking ==> we need to declare the implementation of the signal:
|
||||
@snippet sampleAll.cpp esignal_sample_new_register
|
||||
|
||||
|
||||
|
||||
This Will generate this simple sample code:
|
||||
@snippet sampleAll.cpp esignal_sample_new
|
34
doxy_esignal.py
Normal file
34
doxy_esignal.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import doxy.module as module
|
||||
import doxy.debug as debug
|
||||
import doxy.tools as tools
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name)
|
||||
my_module.set_version("version.txt")
|
||||
my_module.set_title("esignal: Ewol signal interface")
|
||||
my_module.set_website("http://atria-soft.github.io/" + module_name)
|
||||
my_module.set_website_sources("http://github.com/atria-soft/" + module_name)
|
||||
my_module.add_path([
|
||||
module_name,
|
||||
"doc",
|
||||
])
|
||||
my_module.add_sample_path([
|
||||
"sample",
|
||||
])
|
||||
my_module.add_depend([
|
||||
'etk',
|
||||
'ememory',
|
||||
])
|
||||
my_module.add_exclude_symbols([
|
||||
'*operator<<*',
|
||||
])
|
||||
my_module.add_exclude_file([
|
||||
'debug.hpp',
|
||||
])
|
||||
my_module.add_file_patterns([
|
||||
'*.h',
|
||||
'*.md',
|
||||
])
|
||||
return my_module
|
@@ -1,41 +1,69 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/Interface.h>
|
||||
#include <esignal/Base.h>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <esignal/debug.hpp>
|
||||
#include <esignal/Interface.hpp>
|
||||
#include <esignal/Base.hpp>
|
||||
|
||||
size_t esignal::Base::s_uid = 1;
|
||||
int64_t esignal::Base::s_uidSignalEmit = 1;
|
||||
size_t esignal::BaseInternal::s_uid = 1;
|
||||
int64_t esignal::BaseInternal::s_uidSignalEmit = 1;
|
||||
|
||||
esignal::Base::Base(ObserverConnection _countObs) :
|
||||
m_shared(this),
|
||||
m_connectionObserver(_countObs) {
|
||||
void esignal::BaseInternal::setPeriodic(bool _state) {
|
||||
m_periodic = _state;
|
||||
}
|
||||
|
||||
const etk::String& esignal::BaseInternal::getName() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void esignal::BaseInternal::setName(const etk::String& _name) {
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
const etk::String& esignal::BaseInternal::getDescription() const {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void esignal::BaseInternal::setDescription(const etk::String& _desc) {
|
||||
m_description = _desc;
|
||||
}
|
||||
|
||||
esignal::Base::Base() :
|
||||
m_data(null) {
|
||||
|
||||
}
|
||||
|
||||
esignal::Base::~Base() {
|
||||
m_shared.removeData();
|
||||
m_data.reset();
|
||||
}
|
||||
|
||||
|
||||
const std::string& esignal::Base::getName() const {
|
||||
static std::string noValue;
|
||||
const etk::String& esignal::Base::getName() const {
|
||||
if (m_data != null) {
|
||||
return m_data->getName();
|
||||
}
|
||||
static etk::String noValue;
|
||||
return noValue;
|
||||
}
|
||||
|
||||
const std::string& esignal::Base::getDescription() const {
|
||||
static std::string noValue;
|
||||
const etk::String& esignal::Base::getDescription() const {
|
||||
if (m_data != null) {
|
||||
return m_data->getDescription();
|
||||
}
|
||||
static etk::String noValue;
|
||||
return noValue;
|
||||
}
|
||||
|
||||
void esignal::Base::setPeriodic(bool _state) {
|
||||
if (m_data != null) {
|
||||
m_data->setPeriodic(_state);
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& esignal::operator <<(std::ostream& _os, const esignal::Base& _obj) {
|
||||
etk::Stream& esignal::operator <<(etk::Stream& _os, const esignal::Base& _obj) {
|
||||
_os << _obj.getName();
|
||||
return _os;
|
||||
}
|
||||
|
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/Base.h>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <mutex>
|
||||
#include <esignal/LockSharedPtrRef.h>
|
||||
|
||||
namespace esignal {
|
||||
class Base {
|
||||
public:
|
||||
using ObserverConnection = std::function<void(size_t)>; //!< Define an Observer of the number of observer
|
||||
protected:
|
||||
esignal::LockSharedPtrRef<esignal::Base> m_shared; //!< Reference counter on itself.
|
||||
static size_t s_uid; //!< global id of the signal (STATIC)
|
||||
static int64_t s_uidSignalEmit; //!< global id to emit counting
|
||||
ObserverConnection m_connectionObserver;
|
||||
public:
|
||||
//! @brief Basic constructor:
|
||||
Base(ObserverConnection _countObs = nullptr);
|
||||
//! @brief Copy constructor:
|
||||
Base(const Base&) = delete;
|
||||
//! @brief Move constructor
|
||||
Base(Base&& _obj) = delete;
|
||||
|
||||
virtual ~Base();
|
||||
/**
|
||||
* @brief get name of the signal
|
||||
*/
|
||||
virtual void disconnectShared(const std::shared_ptr<void>& _obj) = 0;
|
||||
virtual void disconnect(std::size_t _uid) = 0;
|
||||
/**
|
||||
* @brief Get name of the signal.
|
||||
* @return requested name.
|
||||
*/
|
||||
virtual const std::string& getName() const;
|
||||
/**
|
||||
* @brief Get decription of the signal.
|
||||
* @return requested decription.
|
||||
*/
|
||||
virtual const std::string& getDescription() const;
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const esignal::Base& _obj);
|
||||
#ifdef DEBUG
|
||||
const char* logIndent(int32_t _iii);
|
||||
#endif
|
||||
}
|
138
esignal/Base.hpp
Normal file
138
esignal/Base.hpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Function.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <esignal/debug.hpp>
|
||||
#include <esignal/Base.hpp>
|
||||
#include <etk/Function.hpp>
|
||||
#include <etk/typeTrait.hpp>
|
||||
#include <ethread/Mutex.hpp>
|
||||
|
||||
/**
|
||||
* @brief esignal global interface for all signal implementation
|
||||
*/
|
||||
namespace esignal {
|
||||
class BaseInternal : public ememory::EnableSharedFromThis<esignal::BaseInternal> {
|
||||
public:
|
||||
using ObserverConnection = etk::Function<void(size_t)>; //!< Define an Observer of the number of observer
|
||||
protected:
|
||||
bool m_periodic; //!< The signal is periodic ==> no log with this signal ... (no really needed)
|
||||
static size_t s_uid; //!< global id of the signal (STATIC)
|
||||
static int64_t s_uidSignalEmit; //!< global id to emit counting
|
||||
ObserverConnection m_connectionObserver; //!< propri<72>t<EFBFBD>ry of the connection handle basic
|
||||
etk::String m_name; //!< name of the signal.
|
||||
etk::String m_description; //!< description of the signal.
|
||||
public:
|
||||
/**
|
||||
* @brief Basic constructor:
|
||||
* @param[in] _countObs Observer on the number of connection availlable
|
||||
*/
|
||||
BaseInternal(ObserverConnection _countObs) :
|
||||
m_periodic(false),
|
||||
m_connectionObserver(_countObs) {
|
||||
|
||||
}
|
||||
virtual ~BaseInternal() = default;
|
||||
/**
|
||||
* @brief Disconnect the shared_ptr form the Signal
|
||||
* @param[in] _obj Link with the object to check
|
||||
*/
|
||||
virtual void disconnectShared(const ememory::SharedPtr<void>& _obj) = 0;
|
||||
/**
|
||||
* @brief Disconnect an observer of the signal.
|
||||
* @param[in] _uid Unique id of the signal connection.
|
||||
*/
|
||||
virtual void disconnect(size_t _uid) = 0;
|
||||
/**
|
||||
* @brief Get name of the signal.
|
||||
* @return requested name.
|
||||
*/
|
||||
const etk::String& getName() const;
|
||||
/**
|
||||
* @brief Set name of the signal.
|
||||
* @param[in] _name new name.
|
||||
*/
|
||||
void setName(const etk::String& _name);
|
||||
/**
|
||||
* @brief Get decription of the signal.
|
||||
* @return requested decription.
|
||||
*/
|
||||
const etk::String& getDescription() const;
|
||||
/**
|
||||
* @brief Set decription of the signal.
|
||||
* @param[in] _desc new decription.
|
||||
*/
|
||||
void setDescription(const etk::String& _desc);
|
||||
/**
|
||||
* @brief Tag the signal as periodic...
|
||||
* @param[in] _state state of the periodic element
|
||||
*/
|
||||
void setPeriodic(bool _state);
|
||||
/**
|
||||
* @brief Get the number of observers connected on the signal.
|
||||
* @return The count of observer.
|
||||
*/
|
||||
virtual size_t size() const = 0;
|
||||
/**
|
||||
* @brief Check if we have a connected observers.
|
||||
* @return true More than one observers.
|
||||
* @return false No observers.
|
||||
*/
|
||||
virtual bool empty() const = 0;
|
||||
/**
|
||||
* @brief Clear all connectd observers.
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
};
|
||||
/**
|
||||
* @brief Base signal interface for esignal::Signal (permit to create abstract list of signals...)
|
||||
*/
|
||||
class Base {
|
||||
protected:
|
||||
ememory::SharedPtr<esignal::BaseInternal> m_data;
|
||||
public:
|
||||
/**
|
||||
* @brief Basic constructor:
|
||||
*/
|
||||
Base();
|
||||
//! @brief Copy constructor:
|
||||
Base(const Base&) = delete;
|
||||
//! @brief Move constructor
|
||||
Base(Base&&) = delete;
|
||||
/**
|
||||
* @brief Virtualize the destructor
|
||||
* @internal
|
||||
*/
|
||||
virtual ~Base();
|
||||
/**
|
||||
* @brief Disconnect the shared_ptr form the Signal
|
||||
* @param[in] _obj Link with the object to check
|
||||
*/
|
||||
virtual void disconnectShared(const ememory::SharedPtr<void>& _obj) = 0;
|
||||
/**
|
||||
* @brief Get name of the signal.
|
||||
* @return requested name.
|
||||
*/
|
||||
virtual const etk::String& getName() const;
|
||||
/**
|
||||
* @brief Get decription of the signal.
|
||||
* @return requested decription.
|
||||
*/
|
||||
virtual const etk::String& getDescription() const;
|
||||
/**
|
||||
* @brief Tag the signal as periodic...
|
||||
* @param[in] _state state of the periodic element
|
||||
*/
|
||||
void setPeriodic(bool _state);
|
||||
};
|
||||
//! @not-in-doc
|
||||
etk::Stream& operator <<(etk::Stream& _os, const esignal::Base& _obj);
|
||||
#ifdef DEBUG
|
||||
const char* logIndent(int32_t _iii);
|
||||
#endif
|
||||
}
|
@@ -1,48 +1,61 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/Connection.h>
|
||||
#include <esignal/debug.hpp>
|
||||
#include <esignal/Connection.hpp>
|
||||
|
||||
esignal::Connection::Connection():
|
||||
m_signalRefUnique(), m_uid(0) {
|
||||
m_data(null),
|
||||
m_uid(0) {
|
||||
|
||||
}
|
||||
|
||||
esignal::Connection::Connection(const esignal::LockSharedPtrRef<esignal::Base>& _ref, std::size_t _id):
|
||||
m_signalRefUnique(_ref),
|
||||
esignal::Connection::Connection(ememory::SharedPtr<esignal::BaseInternal> _ref, size_t _id):
|
||||
m_data(_ref),
|
||||
m_uid(_id) {
|
||||
|
||||
}
|
||||
|
||||
esignal::Connection::Connection(esignal::Connection&& _obj):
|
||||
m_signalRefUnique(_obj.m_signalRefUnique),
|
||||
m_data(_obj.m_data),
|
||||
m_uid(_obj.m_uid) {
|
||||
_obj.m_uid = 0;
|
||||
_obj.m_data.reset();
|
||||
}
|
||||
|
||||
esignal::Connection& esignal::Connection::operator=(esignal::Connection&& _obj) {
|
||||
disconnect();
|
||||
m_signalRefUnique = _obj.m_signalRefUnique;
|
||||
m_data = _obj.m_data;
|
||||
m_uid = _obj.m_uid;
|
||||
_obj.m_uid = 0;
|
||||
_obj.m_data.reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
esignal::Connection::~Connection() {
|
||||
m_signalRefUnique.disconnect(m_uid);
|
||||
ememory::SharedPtr<esignal::BaseInternal> ref = m_data.lock();
|
||||
if (ref == null) {
|
||||
return;
|
||||
}
|
||||
ref->disconnect(m_uid);
|
||||
m_data.reset();
|
||||
m_uid = 0;
|
||||
}
|
||||
|
||||
void esignal::Connection::disconnect() {
|
||||
m_signalRefUnique.disconnect(m_uid);
|
||||
ememory::SharedPtr<esignal::BaseInternal> ref = m_data.lock();
|
||||
if (ref == null) {
|
||||
return;
|
||||
}
|
||||
ref->disconnect(m_uid);
|
||||
m_data.reset();
|
||||
m_uid = 0;
|
||||
}
|
||||
|
||||
bool esignal::Connection::isConnected() {
|
||||
return m_signalRefUnique.isAlive();
|
||||
return m_data.useCount() != 0
|
||||
&& m_uid != 0;
|
||||
}
|
||||
|
||||
|
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/Base.h>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <mutex>
|
||||
|
||||
namespace esignal {
|
||||
/**
|
||||
* @brief connection on the signal (disconnect it whe removed)
|
||||
*/
|
||||
class Connection {
|
||||
public:
|
||||
//! @brief Constructor (no link)
|
||||
Connection();
|
||||
//! @brief Constructor (link)
|
||||
Connection(const esignal::LockSharedPtrRef<esignal::Base>& _ref, std::size_t _id);
|
||||
//! @brief Move Constructor
|
||||
Connection(Connection&& _obj);
|
||||
//! @brief Move operator.
|
||||
Connection& operator=(Connection&& _obj);
|
||||
//! @brief Copy constructor (REMOVED)
|
||||
Connection(const Connection&) = delete;
|
||||
//! @brief Copy operator (REMOVED)
|
||||
Connection& operator=(const Connection&) = delete;
|
||||
//! @brief Destructor.
|
||||
~Connection();
|
||||
//! @brief Disconnect the signal.
|
||||
void disconnect();
|
||||
/**
|
||||
* @brief Check if the connection is alive or signal removed
|
||||
* @return true The signal is connected.
|
||||
* @return false The signal is NOT connected.
|
||||
*/
|
||||
bool isConnected();
|
||||
private:
|
||||
esignal::LockSharedPtrRef<esignal::Base> m_signalRefUnique; //!< reference on the Signal.
|
||||
std::size_t m_uid; //!< UID of the current connection.
|
||||
};
|
||||
}
|
||||
|
68
esignal/Connection.hpp
Normal file
68
esignal/Connection.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Function.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <esignal/debug.hpp>
|
||||
#include <esignal/Base.hpp>
|
||||
|
||||
namespace esignal {
|
||||
/**
|
||||
* @brief connection on the signal (disconnect it whe removed)
|
||||
*/
|
||||
class Connection {
|
||||
private:
|
||||
ememory::WeakPtr<esignal::BaseInternal> m_data;
|
||||
size_t m_uid; //!< UID of the current connection.
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor (no link)
|
||||
*/
|
||||
Connection();
|
||||
/**
|
||||
* @brief Constructor (link)
|
||||
* @param[in] _ref Reference ID of the Signal extern handle
|
||||
* @param[in] _id Id of the Connection handle
|
||||
*/
|
||||
Connection(ememory::SharedPtr<esignal::BaseInternal> _ref, size_t _id);
|
||||
/**
|
||||
* @brief Move Constructor
|
||||
* @param[in] _obj Connection Object to move
|
||||
*/
|
||||
Connection(Connection&& _obj);
|
||||
/**
|
||||
* @brief Move operator.
|
||||
* @param[in] _obj Connection Object to move
|
||||
* @return Local reference on the local object (moved)
|
||||
*/
|
||||
Connection& operator=(Connection&& _obj);
|
||||
/**
|
||||
* @brief Copy constructor (REMOVED)
|
||||
*/
|
||||
Connection(const Connection&) = delete;
|
||||
/**
|
||||
* @brief Copy operator (REMOVED)
|
||||
* @return Reference on this
|
||||
*/
|
||||
Connection& operator=(const Connection&) = delete;
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
~Connection();
|
||||
/**
|
||||
* @brief Disconnect the signal.
|
||||
*/
|
||||
void disconnect();
|
||||
/**
|
||||
* @brief Check if the connection is alive or signal removed
|
||||
* @return true The signal is connected.
|
||||
* @return false The signal is NOT connected.
|
||||
*/
|
||||
bool isConnected();
|
||||
};
|
||||
}
|
||||
|
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/Base.h>
|
||||
#include <esignal/Signal.h>
|
||||
#include <esignal/Interface.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ISignal<T_ARGS>"
|
||||
|
||||
namespace esignal {
|
||||
/**
|
||||
* @brief Sigla same as @ref esignal::Signal withe a name and a description to manage a list of signals.
|
||||
*/
|
||||
template<class... T_ARGS>
|
||||
class ISignal : public Signal<T_ARGS...> {
|
||||
protected:
|
||||
esignal::Interface* m_signalInterfaceLink; //!< interface of the signal manager.
|
||||
std::string m_name; //!< name of the signal.
|
||||
std::string m_description; //!< description of the signal.
|
||||
public:
|
||||
/**
|
||||
* @brief Create a signal with a specific type.
|
||||
* @param[in] _signalInterfaceLink reference on the signal lister.
|
||||
* @param[in] _countObs (optionnal) Local observer to know the count of connection on the signal.
|
||||
* @param[in] _name Static name of the signal.
|
||||
* @param[in] _description Description of the signal.
|
||||
*/
|
||||
template<class CLASS_TYPE, class FUNC_TYPE>
|
||||
ISignal(CLASS_TYPE* _signalInterfaceLink,
|
||||
FUNC_TYPE _func,
|
||||
const std::string& _name,
|
||||
const std::string& _description);
|
||||
ISignal(esignal::Interface* _signalInterfaceLink,
|
||||
const std::string& _name,
|
||||
const std::string& _description);
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~ISignal();
|
||||
virtual const std::string& getName() const;
|
||||
virtual const std::string& getDescription() const;
|
||||
};
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
template<class CLASS_TYPE, class FUNC_TYPE>
|
||||
esignal::ISignal<T_ARGS...>::ISignal(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
const std::string& _name,
|
||||
const std::string& _description) :
|
||||
esignal::Signal<T_ARGS...>(_class, _func),
|
||||
m_signalInterfaceLink(_class),
|
||||
m_name(_name),
|
||||
m_description(_description) {
|
||||
// add a reference on the current signal ...
|
||||
if (m_signalInterfaceLink != nullptr) {
|
||||
m_signalInterfaceLink->signalAdd(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/Interface.h>
|
||||
#include <esignal/Base.h>
|
||||
|
||||
esignal::Interface::Interface() {
|
||||
|
||||
}
|
||||
|
||||
esignal::Interface::~Interface() {
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
// note this pointer is not allocated and not free at the end of the class
|
||||
void esignal::Interface::signalAdd(esignal::Base* _pointerOnSignal) {
|
||||
if (_pointerOnSignal == nullptr) {
|
||||
ESIGNAL_ERROR("Try to link a nullptr parameters");
|
||||
return;
|
||||
}
|
||||
m_list.push_back(_pointerOnSignal);
|
||||
}
|
||||
|
||||
void esignal::Interface::signalRemove(esignal::Base* _pointerOnSignal) {
|
||||
auto it = m_list.begin();
|
||||
while (it != m_list.end()) {
|
||||
if ( *it == nullptr
|
||||
|| *it == _pointerOnSignal) {
|
||||
it = m_list.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> esignal::Interface::signalGetAll() const {
|
||||
std::vector<std::string> out;
|
||||
for (auto &it : m_list) {
|
||||
if(it != nullptr) {
|
||||
out.push_back(it->getName());
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void esignal::Interface::signalDisconnect(const std::shared_ptr<void>& _object) {
|
||||
if (_object == nullptr) {
|
||||
ESIGNAL_ERROR("Input ERROR nullptr pointer Object ...");
|
||||
return;
|
||||
}
|
||||
for(auto &it : m_list) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
it->disconnectShared(_object);
|
||||
}
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace esignal {
|
||||
class Base;
|
||||
class Interface {
|
||||
friend class esignal::Base; // to register parameter in the list.
|
||||
private:
|
||||
std::vector<esignal::Base*> m_list; //!< list of availlable Parameters
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor.
|
||||
*/
|
||||
Interface();
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~Interface();
|
||||
/**
|
||||
* @brief Register a parameter class pointer in the List of parameters
|
||||
* @note This class does not destroy the parameter pointer!!!
|
||||
* @param[in] _pointerOnSignal Pointer on the signal that might be added.
|
||||
*/
|
||||
void signalAdd(esignal::Base* _pointerOnSignal);
|
||||
void signalRemove(esignal::Base* _pointerOnSignal);
|
||||
/**
|
||||
* @brief Get All the signal list:
|
||||
* @return vector on all the signals names
|
||||
*/
|
||||
std::vector<std::string> signalGetAll() const;
|
||||
/**
|
||||
* @brief Remove binding on all event class.
|
||||
* @param[in] _sharedPtr sharedPtr to unlink (no type needed ...).
|
||||
*/
|
||||
void signalDisconnect(const std::shared_ptr<void>& _sharedPtr);
|
||||
};
|
||||
}
|
||||
|
22
esignal/Interface.hpp
Normal file
22
esignal/Interface.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
#include <esignal/InterfaceData.hpp>
|
||||
|
||||
namespace esignal {
|
||||
/**
|
||||
* @brief Interface to collect the Signal list (for abstarction connection)
|
||||
* It create a simple "signals" member that permit to access at the signalproperties.
|
||||
*/
|
||||
class Interface {
|
||||
public:
|
||||
esignal::InterfaceData signals; //!< Interface to access at all signals properties...
|
||||
};
|
||||
}
|
||||
|
64
esignal/InterfaceData.cpp
Normal file
64
esignal/InterfaceData.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ememory/memory.hpp>
|
||||
#include <esignal/debug.hpp>
|
||||
#include <esignal/InterfaceData.hpp>
|
||||
#include <esignal/Base.hpp>
|
||||
|
||||
esignal::InterfaceData::InterfaceData() {
|
||||
|
||||
}
|
||||
|
||||
esignal::InterfaceData::~InterfaceData() {
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
// note this pointer is not allocated and not free at the end of the class
|
||||
void esignal::InterfaceData::add(esignal::Base* _pointerOnSignal) {
|
||||
if (_pointerOnSignal == null) {
|
||||
ESIGNAL_ERROR("Try to link a null parameters");
|
||||
return;
|
||||
}
|
||||
m_list.pushBack(_pointerOnSignal);
|
||||
}
|
||||
|
||||
void esignal::InterfaceData::remove(esignal::Base* _pointerOnSignal) {
|
||||
auto it = m_list.begin();
|
||||
while (it != m_list.end()) {
|
||||
if ( *it == null
|
||||
|| *it == _pointerOnSignal) {
|
||||
it = m_list.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
etk::Vector<etk::String> esignal::InterfaceData::getAll() const {
|
||||
etk::Vector<etk::String> out;
|
||||
for (auto &it : m_list) {
|
||||
if(it != null) {
|
||||
out.pushBack(it->getName());
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void esignal::InterfaceData::disconnect(const ememory::SharedPtr<void>& _object) {
|
||||
if (_object == null) {
|
||||
ESIGNAL_ERROR("Input ERROR null pointer Object ...");
|
||||
return;
|
||||
}
|
||||
for(auto &it : m_list) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
it->disconnectShared(_object);
|
||||
}
|
||||
}
|
||||
|
||||
|
52
esignal/InterfaceData.hpp
Normal file
52
esignal/InterfaceData.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
|
||||
namespace esignal {
|
||||
class Base;
|
||||
/**
|
||||
* @brief Interface data to collect the Signal list (for abstarction connection)
|
||||
*/
|
||||
class InterfaceData {
|
||||
private:
|
||||
etk::Vector<esignal::Base*> m_list; //!< list of availlable Parameters
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor.
|
||||
*/
|
||||
InterfaceData();
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~InterfaceData();
|
||||
/**
|
||||
* @brief Register a signal class pointer in the List of signal list
|
||||
* @note This class does not destroy the parameter pointer!!!
|
||||
* @param[in] _pointerOnSignal Pointer on the signal that might be added.
|
||||
*/
|
||||
void add(esignal::Base* _pointerOnSignal);
|
||||
/**
|
||||
* @brief Remove a signal class pointer in the List of signal list
|
||||
* @note This class does not destroy the parameter pointer!!!
|
||||
* @param[in] _pointerOnSignal Pointer on the signal that might be removed.
|
||||
*/
|
||||
void remove(esignal::Base* _pointerOnSignal);
|
||||
/**
|
||||
* @brief Get All the signal list:
|
||||
* @return vector on all the signals names
|
||||
*/
|
||||
etk::Vector<etk::String> getAll() const;
|
||||
/**
|
||||
* @brief Remove binding on all event class.
|
||||
* @param[in] _sharedPtr sharedPtr to unlink (no type needed ...).
|
||||
*/
|
||||
void disconnect(const ememory::SharedPtr<void>& _sharedPtr);
|
||||
};
|
||||
}
|
||||
|
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <esignal/RefCount.h>
|
||||
|
||||
namespace esignal {
|
||||
/**
|
||||
* @brief shared ptr that permeit to lock access of the internal data (it does not manage the allication and remove of the data).
|
||||
* @todo Change this with atomic_shared_ptr<> when availlable.
|
||||
* @input[in] TYPE Type of the internal data
|
||||
*/
|
||||
template<class TYPE>
|
||||
class LockSharedPtrRef {
|
||||
public:
|
||||
// TODO : Remove data from refcounter ...==>
|
||||
// esignal::RefCount* m_counter; //!< Access on the reference counter
|
||||
// TYPE* m_data; //!< Pointer on the data
|
||||
esignal::RefCount<TYPE>* m_counter; //!< Access on the reference counter
|
||||
public:
|
||||
/**
|
||||
* @brief Basic contructor (with the object to ref count)
|
||||
* @param[in] _pointer Pointer on the data (default nullptr)
|
||||
*/
|
||||
LockSharedPtrRef(TYPE* _pointer=nullptr);
|
||||
/**
|
||||
* @brief Copy contructor
|
||||
* @param[in] _obj object to copy
|
||||
*/
|
||||
LockSharedPtrRef(const LockSharedPtrRef<TYPE>& _obj);
|
||||
/**
|
||||
* @brief Copy operator (It copy the counter and increment the it).
|
||||
* @param[in] _obj objetc to copy.
|
||||
* @return Reference of this
|
||||
*/
|
||||
LockSharedPtrRef& operator=(const LockSharedPtrRef<TYPE>& _obj);
|
||||
/**
|
||||
* @brief Contructor (move)
|
||||
* @param[in] _obj move object
|
||||
*/
|
||||
LockSharedPtrRef(LockSharedPtrRef<TYPE>&& _obj);
|
||||
/**
|
||||
* @brief Copy operator (force move) ==> removed
|
||||
*/
|
||||
LockSharedPtrRef& operator=(LockSharedPtrRef<TYPE>&& _obj) = delete;
|
||||
/**
|
||||
* @brief Destructor of the class (decrement the counter and remove it if it is the last one...)
|
||||
*/
|
||||
~LockSharedPtrRef();
|
||||
/**
|
||||
* @brief Remove the data on the conter reference (it does not exist anymore)
|
||||
*/
|
||||
void removeData();
|
||||
/**
|
||||
* @brief Call disconnect on the parameter class with lock prevention
|
||||
* @param[in] _uid ID to dicsonnect on the sub element
|
||||
*/
|
||||
void disconnect(std::size_t _uid);
|
||||
/**
|
||||
* @brief Check if the value is availlable
|
||||
* @return true The data is availlable
|
||||
* @return false The data has been removed
|
||||
*/
|
||||
bool isAlive();
|
||||
private:
|
||||
/**
|
||||
* @remove reference on the refcounter...
|
||||
*/
|
||||
void rmShared();
|
||||
};
|
||||
}
|
||||
|
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
#include <mutex>
|
||||
|
||||
namespace esignal {
|
||||
/**
|
||||
* @brief Ref counting tool.
|
||||
*/
|
||||
template<class TYPE>
|
||||
class RefCount {
|
||||
private:
|
||||
std::mutex m_lock; //!< mutex on the refcounting element
|
||||
int64_t m_count; //!< number of element connected
|
||||
TYPE* m_data; //!< Pointer on the refconting data
|
||||
public:
|
||||
//!< generic constructor
|
||||
RefCount(TYPE* _data);
|
||||
//! @brief Copy constructor (REMOVED)
|
||||
RefCount(const RefCount&) = delete;
|
||||
//! @brief Copy operator (REMOVED)
|
||||
RefCount& operator=(RefCount) = delete;
|
||||
//! @previous
|
||||
RefCount& operator=(const RefCount& _obj) = delete;
|
||||
//! @brief Move constructor (REMOVED)
|
||||
RefCount(RefCount&& _obj) = delete;
|
||||
//! @brief Move operator (REMOVED)
|
||||
RefCount& operator=(RefCount&& _obj) = delete;
|
||||
//! @brief Destructor
|
||||
~RefCount();
|
||||
public:
|
||||
//!< @brief Lock the interface
|
||||
void lock();
|
||||
//!< @brief Unlock the interface
|
||||
void unlock();
|
||||
//!< @brief Increment the ref-counting
|
||||
void inc();
|
||||
//!< @brief Decrement the ref-counting
|
||||
int64_t dec();
|
||||
//!< @brief Get number of connected
|
||||
int64_t getCount() const;
|
||||
//!< @brief Remove the data
|
||||
void remove();
|
||||
//!< @brief Get the recoreded data
|
||||
TYPE* get();
|
||||
};
|
||||
}
|
245
esignal/Signal.h
245
esignal/Signal.h
@@ -1,245 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/Base.h>
|
||||
#include <esignal/LockSharedPtrRef.h>
|
||||
#include <esignal/RefCount.h>
|
||||
#include <esignal/Connection.h>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <mutex>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Signal<T_ARGS>"
|
||||
|
||||
namespace esignal {
|
||||
/**
|
||||
* @brief Basic signal base
|
||||
* @param[in] Args... Argument of the signal
|
||||
*/
|
||||
template<class... T_ARGS>
|
||||
class Signal : public esignal::Base {
|
||||
public:
|
||||
using Observer = std::function<void(const T_ARGS&...)>; //!< Define an Observer: function pointer
|
||||
protected:
|
||||
int32_t m_callInProgress; //!< know if we are in a recursive loop
|
||||
public:
|
||||
/**
|
||||
* @brief Basic constructor
|
||||
* @param[in] _countObs Local observer to know the count of connection on the signal.
|
||||
*/
|
||||
Signal(ObserverConnection _countObs=nullptr);
|
||||
template<class CLASS_TYPE, class FUNC_TYPE>
|
||||
Signal(CLASS_TYPE* _class, FUNC_TYPE _func);
|
||||
//! @brief Copy constructor (REMOVED)
|
||||
Signal(const Signal&) = delete;
|
||||
//! @brief Copy operator (REMOVED)
|
||||
Signal& operator=(Signal) = delete;
|
||||
Signal& operator=(const Signal& _obj) = delete;
|
||||
//! @brief Move constructor (REMOVED)
|
||||
Signal(Signal&& _obj) = delete;
|
||||
//! @brief Move operator
|
||||
Signal& operator=(Signal&& _obj) = delete;
|
||||
private:
|
||||
/**
|
||||
* @brief Executor: Class to manage the UID and basic value of an observer
|
||||
*/
|
||||
class Executor {
|
||||
public:
|
||||
Observer m_observer; //!< Observer to call when needed (if not removed).
|
||||
bool m_removed; //!< the executor has been removed.
|
||||
size_t m_uid; //!< unique ID of the signal (used to remove it).
|
||||
public:
|
||||
/**
|
||||
* @brief Basic constructor.
|
||||
* @param[in] _observer Observer to call.
|
||||
*/
|
||||
Executor(Observer&& _observer);
|
||||
//! @brief virtual destructor.
|
||||
virtual ~Executor() = default;
|
||||
public:
|
||||
/**
|
||||
* @brief Emit the data on the observer.
|
||||
* @param[in] _values... Multiple value needed to send on observers
|
||||
*/
|
||||
virtual void emit(const T_ARGS&... _values);
|
||||
public:
|
||||
/**
|
||||
* @brief check if the Executor is a managed by this shared_ptr
|
||||
* @param[in] _obj Object to check
|
||||
* @return true The Executor depend on this shared_ptr
|
||||
* @return false The Executor does not depend on this shared_ptr
|
||||
*/
|
||||
virtual bool isSharedPtr(const std::shared_ptr<void>& _obj);
|
||||
};
|
||||
protected:
|
||||
std::vector<std::unique_ptr<Executor>> m_executors; //!< List of all executors.
|
||||
private:
|
||||
/**
|
||||
* @brief Executor specific to the Shared_ptr caller that does not want to worry about the removing of the signal.
|
||||
* @param[in] T_ARGS... Argument of the signal
|
||||
*/
|
||||
class ExecutorShared : public Executor {
|
||||
protected:
|
||||
std::weak_ptr<void> m_object; //!< a weak reference on the object to verify that it is alive
|
||||
public:
|
||||
/**
|
||||
* @brief shared constructor.
|
||||
* @param[in] _object A weak reference of the object.
|
||||
* @param[in] _observer Observer to call.
|
||||
*/
|
||||
ExecutorShared(std::weak_ptr<void> _object, Observer&& _observer);
|
||||
public:
|
||||
/**
|
||||
* @brief Emit the data on the observer.
|
||||
* @param[in] _values... Multiple value needed to send on observers
|
||||
*/
|
||||
virtual void emit(const T_ARGS&... _values);
|
||||
public:
|
||||
virtual bool isSharedPtr(const std::shared_ptr<void>& _obj);
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief Connect an observer on the signal.
|
||||
* @param[in] _observer Observer to call.
|
||||
*/
|
||||
template< class OBSERVER_TYPE >
|
||||
esignal::Connection connect(OBSERVER_TYPE&& _observer);
|
||||
/**
|
||||
* @brief Connect an function member on the signal.
|
||||
* @param[in] _class Object on whe we need to call.
|
||||
* @param[in] _func Function to call.
|
||||
* @param[in] _arg Argument optinnal the user want to add.
|
||||
*/
|
||||
template<class CLASS_TYPE, class FUNC_TYPE, class... FUNC_ARGS_TYPE>
|
||||
esignal::Connection connect(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
FUNC_ARGS_TYPE... _arg);
|
||||
/**
|
||||
* @brief Connect an function member on the signal with the shared_ptr object.
|
||||
* @param[in] _class shared_ptr Object on whe we need to call ==> the object is get in keeped in weak_ptr.
|
||||
* @param[in] _func Function to call.
|
||||
* @param[in] _arg Argument optinnal the user want to add.
|
||||
*/
|
||||
template<class PARENT_CLASS_TYPE, class CLASS_TYPE, typename... FUNC_ARGS_TYPE>
|
||||
void connect(const std::shared_ptr<PARENT_CLASS_TYPE>& _class,
|
||||
void (CLASS_TYPE::*_func)(const T_ARGS&..., FUNC_ARGS_TYPE...),
|
||||
FUNC_ARGS_TYPE... _args);
|
||||
public:
|
||||
/**
|
||||
* @brief Emit data on the signal.
|
||||
* @param[in] _args Argument data to emit.
|
||||
*/
|
||||
void emit(const T_ARGS&... _args);
|
||||
protected:
|
||||
void removeIfPossible();
|
||||
public:
|
||||
/**
|
||||
* @brief Disconnect an observer of the signal.
|
||||
* @param[in] _uid Unique id of the signal.
|
||||
*/
|
||||
void disconnect(std::size_t _uid);
|
||||
void disconnectShared(const std::shared_ptr<void>& _obj);
|
||||
/**
|
||||
* @brief Get the number of observers connected on the signal.
|
||||
* @return The count of observer.
|
||||
*/
|
||||
size_t size() const;
|
||||
/**
|
||||
* @brief Check if we have a connected observers.
|
||||
* @return true More than one observers.
|
||||
* @return false No observers.
|
||||
*/
|
||||
bool empty() const;
|
||||
/**
|
||||
* @brief Clear all connectd observers.
|
||||
*/
|
||||
void clear();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
template<class... T_ARGS>
|
||||
template< class OBSERVER_TYPE >
|
||||
esignal::Connection esignal::Signal<T_ARGS...>::connect(OBSERVER_TYPE&& _observer ) {
|
||||
ESIGNAL_DEBUG("esignal: '" << getName() << "' try connect: '" << getName() << "' (observer)");
|
||||
std::unique_ptr<Executor> executer(new Executor(std::forward<OBSERVER_TYPE>(_observer)));
|
||||
std::size_t uid = executer->m_uid;
|
||||
m_executors.push_back(std::move(executer));
|
||||
if (m_connectionObserver!=nullptr) {
|
||||
m_connectionObserver(m_executors.size());
|
||||
}
|
||||
ESIGNAL_DEBUG(" '" << getName() << "' new count: " << m_executors.size());
|
||||
return esignal::Connection(Base::m_shared, uid);
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
template<class CLASS_TYPE, class FUNC_TYPE, class... FUNC_ARGS_TYPE>
|
||||
esignal::Connection esignal::Signal<T_ARGS...>::connect(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
FUNC_ARGS_TYPE... _arg) {
|
||||
ESIGNAL_DEBUG("esignal: '" << getName() << "' try connect: '" << getName() << "' (reference)");
|
||||
if (_class == nullptr) {
|
||||
ESIGNAL_ERROR(" '" << getName() << "' Class pointer in nullptr");
|
||||
return esignal::Connection();
|
||||
}
|
||||
std::unique_ptr<Executor> executer(new Executor([=](const T_ARGS& ... _argBase){
|
||||
(*_class.*_func)(_argBase..., _arg... );
|
||||
}));
|
||||
std::size_t uid = executer->m_uid;
|
||||
m_executors.push_back(std::move(executer));
|
||||
if (m_connectionObserver != nullptr) {
|
||||
m_connectionObserver(m_executors.size());
|
||||
}
|
||||
ESIGNAL_DEBUG(" '" << getName() << "' new count: " << m_executors.size());
|
||||
return Connection(Base::m_shared, uid);
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
template<class PARENT_CLASS_TYPE, class CLASS_TYPE, typename... FUNC_ARGS_TYPE>
|
||||
void esignal::Signal<T_ARGS...>::connect(const std::shared_ptr<PARENT_CLASS_TYPE>& _class,
|
||||
void (CLASS_TYPE::*_func)(const T_ARGS&..., FUNC_ARGS_TYPE...),
|
||||
FUNC_ARGS_TYPE... _args) {
|
||||
ESIGNAL_DEBUG("esignal: '" << getName() << "' try connect: '" << getName() << "' (weak pointer)");
|
||||
if (_class == nullptr) {
|
||||
ESIGNAL_ERROR(" '" << getName() << "' Class pointer in nullptr");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<CLASS_TYPE> obj2 = std::dynamic_pointer_cast<CLASS_TYPE>(_class);
|
||||
if (obj2 == nullptr) {
|
||||
ESIGNAL_ERROR("Can not connect signal ...");
|
||||
return;
|
||||
}
|
||||
CLASS_TYPE* directPointer = obj2.get();
|
||||
std::unique_ptr<ExecutorShared> executer(new ExecutorShared(_class, [=]( const T_ARGS& ... _argBase){
|
||||
// TODO : Check if compilator does not use the shared ptr ...
|
||||
(*directPointer.*_func)(_argBase..., _args... );
|
||||
}));
|
||||
m_executors.push_back(std::move(executer));
|
||||
if (m_connectionObserver!=nullptr) {
|
||||
m_connectionObserver(m_executors.size());
|
||||
}
|
||||
ESIGNAL_DEBUG(" '" << getName() << "' new count: " << m_executors.size());
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
template<class CLASS_TYPE, class FUNC_TYPE>
|
||||
esignal::Signal<T_ARGS...>::Signal(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func):
|
||||
esignal::Base([=](size_t _val){(*_class.*_func)(_val);}),
|
||||
m_callInProgress(0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
429
esignal/Signal.hpp
Normal file
429
esignal/Signal.hpp
Normal file
@@ -0,0 +1,429 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Function.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <ememory/UniquePtr.hpp>
|
||||
#include <esignal/debug.hpp>
|
||||
#include <esignal/Base.hpp>
|
||||
#include <esignal/Connection.hpp>
|
||||
#include <esignal/Interface.hpp>
|
||||
|
||||
namespace esignal {
|
||||
|
||||
template<class... T_ARGS>
|
||||
class SignalInternal : public esignal::BaseInternal {
|
||||
public:
|
||||
using Observer = etk::Function<void(const T_ARGS&...)>; //!< Define an Observer: function pointer
|
||||
protected:
|
||||
int32_t m_callInProgress; //!< know if we are in a recursive loop
|
||||
public:
|
||||
/**
|
||||
* @brief Basic constructor:
|
||||
* @param[in] _countObs Observer on the number of connection availlable
|
||||
*/
|
||||
SignalInternal(ObserverConnection _countObs):
|
||||
esignal::BaseInternal(_countObs),
|
||||
m_callInProgress(0) {
|
||||
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* @brief Executor: Class to manage the UID and basic value of an observer
|
||||
*/
|
||||
class Executor {
|
||||
public:
|
||||
Observer m_observer; //!< Observer to call when needed (if not removed).
|
||||
bool m_removed; //!< the executor has been removed.
|
||||
size_t m_uid; //!< unique ID of the signal (used to remove it).
|
||||
public:
|
||||
/**
|
||||
* @brief Basic constructor.
|
||||
* @param[in] _observer Observer to call.
|
||||
*/
|
||||
Executor(Observer&& _observer);
|
||||
//! @brief virtual destructor.
|
||||
virtual ~Executor() = default;
|
||||
public:
|
||||
/**
|
||||
* @brief Emit the data on the observer.
|
||||
* @param[in] _values... Multiple value needed to send on observers
|
||||
*/
|
||||
virtual void emit(const T_ARGS&... _values);
|
||||
public:
|
||||
/**
|
||||
* @brief check if the Executor is a managed by this shared_ptr
|
||||
* @param[in] _obj Object to check
|
||||
* @return true The Executor depend on this shared_ptr
|
||||
* @return false The Executor does not depend on this shared_ptr
|
||||
*/
|
||||
virtual bool isSharedPtr(const ememory::SharedPtr<void>& _obj);
|
||||
};
|
||||
protected:
|
||||
etk::Vector<ememory::UniquePtr<Executor>> m_executors; //!< List of all executors.
|
||||
private:
|
||||
/**
|
||||
* @brief Executor specific to the Shared_ptr caller that does not want to worry about the removing of the signal.
|
||||
*/
|
||||
class ExecutorShared : public Executor {
|
||||
protected:
|
||||
ememory::WeakPtr<void> m_object; //!< a weak reference on the object to verify that it is alive
|
||||
public:
|
||||
/**
|
||||
* @brief shared constructor.
|
||||
* @param[in] _object A weak reference of the object.
|
||||
* @param[in] _observer Observer to call.
|
||||
*/
|
||||
ExecutorShared(ememory::WeakPtr<void> _object, Observer&& _observer);
|
||||
public:
|
||||
/**
|
||||
* @brief Emit the data on the observer.
|
||||
* @param[in] _values... Multiple value needed to send on observers
|
||||
*/
|
||||
void emit(const T_ARGS&... _values) override;
|
||||
public:
|
||||
bool isSharedPtr(const ememory::SharedPtr<void>& _obj) override;
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief Connect an observer on the signal.
|
||||
* @param[in] _observer Observer to call.
|
||||
* @return Connection handle (connection is removed if the handle is destroy)
|
||||
*/
|
||||
template< class OBSERVER_TYPE >
|
||||
esignal::Connection connect(OBSERVER_TYPE&& _observer);
|
||||
/**
|
||||
* @brief Connect an function member on the signal.
|
||||
* @param[in] _class Object on whe we need to call.
|
||||
* @param[in] _func Function to call.
|
||||
* @param[in] _arg Argument optinnal the user want to add.
|
||||
* @return Connection handle (connection is removed if the handle is destroy)
|
||||
*/
|
||||
template<class CLASS_TYPE, class FUNC_TYPE, class... FUNC_ARGS_TYPE>
|
||||
esignal::Connection connect(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
FUNC_ARGS_TYPE... _arg);
|
||||
/**
|
||||
* @brief Connect an function member on the signal with the shared_ptr object.
|
||||
* @param[in] _class shared_ptr Object on whe we need to call ==> the object is get in keeped in weak_ptr.
|
||||
* @param[in] _func Function to call.
|
||||
* @param[in] _args Argument optinnal the user want to add.
|
||||
*/
|
||||
template<class PARENT_CLASS_TYPE, class CLASS_TYPE, typename... FUNC_ARGS_TYPE>
|
||||
void connect(const ememory::SharedPtr<PARENT_CLASS_TYPE>& _class,
|
||||
void (CLASS_TYPE::*_func)(const T_ARGS&..., FUNC_ARGS_TYPE...),
|
||||
FUNC_ARGS_TYPE... _args);
|
||||
/**
|
||||
* @brief Emit data on the signal.
|
||||
* @param[in] _args Argument data to emit.
|
||||
*/
|
||||
void emit(const T_ARGS&... _args);
|
||||
protected:
|
||||
/**
|
||||
* @brief Remove observer in the internal list if the user has disconnected
|
||||
* @note Done only if it is the last caller ...
|
||||
*/
|
||||
void removeIfPossible();
|
||||
public:
|
||||
void disconnect(size_t _uid) override;
|
||||
void disconnectShared(const ememory::SharedPtr<void>& _obj) override;
|
||||
size_t size() const override;
|
||||
bool empty() const override;
|
||||
void clear() override;
|
||||
};
|
||||
/**
|
||||
* @brief Basic signal base
|
||||
* @param[in] Args... Argument of the signal
|
||||
*/
|
||||
template<class... T_ARGS>
|
||||
class Signal : public esignal::Base {
|
||||
protected:
|
||||
esignal::Interface* m_signalInterfaceLink; //!< interface of the signal manager.
|
||||
public:
|
||||
/**
|
||||
* @brief Basic constructor with connection observer
|
||||
* @param[in] _countObs Local observer to know the count of connection on the signal.
|
||||
* @param[in] _name Static name of the signal.
|
||||
* @param[in] _description Description of the signal.
|
||||
*/
|
||||
Signal(esignal::BaseInternal::ObserverConnection _countObs=null,
|
||||
const etk::String& _name="",
|
||||
const etk::String& _description="");
|
||||
/**
|
||||
* @brief Basic constructor with connection interface
|
||||
* @param[in] _signalInterfaceLink reference on the signal lister.
|
||||
* @param[in] _name Static name of the signal.
|
||||
* @param[in] _description Description of the signal.
|
||||
*/
|
||||
Signal(esignal::Interface* _signalInterfaceLink,
|
||||
const etk::String& _name,
|
||||
const etk::String& _description);
|
||||
/**
|
||||
* @brief Basic constructor with connection observer
|
||||
* @param[in] _class Class which is associated the function to call.
|
||||
* @param[in] _func Function to call when an observer has connected or disconnected.
|
||||
* @param[in] _name Static name of the signal.
|
||||
* @param[in] _description Description of the signal.
|
||||
*/
|
||||
template<class CLASS_TYPE,
|
||||
class FUNC_TYPE,
|
||||
typename etk::EnableIf<etk::IsBaseOf<esignal::Interface, CLASS_TYPE>::value
|
||||
, int>::type = 0>
|
||||
Signal(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
const etk::String& _name,
|
||||
const etk::String& _description);
|
||||
template<class CLASS_TYPE,
|
||||
class FUNC_TYPE,
|
||||
typename etk::EnableIf<!etk::IsBaseOf<esignal::Interface, CLASS_TYPE>::value
|
||||
, int>::type = 0>
|
||||
Signal(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
const etk::String& _name="",
|
||||
const etk::String& _description="");
|
||||
//! @brief Copy constructor (REMOVED)
|
||||
Signal(const Signal&) = delete;
|
||||
/**
|
||||
* @brief Copy operator (REMOVED)
|
||||
* @return Reference on this
|
||||
*/
|
||||
Signal& operator=(Signal) = delete;
|
||||
/**
|
||||
* @brief Copy operator (REMOVED)
|
||||
* @return Reference on this
|
||||
*/
|
||||
Signal& operator=(const Signal&) = delete;
|
||||
//! @brief Move constructor (REMOVED)
|
||||
Signal(Signal&&) = delete;
|
||||
/**
|
||||
* @brief Move operator (REMOVED)
|
||||
* @return Reference on this
|
||||
*/
|
||||
Signal& operator=(Signal&&) = delete;
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~Signal();
|
||||
public:
|
||||
/**
|
||||
* @brief Connect an observer on the signal.
|
||||
* @param[in] _observer Observer to call.
|
||||
* @return Connection handle (connection is removed if the handle is destroy)
|
||||
*/
|
||||
template< class OBSERVER_TYPE >
|
||||
esignal::Connection connect(OBSERVER_TYPE&& _observer) {
|
||||
if (m_data == null) {
|
||||
return esignal::Connection();
|
||||
}
|
||||
ememory::SharedPtr<esignal::SignalInternal<T_ARGS...>> pointer = ememory::staticPointerCast<esignal::SignalInternal<T_ARGS...>>(m_data);
|
||||
return pointer->connect(etk::forward<OBSERVER_TYPE>(_observer));
|
||||
}
|
||||
/**
|
||||
* @brief Connect an function member on the signal.
|
||||
* @param[in] _class Object on whe we need to call.
|
||||
* @param[in] _func Function to call.
|
||||
* @param[in] _args Argument optinnal the user want to add.
|
||||
* @return Connection handle (connection is removed if the handle is destroy)
|
||||
*/
|
||||
template<class CLASS_TYPE, class FUNC_TYPE, class... FUNC_ARGS_TYPE>
|
||||
esignal::Connection connect(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
FUNC_ARGS_TYPE... _args) {
|
||||
if (m_data == null) {
|
||||
return esignal::Connection();
|
||||
}
|
||||
ememory::SharedPtr<esignal::SignalInternal<T_ARGS...>> pointer = ememory::staticPointerCast<esignal::SignalInternal<T_ARGS...>>(m_data);
|
||||
return pointer->connect(_class, _func, etk::forward<FUNC_ARGS_TYPE>(_args)...);
|
||||
}
|
||||
/**
|
||||
* @brief Connect an function member on the signal with the shared_ptr object.
|
||||
* @param[in] _class shared_ptr Object on whe we need to call ==> the object is get in keeped in weak_ptr.
|
||||
* @param[in] _func Function to call.
|
||||
* @param[in] _args Argument optinnal the user want to add.
|
||||
*/
|
||||
template<class PARENT_CLASS_TYPE, class CLASS_TYPE, typename... FUNC_ARGS_TYPE>
|
||||
void connect(const ememory::SharedPtr<PARENT_CLASS_TYPE>& _class,
|
||||
void (CLASS_TYPE::*_func)(const T_ARGS&..., FUNC_ARGS_TYPE...),
|
||||
FUNC_ARGS_TYPE... _args) {
|
||||
if (m_data == null) {
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<esignal::SignalInternal<T_ARGS...>> pointer = ememory::staticPointerCast<esignal::SignalInternal<T_ARGS...>>(m_data);
|
||||
return pointer->connect(_class, _func, etk::forward<FUNC_ARGS_TYPE>(_args)...);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Emit data on the signal.
|
||||
* @param[in] _args Argument data to emit.
|
||||
*/
|
||||
void emit(const T_ARGS&... _args) {
|
||||
if (m_data == null) {
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<esignal::SignalInternal<T_ARGS...>> pointer = ememory::staticPointerCast<esignal::SignalInternal<T_ARGS...>>(m_data);
|
||||
return pointer->emit(etk::forward<const T_ARGS&>(_args)...);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Disconnect the shared_ptr form the Signal
|
||||
* @param[in] _obj Link with the object to check
|
||||
*/
|
||||
void disconnectShared(const ememory::SharedPtr<void>& _obj) override {
|
||||
if (m_data == null) {
|
||||
return;;
|
||||
}
|
||||
m_data->disconnectShared(_obj);
|
||||
}
|
||||
/**
|
||||
* @brief Get the number of observers connected on the signal.
|
||||
* @return The count of observer.
|
||||
*/
|
||||
size_t size() const {
|
||||
if (m_data == null) {
|
||||
return 0;
|
||||
}
|
||||
return m_data->size();
|
||||
}
|
||||
/**
|
||||
* @brief Check if we have a connected observers.
|
||||
* @return true More than one observers.
|
||||
* @return false No observers.
|
||||
*/
|
||||
bool empty() const {
|
||||
if (m_data == null) {
|
||||
return true;
|
||||
}
|
||||
return m_data->empty();
|
||||
}
|
||||
/**
|
||||
* @brief Clear all connectd observers.
|
||||
*/
|
||||
void clear() {
|
||||
if (m_data == null) {
|
||||
return;
|
||||
}
|
||||
m_data->clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
template<class... T_ARGS>
|
||||
template<class OBSERVER_TYPE >
|
||||
esignal::Connection esignal::SignalInternal<T_ARGS...>::connect(OBSERVER_TYPE&& _observer ) {
|
||||
ESIGNAL_DEBUG("esignal: '" << getName() << "' try connect: '" << getName() << "' (observer)");
|
||||
ememory::UniquePtr<Executor> executer(ETK_NEW(Executor, etk::forward<OBSERVER_TYPE>(_observer)));
|
||||
size_t uid = executer->m_uid;
|
||||
m_executors.pushBack(etk::move(executer));
|
||||
if (m_connectionObserver!=null) {
|
||||
m_connectionObserver(m_executors.size());
|
||||
}
|
||||
ESIGNAL_DEBUG(" '" << getName() << "' new count: " << m_executors.size());
|
||||
return esignal::Connection(sharedFromThis(), uid);
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
template<class CLASS_TYPE, class FUNC_TYPE, class... FUNC_ARGS_TYPE>
|
||||
esignal::Connection esignal::SignalInternal<T_ARGS...>::connect(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
FUNC_ARGS_TYPE... _arg) {
|
||||
ESIGNAL_DEBUG("esignal: '" << getName() << "' try connect: '" << getName() << "' (reference)");
|
||||
if (_class == null) {
|
||||
ESIGNAL_ERROR(" '" << getName() << "' Class pointer in null");
|
||||
return esignal::Connection();
|
||||
}
|
||||
ememory::UniquePtr<Executor> executer(ETK_NEW(Executor, [=](const T_ARGS& ... _argBase){
|
||||
(*_class.*_func)(_argBase..., _arg... );
|
||||
}));
|
||||
size_t uid = executer->m_uid;
|
||||
m_executors.pushBack(etk::move(executer));
|
||||
if (m_connectionObserver != null) {
|
||||
m_connectionObserver(m_executors.size());
|
||||
}
|
||||
ESIGNAL_DEBUG(" '" << getName() << "' new count: " << m_executors.size());
|
||||
return Connection(sharedFromThis(), uid);
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
template<class PARENT_CLASS_TYPE, class CLASS_TYPE, typename... FUNC_ARGS_TYPE>
|
||||
void esignal::SignalInternal<T_ARGS...>::connect(const ememory::SharedPtr<PARENT_CLASS_TYPE>& _class,
|
||||
void (CLASS_TYPE::*_func)(const T_ARGS&..., FUNC_ARGS_TYPE...),
|
||||
FUNC_ARGS_TYPE... _args) {
|
||||
ESIGNAL_DEBUG("esignal: '" << getName() << "' try connect: '" << getName() << "' (weak pointer)");
|
||||
if (_class == null) {
|
||||
ESIGNAL_ERROR(" '" << getName() << "' Class pointer in null");
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<CLASS_TYPE> obj2 = ememory::dynamicPointerCast<CLASS_TYPE>(_class);
|
||||
if (obj2 == null) {
|
||||
ESIGNAL_ERROR("Can not connect signal ...");
|
||||
return;
|
||||
}
|
||||
CLASS_TYPE* directPointer = obj2.get();
|
||||
ememory::UniquePtr<Executor> executer(ETK_NEW(ExecutorShared, _class, [=]( const T_ARGS& ... _argBase){
|
||||
// TODO : Check if compilator does not use the shared ptr ...
|
||||
(*directPointer.*_func)(_argBase..., _args... );
|
||||
}));
|
||||
m_executors.pushBack(etk::move(executer));
|
||||
if (m_connectionObserver!=null) {
|
||||
m_connectionObserver(m_executors.size());
|
||||
}
|
||||
ESIGNAL_DEBUG(" '" << getName() << "' new count: " << m_executors.size());
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
template<class CLASS_TYPE,
|
||||
class FUNC_TYPE,
|
||||
typename etk::EnableIf<etk::IsBaseOf<esignal::Interface, CLASS_TYPE>::value
|
||||
, int>::type>
|
||||
esignal::Signal<T_ARGS...>::Signal(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
const etk::String& _name,
|
||||
const etk::String& _description):
|
||||
m_signalInterfaceLink(null) {
|
||||
// nothing to do
|
||||
if (_func != null) {
|
||||
esignal::Base::m_data = ememory::makeShared<esignal::SignalInternal<T_ARGS...>>([=](size_t _val){(*_class.*_func)(_val);});
|
||||
} else {
|
||||
esignal::Base::m_data = ememory::makeShared<esignal::SignalInternal<T_ARGS...>>(null);
|
||||
}
|
||||
if (esignal::Base::m_data != null) {
|
||||
esignal::Base::m_data->setName(_name);
|
||||
esignal::Base::m_data->setDescription(_description);
|
||||
}
|
||||
m_signalInterfaceLink = _class;
|
||||
// add a reference on the current signal ...
|
||||
if (m_signalInterfaceLink != null) {
|
||||
m_signalInterfaceLink->signals.add(this);
|
||||
}
|
||||
}
|
||||
template<class... T_ARGS>
|
||||
template<class CLASS_TYPE,
|
||||
class FUNC_TYPE,
|
||||
typename etk::EnableIf<!etk::IsBaseOf<esignal::Interface, CLASS_TYPE>::value
|
||||
, int>::type>
|
||||
esignal::Signal<T_ARGS...>::Signal(CLASS_TYPE* _class,
|
||||
FUNC_TYPE _func,
|
||||
const etk::String& _name,
|
||||
const etk::String& _description):
|
||||
m_signalInterfaceLink(null) {
|
||||
// nothing to do
|
||||
if (_func != null) {
|
||||
esignal::Base::m_data = ememory::makeShared<esignal::SignalInternal<T_ARGS...>>([=](size_t _val){(*_class.*_func)(_val);});
|
||||
} else {
|
||||
esignal::Base::m_data = ememory::makeShared<esignal::SignalInternal<T_ARGS...>>(null);
|
||||
}
|
||||
if (esignal::Base::m_data != null) {
|
||||
esignal::Base::m_data->setName(_name);
|
||||
esignal::Base::m_data->setDescription(_description);
|
||||
}
|
||||
}
|
||||
|
||||
#define ESIGNAL_DECLARE_SIGNAL(...) \
|
||||
template class esignal::Signal<__VA_ARGS__>; \
|
||||
template class esignal::SignalInternal<__VA_ARGS__>;
|
||||
|
@@ -1,12 +1,10 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/debug.hpp>
|
||||
|
||||
int32_t esignal::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("esignal");
|
||||
|
@@ -1,13 +1,11 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.h>
|
||||
#include <elog/log.hpp>
|
||||
|
||||
namespace esignal {
|
||||
int32_t getLogId();
|
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <esignal/details/ISignal.hxx>
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/Color.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ISignal<void>"
|
||||
// void generic signal
|
||||
template class esignal::ISignal<>;
|
||||
// std generic signal
|
||||
template class esignal::ISignal<bool>;
|
||||
template class esignal::ISignal<std::string>;
|
||||
#if __CPP_VERSION__ >= 2011
|
||||
template class esignal::ISignal<std::u32string>;
|
||||
#endif
|
||||
|
||||
template class esignal::ISignal<int64_t>;
|
||||
template class esignal::ISignal<int32_t>;
|
||||
template class esignal::ISignal<int16_t>;
|
||||
template class esignal::ISignal<int8_t>;
|
||||
|
||||
template class esignal::ISignal<uint64_t>;
|
||||
template class esignal::ISignal<uint32_t>;
|
||||
template class esignal::ISignal<uint16_t>;
|
||||
template class esignal::ISignal<uint8_t>;
|
||||
|
||||
template class esignal::ISignal<float>;
|
||||
template class esignal::ISignal<double>;
|
||||
// etk generic vetor 2D
|
||||
template class esignal::ISignal<vec2>;
|
||||
template class esignal::ISignal<bvec2>;
|
||||
template class esignal::ISignal<ivec2>;
|
||||
template class esignal::ISignal<uivec2>;
|
||||
// etk generic vetor 3D
|
||||
template class esignal::ISignal<vec3>;
|
||||
template class esignal::ISignal<bvec3>;
|
||||
template class esignal::ISignal<ivec3>;
|
||||
template class esignal::ISignal<uivec3>;
|
||||
// etk generic color
|
||||
template class esignal::ISignal<etk::Color<unsigned char,4>>;
|
||||
template class esignal::ISignal<etk::Color<unsigned char,3>>;
|
||||
template class esignal::ISignal<etk::Color<float,4>>;
|
||||
template class esignal::ISignal<etk::Color<float,3>>;
|
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <esignal/ISignal.h>
|
||||
#include <esignal/details/Signal.hxx>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ISignal<T_ARGS>"
|
||||
|
||||
template<class... T_ARGS>
|
||||
esignal::ISignal<T_ARGS...>::ISignal(esignal::Interface* _signalInterfaceLink,
|
||||
const std::string& _name,
|
||||
const std::string& _description):
|
||||
m_signalInterfaceLink(_signalInterfaceLink),
|
||||
m_name(_name),
|
||||
m_description(_description) {
|
||||
// add a reference on the current signal ...
|
||||
if (m_signalInterfaceLink != nullptr) {
|
||||
m_signalInterfaceLink->signalAdd(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
esignal::ISignal<T_ARGS...>::~ISignal() {
|
||||
if (m_signalInterfaceLink != nullptr) {
|
||||
m_signalInterfaceLink->signalRemove(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
const std::string& esignal::ISignal<T_ARGS...>::getName() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
const std::string& esignal::ISignal<T_ARGS...>::getDescription() const {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
||||
|
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/details/LockSharedPtrRef.hxx>
|
||||
#include <esignal/Base.h>
|
||||
|
||||
// only one really needed ...
|
||||
template class esignal::LockSharedPtrRef<esignal::Base>;
|
||||
|
||||
|
@@ -1,117 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esignal/LockSharedPtrRef.h>
|
||||
#include <esignal/debug.h>
|
||||
|
||||
template<class TYPE>
|
||||
esignal::LockSharedPtrRef<TYPE>::LockSharedPtrRef(TYPE* _pointer) :
|
||||
m_counter(nullptr) {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef new [START] " << int64_t(_pointer));
|
||||
if (_pointer != nullptr) {
|
||||
m_counter = new RefCount<TYPE>(_pointer);
|
||||
m_counter->inc();
|
||||
}
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef new [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
esignal::LockSharedPtrRef<TYPE>::LockSharedPtrRef(const LockSharedPtrRef<TYPE>& _obj) :
|
||||
m_counter(_obj.m_counter) {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef new [START] ref ...");
|
||||
if (m_counter == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_counter->inc();
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef new [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
esignal::LockSharedPtrRef<TYPE>& esignal::LockSharedPtrRef<TYPE>::operator=(const esignal::LockSharedPtrRef<TYPE>& _obj) {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef copy [START]");
|
||||
if (&_obj == this) {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef copy [STOP] auto-copy");
|
||||
return *this;
|
||||
}
|
||||
if (m_counter != nullptr) {
|
||||
m_counter->dec();
|
||||
m_counter = nullptr;
|
||||
}
|
||||
m_counter = _obj.m_counter;
|
||||
if (m_counter == nullptr) {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef copy [STOP] no counter");
|
||||
return *this;
|
||||
}
|
||||
m_counter->inc();
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef copy [STOP]");
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
esignal::LockSharedPtrRef<TYPE>::LockSharedPtrRef(LockSharedPtrRef<TYPE>&& _obj) :
|
||||
m_counter(std::move(_obj.m_counter)) {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef move [DONE]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
esignal::LockSharedPtrRef<TYPE>::~LockSharedPtrRef() {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef delete [START]");
|
||||
rmShared();
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef delete [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void esignal::LockSharedPtrRef<TYPE>::rmShared() {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef rmShared [START]");
|
||||
if (m_counter == nullptr) {
|
||||
return;
|
||||
}
|
||||
int64_t count = m_counter->dec();
|
||||
if (count > 0) {
|
||||
m_counter = nullptr;
|
||||
return;
|
||||
}
|
||||
delete m_counter;
|
||||
m_counter = nullptr;
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef rmShared [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void esignal::LockSharedPtrRef<TYPE>::removeData() {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef removeData [START]");
|
||||
if (m_counter != nullptr) {
|
||||
m_counter->remove();
|
||||
}
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef removeData [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void esignal::LockSharedPtrRef<TYPE>::disconnect(std::size_t _uid) {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef disconnect [START] " << _uid);
|
||||
if (m_counter == nullptr) {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef disconnect [STOP] No counter");
|
||||
return;
|
||||
}
|
||||
m_counter->lock();
|
||||
TYPE* val = m_counter->get();
|
||||
if (val != nullptr) {
|
||||
val->disconnect(_uid);
|
||||
}
|
||||
m_counter->unlock();
|
||||
rmShared();
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef disconnect [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
bool esignal::LockSharedPtrRef<TYPE>::isAlive() {
|
||||
ESIGNAL_VERBOSE("LockSharedPtrRef isAlive [DONE] ");
|
||||
return m_counter != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <esignal/debug.h>
|
||||
#include <esignal/details/RefCount.hxx>
|
||||
#include <esignal/Base.h>
|
||||
|
||||
// only one really needed ...
|
||||
template class esignal::RefCount<esignal::Base>;
|
||||
|
||||
|
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <esignal/RefCount.h>
|
||||
#include <esignal/debug.h>
|
||||
|
||||
template<class TYPE>
|
||||
esignal::RefCount<TYPE>::RefCount(TYPE* _data) :
|
||||
m_count(0),
|
||||
m_data(_data) {
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount New : " << int64_t(_data));
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
esignal::RefCount<TYPE>::~RefCount() {
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount delete");
|
||||
m_data = nullptr;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void esignal::RefCount<TYPE>::lock() {
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount LOCK [START]");
|
||||
m_lock.lock();
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount LOCK [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void esignal::RefCount<TYPE>::unlock() {
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount UN-LOCK [START]");
|
||||
m_lock.unlock();
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount UN-LOCK [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void esignal::RefCount<TYPE>::inc() {
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount INC [START] " << m_count);
|
||||
lock();
|
||||
m_count++;
|
||||
unlock();
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount INC [STOP] " << m_count);
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
int64_t esignal::RefCount<TYPE>::dec() {
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount DEC [START] " << m_count);
|
||||
int64_t val;
|
||||
lock();
|
||||
m_count--;
|
||||
val = m_count;
|
||||
unlock();
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount DEC [STOP] " << m_count);
|
||||
return val;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
int64_t esignal::RefCount<TYPE>::getCount() const {
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount get count " << m_count);
|
||||
return m_count;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void esignal::RefCount<TYPE>::remove() {
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount remove [START]");
|
||||
lock();
|
||||
m_data = nullptr;
|
||||
unlock();
|
||||
ESIGNAL_VERBOSE(int64_t(this) << " RefCount remove [STOP]");
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
TYPE* esignal::RefCount<TYPE>::get() {
|
||||
return m_data;
|
||||
}
|
@@ -1,51 +1,68 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <esignal/details/Signal.hxx>
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/Color.h>
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/math/Vector2D.hpp>
|
||||
#include <etk/math/Vector3D.hpp>
|
||||
#include <etk/math/Quaternion.hpp>
|
||||
#include <etk/math/Transform3D.hpp>
|
||||
#include <etk/Color.hpp>
|
||||
#include <etk/path/Path.hpp>
|
||||
#include <etk/uri/Uri.hpp>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Signal<void>"
|
||||
// void generic signal
|
||||
template class esignal::Signal<>;
|
||||
ESIGNAL_DECLARE_SIGNAL();
|
||||
// std generic signal
|
||||
template class esignal::Signal<bool>;
|
||||
template class esignal::Signal<std::string>;
|
||||
ESIGNAL_DECLARE_SIGNAL(bool);
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::String);
|
||||
#if __CPP_VERSION__ >= 2011
|
||||
template class esignal::Signal<std::u32string>;
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::UString);
|
||||
#endif
|
||||
|
||||
template class esignal::Signal<int64_t>;
|
||||
template class esignal::Signal<int32_t>;
|
||||
template class esignal::Signal<int16_t>;
|
||||
template class esignal::Signal<int8_t>;
|
||||
ESIGNAL_DECLARE_SIGNAL(int64_t);
|
||||
ESIGNAL_DECLARE_SIGNAL(int32_t);
|
||||
ESIGNAL_DECLARE_SIGNAL(int16_t);
|
||||
ESIGNAL_DECLARE_SIGNAL(int8_t);
|
||||
|
||||
template class esignal::Signal<uint64_t>;
|
||||
template class esignal::Signal<uint32_t>;
|
||||
template class esignal::Signal<uint16_t>;
|
||||
template class esignal::Signal<uint8_t>;
|
||||
ESIGNAL_DECLARE_SIGNAL(uint64_t);
|
||||
ESIGNAL_DECLARE_SIGNAL(uint32_t);
|
||||
ESIGNAL_DECLARE_SIGNAL(uint16_t);
|
||||
ESIGNAL_DECLARE_SIGNAL(uint8_t);
|
||||
|
||||
template class esignal::Signal<float>;
|
||||
template class esignal::Signal<double>;
|
||||
// etk generic vetor 2D
|
||||
template class esignal::Signal<vec2>;
|
||||
template class esignal::Signal<bvec2>;
|
||||
template class esignal::Signal<ivec2>;
|
||||
template class esignal::Signal<uivec2>;
|
||||
// etk generic vetor 3D
|
||||
template class esignal::Signal<vec3>;
|
||||
template class esignal::Signal<bvec3>;
|
||||
template class esignal::Signal<ivec3>;
|
||||
template class esignal::Signal<uivec3>;
|
||||
ESIGNAL_DECLARE_SIGNAL(float);
|
||||
ESIGNAL_DECLARE_SIGNAL(double);
|
||||
// etk generic vector 2D
|
||||
ESIGNAL_DECLARE_SIGNAL(vec2);
|
||||
ESIGNAL_DECLARE_SIGNAL(bvec2);
|
||||
ESIGNAL_DECLARE_SIGNAL(ivec2);
|
||||
ESIGNAL_DECLARE_SIGNAL(uivec2);
|
||||
// etk generic vector 3D
|
||||
ESIGNAL_DECLARE_SIGNAL(vec3);
|
||||
ESIGNAL_DECLARE_SIGNAL(bvec3);
|
||||
ESIGNAL_DECLARE_SIGNAL(ivec3);
|
||||
ESIGNAL_DECLARE_SIGNAL(uivec3);
|
||||
// etk generic 3D elements
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::Quaternion);
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::Transform3D);
|
||||
// etk generic color
|
||||
template class esignal::Signal<etk::Color<unsigned char,4>>;
|
||||
template class esignal::Signal<etk::Color<unsigned char,3>>;
|
||||
template class esignal::Signal<etk::Color<float,4>>;
|
||||
template class esignal::Signal<etk::Color<float,3>>;
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::Color<unsigned char,4>);
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::Color<unsigned char,3>);
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::Color<float,4>);
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::Color<float,3>);
|
||||
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::Path);
|
||||
ESIGNAL_DECLARE_SIGNAL(etk::Uri);
|
||||
|
||||
#ifdef ESIGNAL_BUILD_WITH_ECHRONO
|
||||
#include <echrono/Clock.hpp>
|
||||
#include <echrono/Duration.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <echrono/Time.hpp>
|
||||
ESIGNAL_DECLARE_SIGNAL(echrono::Clock);
|
||||
ESIGNAL_DECLARE_SIGNAL(echrono::Duration);
|
||||
ESIGNAL_DECLARE_SIGNAL(echrono::Steady);
|
||||
ESIGNAL_DECLARE_SIGNAL(echrono::Time);
|
||||
#endif
|
||||
|
@@ -1,43 +1,73 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <esignal/Signal.h>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Signal<T_ARGS>"
|
||||
|
||||
template<typename... T_ARGS>
|
||||
esignal::Signal<T_ARGS...>::Signal(ObserverConnection _countObs):
|
||||
esignal::Base(_countObs),
|
||||
m_callInProgress(0) {
|
||||
// nothing to do
|
||||
template<class... T_ARGS>
|
||||
esignal::Signal<T_ARGS...>::~Signal() {
|
||||
if (m_signalInterfaceLink != null) {
|
||||
m_signalInterfaceLink->signals.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
esignal::Signal<T_ARGS...>::Signal(esignal::BaseInternal::ObserverConnection _countObs,
|
||||
const etk::String& _name,
|
||||
const etk::String& _description):
|
||||
esignal::Base(),
|
||||
m_signalInterfaceLink(null) {
|
||||
// create internal data assiciated:
|
||||
m_data = ememory::makeShared<esignal::SignalInternal<T_ARGS...>>(etk::move(_countObs));
|
||||
if (esignal::Base::m_data != null) {
|
||||
esignal::Base::m_data->setName(_name);
|
||||
esignal::Base::m_data->setDescription(_description);
|
||||
}
|
||||
}
|
||||
|
||||
template<class... T_ARGS>
|
||||
esignal::Signal<T_ARGS...>::Signal(esignal::Interface* _signalInterfaceLink,
|
||||
const etk::String& _name,
|
||||
const etk::String& _description):
|
||||
m_signalInterfaceLink(_signalInterfaceLink) {
|
||||
// create internal data assiciated:
|
||||
m_data = ememory::makeShared<esignal::SignalInternal<T_ARGS...>>(null);
|
||||
if (esignal::Base::m_data != null) {
|
||||
esignal::Base::m_data->setName(_name);
|
||||
esignal::Base::m_data->setDescription(_description);
|
||||
}
|
||||
// add a reference on the current signal ...
|
||||
if (m_signalInterfaceLink != null) {
|
||||
m_signalInterfaceLink->signals.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
void esignal::Signal<T_ARGS...>::emit(const T_ARGS&... _args) {
|
||||
void esignal::SignalInternal<T_ARGS...>::emit(const T_ARGS&... _args) {
|
||||
#ifdef DEBUG
|
||||
int32_t tmpID = s_uidSignalEmit++;
|
||||
#endif
|
||||
// TODO : Add protection ... but how ...
|
||||
m_callInProgress++;
|
||||
ESIGNAL_DEBUG(esignal::logIndent(m_callInProgress-1) << " signal{" << tmpID << "} : '" << getName() << "' ***/" << m_executors.size());
|
||||
for (size_t iii=0; iii < m_executors.size(); ++iii) {
|
||||
ESIGNAL_VERBOSE(esignal::logIndent(m_callInProgress-1) << " {" << tmpID << "} : " << iii);
|
||||
m_executors[iii]->emit(_args...);
|
||||
if (m_periodic == false) {
|
||||
ESIGNAL_DEBUG(esignal::logIndent(m_callInProgress-1) << " signal{" << tmpID << "} : '" << getName() << "' ***/" << m_executors.size());
|
||||
for (size_t iii=0; iii < m_executors.size(); ++iii) {
|
||||
ESIGNAL_VERBOSE(esignal::logIndent(m_callInProgress-1) << " {" << tmpID << "} : " << iii);
|
||||
m_executors[iii]->emit(_args...);
|
||||
}
|
||||
} else {
|
||||
for (size_t iii=0; iii < m_executors.size(); ++iii) {
|
||||
m_executors[iii]->emit(_args...);
|
||||
}
|
||||
}
|
||||
if (m_callInProgress == 1) {
|
||||
bool haveRemove = false;
|
||||
auto it = m_executors.begin();
|
||||
while (it != m_executors.end()) {
|
||||
if ( *it == nullptr
|
||||
if ( *it == null
|
||||
|| (*it)->m_removed == true) {
|
||||
it = m_executors.erase(it);
|
||||
haveRemove = true;
|
||||
@@ -46,7 +76,7 @@ void esignal::Signal<T_ARGS...>::emit(const T_ARGS&... _args) {
|
||||
++it;
|
||||
}
|
||||
if (haveRemove == true) {
|
||||
if (m_connectionObserver!=nullptr) {
|
||||
if (m_connectionObserver!=null) {
|
||||
m_connectionObserver(m_executors.size());
|
||||
}
|
||||
}
|
||||
@@ -55,14 +85,14 @@ void esignal::Signal<T_ARGS...>::emit(const T_ARGS&... _args) {
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
void esignal::Signal<T_ARGS...>::removeIfPossible() {
|
||||
void esignal::SignalInternal<T_ARGS...>::removeIfPossible() {
|
||||
if (m_callInProgress != 0) {
|
||||
return;
|
||||
}
|
||||
bool haveRemove = false;
|
||||
auto it = m_executors.begin();
|
||||
while (it != m_executors.end()) {
|
||||
if ( *it == nullptr
|
||||
if ( *it == null
|
||||
|| (*it)->m_removed == true) {
|
||||
it = m_executors.erase(it);
|
||||
haveRemove = true;
|
||||
@@ -71,14 +101,14 @@ void esignal::Signal<T_ARGS...>::removeIfPossible() {
|
||||
++it;
|
||||
}
|
||||
if (haveRemove == true) {
|
||||
if (m_connectionObserver!=nullptr) {
|
||||
if (m_connectionObserver!=null) {
|
||||
m_connectionObserver(m_executors.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
void esignal::Signal<T_ARGS...>::disconnect(std::size_t _uid) {
|
||||
void esignal::SignalInternal<T_ARGS...>::disconnect(size_t _uid) {
|
||||
for (size_t iii=0; iii < m_executors.size(); ++iii) {
|
||||
if (m_executors[iii]->m_uid == _uid) {
|
||||
m_executors[iii]->m_removed = true;
|
||||
@@ -89,7 +119,7 @@ void esignal::Signal<T_ARGS...>::disconnect(std::size_t _uid) {
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
void esignal::Signal<T_ARGS...>::disconnectShared(const std::shared_ptr<void>& _obj) {
|
||||
void esignal::SignalInternal<T_ARGS...>::disconnectShared(const ememory::SharedPtr<void>& _obj) {
|
||||
for (size_t iii=0; iii < m_executors.size(); ++iii) {
|
||||
if (m_executors[iii]->isSharedPtr(_obj) == true) {
|
||||
m_executors[iii]->m_removed = true;
|
||||
@@ -99,17 +129,17 @@ void esignal::Signal<T_ARGS...>::disconnectShared(const std::shared_ptr<void>& _
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
size_t esignal::Signal<T_ARGS...>::size() const {
|
||||
size_t esignal::SignalInternal<T_ARGS...>::size() const {
|
||||
return m_executors.size();
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
bool esignal::Signal<T_ARGS...>::empty() const {
|
||||
bool esignal::SignalInternal<T_ARGS...>::empty() const {
|
||||
return m_executors.empty();
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
void esignal::Signal<T_ARGS...>::clear() {
|
||||
void esignal::SignalInternal<T_ARGS...>::clear() {
|
||||
for (size_t iii=0; iii < m_executors.size(); ++iii) {
|
||||
m_executors[iii]->m_removed = true;
|
||||
}
|
||||
@@ -118,15 +148,15 @@ void esignal::Signal<T_ARGS...>::clear() {
|
||||
|
||||
|
||||
template<typename... T_ARGS>
|
||||
esignal::Signal<T_ARGS...>::Executor::Executor(Observer&& _observer):
|
||||
esignal::SignalInternal<T_ARGS...>::Executor::Executor(Observer&& _observer):
|
||||
m_removed(false),
|
||||
m_uid(0) {
|
||||
m_uid = s_uid++;
|
||||
m_observer = std::move(_observer);
|
||||
m_observer = etk::move(_observer);
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
void esignal::Signal<T_ARGS...>::Executor::emit(const T_ARGS&... _values) {
|
||||
void esignal::SignalInternal<T_ARGS...>::Executor::emit(const T_ARGS&... _values) {
|
||||
if (m_removed == true) {
|
||||
return;
|
||||
}
|
||||
@@ -138,7 +168,7 @@ void esignal::Signal<T_ARGS...>::Executor::emit(const T_ARGS&... _values) {
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
bool esignal::Signal<T_ARGS...>::Executor::isSharedPtr(const std::shared_ptr<void>& _obj) {
|
||||
bool esignal::SignalInternal<T_ARGS...>::Executor::isSharedPtr(const ememory::SharedPtr<void>& _obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,17 +176,17 @@ bool esignal::Signal<T_ARGS...>::Executor::isSharedPtr(const std::shared_ptr<voi
|
||||
|
||||
|
||||
template<typename... T_ARGS>
|
||||
esignal::Signal<T_ARGS...>::ExecutorShared::ExecutorShared(std::weak_ptr<void> _object, Observer&& _observer) :
|
||||
Executor(std::move(_observer)),
|
||||
esignal::SignalInternal<T_ARGS...>::ExecutorShared::ExecutorShared(ememory::WeakPtr<void> _object, Observer&& _observer) :
|
||||
Executor(etk::move(_observer)),
|
||||
m_object(_object) {
|
||||
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
void esignal::Signal<T_ARGS...>::ExecutorShared::emit(const T_ARGS&... _values) {
|
||||
void esignal::SignalInternal<T_ARGS...>::ExecutorShared::emit(const T_ARGS&... _values) {
|
||||
// TODO: maybe an error if the object is not manage by the same thread.
|
||||
std::shared_ptr<void> destObject = m_object.lock();
|
||||
if (destObject == nullptr) {
|
||||
ememory::SharedPtr<void> destObject = m_object.lock();
|
||||
if (destObject == null) {
|
||||
Executor::m_removed = true;
|
||||
return;
|
||||
}
|
||||
@@ -171,9 +201,9 @@ void esignal::Signal<T_ARGS...>::ExecutorShared::emit(const T_ARGS&... _values)
|
||||
}
|
||||
|
||||
template<typename... T_ARGS>
|
||||
bool esignal::Signal<T_ARGS...>::ExecutorShared::isSharedPtr(const std::shared_ptr<void>& _obj) {
|
||||
std::shared_ptr<void> destObject = m_object.lock();
|
||||
if (destObject == nullptr) {
|
||||
bool esignal::SignalInternal<T_ARGS...>::ExecutorShared::isSharedPtr(const ememory::SharedPtr<void>& _obj) {
|
||||
ememory::SharedPtr<void> destObject = m_object.lock();
|
||||
if (destObject == null) {
|
||||
return true;
|
||||
}
|
||||
if (destObject == _obj) {
|
||||
@@ -181,8 +211,3 @@ bool esignal::Signal<T_ARGS...>::ExecutorShared::isSharedPtr(const std::shared_p
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
||||
|
||||
|
||||
|
35
lutin_esignal-sample.py
Normal file
35
lutin_esignal-sample.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/python
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
|
||||
def get_type():
|
||||
return "BINARY"
|
||||
|
||||
def get_sub_type():
|
||||
return "SAMPLE"
|
||||
|
||||
def get_desc():
|
||||
return "e-signal sample 1"
|
||||
|
||||
def get_licence():
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
||||
def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return "authors.txt"
|
||||
|
||||
def configure(target, my_module):
|
||||
my_module.add_src_file([
|
||||
'sample/sampleAll.cpp'
|
||||
])
|
||||
my_module.add_depend([
|
||||
'esignal',
|
||||
'test-debug'
|
||||
])
|
||||
return True
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
import datetime
|
||||
|
||||
|
||||
def get_type():
|
||||
@@ -14,7 +13,7 @@ def get_desc():
|
||||
return "e-signal test software"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@@ -23,20 +22,23 @@ def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
return "authors.txt"
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
def configure(target, my_module):
|
||||
my_module.add_src_file([
|
||||
'test/main.cpp',
|
||||
'test/declareSignals.cpp',
|
||||
'test/test_signal_counter.cpp',
|
||||
'test/test_signal_class_func.cpp',
|
||||
'test/test_signal_recursive.cpp',
|
||||
'test/test_signal_shared_ptr_func.cpp',
|
||||
'test/test_signal_static_func.cpp',
|
||||
'test/test_isignal.cpp'
|
||||
])
|
||||
my_module.add_module_depend(['esignal', 'gtest', 'test-debug'])
|
||||
return my_module
|
||||
'test/main.cpp',
|
||||
'test/declareSignals.cpp',
|
||||
'test/test_signal_counter.cpp',
|
||||
'test/test_signal_class_func.cpp',
|
||||
'test/test_signal_recursive.cpp',
|
||||
'test/test_signal_shared_ptr_func.cpp',
|
||||
'test/test_signal_static_func.cpp',
|
||||
'test/test_isignal.cpp'
|
||||
])
|
||||
my_module.add_depend([
|
||||
'esignal',
|
||||
'etest',
|
||||
'test-debug'
|
||||
])
|
||||
return True
|
||||
|
||||
|
@@ -1,9 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import lutin.tools as tools
|
||||
import lutin.debug as debug
|
||||
import os
|
||||
import lutin.multiprocess as lutinMultiprocess
|
||||
import realog.debug as debug
|
||||
|
||||
|
||||
def get_type():
|
||||
@@ -13,7 +10,7 @@ def get_desc():
|
||||
return "esignal is signal management for all class"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@@ -22,44 +19,39 @@ def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
return "authors.txt"
|
||||
|
||||
def get_version():
|
||||
return [0,1,"dev"]
|
||||
return "version.txt"
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_extra_compile_flags()
|
||||
def configure(target, my_module):
|
||||
my_module.add_extra_flags()
|
||||
my_module.add_src_file([
|
||||
'esignal/debug.cpp',
|
||||
'esignal/Connection.cpp',
|
||||
'esignal/Interface.cpp',
|
||||
'esignal/Base.cpp',
|
||||
'esignal/details/LockSharedPtrRef.cpp',
|
||||
'esignal/details/RefCount.cpp',
|
||||
'esignal/details/Signal.cpp',
|
||||
'esignal/details/ISignal.cpp',
|
||||
])
|
||||
'esignal/debug.cpp',
|
||||
'esignal/Connection.cpp',
|
||||
'esignal/InterfaceData.cpp',
|
||||
'esignal/Base.cpp',
|
||||
'esignal/details/Signal.cpp',
|
||||
])
|
||||
my_module.add_header_file([
|
||||
'esignal/debug.h',
|
||||
'esignal/Interface.h',
|
||||
'esignal/Base.h',
|
||||
'esignal/Signal.h',
|
||||
'esignal/ISignal.h',
|
||||
'esignal/LockSharedPtrRef.h',
|
||||
'esignal/RefCount.h',
|
||||
'esignal/Connection.h',
|
||||
'esignal/details/Signal.hxx',
|
||||
'esignal/details/ISignal.hxx',
|
||||
'esignal/details/LockSharedPtrRef.hxx',
|
||||
'esignal/details/RefCount.hxx',
|
||||
])
|
||||
'esignal/debug.hpp',
|
||||
'esignal/Interface.hpp',
|
||||
'esignal/InterfaceData.hpp',
|
||||
'esignal/Base.hpp',
|
||||
'esignal/Signal.hpp',
|
||||
'esignal/Connection.hpp',
|
||||
'esignal/details/Signal.hxx',
|
||||
])
|
||||
my_module.compile_version("c++", 2011)
|
||||
my_module.add_module_depend(['etk'])
|
||||
my_module.add_path(tools.get_current_path(__file__))
|
||||
my_module.compile_flags('c++', [
|
||||
my_module.add_depend([
|
||||
'etk',
|
||||
'ememory'
|
||||
])
|
||||
my_module.add_path(".")
|
||||
my_module.add_flag('c++', [
|
||||
"-DESIGNAL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
|
||||
])
|
||||
my_module.add_optionnal_depend('echrono', compilation_flags=["c++", "-DESIGNAL_BUILD_WITH_ECHRONO"])
|
||||
my_module.add_tools(['esignal-test'])
|
||||
return my_module
|
||||
return True
|
||||
|
||||
|
19
monk_esignal.py
Normal file
19
monk_esignal.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
import monkModule
|
||||
import monkTools as tools
|
||||
import os
|
||||
|
||||
def get_desc():
|
||||
return "E-signal simple signal syncronous library"
|
||||
|
||||
def create():
|
||||
# module name is 'ewol' and type binary.
|
||||
myModule = monkModule.Module(__file__, 'esignal', 'LIBRARY')
|
||||
# enable doculentation :
|
||||
myModule.set_website("http://atria-soft.github.io/esignal/")
|
||||
myModule.set_website_sources("http://github.com/atria-soft/esignal/")
|
||||
myModule.set_path(os.path.join(tools.get_current_path(__file__), "esignal"))
|
||||
myModule.set_path_general_doc(os.path.join(tools.get_current_path(__file__), "doc"))
|
||||
# add the currrent module at the
|
||||
return myModule
|
||||
|
156
sample/sampleAll.cpp
Normal file
156
sample/sampleAll.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/etk.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
|
||||
//! [esignal_sample_declare]
|
||||
#include <esignal/Signal.hpp>
|
||||
//! [esignal_sample_declare]
|
||||
|
||||
void declareSignals() {
|
||||
//! [esignal_sample_declare_int]
|
||||
esignal::Signal<int32_t> signalInt;
|
||||
//! [esignal_sample_declare_int]
|
||||
|
||||
//! [esignal_sample_declare_void]
|
||||
esignal::Signal<> signalVoid;
|
||||
//! [esignal_sample_declare_void]
|
||||
|
||||
//! [esignal_sample_declare_string]
|
||||
esignal::Signal<etk::String> signalString;
|
||||
//! [esignal_sample_declare_string]
|
||||
}
|
||||
|
||||
//! [esignal_sample_connection_simple]
|
||||
//! [esignal_sample_connection_simple_extern_function]
|
||||
void localCallBack(int32_t _val) {
|
||||
TEST_PRINT("Callback Local the value is : " << _val);
|
||||
}
|
||||
//! [esignal_sample_connection_simple_extern_function]
|
||||
|
||||
void basicConnection() {
|
||||
// Create the signal
|
||||
//! [esignal_sample_connection_simple_connection_declare]
|
||||
esignal::Signal<int32_t> signalValue;
|
||||
//! [esignal_sample_connection_simple_connection_declare]
|
||||
// Connect the signal function
|
||||
//! [esignal_sample_connection_simple_connection_function]
|
||||
esignal::Connection con1 = signalValue.connect(&localCallBack);
|
||||
//! [esignal_sample_connection_simple_connection_function]
|
||||
// Connect the signal Lambda
|
||||
//! [esignal_sample_connection_simple_connection_lambda]
|
||||
esignal::Connection con2 = signalValue.connect(
|
||||
[](int32_t _val) {
|
||||
TEST_PRINT("Callback 1 the value is : " << _val);
|
||||
});
|
||||
//! [esignal_sample_connection_simple_connection_lambda]
|
||||
// Emit the signal
|
||||
//! [esignal_sample_connection_simple_emit]
|
||||
signalValue.emit(1001001);
|
||||
//! [esignal_sample_connection_simple_emit]
|
||||
// Disconnect the connection n°1
|
||||
//! [esignal_sample_connection_simple_disconnect]
|
||||
con1.disconnect();
|
||||
//! [esignal_sample_connection_simple_disconnect]
|
||||
// Second emit to check disconnection
|
||||
signalValue.emit(2002002);
|
||||
}
|
||||
//! [esignal_sample_connection_simple]
|
||||
|
||||
//*********************************************************************************************
|
||||
|
||||
//! [esignal_sample_class_connection]
|
||||
//! [esignal_sample_class_connection_callback]
|
||||
class TmpClass {
|
||||
public:
|
||||
void localCallBack(const int32_t& _val) {
|
||||
TEST_PRINT("Callback Local the value is : " << _val);
|
||||
}
|
||||
void localCallBackSecond(const int32_t& _val, const etk::String& _otherValue) {
|
||||
TEST_PRINT("Callback 2 Local the value is : " << _val << " with perso: '" << _otherValue << "'");
|
||||
}
|
||||
};
|
||||
//! [esignal_sample_class_connection_callback]
|
||||
|
||||
void classConnection() {
|
||||
// Create the signal
|
||||
esignal::Signal<int32_t> signalValue;
|
||||
// Declare the class
|
||||
TmpClass myClass;
|
||||
// Connect signals
|
||||
//! [esignal_sample_class_connection_callback_connect]
|
||||
esignal::Connection con1 = signalValue.connect(&myClass, &TmpClass::localCallBack);
|
||||
esignal::Connection con2 = signalValue.connect(&myClass, &TmpClass::localCallBackSecond, "Hello, HowAreYou");
|
||||
//! [esignal_sample_class_connection_callback_connect]
|
||||
// Emit sample signals
|
||||
signalValue.emit(4004004);
|
||||
}
|
||||
|
||||
//! [esignal_sample_class_connection]
|
||||
|
||||
|
||||
//! [esignal_sample_shared_connection]
|
||||
|
||||
void sharedConnection() {
|
||||
// Create the signal
|
||||
esignal::Signal<int32_t> signalValue;
|
||||
// Declare the class
|
||||
ememory::SharedPtr<TmpClass> myClassShared = ememory::makeShared<TmpClass>();
|
||||
// Connect signals
|
||||
signalValue.connect(myClassShared, &TmpClass::localCallBack);
|
||||
// Emit sample signals
|
||||
signalValue.emit(7007007);
|
||||
}
|
||||
//! [esignal_sample_shared_connection]
|
||||
|
||||
|
||||
//! [esignal_sample_new]
|
||||
|
||||
void newSignal() {
|
||||
// Declare new signal
|
||||
//! [esignal_sample_new_declare]
|
||||
esignal::Signal<int32_t, etk::String> signalCustum;
|
||||
//! [esignal_sample_new_declare]
|
||||
// Connect a lambda
|
||||
//! [esignal_sample_new_lambda]
|
||||
esignal::Connection con2 = signalCustum.connect(
|
||||
[](int32_t _val, etk::String _val2) {
|
||||
TEST_PRINT("lambda callback: " << _val << " vel2=" << _val2);
|
||||
});
|
||||
//! [esignal_sample_new_lambda]
|
||||
// Example emit
|
||||
//! [esignal_sample_new_emit]
|
||||
signalCustum.emit(1001001, "plop");
|
||||
//! [esignal_sample_new_emit]
|
||||
}
|
||||
|
||||
// do it in a single C++: Implementation of signal
|
||||
//! [esignal_sample_new_register]
|
||||
#include <esignal/details/Signal.hxx>
|
||||
ESIGNAL_DECLARE_SIGNAL(int32_t, etk::String);
|
||||
//! [esignal_sample_new_register]
|
||||
|
||||
//! [esignal_sample_new]
|
||||
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
TEST_INFO("declare [START] ***************************");
|
||||
declareSignals();
|
||||
TEST_INFO("declare [STOP] ***************************");
|
||||
TEST_INFO("Basic connection [START] ***************************");
|
||||
basicConnection();
|
||||
TEST_INFO("Basic connection [STOP] ***************************");
|
||||
TEST_INFO("class connection [START] ***************************");
|
||||
classConnection();
|
||||
TEST_INFO("class connection [STOP] ***************************");
|
||||
TEST_INFO("shared_ptr connection [START] ***************************");
|
||||
sharedConnection();
|
||||
TEST_INFO("shared_ptr connection [STOP] ***************************");
|
||||
return 0;
|
||||
}
|
@@ -3,11 +3,12 @@
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <esignal/details/Signal.hxx>
|
||||
#include <etk/types.h>
|
||||
|
||||
template class esignal::Signal<int32_t, std::string>;
|
||||
#include <etk/types.hpp>
|
||||
|
||||
|
||||
ESIGNAL_DECLARE_SIGNAL(int32_t, etk::String);
|
||||
|
||||
|
||||
|
@@ -1,25 +1,21 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#define NAME "Empty"
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/etk.h>
|
||||
#include <test-debug/debug.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "esignal-test"
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
::testing::InitGoogleTest(&_argc, const_cast<char **>(_argv));
|
||||
etk::init(_argc, _argv);
|
||||
etest::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_PRINT("esignal-test - help : ");
|
||||
|
@@ -1,27 +1,24 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#define NAME "SingleArg"
|
||||
#include <gtest/gtest.h>
|
||||
#include <esignal/ISignal.h>
|
||||
#include <esignal/Interface.h>
|
||||
#include <memory>
|
||||
#include <test-debug/debug.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <esignal/Interface.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "test_isignal"
|
||||
|
||||
class testISignal : public esignal::Interface {
|
||||
public:
|
||||
esignal::ISignal<int32_t> m_signalInt;
|
||||
esignal::ISignal<std::string> m_signalString;
|
||||
esignal::ISignal<float> m_signalFloat;
|
||||
esignal::Signal<int32_t> m_signalInt;
|
||||
esignal::Signal<etk::String> m_signalString;
|
||||
esignal::Signal<float> m_signalFloat;
|
||||
public:
|
||||
size_t m_count;
|
||||
testISignal():
|
||||
@@ -40,10 +37,10 @@ TEST(test_isignal_counter, localbasicCounter1) {
|
||||
testISignal localClass;
|
||||
EXPECT_EQ(localClass.m_signalString.size(), 0);
|
||||
EXPECT_EQ(localClass.m_signalString.empty(), true);
|
||||
esignal::Connection connection1 = localClass.m_signalString.connect([=](std::string){});
|
||||
esignal::Connection connection1 = localClass.m_signalString.connect([=](etk::String){});
|
||||
EXPECT_EQ(localClass.m_signalString.size(), 1);
|
||||
EXPECT_EQ(localClass.m_signalString.empty(), false);
|
||||
esignal::Connection connection2 = localClass.m_signalString.connect([=](std::string){});
|
||||
esignal::Connection connection2 = localClass.m_signalString.connect([=](etk::String){});
|
||||
EXPECT_EQ(localClass.m_signalString.size(), 2);
|
||||
EXPECT_EQ(localClass.m_signalString.empty(), false);
|
||||
connection1.disconnect();
|
||||
@@ -88,7 +85,7 @@ TEST(test_isignal_counter, localbasicNameDesc) {
|
||||
EXPECT_EQ(localClass.m_signalString.getDescription(), "desc string");
|
||||
}
|
||||
|
||||
class testCallbackIShared : public std::enable_shared_from_this<testCallbackIShared> {
|
||||
class testCallbackIShared : public ememory::EnableSharedFromThis<testCallbackIShared> {
|
||||
public:
|
||||
testCallbackIShared() {
|
||||
}
|
||||
@@ -99,29 +96,29 @@ class testCallbackIShared : public std::enable_shared_from_this<testCallbackISha
|
||||
|
||||
TEST(test_isignal_counter, localbasicInterfaceGetListSignal) {
|
||||
testISignal localClass;
|
||||
std::vector<std::string> list;
|
||||
list.push_back("int");
|
||||
list.push_back("string");
|
||||
list.push_back("float");
|
||||
EXPECT_EQ(localClass.signalGetAll(), list);
|
||||
etk::Vector<etk::String> list;
|
||||
list.pushBack("int");
|
||||
list.pushBack("string");
|
||||
list.pushBack("float");
|
||||
EXPECT_EQ(localClass.signals.getAll(), list);
|
||||
}
|
||||
|
||||
TEST(test_isignal_counter, localbasicInterfaceDisconnectNullPtr) {
|
||||
testISignal localClass;
|
||||
localClass.signalDisconnect(nullptr);
|
||||
localClass.signals.disconnect(null);
|
||||
}
|
||||
|
||||
TEST(test_isignal_counter, localbasicInterfaceDisconnectSharedPtr) {
|
||||
testISignal localClass;
|
||||
std::shared_ptr<testCallbackIShared> tmp = std::make_shared<testCallbackIShared>();
|
||||
localClass.signalDisconnect(tmp);
|
||||
ememory::SharedPtr<testCallbackIShared> tmp = ememory::makeShared<testCallbackIShared>();
|
||||
localClass.signals.disconnect(tmp);
|
||||
EXPECT_EQ(localClass.m_signalInt.size(), 0);
|
||||
EXPECT_EQ(localClass.m_signalInt.empty(), true);
|
||||
localClass.m_signalInt.connect(tmp, &testCallbackIShared::callbackConstInt);
|
||||
EXPECT_EQ(localClass.m_signalInt.size(), 1);
|
||||
EXPECT_EQ(localClass.m_signalInt.empty(), false);
|
||||
localClass.m_signalInt.emit(34567);
|
||||
localClass.signalDisconnect(tmp);
|
||||
localClass.signals.disconnect(tmp);
|
||||
EXPECT_EQ(localClass.m_signalInt.size(), 0);
|
||||
EXPECT_EQ(localClass.m_signalInt.empty(), true);
|
||||
}
|
||||
|
@@ -1,33 +1,30 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#define NAME "SingleArg"
|
||||
#include <gtest/gtest.h>
|
||||
#include <esignal/Signal.h>
|
||||
#include <esignal/Interface.h>
|
||||
#include <memory>
|
||||
#include <test-debug/debug.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <esignal/Interface.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "test_signal_class_func"
|
||||
class testCallback {
|
||||
public:
|
||||
int32_t m_int32;
|
||||
std::string m_string;
|
||||
etk::String m_string;
|
||||
bool m_void;
|
||||
testCallback() {
|
||||
m_emptyFunctor = nullptr;
|
||||
m_emptyFunctor = null;
|
||||
m_void = false;
|
||||
m_int32 = 0;
|
||||
m_string = "";
|
||||
}
|
||||
using stupidFunctor = std::function<void()>;
|
||||
using stupidFunctor = etk::Function<void()>;
|
||||
|
||||
stupidFunctor m_emptyFunctor;
|
||||
|
||||
@@ -43,30 +40,30 @@ class testCallback {
|
||||
TEST_VERBOSE("event a=" << _a);
|
||||
m_int32 = _a;
|
||||
}
|
||||
void callbackString(std::string _b){
|
||||
void callbackString(etk::String _b){
|
||||
TEST_VERBOSE("event b=" << _b);
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackConstString(const std::string& _b){
|
||||
void callbackConstString(const etk::String& _b){
|
||||
TEST_VERBOSE("event b=" << _b);
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackIntString(int32_t _a, std::string _b){
|
||||
void callbackIntString(int32_t _a, etk::String _b){
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
m_int32 = _a;
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackConstIntString(const int32_t& _a, const std::string& _b){
|
||||
void callbackConstIntString(const int32_t& _a, const etk::String& _b){
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
m_int32 = _a;
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackMixedIntString(int32_t _a, const std::string& _b){
|
||||
void callbackMixedIntString(int32_t _a, const etk::String& _b){
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
m_int32 = _a;
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackPolyargs(const int32_t& _a, const std::string& _b, char _char, int _int) {
|
||||
void callbackPolyargs(const int32_t& _a, const etk::String& _b, char _char, int _int) {
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b << " _char=" << _char << " _int=" << _int);
|
||||
m_int32 = _a + _int;
|
||||
m_string = _b + _char;
|
||||
@@ -108,7 +105,7 @@ TEST(test_signal_class_func, localbasicNameDesc) {
|
||||
}
|
||||
|
||||
TEST(test_signal_class_func, localNullClass) {
|
||||
testCallback* localClass = nullptr;
|
||||
testCallback* localClass = null;
|
||||
esignal::Signal<> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -171,7 +168,7 @@ TEST(test_signal_class_func, localFunctionConstInt32) {
|
||||
|
||||
TEST(test_signal_class_func, localFunctionString) {
|
||||
testCallback localClass;
|
||||
esignal::Signal<std::string> signal;
|
||||
esignal::Signal<etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&localClass, &testCallback::callbackString);
|
||||
@@ -183,7 +180,7 @@ TEST(test_signal_class_func, localFunctionString) {
|
||||
|
||||
TEST(test_signal_class_func, localFunctionConstString) {
|
||||
testCallback localClass;
|
||||
esignal::Signal<std::string> signal;
|
||||
esignal::Signal<etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&localClass, &testCallback::callbackConstString);
|
||||
@@ -195,7 +192,7 @@ TEST(test_signal_class_func, localFunctionConstString) {
|
||||
|
||||
TEST(test_signal_class_func, localFunctionIntString) {
|
||||
testCallback localClass;
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&localClass, &testCallback::callbackIntString);
|
||||
@@ -208,7 +205,7 @@ TEST(test_signal_class_func, localFunctionIntString) {
|
||||
|
||||
TEST(test_signal_class_func, localFunctionConstIntString) {
|
||||
testCallback localClass;
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&localClass, &testCallback::callbackConstIntString);
|
||||
@@ -221,7 +218,7 @@ TEST(test_signal_class_func, localFunctionConstIntString) {
|
||||
|
||||
TEST(test_signal_class_func, localFunctionMixedIntString) {
|
||||
testCallback localClass;
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&localClass, &testCallback::callbackMixedIntString);
|
||||
@@ -234,7 +231,7 @@ TEST(test_signal_class_func, localFunctionMixedIntString) {
|
||||
|
||||
TEST(test_signal_class_func, localFunctionConstIntStringPolyArg) {
|
||||
testCallback localClass;
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&localClass, &testCallback::callbackPolyargs, 'c', 12365);
|
||||
|
@@ -1,24 +1,21 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#define NAME "SingleArg"
|
||||
#include <gtest/gtest.h>
|
||||
#include <esignal/Signal.h>
|
||||
#include <esignal/Interface.h>
|
||||
#include <memory>
|
||||
#include <test-debug/debug.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <esignal/Interface.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "test_signal_counter"
|
||||
class testCounter {
|
||||
public:
|
||||
esignal::Signal<std::string> m_signal;
|
||||
esignal::Signal<etk::String> m_signal;
|
||||
public:
|
||||
size_t m_int32;
|
||||
testCounter():
|
||||
@@ -36,11 +33,11 @@ TEST(test_signal_counter, localbasicCounter) {
|
||||
EXPECT_EQ(localClass.m_signal.size(), 0);
|
||||
EXPECT_EQ(localClass.m_signal.empty(), true);
|
||||
EXPECT_EQ(localClass.m_int32, 0);
|
||||
esignal::Connection connection1 = localClass.m_signal.connect([=](std::string){});
|
||||
esignal::Connection connection1 = localClass.m_signal.connect([=](etk::String){});
|
||||
EXPECT_EQ(localClass.m_signal.size(), 1);
|
||||
EXPECT_EQ(localClass.m_signal.empty(), false);
|
||||
EXPECT_EQ(localClass.m_int32, 1);
|
||||
esignal::Connection connection2 = localClass.m_signal.connect([=](std::string){});
|
||||
esignal::Connection connection2 = localClass.m_signal.connect([=](etk::String){});
|
||||
EXPECT_EQ(localClass.m_signal.size(), 2);
|
||||
EXPECT_EQ(localClass.m_signal.empty(), false);
|
||||
EXPECT_EQ(localClass.m_int32, 2);
|
||||
@@ -60,11 +57,11 @@ TEST(test_signal_counter, localbasicCopy) {
|
||||
EXPECT_EQ(localClass.m_signal.size(), 0);
|
||||
EXPECT_EQ(localClass.m_signal.empty(), true);
|
||||
EXPECT_EQ(localClass.m_int32, 0);
|
||||
esignal::Connection connection1 = localClass.m_signal.connect([=](std::string){});
|
||||
esignal::Connection connection1 = localClass.m_signal.connect([=](etk::String){});
|
||||
EXPECT_EQ(localClass.m_signal.size(), 1);
|
||||
EXPECT_EQ(localClass.m_signal.empty(), false);
|
||||
EXPECT_EQ(localClass.m_int32, 1);
|
||||
esignal::Connection connection2 = std::move(connection1);
|
||||
esignal::Connection connection2 = etk::move(connection1);
|
||||
EXPECT_EQ(localClass.m_signal.size(), 1);
|
||||
EXPECT_EQ(localClass.m_signal.empty(), false);
|
||||
EXPECT_EQ(localClass.m_int32, 1);
|
||||
@@ -84,7 +81,7 @@ TEST(test_signal_counter, localbasicCheckConnection) {
|
||||
EXPECT_EQ(localClass.m_signal.size(), 0);
|
||||
EXPECT_EQ(localClass.m_signal.empty(), true);
|
||||
EXPECT_EQ(localClass.m_int32, 0);
|
||||
esignal::Connection connection1 = localClass.m_signal.connect([=](std::string){});
|
||||
esignal::Connection connection1 = localClass.m_signal.connect([=](etk::String){});
|
||||
EXPECT_EQ(connection1.isConnected(), true);
|
||||
connection1.disconnect();
|
||||
EXPECT_EQ(connection1.isConnected(), false);
|
||||
|
@@ -1,21 +1,17 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#define NAME "SingleArg"
|
||||
#include <gtest/gtest.h>
|
||||
#include <esignal/Signal.h>
|
||||
#include <esignal/Interface.h>
|
||||
#include <memory>
|
||||
#include <test-debug/debug.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "test_signal_static_func"
|
||||
#include <etest/etest.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <esignal/Interface.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
|
||||
static esignal::Signal<int32_t>* signalll;
|
||||
static int32_t tmpRetInt32 = 0;
|
||||
@@ -32,7 +28,7 @@ static auto callbackInt = [](int32_t _a){
|
||||
|
||||
TEST(test_signal_recursive, base) {
|
||||
tmpRetInt32 = -1;
|
||||
signalll = new esignal::Signal<int32_t>();
|
||||
signalll = ETK_NEW(esignal::Signal<int32_t>);
|
||||
EXPECT_EQ(signalll->size(), 0);
|
||||
EXPECT_EQ(signalll->empty(), true);
|
||||
esignal::Connection connection1 = signalll->connect(callbackInt);
|
||||
|
@@ -1,28 +1,25 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#define NAME "SingleArg"
|
||||
#include <gtest/gtest.h>
|
||||
#include <esignal/Signal.h>
|
||||
#include <esignal/Interface.h>
|
||||
#include <memory>
|
||||
#include <test-debug/debug.h>
|
||||
#include <etest/etest.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <esignal/Interface.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "test_signal_class_func"
|
||||
class testCallbackShared : public std::enable_shared_from_this<testCallbackShared> {
|
||||
class testCallbackShared : public ememory::EnableSharedFromThis<testCallbackShared> {
|
||||
public:
|
||||
int32_t m_int32;
|
||||
std::string m_string;
|
||||
etk::String m_string;
|
||||
bool m_void;
|
||||
testCallbackShared() {
|
||||
m_emptyFunctor = nullptr;
|
||||
m_emptyFunctor = null;
|
||||
m_void = false;
|
||||
m_int32 = 0;
|
||||
m_string = "";
|
||||
@@ -30,7 +27,7 @@ class testCallbackShared : public std::enable_shared_from_this<testCallbackShare
|
||||
virtual ~testCallbackShared() {
|
||||
|
||||
}
|
||||
//using stupidFunctor = std::function<void()>;
|
||||
//using stupidFunctor = etk::Function<void()>;
|
||||
|
||||
using stupidFunctor = void();
|
||||
|
||||
@@ -48,36 +45,36 @@ class testCallbackShared : public std::enable_shared_from_this<testCallbackShare
|
||||
TEST_VERBOSE("event a=" << _a);
|
||||
m_int32 = _a;
|
||||
}
|
||||
void callbackString(std::string _b) {
|
||||
void callbackString(etk::String _b) {
|
||||
TEST_VERBOSE("event b=" << _b);
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackConstString(const std::string& _b) {
|
||||
void callbackConstString(const etk::String& _b) {
|
||||
TEST_VERBOSE("event b=" << _b);
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackIntString(int32_t _a, std::string _b) {
|
||||
void callbackIntString(int32_t _a, etk::String _b) {
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
m_int32 = _a;
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackConstIntString(const int32_t& _a, const std::string& _b) {
|
||||
void callbackConstIntString(const int32_t& _a, const etk::String& _b) {
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
m_int32 = _a;
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackMixedIntString(int32_t _a, const std::string& _b) {
|
||||
void callbackMixedIntString(int32_t _a, const etk::String& _b) {
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
m_int32 = _a;
|
||||
m_string = _b;
|
||||
}
|
||||
void callbackPolyargs(const int32_t& _a, const std::string& _b, char _char, int _int) {
|
||||
void callbackPolyargs(const int32_t& _a, const etk::String& _b, char _char, int _int) {
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b << " _char=" << _char << " _int=" << _int);
|
||||
m_int32 = _a + _int;
|
||||
m_string = _b + _char;
|
||||
}
|
||||
void callbackDisconnect(esignal::Signal<>* _signal) {
|
||||
_signal->disconnectShared(shared_from_this());
|
||||
_signal->disconnectShared(sharedFromThis());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -87,7 +84,7 @@ void removeObserver(size_t _count) {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localNullClass) {
|
||||
std::shared_ptr<testCallbackShared> localClass;
|
||||
ememory::SharedPtr<testCallbackShared> localClass;
|
||||
esignal::Signal<> signal(&removeObserver);
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -99,7 +96,7 @@ TEST(test_signal_shared_ptr_func, localNullClass) {
|
||||
/*
|
||||
Impossible case ...
|
||||
TEST(test_signal_shared_ptr_func, localNullFunction) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -111,7 +108,7 @@ TEST(test_signal_shared_ptr_func, localNullFunction) {
|
||||
}
|
||||
*/
|
||||
TEST(test_signal_shared_ptr_func, localFunctionVoid) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -123,7 +120,7 @@ TEST(test_signal_shared_ptr_func, localFunctionVoid) {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionInt32) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<int32_t> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -139,7 +136,7 @@ TEST(test_signal_shared_ptr_func, localFunctionInt32) {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionConstInt32) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<int32_t> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -151,8 +148,8 @@ TEST(test_signal_shared_ptr_func, localFunctionConstInt32) {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionString) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
esignal::Signal<std::string> signal;
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
#if 0
|
||||
@@ -167,8 +164,8 @@ TEST(test_signal_shared_ptr_func, localFunctionString) {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionConstString) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
esignal::Signal<std::string> signal;
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
signal.connect(localClass, &testCallbackShared::callbackConstString);
|
||||
@@ -179,8 +176,8 @@ TEST(test_signal_shared_ptr_func, localFunctionConstString) {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionIntString) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
#if 0
|
||||
@@ -196,8 +193,8 @@ TEST(test_signal_shared_ptr_func, localFunctionIntString) {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionConstIntString) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
signal.connect(localClass, &testCallbackShared::callbackConstIntString);
|
||||
@@ -209,8 +206,8 @@ TEST(test_signal_shared_ptr_func, localFunctionConstIntString) {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionMixedIntString) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
#if 0
|
||||
@@ -227,8 +224,8 @@ TEST(test_signal_shared_ptr_func, localFunctionMixedIntString) {
|
||||
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionConstIntStringPolyArg) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
signal.connect(localClass, &testCallbackShared::callbackPolyargs, 'c', 12365);
|
||||
@@ -241,7 +238,7 @@ TEST(test_signal_shared_ptr_func, localFunctionConstIntStringPolyArg) {
|
||||
|
||||
class testCallbackSharedHerited : public testCallbackShared {
|
||||
public:
|
||||
void callbackHerited(const int32_t& _a, const std::string& _b) {
|
||||
void callbackHerited(const int32_t& _a, const etk::String& _b) {
|
||||
m_int32 = _a;
|
||||
m_string = _b;
|
||||
}
|
||||
@@ -249,8 +246,8 @@ class testCallbackSharedHerited : public testCallbackShared {
|
||||
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionHerited) {
|
||||
std::shared_ptr<testCallbackSharedHerited> localClass = std::make_shared<testCallbackSharedHerited>();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
ememory::SharedPtr<testCallbackSharedHerited> localClass = ememory::makeShared<testCallbackSharedHerited>();
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
signal.connect(localClass, &testCallbackSharedHerited::callbackHerited);
|
||||
@@ -263,7 +260,7 @@ TEST(test_signal_shared_ptr_func, localFunctionHerited) {
|
||||
|
||||
|
||||
TEST(test_signal_shared_ptr_func, disconnect) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<int32_t> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -279,7 +276,7 @@ TEST(test_signal_shared_ptr_func, disconnect) {
|
||||
|
||||
|
||||
TEST(test_signal_shared_ptr_func, connect_disconnect_multiple) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<int32_t> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -305,7 +302,7 @@ TEST(test_signal_shared_ptr_func, connect_disconnect_multiple) {
|
||||
|
||||
|
||||
TEST(test_signal_shared_ptr_func, disconnect_inCallback) {
|
||||
std::shared_ptr<testCallbackShared> localClass = std::make_shared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClass = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -322,8 +319,8 @@ static void callbackVoid() {
|
||||
}
|
||||
|
||||
TEST(test_signal_shared_ptr_func, localFunctionWeakTest) {
|
||||
std::shared_ptr<testCallbackShared> localClassA = std::make_shared<testCallbackShared>();
|
||||
std::shared_ptr<testCallbackShared> localClassB = std::make_shared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClassA = ememory::makeShared<testCallbackShared>();
|
||||
ememory::SharedPtr<testCallbackShared> localClassB = ememory::makeShared<testCallbackShared>();
|
||||
esignal::Signal<> signal(&removeObserver);
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
@@ -342,7 +339,7 @@ TEST(test_signal_shared_ptr_func, localFunctionWeakTest) {
|
||||
signal.emit();
|
||||
EXPECT_EQ(signal.size(), 3);
|
||||
EXPECT_EQ(signal.empty(), false);
|
||||
localClassB = std::make_shared<testCallbackShared>();
|
||||
localClassB = ememory::makeShared<testCallbackShared>();
|
||||
signal.connect(localClassB, &testCallbackShared::callbackVoid);
|
||||
EXPECT_EQ(signal.size(), 4);
|
||||
EXPECT_EQ(signal.empty(), false);
|
||||
|
@@ -1,24 +1,20 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#define NAME "SingleArg"
|
||||
#include <gtest/gtest.h>
|
||||
#include <esignal/Signal.h>
|
||||
#include <esignal/Interface.h>
|
||||
#include <memory>
|
||||
#include <test-debug/debug.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "test_signal_static_func"
|
||||
#include <etest/etest.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <esignal/Interface.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
|
||||
static int32_t tmpRetInt32 = 0;
|
||||
static std::string tmpRetString = "";
|
||||
static etk::String tmpRetString = "";
|
||||
static bool tmpRetVoid = false;
|
||||
|
||||
static void clear() {
|
||||
@@ -42,35 +38,35 @@ static void callbackConstInt(const int32_t& _a){
|
||||
tmpRetInt32 = _a;
|
||||
};
|
||||
|
||||
static void callbackString(std::string _b){
|
||||
static void callbackString(etk::String _b){
|
||||
TEST_VERBOSE("event b=" << _b);
|
||||
tmpRetString = _b;
|
||||
};
|
||||
|
||||
static void callbackConstString(const std::string& _b){
|
||||
static void callbackConstString(const etk::String& _b){
|
||||
TEST_VERBOSE("event b=" << _b);
|
||||
tmpRetString = _b;
|
||||
};
|
||||
|
||||
static void callbackIntString(int32_t _a, std::string _b){
|
||||
static void callbackIntString(int32_t _a, etk::String _b){
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
tmpRetInt32 = _a;
|
||||
tmpRetString = _b;
|
||||
};
|
||||
|
||||
static void callbackConstIntString(const int32_t& _a, const std::string& _b){
|
||||
static void callbackConstIntString(const int32_t& _a, const etk::String& _b){
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
tmpRetInt32 = _a;
|
||||
tmpRetString = _b;
|
||||
};
|
||||
|
||||
static void callbackMixedIntString(int32_t _a, const std::string& _b){
|
||||
static void callbackMixedIntString(int32_t _a, const etk::String& _b){
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b);
|
||||
tmpRetInt32 = _a;
|
||||
tmpRetString = _b;
|
||||
};
|
||||
|
||||
static void callbackPolyargs(const int32_t& _a, const std::string& _b, char _char, int _int) {
|
||||
static void callbackPolyargs(const int32_t& _a, const etk::String& _b, char _char, int _int) {
|
||||
TEST_VERBOSE("event a=" << _a << " b=" << _b << " _char=" << _char << " _int=" << _int);
|
||||
tmpRetInt32 = _a + _int;
|
||||
tmpRetString = _b + _char;
|
||||
@@ -114,7 +110,7 @@ TEST(test_signal_static_func, localFunctionConstInt32) {
|
||||
|
||||
TEST(test_signal_static_func, localFunctionString) {
|
||||
clear();
|
||||
esignal::Signal<std::string> signal;
|
||||
esignal::Signal<etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&callbackString);
|
||||
@@ -126,7 +122,7 @@ TEST(test_signal_static_func, localFunctionString) {
|
||||
|
||||
TEST(test_signal_static_func, localFunctionConstString) {
|
||||
clear();
|
||||
esignal::Signal<std::string> signal;
|
||||
esignal::Signal<etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&callbackConstString);
|
||||
@@ -138,7 +134,7 @@ TEST(test_signal_static_func, localFunctionConstString) {
|
||||
|
||||
TEST(test_signal_static_func, localFunctionIntString) {
|
||||
clear();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&callbackIntString);
|
||||
@@ -151,7 +147,7 @@ TEST(test_signal_static_func, localFunctionIntString) {
|
||||
|
||||
TEST(test_signal_static_func, localFunctionConstIntString) {
|
||||
clear();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&callbackConstIntString);
|
||||
@@ -164,7 +160,7 @@ TEST(test_signal_static_func, localFunctionConstIntString) {
|
||||
|
||||
TEST(test_signal_static_func, localFunctionMixedIntString) {
|
||||
clear();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&callbackMixedIntString);
|
||||
@@ -184,7 +180,7 @@ TEST(test_signal_static_func, localFunctionMixedIntString) {
|
||||
}
|
||||
TEST(test_signal_static_func, localFunctionConstIntStringPolyArg) {
|
||||
clear();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(complete_args(&callbackPolyargs, 'c', 12365));
|
||||
@@ -197,7 +193,7 @@ TEST(test_signal_static_func, localFunctionMixedIntString) {
|
||||
#else
|
||||
/*
|
||||
template<class Func, class... ARGS_BASE, class... ARGS_CURR>
|
||||
std::function<void(const ARGS_BASE&...)> complete_args(Func _f, ARGS_BASE... _arg) {
|
||||
etk::Function<void(const ARGS_BASE&...)> complete_args(Func _f, ARGS_BASE... _arg) {
|
||||
return [=](const ARGS_BASE&..., ARGS_CURR...){
|
||||
return _f( cargs..., _arg... );
|
||||
};
|
||||
@@ -208,7 +204,7 @@ TEST(test_signal_static_func, localFunctionMixedIntString) {
|
||||
#if 0
|
||||
TEST(test_signal_static_func, localFunctionConstIntStringPolyArgWithJAJA) {
|
||||
clear();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(&callbackPolyargs, 'c', 12365);
|
||||
@@ -222,11 +218,11 @@ TEST(test_signal_static_func, localFunctionConstIntStringPolyArgWithJAJA) {
|
||||
|
||||
TEST(test_signal_static_func, localFunctionLambda) {
|
||||
clear();
|
||||
esignal::Signal<int32_t, std::string> signal;
|
||||
esignal::Signal<int32_t, etk::String> signal;
|
||||
EXPECT_EQ(signal.size(), 0);
|
||||
EXPECT_EQ(signal.empty(), true);
|
||||
esignal::Connection connection1 = signal.connect(
|
||||
[](int32_t _a, const std::string& _b) {
|
||||
[](int32_t _a, const etk::String& _b) {
|
||||
tmpRetInt32 = _a;
|
||||
tmpRetString = _b;
|
||||
}
|
||||
|
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
||||
1.0.0
|
Reference in New Issue
Block a user