Initial contribution
This commit is contained in:
parent
7b5cc4fa59
commit
11d9ce37aa
580 changed files with 155133 additions and 162 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
gen
|
||||||
|
gen.*
|
||||||
|
.cproject
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
.vs/
|
||||||
0
.gitmodules
vendored
Normal file
0
.gitmodules
vendored
Normal file
44
CONTRIBUTING
Normal file
44
CONTRIBUTING
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Contributing to Eclipse Cyclone DDS
|
||||||
|
|
||||||
|
Thanks for your interest in this project.
|
||||||
|
|
||||||
|
## Project description
|
||||||
|
|
||||||
|
Eclipse Cyclone DDS is an implementation of the OMG Data Distribution Service
|
||||||
|
(DDS) specification (see http://www.omg.org/spec/DDS/ ) and the related
|
||||||
|
specifications for interoperability (see http://www.omg.org/spec/DDSI-RTPS/ )
|
||||||
|
|
||||||
|
* https://projects.eclipse.org/projects/iot.cyclonedds
|
||||||
|
|
||||||
|
## Developer resources
|
||||||
|
|
||||||
|
Information regarding source code management, builds, coding standards, and
|
||||||
|
more.
|
||||||
|
|
||||||
|
* https://projects.eclipse.org/projects/iot.cyclonedds/developer
|
||||||
|
|
||||||
|
The project maintains the following source code repositories
|
||||||
|
|
||||||
|
* https://github.com/eclipse/cyclonedds
|
||||||
|
|
||||||
|
## Eclipse Contributor Agreement
|
||||||
|
|
||||||
|
Before your contribution can be accepted by the project team contributors must
|
||||||
|
electronically sign the Eclipse Contributor Agreement (ECA).
|
||||||
|
|
||||||
|
* http://www.eclipse.org/legal/ECA.php
|
||||||
|
|
||||||
|
Commits that are provided by non-committers must have a Signed-off-by field in
|
||||||
|
the footer indicating that the author is aware of the terms by which the
|
||||||
|
contribution has been provided to the project. The non-committer must
|
||||||
|
additionally have an Eclipse Foundation account and must have a signed Eclipse
|
||||||
|
Contributor Agreement (ECA) on file.
|
||||||
|
|
||||||
|
For more information, please see the Eclipse Committer Handbook:
|
||||||
|
https://www.eclipse.org/projects/handbook/#resources-commit
|
||||||
|
|
||||||
|
## Contact
|
||||||
|
|
||||||
|
Contact the project developers via the project's "dev" list.
|
||||||
|
|
||||||
|
* https://accounts.eclipse.org/mailing-list/cyclonedds-dev
|
||||||
435
LICENSE
435
LICENSE
|
|
@ -1,203 +1,318 @@
|
||||||
Eclipse Public License - v 1.0
|
This program and the accompanying materials are made available under the
|
||||||
|
terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
v. 1.0 which is available at
|
||||||
|
http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
|
||||||
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
|
|
||||||
LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
|
|
||||||
CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
|
Eclipse Public License - v 2.0
|
||||||
|
|
||||||
|
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
|
||||||
|
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
|
||||||
|
OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
|
||||||
|
|
||||||
1. DEFINITIONS
|
1. DEFINITIONS
|
||||||
|
|
||||||
"Contribution" means:
|
"Contribution" means:
|
||||||
|
|
||||||
a) in the case of the initial Contributor, the initial code and documentation
|
a) in the case of the initial Contributor, the initial content
|
||||||
distributed under this Agreement, and
|
Distributed under this Agreement, and
|
||||||
b) in the case of each subsequent Contributor:
|
|
||||||
|
b) in the case of each subsequent Contributor:
|
||||||
i) changes to the Program, and
|
i) changes to the Program, and
|
||||||
ii) additions to the Program;
|
ii) additions to the Program;
|
||||||
|
where such changes and/or additions to the Program originate from
|
||||||
|
and are Distributed by that particular Contributor. A Contribution
|
||||||
|
"originates" from a Contributor if it was added to the Program by
|
||||||
|
such Contributor itself or anyone acting on such Contributor's behalf.
|
||||||
|
Contributions do not include changes or additions to the Program that
|
||||||
|
are not Modified Works.
|
||||||
|
|
||||||
where such changes and/or additions to the Program originate from and are
|
"Contributor" means any person or entity that Distributes the Program.
|
||||||
distributed by that particular Contributor. A Contribution 'originates'
|
|
||||||
from a Contributor if it was added to the Program by such Contributor
|
|
||||||
itself or anyone acting on such Contributor's behalf. Contributions do not
|
|
||||||
include additions to the Program which: (i) are separate modules of
|
|
||||||
software distributed in conjunction with the Program under their own
|
|
||||||
license agreement, and (ii) are not derivative works of the Program.
|
|
||||||
|
|
||||||
"Contributor" means any person or entity that distributes the Program.
|
"Licensed Patents" mean patent claims licensable by a Contributor which
|
||||||
|
are necessarily infringed by the use or sale of its Contribution alone
|
||||||
|
or when combined with the Program.
|
||||||
|
|
||||||
"Licensed Patents" mean patent claims licensable by a Contributor which are
|
"Program" means the Contributions Distributed in accordance with this
|
||||||
necessarily infringed by the use or sale of its Contribution alone or when
|
|
||||||
combined with the Program.
|
|
||||||
|
|
||||||
"Program" means the Contributions distributed in accordance with this
|
|
||||||
Agreement.
|
Agreement.
|
||||||
|
|
||||||
"Recipient" means anyone who receives the Program under this Agreement,
|
"Recipient" means anyone who receives the Program under this Agreement
|
||||||
including all Contributors.
|
or any Secondary License (as applicable), including Contributors.
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source Code or other
|
||||||
|
form, that is based on (or derived from) the Program and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship.
|
||||||
|
|
||||||
|
"Modified Works" shall mean any work in Source Code or other form that
|
||||||
|
results from an addition to, deletion from, or modification of the
|
||||||
|
contents of the Program, including, for purposes of clarity any new file
|
||||||
|
in Source Code form that contains any contents of the Program. Modified
|
||||||
|
Works shall not include works that contain only declarations,
|
||||||
|
interfaces, types, classes, structures, or files of the Program solely
|
||||||
|
in each case in order to link to, bind by name, or subclass the Program
|
||||||
|
or Modified Works thereof.
|
||||||
|
|
||||||
|
"Distribute" means the acts of a) distributing or b) making available
|
||||||
|
in any manner that enables the transfer of a copy.
|
||||||
|
|
||||||
|
"Source Code" means the form of a Program preferred for making
|
||||||
|
modifications, including but not limited to software source code,
|
||||||
|
documentation source, and configuration files.
|
||||||
|
|
||||||
|
"Secondary License" means either the GNU General Public License,
|
||||||
|
Version 2.0, or any later versions of that license, including any
|
||||||
|
exceptions or additional permissions as identified by the initial
|
||||||
|
Contributor.
|
||||||
|
|
||||||
2. GRANT OF RIGHTS
|
2. GRANT OF RIGHTS
|
||||||
a) Subject to the terms of this Agreement, each Contributor hereby grants
|
|
||||||
Recipient a non-exclusive, worldwide, royalty-free copyright license to
|
a) Subject to the terms of this Agreement, each Contributor hereby
|
||||||
reproduce, prepare derivative works of, publicly display, publicly
|
grants Recipient a non-exclusive, worldwide, royalty-free copyright
|
||||||
perform, distribute and sublicense the Contribution of such Contributor,
|
license to reproduce, prepare Derivative Works of, publicly display,
|
||||||
if any, and such derivative works, in source code and object code form.
|
publicly perform, Distribute and sublicense the Contribution of such
|
||||||
b) Subject to the terms of this Agreement, each Contributor hereby grants
|
Contributor, if any, and such Derivative Works.
|
||||||
Recipient a non-exclusive, worldwide, royalty-free patent license under
|
|
||||||
Licensed Patents to make, use, sell, offer to sell, import and otherwise
|
b) Subject to the terms of this Agreement, each Contributor hereby
|
||||||
transfer the Contribution of such Contributor, if any, in source code and
|
grants Recipient a non-exclusive, worldwide, royalty-free patent
|
||||||
object code form. This patent license shall apply to the combination of
|
license under Licensed Patents to make, use, sell, offer to sell,
|
||||||
the Contribution and the Program if, at the time the Contribution is
|
import and otherwise transfer the Contribution of such Contributor,
|
||||||
added by the Contributor, such addition of the Contribution causes such
|
if any, in Source Code or other form. This patent license shall
|
||||||
combination to be covered by the Licensed Patents. The patent license
|
apply to the combination of the Contribution and the Program if, at
|
||||||
shall not apply to any other combinations which include the Contribution.
|
the time the Contribution is added by the Contributor, such addition
|
||||||
No hardware per se is licensed hereunder.
|
of the Contribution causes such combination to be covered by the
|
||||||
c) Recipient understands that although each Contributor grants the licenses
|
Licensed Patents. The patent license shall not apply to any other
|
||||||
to its Contributions set forth herein, no assurances are provided by any
|
combinations which include the Contribution. No hardware per se is
|
||||||
Contributor that the Program does not infringe the patent or other
|
licensed hereunder.
|
||||||
intellectual property rights of any other entity. Each Contributor
|
|
||||||
disclaims any liability to Recipient for claims brought by any other
|
c) Recipient understands that although each Contributor grants the
|
||||||
entity based on infringement of intellectual property rights or
|
licenses to its Contributions set forth herein, no assurances are
|
||||||
otherwise. As a condition to exercising the rights and licenses granted
|
provided by any Contributor that the Program does not infringe the
|
||||||
hereunder, each Recipient hereby assumes sole responsibility to secure
|
patent or other intellectual property rights of any other entity.
|
||||||
any other intellectual property rights needed, if any. For example, if a
|
Each Contributor disclaims any liability to Recipient for claims
|
||||||
third party patent license is required to allow Recipient to distribute
|
brought by any other entity based on infringement of intellectual
|
||||||
the Program, it is Recipient's responsibility to acquire that license
|
property rights or otherwise. As a condition to exercising the
|
||||||
|
rights and licenses granted hereunder, each Recipient hereby
|
||||||
|
assumes sole responsibility to secure any other intellectual
|
||||||
|
property rights needed, if any. For example, if a third party
|
||||||
|
patent license is required to allow Recipient to Distribute the
|
||||||
|
Program, it is Recipient's responsibility to acquire that license
|
||||||
before distributing the Program.
|
before distributing the Program.
|
||||||
d) Each Contributor represents that to its knowledge it has sufficient
|
|
||||||
copyright rights in its Contribution, if any, to grant the copyright
|
d) Each Contributor represents that to its knowledge it has
|
||||||
license set forth in this Agreement.
|
sufficient copyright rights in its Contribution, if any, to grant
|
||||||
|
the copyright license set forth in this Agreement.
|
||||||
|
|
||||||
|
e) Notwithstanding the terms of any Secondary License, no
|
||||||
|
Contributor makes additional grants to any Recipient (other than
|
||||||
|
those set forth in this Agreement) as a result of such Recipient's
|
||||||
|
receipt of the Program under the terms of a Secondary License
|
||||||
|
(if permitted under the terms of Section 3).
|
||||||
|
|
||||||
3. REQUIREMENTS
|
3. REQUIREMENTS
|
||||||
|
|
||||||
A Contributor may choose to distribute the Program in object code form under
|
3.1 If a Contributor Distributes the Program in any form, then:
|
||||||
its own license agreement, provided that:
|
|
||||||
|
|
||||||
a) it complies with the terms and conditions of this Agreement; and
|
a) the Program must also be made available as Source Code, in
|
||||||
b) its license agreement:
|
accordance with section 3.2, and the Contributor must accompany
|
||||||
i) effectively disclaims on behalf of all Contributors all warranties
|
the Program with a statement that the Source Code for the Program
|
||||||
and conditions, express and implied, including warranties or
|
is available under this Agreement, and informs Recipients how to
|
||||||
conditions of title and non-infringement, and implied warranties or
|
obtain it in a reasonable manner on or through a medium customarily
|
||||||
conditions of merchantability and fitness for a particular purpose;
|
used for software exchange; and
|
||||||
ii) effectively excludes on behalf of all Contributors all liability for
|
|
||||||
damages, including direct, indirect, special, incidental and
|
|
||||||
consequential damages, such as lost profits;
|
|
||||||
iii) states that any provisions which differ from this Agreement are
|
|
||||||
offered by that Contributor alone and not by any other party; and
|
|
||||||
iv) states that source code for the Program is available from such
|
|
||||||
Contributor, and informs licensees how to obtain it in a reasonable
|
|
||||||
manner on or through a medium customarily used for software exchange.
|
|
||||||
|
|
||||||
When the Program is made available in source code form:
|
b) the Contributor may Distribute the Program under a license
|
||||||
|
different than this Agreement, provided that such license:
|
||||||
|
i) effectively disclaims on behalf of all other Contributors all
|
||||||
|
warranties and conditions, express and implied, including
|
||||||
|
warranties or conditions of title and non-infringement, and
|
||||||
|
implied warranties or conditions of merchantability and fitness
|
||||||
|
for a particular purpose;
|
||||||
|
|
||||||
a) it must be made available under this Agreement; and
|
ii) effectively excludes on behalf of all other Contributors all
|
||||||
b) a copy of this Agreement must be included with each copy of the Program.
|
liability for damages, including direct, indirect, special,
|
||||||
Contributors may not remove or alter any copyright notices contained
|
incidental and consequential damages, such as lost profits;
|
||||||
within the Program.
|
|
||||||
|
|
||||||
Each Contributor must identify itself as the originator of its Contribution,
|
iii) does not attempt to limit or alter the recipients' rights
|
||||||
if
|
in the Source Code under section 3.2; and
|
||||||
any, in a manner that reasonably allows subsequent Recipients to identify the
|
|
||||||
originator of the Contribution.
|
iv) requires any subsequent distribution of the Program by any
|
||||||
|
party to be under a license that satisfies the requirements
|
||||||
|
of this section 3.
|
||||||
|
|
||||||
|
3.2 When the Program is Distributed as Source Code:
|
||||||
|
|
||||||
|
a) it must be made available under this Agreement, or if the
|
||||||
|
Program (i) is combined with other material in a separate file or
|
||||||
|
files made available under a Secondary License, and (ii) the initial
|
||||||
|
Contributor attached to the Source Code the notice described in
|
||||||
|
Exhibit A of this Agreement, then the Program may be made available
|
||||||
|
under the terms of such Secondary Licenses, and
|
||||||
|
|
||||||
|
b) a copy of this Agreement must be included with each copy of
|
||||||
|
the Program.
|
||||||
|
|
||||||
|
3.3 Contributors may not remove or alter any copyright, patent,
|
||||||
|
trademark, attribution notices, disclaimers of warranty, or limitations
|
||||||
|
of liability ("notices") contained within the Program from any copy of
|
||||||
|
the Program which they Distribute, provided that Contributors may add
|
||||||
|
their own appropriate notices.
|
||||||
|
|
||||||
4. COMMERCIAL DISTRIBUTION
|
4. COMMERCIAL DISTRIBUTION
|
||||||
|
|
||||||
Commercial distributors of software may accept certain responsibilities with
|
Commercial distributors of software may accept certain responsibilities
|
||||||
respect to end users, business partners and the like. While this license is
|
with respect to end users, business partners and the like. While this
|
||||||
intended to facilitate the commercial use of the Program, the Contributor who
|
license is intended to facilitate the commercial use of the Program,
|
||||||
includes the Program in a commercial product offering should do so in a manner
|
the Contributor who includes the Program in a commercial product
|
||||||
which does not create potential liability for other Contributors. Therefore,
|
offering should do so in a manner which does not create potential
|
||||||
if a Contributor includes the Program in a commercial product offering, such
|
liability for other Contributors. Therefore, if a Contributor includes
|
||||||
Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
|
the Program in a commercial product offering, such Contributor
|
||||||
every other Contributor ("Indemnified Contributor") against any losses,
|
("Commercial Contributor") hereby agrees to defend and indemnify every
|
||||||
damages and costs (collectively "Losses") arising from claims, lawsuits and
|
other Contributor ("Indemnified Contributor") against any losses,
|
||||||
other legal actions brought by a third party against the Indemnified
|
damages and costs (collectively "Losses") arising from claims, lawsuits
|
||||||
Contributor to the extent caused by the acts or omissions of such Commercial
|
and other legal actions brought by a third party against the Indemnified
|
||||||
Contributor in connection with its distribution of the Program in a commercial
|
Contributor to the extent caused by the acts or omissions of such
|
||||||
product offering. The obligations in this section do not apply to any claims
|
Commercial Contributor in connection with its distribution of the Program
|
||||||
or Losses relating to any actual or alleged intellectual property
|
in a commercial product offering. The obligations in this section do not
|
||||||
infringement. In order to qualify, an Indemnified Contributor must:
|
apply to any claims or Losses relating to any actual or alleged
|
||||||
a) promptly notify the Commercial Contributor in writing of such claim, and
|
intellectual property infringement. In order to qualify, an Indemnified
|
||||||
b) allow the Commercial Contributor to control, and cooperate with the
|
Contributor must: a) promptly notify the Commercial Contributor in
|
||||||
Commercial Contributor in, the defense and any related settlement
|
writing of such claim, and b) allow the Commercial Contributor to control,
|
||||||
negotiations. The Indemnified Contributor may participate in any such claim at
|
and cooperate with the Commercial Contributor in, the defense and any
|
||||||
its own expense.
|
related settlement negotiations. The Indemnified Contributor may
|
||||||
|
participate in any such claim at its own expense.
|
||||||
|
|
||||||
For example, a Contributor might include the Program in a commercial product
|
For example, a Contributor might include the Program in a commercial
|
||||||
offering, Product X. That Contributor is then a Commercial Contributor. If
|
product offering, Product X. That Contributor is then a Commercial
|
||||||
that Commercial Contributor then makes performance claims, or offers
|
Contributor. If that Commercial Contributor then makes performance
|
||||||
warranties related to Product X, those performance claims and warranties are
|
claims, or offers warranties related to Product X, those performance
|
||||||
such Commercial Contributor's responsibility alone. Under this section, the
|
claims and warranties are such Commercial Contributor's responsibility
|
||||||
Commercial Contributor would have to defend claims against the other
|
alone. Under this section, the Commercial Contributor would have to
|
||||||
Contributors related to those performance claims and warranties, and if a
|
defend claims against the other Contributors related to those performance
|
||||||
court requires any other Contributor to pay any damages as a result, the
|
claims and warranties, and if a court requires any other Contributor to
|
||||||
Commercial Contributor must pay those damages.
|
pay any damages as a result, the Commercial Contributor must pay
|
||||||
|
those damages.
|
||||||
|
|
||||||
5. NO WARRANTY
|
5. NO WARRANTY
|
||||||
|
|
||||||
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
|
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
|
PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
|
||||||
IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
|
||||||
NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
|
IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
|
||||||
Recipient is solely responsible for determining the appropriateness of using
|
TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
|
||||||
and distributing the Program and assumes all risks associated with its
|
PURPOSE. Each Recipient is solely responsible for determining the
|
||||||
exercise of rights under this Agreement , including but not limited to the
|
appropriateness of using and distributing the Program and assumes all
|
||||||
risks and costs of program errors, compliance with applicable laws, damage to
|
risks associated with its exercise of rights under this Agreement,
|
||||||
or loss of data, programs or equipment, and unavailability or interruption of
|
including but not limited to the risks and costs of program errors,
|
||||||
operations.
|
compliance with applicable laws, damage to or loss of data, programs
|
||||||
|
or equipment, and unavailability or interruption of operations.
|
||||||
|
|
||||||
6. DISCLAIMER OF LIABILITY
|
6. DISCLAIMER OF LIABILITY
|
||||||
|
|
||||||
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
|
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
|
||||||
CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
|
SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
|
||||||
|
PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
|
ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
|
||||||
EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
|
EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
|
||||||
OF SUCH DAMAGES.
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
7. GENERAL
|
7. GENERAL
|
||||||
|
|
||||||
If any provision of this Agreement is invalid or unenforceable under
|
If any provision of this Agreement is invalid or unenforceable under
|
||||||
applicable law, it shall not affect the validity or enforceability of the
|
applicable law, it shall not affect the validity or enforceability of
|
||||||
remainder of the terms of this Agreement, and without further action by the
|
the remainder of the terms of this Agreement, and without further
|
||||||
parties hereto, such provision shall be reformed to the minimum extent
|
action by the parties hereto, such provision shall be reformed to the
|
||||||
necessary to make such provision valid and enforceable.
|
minimum extent necessary to make such provision valid and enforceable.
|
||||||
|
|
||||||
If Recipient institutes patent litigation against any entity (including a
|
If Recipient institutes patent litigation against any entity
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Program itself
|
(including a cross-claim or counterclaim in a lawsuit) alleging that the
|
||||||
(excluding combinations of the Program with other software or hardware)
|
Program itself (excluding combinations of the Program with other software
|
||||||
infringes such Recipient's patent(s), then such Recipient's rights granted
|
or hardware) infringes such Recipient's patent(s), then such Recipient's
|
||||||
under Section 2(b) shall terminate as of the date such litigation is filed.
|
rights granted under Section 2(b) shall terminate as of the date such
|
||||||
|
litigation is filed.
|
||||||
|
|
||||||
All Recipient's rights under this Agreement shall terminate if it fails to
|
All Recipient's rights under this Agreement shall terminate if it
|
||||||
comply with any of the material terms or conditions of this Agreement and does
|
fails to comply with any of the material terms or conditions of this
|
||||||
not cure such failure in a reasonable period of time after becoming aware of
|
Agreement and does not cure such failure in a reasonable period of
|
||||||
such noncompliance. If all Recipient's rights under this Agreement terminate,
|
time after becoming aware of such noncompliance. If all Recipient's
|
||||||
Recipient agrees to cease use and distribution of the Program as soon as
|
rights under this Agreement terminate, Recipient agrees to cease use
|
||||||
reasonably practicable. However, Recipient's obligations under this Agreement
|
and distribution of the Program as soon as reasonably practicable.
|
||||||
and any licenses granted by Recipient relating to the Program shall continue
|
However, Recipient's obligations under this Agreement and any licenses
|
||||||
and survive.
|
granted by Recipient relating to the Program shall continue and survive.
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute copies of this Agreement, but in
|
Everyone is permitted to copy and distribute copies of this Agreement,
|
||||||
order to avoid inconsistency the Agreement is copyrighted and may only be
|
but in order to avoid inconsistency the Agreement is copyrighted and
|
||||||
modified in the following manner. The Agreement Steward reserves the right to
|
may only be modified in the following manner. The Agreement Steward
|
||||||
publish new versions (including revisions) of this Agreement from time to
|
reserves the right to publish new versions (including revisions) of
|
||||||
time. No one other than the Agreement Steward has the right to modify this
|
this Agreement from time to time. No one other than the Agreement
|
||||||
Agreement. The Eclipse Foundation is the initial Agreement Steward. The
|
Steward has the right to modify this Agreement. The Eclipse Foundation
|
||||||
Eclipse Foundation may assign the responsibility to serve as the Agreement
|
is the initial Agreement Steward. The Eclipse Foundation may assign the
|
||||||
Steward to a suitable separate entity. Each new version of the Agreement will
|
responsibility to serve as the Agreement Steward to a suitable separate
|
||||||
be given a distinguishing version number. The Program (including
|
entity. Each new version of the Agreement will be given a distinguishing
|
||||||
Contributions) may always be distributed subject to the version of the
|
version number. The Program (including Contributions) may always be
|
||||||
Agreement under which it was received. In addition, after a new version of the
|
Distributed subject to the version of the Agreement under which it was
|
||||||
Agreement is published, Contributor may elect to distribute the Program
|
received. In addition, after a new version of the Agreement is published,
|
||||||
(including its Contributions) under the new version. Except as expressly
|
Contributor may elect to Distribute the Program (including its
|
||||||
stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
|
Contributions) under the new version.
|
||||||
licenses to the intellectual property of any Contributor under this Agreement,
|
|
||||||
whether expressly, by implication, estoppel or otherwise. All rights in the
|
|
||||||
Program not expressly granted under this Agreement are reserved.
|
|
||||||
|
|
||||||
This Agreement is governed by the laws of the State of New York and the
|
Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
|
||||||
intellectual property laws of the United States of America. No party to this
|
receives no rights or licenses to the intellectual property of any
|
||||||
Agreement will bring a legal action under this Agreement more than one year
|
Contributor under this Agreement, whether expressly, by implication,
|
||||||
after the cause of action arose. Each party waives its rights to a jury trial in
|
estoppel or otherwise. All rights in the Program not expressly granted
|
||||||
any resulting litigation.
|
under this Agreement are reserved. Nothing in this Agreement is intended
|
||||||
|
to be enforceable by any entity that is not a Contributor or Recipient.
|
||||||
|
No third-party beneficiary rights are created under this Agreement.
|
||||||
|
|
||||||
|
Exhibit A - Form of Secondary Licenses Notice
|
||||||
|
|
||||||
|
"This Source Code may also be made available under the following
|
||||||
|
Secondary Licenses when the conditions for such availability set forth
|
||||||
|
in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
|
||||||
|
version(s), and exceptions or additional permissions here}."
|
||||||
|
|
||||||
|
Simply including a copy of this Agreement, including this Exhibit A
|
||||||
|
is not sufficient to license the Source Code under Secondary Licenses.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Eclipse Distribution License - v 1.0
|
||||||
|
|
||||||
|
Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
Neither the name of the Eclipse Foundation, Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
|
||||||
44
NOTICE
Normal file
44
NOTICE
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Notices for Eclipse Cyclone DDS
|
||||||
|
|
||||||
|
This content is produced and maintained by the Eclipse Cyclone DDS project.
|
||||||
|
|
||||||
|
* Project home: https://projects.eclipse.org/projects/iot.cyclonedds
|
||||||
|
|
||||||
|
## Trademarks
|
||||||
|
|
||||||
|
Eclipse Cyclone DDS is a trademark of the Eclipse Foundation.
|
||||||
|
|
||||||
|
## Copyright
|
||||||
|
|
||||||
|
All content is the property of the respective authors or their employers. For
|
||||||
|
more information regarding authorship of content, please consult the listed
|
||||||
|
source code repository logs.
|
||||||
|
|
||||||
|
## Declared Project Licenses
|
||||||
|
|
||||||
|
This program and the accompanying materials are made available under the terms
|
||||||
|
of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License v. 1.0
|
||||||
|
which is available at http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
|
||||||
|
## Source Code
|
||||||
|
|
||||||
|
The project maintains the following source code repositories:
|
||||||
|
|
||||||
|
* https://github.com/eclipse/cyclonedds
|
||||||
|
|
||||||
|
## Third-party Content
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Cryptography
|
||||||
|
|
||||||
|
Content may contain encryption software. The country in which you are currently
|
||||||
|
may have restrictions on the import, possession, and use, and/or re-export to
|
||||||
|
another country, of encryption software. BEFORE using any encryption software,
|
||||||
|
please check the country's laws, regulations and policies concerning the import,
|
||||||
|
possession, or use, and re-export of encryption software, to see if this is
|
||||||
|
permitted.
|
||||||
|
|
||||||
77
src/CMakeLists.txt
Normal file
77
src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
FUNCTION(PREPEND var prefix)
|
||||||
|
SET(listVar "")
|
||||||
|
FOREACH(f ${ARGN})
|
||||||
|
LIST(APPEND listVar "${prefix}/${f}")
|
||||||
|
ENDFOREACH(f)
|
||||||
|
SET(${var} "${listVar}" PARENT_SCOPE)
|
||||||
|
ENDFUNCTION(PREPEND)
|
||||||
|
|
||||||
|
# Update the git submodules
|
||||||
|
execute_process(COMMAND git submodule init
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
execute_process(COMMAND git submodule update
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
# Set module path before defining project so platform files will work.
|
||||||
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")
|
||||||
|
set(CMAKE_PROJECT_NAME_FULL "Cyclone DDS")
|
||||||
|
string(REPLACE " " "" PROJECT_NAME "${CMAKE_PROJECT_NAME_FULL}")
|
||||||
|
project(${PROJECT_NAME} VERSION 0.1.0)
|
||||||
|
|
||||||
|
find_package(Abstraction REQUIRED)
|
||||||
|
|
||||||
|
# Set some convenience variants of the project-name
|
||||||
|
string(REPLACE " " "-" CMAKE_PROJECT_NAME_DASHED "${CMAKE_PROJECT_NAME_FULL}")
|
||||||
|
string(TOUPPER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_CAPS)
|
||||||
|
string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_SMALL)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "VxWorks")
|
||||||
|
add_definitions(-std=c99)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FileIDs)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
include(AnalyzeBuild)
|
||||||
|
# Include Coverage before CTest so that COVERAGE_COMMAND can be modified
|
||||||
|
# in the Coverage module should that ever be necessary.
|
||||||
|
include(Coverage)
|
||||||
|
set(MEMORYCHECK_COMMAND_OPTIONS "--track-origins=yes --leak-check=full --trace-children=yes --child-silent-after-fork=yes --xml=yes --xml-file=TestResultValgrind_%p.xml --tool=memcheck --show-reachable=yes --leak-resolution=high")
|
||||||
|
set(MEMORYCHECK_SUPPRESSIONS_FILE "${CMAKE_CURRENT_LIST_DIR}/valgrind.supp" CACHE FILEPATH "suppression file")
|
||||||
|
|
||||||
|
# By default building the testing tree is enabled by including CTest, but
|
||||||
|
# since not everybody has CUnit and/or Criterion installed, and because it is
|
||||||
|
# not strictly required to build the product itself, switch to off by default.
|
||||||
|
option(BUILD_TESTING "Build the testing tree." OFF)
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
|
# Build all executables and libraries into the top-level /bin and /lib folders.
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
|
|
||||||
|
add_subdirectory(idlc)
|
||||||
|
add_subdirectory(os)
|
||||||
|
add_subdirectory(etc)
|
||||||
|
add_subdirectory(util)
|
||||||
|
add_subdirectory(core)
|
||||||
|
add_subdirectory(tools)
|
||||||
|
add_subdirectory(scripts)
|
||||||
|
#add_subdirectory(examples)
|
||||||
|
#add_subdirectory(docs)
|
||||||
|
|
||||||
|
# Pull-in CPack and support for generating <Package>Config.cmake and packages.
|
||||||
|
include(Packaging)
|
||||||
31
src/cmake/CoverageSettings.cmake.in
Normal file
31
src/cmake/CoverageSettings.cmake.in
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
set(COVERAGE_SOURCE_DIR "@PROJECT_SOURCE_DIR@")
|
||||||
|
set(COVERAGE_RUN_DIR "@CMAKE_BINARY_DIR@")
|
||||||
|
set(COVERAGE_OUTPUT_DIR "@CMAKE_BINARY_DIR@/coverage")
|
||||||
|
|
||||||
|
# TODO: Make this a list instead of separate variables when more directories
|
||||||
|
# need to be excluded. Currently there's actually only one directory to
|
||||||
|
# be excluded, but when the test(s) are moved, more directories will be
|
||||||
|
# added. I just added two directories to indicate how the coverage
|
||||||
|
# generators handle multiple exclusion directories.
|
||||||
|
#
|
||||||
|
# Do not include the various test directories.
|
||||||
|
set(COVERAGE_EXCLUDE_TESTS "tests")
|
||||||
|
set(COVERAGE_EXCLUDE_EXAMPLES "examples")
|
||||||
|
set(COVERAGE_EXCLUDE_BUILD_SUPPORT "cmake")
|
||||||
|
|
||||||
|
# Add this flag when you want to suppress LCOV and ctest outputs during coverage collecting.
|
||||||
|
#set(COVERAGE_QUIET_FLAG "--quiet")
|
||||||
|
|
||||||
26
src/cmake/launch-c.bat.in
Normal file
26
src/cmake/launch-c.bat.in
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
@echo off
|
||||||
|
REM Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
REM
|
||||||
|
REM This program and the accompanying materials are made available under the
|
||||||
|
REM terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
REM http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
REM v. 1.0 which is available at
|
||||||
|
REM http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
REM
|
||||||
|
REM SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
|
||||||
|
REM VxWorks toolchain requires WIND_BASE to be exported, should the user be
|
||||||
|
REM compiling for VxWorks and not have WIND_BASE exported, do that here before
|
||||||
|
REM invoking the compiler.
|
||||||
|
if "%WIND_BASE%" == "" (
|
||||||
|
set WIND_BASE="@WIND_BASE@"
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Strip C compiler from command line arguments for compatibility because
|
||||||
|
REM this launcher may also be used from an integrated development environment
|
||||||
|
REM at some point.
|
||||||
|
if "%1" == "@CMAKE_C_COMPILER@" (
|
||||||
|
shift
|
||||||
|
)
|
||||||
|
|
||||||
|
"@CMAKE_C_COMPILER@" %*
|
||||||
40
src/cmake/launch-c.in
Normal file
40
src/cmake/launch-c.in
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
# VxWorks toolchain requires WIND_BASE to be exported, should the user be
|
||||||
|
# compiling for VxWorks and not have WIND_BASE exported, to that here before
|
||||||
|
# invoking the compiler.
|
||||||
|
if [ -z "${WIND_BASE}" ] && [ -n "@WIND_BASE@" ]; then
|
||||||
|
WIND_BASE="@WIND_BASE@"
|
||||||
|
export WIND_BASE
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "@WIND_LMAPI@" ]; then
|
||||||
|
if [ -z "${LD_LIBRARY_PATH}" ]; then
|
||||||
|
LD_LIBRARY_PATH="@WIND_LMAPI@"
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
elif [[ "${LD_LIBRARY_PATH}" == ?(*:)"@WIND_LMAPI@"?(:*) ]]; then
|
||||||
|
LD_LIBRARY_PATH="@WIND_LMAPI@:${LD_LIBRARY_PATH}"
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Strip C compiler from command line arguments for compatibility because this
|
||||||
|
# launcher may also be used from an integrated development environment at some
|
||||||
|
# point.
|
||||||
|
if [ "$1" = "@CMAKE_C_COMPILER@" ]; then
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "@CMAKE_C_COMPILER@" "$@"
|
||||||
|
|
||||||
26
src/cmake/launch-cxx.bat.in
Normal file
26
src/cmake/launch-cxx.bat.in
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
@echo off
|
||||||
|
REM Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
REM
|
||||||
|
REM This program and the accompanying materials are made available under the
|
||||||
|
REM terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
REM http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
REM v. 1.0 which is available at
|
||||||
|
REM http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
REM
|
||||||
|
REM SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
|
||||||
|
REM VxWorks toolchain requires WIND_BASE to be exported, should the user be
|
||||||
|
REM compiling for VxWorks and not have WIND_BASE exported, do that here before
|
||||||
|
REM invoking the compiler.
|
||||||
|
if "%WIND_BASE%" == "" (
|
||||||
|
set WIND_BASE="@WIND_BASE@"
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Strip C compiler from command line arguments for compatibility because
|
||||||
|
REM this launcher may also be used from an integrated development environment
|
||||||
|
REM at some point.
|
||||||
|
if "%1" == "@CMAKE_CXX_COMPILER@" (
|
||||||
|
shift
|
||||||
|
)
|
||||||
|
|
||||||
|
"@CMAKE_CXX_COMPILER@" %*
|
||||||
40
src/cmake/launch-cxx.in
Normal file
40
src/cmake/launch-cxx.in
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
# VxWorks toolchain requires WIND_BASE to be exported, should the user be
|
||||||
|
# compiling for VxWorks and not have WIND_BASE exported, to that here before
|
||||||
|
# invoking the compiler.
|
||||||
|
if [ -z "${WIND_BASE}" ] && [ -n "@WIND_BASE@" ]; then
|
||||||
|
WIND_BASE="@WIND_BASE@"
|
||||||
|
export WIND_BASE
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "@WIND_LMAPI@" ]; then
|
||||||
|
if [ -z "${LD_LIBRARY_PATH}" ]; then
|
||||||
|
LD_LIBRARY_PATH="@WIND_LMAPI@"
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
elif [[ "${LD_LIBRARY_PATH}" == ?(*:)"@WIND_LMAPI@"?(:*) ]]; then
|
||||||
|
LD_LIBRARY_PATH="@WIND_LMAPI@:${LD_LIBRARY_PATH}"
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Strip C compiler from command line arguments for compatibility because this
|
||||||
|
# launcher may also be used from an integrated development environment at some
|
||||||
|
# point.
|
||||||
|
if [ "$1" = "@CMAKE_CXX_COMPILER@" ]; then
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "@CMAKE_CXX_COMPILER@" "$@"
|
||||||
|
|
||||||
65
src/cmake/modules/AnalyzeBuild.cmake
Normal file
65
src/cmake/modules/AnalyzeBuild.cmake
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
cmake_minimum_required(VERSION 3.3) # For IN_LIST
|
||||||
|
|
||||||
|
option(ANALYZE_BUILD "Enable static analysis during build" OFF)
|
||||||
|
|
||||||
|
if(ANALYZE_BUILD)
|
||||||
|
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||||
|
set(scan_build_supported Clang AppleClang GNU)
|
||||||
|
|
||||||
|
if("C" IN_LIST languages)
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
set(ANALYZE_C_BUILD_FLAG "/analyze")
|
||||||
|
elseif(CMAKE_C_COMPILER_ID IN_LIST scan_build_supported)
|
||||||
|
message(STATUS "Static analysis for C using ${CMAKE_C_COMPILER_ID}-compiler is available by using 'scan-build' manually only")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
CHECK_C_COMPILER_FLAG(${ANALYZE_C_BUILD_FLAG} C_COMPILER_HAS_ANALYZE_BUILD)
|
||||||
|
|
||||||
|
if(C_COMPILER_HAS_ANALYZE_BUILD)
|
||||||
|
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||||
|
# $<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
|
||||||
|
add_compile_options(${ANALYZE_C_BUILD_FLAG})
|
||||||
|
else()
|
||||||
|
add_compile_options($<$<COMPILE_LANGUAGE:C>:${ANALYZE_C_BUILD_FLAG}>)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("CXX" IN_LIST languages)
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
set(ANALYZE_CXX_BUILD_FLAG "/analyze")
|
||||||
|
elseif(CMAKE_C_COMPILER_ID IN_LIST scan_build_supported)
|
||||||
|
message(STATUS "Static analysis for CXX using ${CMAKE_CXX_COMPILER_ID}-compiler is available by using 'scan-build' manually only")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED ANALYZE_CXX_BUILD_FLAG)
|
||||||
|
CHECK_CXX_COMPILER_FLAG(${ANALYZE_CXX_BUILD_FLAG} CXX_COMPILER_HAS_ANALYZE_BUILD)
|
||||||
|
|
||||||
|
if(CXX_COMPILER_HAS_ANALYZE_BUILD)
|
||||||
|
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||||
|
add_compile_options(${ANALYZE_CXX_BUILD_FLAG})
|
||||||
|
else()
|
||||||
|
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${ANALYZE_CXX_BUILD_FLAG}>)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
128
src/cmake/modules/CUnit.cmake
Normal file
128
src/cmake/modules/CUnit.cmake
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
find_package(CUnit REQUIRED)
|
||||||
|
|
||||||
|
include(Glob)
|
||||||
|
|
||||||
|
set(CUNIT_DIR "${CMAKE_CURRENT_LIST_DIR}/CUnit")
|
||||||
|
|
||||||
|
function(add_cunit_executable target)
|
||||||
|
# Generate semi-random filename to store the generated code in to avoid
|
||||||
|
# possible naming conflicts.
|
||||||
|
string(RANDOM random)
|
||||||
|
set(runner "${target}_${random}")
|
||||||
|
|
||||||
|
set(s "[ \t\r\n]") # space
|
||||||
|
set(w "[0-9a-zA-Z_]") # word
|
||||||
|
set(param "${s}*(${w}+)${s}*")
|
||||||
|
set(pattern "CUnit_${w}+${s}*\\(${param}(,${param}(,${param})?)?\\)")
|
||||||
|
|
||||||
|
glob(filenames "c" ${ARGN})
|
||||||
|
|
||||||
|
foreach(filename ${filenames})
|
||||||
|
file(READ "${filename}" contents)
|
||||||
|
string(REGEX MATCHALL "${pattern}" captures "${contents}")
|
||||||
|
|
||||||
|
list(APPEND sources "${filename}")
|
||||||
|
list(LENGTH captures length)
|
||||||
|
if(length)
|
||||||
|
foreach(capture ${captures})
|
||||||
|
string(REGEX REPLACE "${pattern}" "\\1" suite "${capture}")
|
||||||
|
|
||||||
|
if("${capture}" MATCHES "CUnit_Suite_Initialize")
|
||||||
|
list(APPEND suites ${suite})
|
||||||
|
list(APPEND suites_w_init ${suite})
|
||||||
|
elseif("${capture}" MATCHES "CUnit_Suite_Cleanup")
|
||||||
|
list(APPEND suites ${suite})
|
||||||
|
list(APPEND suites_w_deinit ${suite})
|
||||||
|
elseif("${capture}" MATCHES "CUnit_Test")
|
||||||
|
list(APPEND suites ${suite})
|
||||||
|
|
||||||
|
# Specifying a test name is mandatory
|
||||||
|
if("${capture}" MATCHES ",")
|
||||||
|
string(REGEX REPLACE "${pattern}" "\\3" test "${capture}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Bad CUnit_Test signature in ${filename}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Specifying if a test is enabled is optional
|
||||||
|
set(enable "true")
|
||||||
|
if("${capture}" MATCHES ",${param},")
|
||||||
|
string(REGEX REPLACE "${pattern}" "\\5" enable "${capture}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if((NOT "${enable}" STREQUAL "true") AND
|
||||||
|
(NOT "${enable}" STREQUAL "false"))
|
||||||
|
message(FATAL_ERROR "Bad CUnit_Test signature in ${filename}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND tests "${suite}:${test}:${enable}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Bad CUnit signature in ${filename}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Test suite signatures can be decided on only after everything is parsed.
|
||||||
|
set(lf "\n")
|
||||||
|
set(declf "")
|
||||||
|
set(deflf "")
|
||||||
|
|
||||||
|
list(REMOVE_DUPLICATES suites)
|
||||||
|
list(SORT suites)
|
||||||
|
foreach(suite ${suites})
|
||||||
|
set(init "NULL")
|
||||||
|
set(deinit "NULL")
|
||||||
|
if(${suite} IN_LIST suites_w_init)
|
||||||
|
set(init "CUnit_Suite_Initialize__(${suite})")
|
||||||
|
set(decls "${decls}${declf}CUnit_Suite_Initialize_Decl__(${suite});")
|
||||||
|
set(declf "${lf}")
|
||||||
|
endif()
|
||||||
|
if(${suite} IN_LIST suites_w_deinit)
|
||||||
|
set(deinit "CUnit_Suite_Cleanup__(${suite})")
|
||||||
|
set(decls "${decls}${declf}CUnit_Suite_Cleanup_Decl__(${suite});")
|
||||||
|
set(declf "${lf}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(defs "${defs}${deflf}CUnit_Suite__(${suite}, ${init}, ${deinit});")
|
||||||
|
set(deflf "${lf}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
list(REMOVE_DUPLICATES tests)
|
||||||
|
list(SORT tests)
|
||||||
|
foreach(entry ${tests})
|
||||||
|
string(REPLACE ":" ";" entry ${entry})
|
||||||
|
list(GET entry 0 suite)
|
||||||
|
list(GET entry 1 test)
|
||||||
|
list(GET entry 2 enable)
|
||||||
|
|
||||||
|
set(decls "${decls}${declf}CUnit_Test_Decl__(${suite}, ${test});")
|
||||||
|
set(declf "${lf}")
|
||||||
|
set(defs "${defs}${deflf}CUnit_Test__(${suite}, ${test}, ${enable});")
|
||||||
|
set(deflf "${lf}")
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME "CUnit_${suite}_${test}"
|
||||||
|
COMMAND ${target} -a -r "${suite}-${test}" -s ${suite} -t ${test})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(root "${CUNIT_DIR}")
|
||||||
|
set(CUnit_Decls "${decls}")
|
||||||
|
set(CUnit_Defs "${defs}")
|
||||||
|
|
||||||
|
configure_file("${root}/src/main.c.in" "${runner}.c" @ONLY)
|
||||||
|
add_executable(${target} "${runner}.c" "${root}/src/runner.c" ${sources})
|
||||||
|
target_link_libraries(${target} CUnit)
|
||||||
|
target_include_directories(${target} PRIVATE "${root}/include")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
83
src/cmake/modules/CUnit/include/CUnit/Runner.h
Normal file
83
src/cmake/modules/CUnit/include/CUnit/Runner.h
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef CUNIT_RUNNER_H
|
||||||
|
#define CUNIT_RUNNER_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <CUnit/CUnit.h>
|
||||||
|
#include <CUnit/CUError.h>
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CUnit_Suite_Initialize_Name__(s) \
|
||||||
|
s ## _Initialize
|
||||||
|
#define CUnit_Suite_Initialize(s) \
|
||||||
|
int CUnit_Suite_Initialize_Name__(s)(void)
|
||||||
|
#define CUnit_Suite_Initialize_Decl__(s) \
|
||||||
|
extern CUnit_Suite_Initialize(s)
|
||||||
|
#define CUnit_Suite_Initialize__(s) \
|
||||||
|
CUnit_Suite_Initialize_Name__(s)
|
||||||
|
|
||||||
|
#define CUnit_Suite_Cleanup_Name__(s) \
|
||||||
|
s ## _Cleanup
|
||||||
|
#define CUnit_Suite_Cleanup(s) \
|
||||||
|
int CUnit_Suite_Cleanup_Name__(s)(void)
|
||||||
|
#define CUnit_Suite_Cleanup_Decl__(s) \
|
||||||
|
extern CUnit_Suite_Cleanup(s)
|
||||||
|
#define CUnit_Suite_Cleanup__(s) \
|
||||||
|
CUnit_Suite_Cleanup_Name__(s)
|
||||||
|
|
||||||
|
#define CUnit_Test_Name__(s, t) \
|
||||||
|
s ## _ ## t
|
||||||
|
#define CUnit_Test(s, t, ...) \
|
||||||
|
void CUnit_Test_Name__(s, t)(void)
|
||||||
|
#define CUnit_Test_Decl__(s, t) \
|
||||||
|
extern CUnit_Test(s, t)
|
||||||
|
|
||||||
|
#define CUnit_Suite__(s, c, d) \
|
||||||
|
cu_runner_add_suite(#s, c, d)
|
||||||
|
#define CUnit_Test__(s, t, e) \
|
||||||
|
cu_runner_add_test(#s, #t, CUnit_Test_Name__(s, t), e)
|
||||||
|
|
||||||
|
CU_ErrorCode
|
||||||
|
cu_runner_init(
|
||||||
|
int argc,
|
||||||
|
char *argv[]);
|
||||||
|
|
||||||
|
void
|
||||||
|
cu_runner_fini(
|
||||||
|
void);
|
||||||
|
|
||||||
|
void
|
||||||
|
cu_runner_add_suite(
|
||||||
|
const char *suite,
|
||||||
|
CU_InitializeFunc pInitFunc,
|
||||||
|
CU_CleanupFunc pCleanFunc);
|
||||||
|
|
||||||
|
void
|
||||||
|
cu_runner_add_test(
|
||||||
|
const char *suite,
|
||||||
|
const char *test,
|
||||||
|
CU_TestFunc pTestFunc,
|
||||||
|
bool enable);
|
||||||
|
|
||||||
|
CU_ErrorCode
|
||||||
|
cu_runner_run(
|
||||||
|
void);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CUNIT_RUNNER_H */
|
||||||
31
src/cmake/modules/CUnit/src/main.c.in
Normal file
31
src/cmake/modules/CUnit/src/main.c.in
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include "CUnit/Runner.h"
|
||||||
|
|
||||||
|
@CUnit_Decls@
|
||||||
|
|
||||||
|
int main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
CU_ErrorCode err;
|
||||||
|
|
||||||
|
if ((err = cu_runner_init(argc, argv))) {
|
||||||
|
goto err_init;
|
||||||
|
}
|
||||||
|
|
||||||
|
@CUnit_Defs@
|
||||||
|
|
||||||
|
err = cu_runner_run();
|
||||||
|
cu_runner_fini();
|
||||||
|
err_init:
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
213
src/cmake/modules/CUnit/src/runner.c
Normal file
213
src/cmake/modules/CUnit/src/runner.c
Normal file
|
|
@ -0,0 +1,213 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <CUnit/Basic.h>
|
||||||
|
#include <CUnit/Automated.h>
|
||||||
|
|
||||||
|
#include "CUnit/Runner.h"
|
||||||
|
|
||||||
|
static struct cunit_runner {
|
||||||
|
bool automated;
|
||||||
|
bool junit;
|
||||||
|
const char * results;
|
||||||
|
CU_BasicRunMode mode;
|
||||||
|
CU_ErrorAction error_action;
|
||||||
|
const char *suite;
|
||||||
|
const char *test;
|
||||||
|
} runner;
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(
|
||||||
|
const char * name)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "usage: %s [flags]\n", name);
|
||||||
|
fprintf(stderr, "Supported flags:\n");
|
||||||
|
fprintf(stderr, " -a run in automated mode\n");
|
||||||
|
fprintf(stderr, " -r <file_name> results file for automated run\n");
|
||||||
|
fprintf(stderr, " -j junit format results \n");
|
||||||
|
fprintf(stderr, " -f fail fast \n");
|
||||||
|
fprintf(stderr, " -s suite\n");
|
||||||
|
fprintf(stderr, " -t test\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
patmatch(
|
||||||
|
const char *pat,
|
||||||
|
const char *str)
|
||||||
|
{
|
||||||
|
while (*pat) {
|
||||||
|
if (*pat == '?') {
|
||||||
|
/* any character will do */
|
||||||
|
if (*str++ == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pat++;
|
||||||
|
} else if (*pat == '*') {
|
||||||
|
/* collapse a sequence of wildcards, requiring as many
|
||||||
|
characters in str as there are ?s in the sequence */
|
||||||
|
while (*pat == '*' || *pat == '?') {
|
||||||
|
if (*pat == '?' && *str++ == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pat++;
|
||||||
|
}
|
||||||
|
/* try matching on all positions where str matches pat */
|
||||||
|
while (*str) {
|
||||||
|
if (*str == *pat && patmatch(pat+1, str+1)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
return *pat == 0;
|
||||||
|
} else {
|
||||||
|
/* only an exact match */
|
||||||
|
if (*str++ != *pat++) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *str == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CU_ErrorCode
|
||||||
|
cu_runner_init(
|
||||||
|
int argc,
|
||||||
|
char* argv[])
|
||||||
|
{
|
||||||
|
int c, i;
|
||||||
|
CU_ErrorCode e = CUE_SUCCESS;
|
||||||
|
|
||||||
|
runner.automated = false;
|
||||||
|
runner.junit = false;
|
||||||
|
runner.results = NULL;
|
||||||
|
runner.mode = CU_BRM_NORMAL;
|
||||||
|
runner.error_action = CUEA_IGNORE;
|
||||||
|
runner.suite = "*";
|
||||||
|
runner.test = "*";
|
||||||
|
|
||||||
|
for (i = 1; e == CUE_SUCCESS && i < argc; i++) {
|
||||||
|
c = (argv[i][0] == '-') ? argv[i][1] : -1;
|
||||||
|
switch (argv[i][1]) {
|
||||||
|
case 'a':
|
||||||
|
runner.automated = true;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
runner.error_action = CUEA_FAIL;
|
||||||
|
break;
|
||||||
|
case 'j':
|
||||||
|
runner.junit = true;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
if((i+1) < argc){
|
||||||
|
runner.results = argv[++i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* no break */
|
||||||
|
case 's':
|
||||||
|
if ((i+1) < argc) {
|
||||||
|
runner.suite = argv[++i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* no break */
|
||||||
|
case 't':
|
||||||
|
if ((i+1) < argc) {
|
||||||
|
runner.test = argv[++i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* no break */
|
||||||
|
default:
|
||||||
|
e = (CU_ErrorCode)256;
|
||||||
|
CU_set_error(e); /* Will print as "Undefined Errpr" */
|
||||||
|
usage(argv[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e == CUE_SUCCESS) {
|
||||||
|
if ((e = CU_initialize_registry()) != CUE_SUCCESS) {
|
||||||
|
fprintf(
|
||||||
|
stderr, "Test registry initialization failed: %s\n", CU_get_error_msg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CU_set_error_action (runner.error_action);
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cu_runner_fini(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
CU_cleanup_registry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cu_runner_add_suite(
|
||||||
|
const char *suite,
|
||||||
|
CU_InitializeFunc pInitFunc,
|
||||||
|
CU_CleanupFunc pCleanFunc)
|
||||||
|
{
|
||||||
|
CU_pSuite pSuite;
|
||||||
|
|
||||||
|
pSuite = CU_get_suite(suite);
|
||||||
|
if (pSuite == NULL) {
|
||||||
|
pSuite = CU_add_suite(suite, pInitFunc, pCleanFunc);
|
||||||
|
//assert(pSuite != NULL);
|
||||||
|
CU_set_suite_active(pSuite, patmatch(runner.suite, suite));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cu_runner_add_test(
|
||||||
|
const char *suite,
|
||||||
|
const char *test,
|
||||||
|
CU_TestFunc pTestFunc,
|
||||||
|
bool enable)
|
||||||
|
{
|
||||||
|
CU_pSuite pSuite;
|
||||||
|
CU_pTest pTest;
|
||||||
|
|
||||||
|
pSuite = CU_get_suite(suite);
|
||||||
|
//assert(pSuite != NULL);
|
||||||
|
pTest = CU_add_test(pSuite, test, pTestFunc);
|
||||||
|
//assert(pTest != NULL);
|
||||||
|
CU_set_test_active(pTest, enable && patmatch(runner.test, test));
|
||||||
|
}
|
||||||
|
|
||||||
|
CU_ErrorCode
|
||||||
|
cu_runner_run(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
if (runner.automated) {
|
||||||
|
/* Generate CUnit or JUnit format results */
|
||||||
|
if (runner.results != NULL) {
|
||||||
|
CU_set_output_filename(runner.results);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runner.junit) {
|
||||||
|
CU_automated_enable_junit_xml(CU_TRUE);
|
||||||
|
} else {
|
||||||
|
CU_list_tests_to_file();
|
||||||
|
}
|
||||||
|
CU_automated_run_tests();
|
||||||
|
} else {
|
||||||
|
CU_basic_set_mode(runner.mode);
|
||||||
|
CU_basic_run_tests();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CU_get_error() == 0) {
|
||||||
|
return (CU_get_number_of_failures() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return CU_get_error();
|
||||||
|
}
|
||||||
50
src/cmake/modules/Coverage.cmake
Normal file
50
src/cmake/modules/Coverage.cmake
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Coverage")
|
||||||
|
set(BUILD_TYPE_SUPPORTED False)
|
||||||
|
mark_as_advanced(BUILD_TYPE_SUPPORTED)
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
set(BUILD_TYPE_SUPPORTED True)
|
||||||
|
elseif(("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang") AND
|
||||||
|
("${CMAKE_C_COMPILER_VERSION}" VERSION_GREATER "3.0.0"))
|
||||||
|
set(BUILD_TYPE_SUPPORTED True)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT BUILD_TYPE_SUPPORTED)
|
||||||
|
message(FATAL_ERROR "Coverage build type not supported. (GCC or Clang "
|
||||||
|
">3.0.0 required)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# NOTE: Since either GCC or Clang is required for now, and the coverage
|
||||||
|
# flags are the same for both, there is no need for seperate branches
|
||||||
|
# to set compiler flags. That might change in the future.
|
||||||
|
|
||||||
|
# CMake has per build type compiler and linker flags. If 'Coverage' is
|
||||||
|
# chosen, the flags below are automatically inserted into CMAKE_C_FLAGS.
|
||||||
|
#
|
||||||
|
# Any optimizations are disabled to ensure coverage results are correct.
|
||||||
|
# See https://gcc.gnu.org/onlinedocs/gcc/Gcov-and-Optimization.html.
|
||||||
|
set(CMAKE_C_FLAGS_COVERAGE
|
||||||
|
"-DNDEBUG -g -O0 --coverage -fprofile-arcs -ftest-coverage")
|
||||||
|
set(CMAKE_CXX_FLAGS_COVERAGE
|
||||||
|
"-DNDEBUG -g -O0 --coverage -fprofile-arcs -ftest-coverage")
|
||||||
|
mark_as_advanced(
|
||||||
|
CMAKE_C_FLAGS_COVERAGE
|
||||||
|
CMAKE_CXX_FLAGS_COVERAGE
|
||||||
|
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||||
|
CMAKE_SHARED_LINKER_FLAGS_COVERAGE)
|
||||||
|
|
||||||
|
configure_file(${CMAKE_MODULE_PATH}/../CoverageSettings.cmake.in CoverageSettings.cmake @ONLY)
|
||||||
|
|
||||||
|
message(STATUS "Coverage build type available")
|
||||||
|
endif()
|
||||||
|
|
||||||
78
src/cmake/modules/Criterion.cmake
Normal file
78
src/cmake/modules/Criterion.cmake
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
find_package(Criterion REQUIRED)
|
||||||
|
|
||||||
|
include(Glob)
|
||||||
|
|
||||||
|
set(_criterion_dir "${CMAKE_CURRENT_LIST_DIR}/Criterion")
|
||||||
|
|
||||||
|
function(add_criterion_executable _target)
|
||||||
|
set(s "[ \t\r\n]") # space
|
||||||
|
set(w "[0-9a-zA-Z_]") # word
|
||||||
|
set(b "[^0-9a-zA-Z_]") # boundary
|
||||||
|
set(arg "${s}*(${w}+)${s}*")
|
||||||
|
set(test "(^|${b})Test${s}*\\(${arg},${arg}(,[^\\)]+)?\\)") # Test
|
||||||
|
set(params "${s}*\\([^\\)]*\\)${s}*")
|
||||||
|
set(theory "(^|${b})Theory${s}*\\(${params},${arg},${arg}(,[^\\)]+)?\\)") # Theory
|
||||||
|
set(paramtest "(^|${b})ParameterizedTest${s}*\\([^,]+,${arg},${arg}(,[^\\)]+)?\\)") # ParameterizedTest
|
||||||
|
|
||||||
|
glob(_files "c" ${ARGN})
|
||||||
|
|
||||||
|
foreach(_file ${_files})
|
||||||
|
file(READ "${_file}" _contents)
|
||||||
|
string(REGEX MATCHALL "${test}" _matches "${_contents}")
|
||||||
|
|
||||||
|
list(APPEND _sources "${_file}")
|
||||||
|
list(LENGTH _matches _length)
|
||||||
|
if(_length)
|
||||||
|
foreach(_match ${_matches})
|
||||||
|
string(REGEX REPLACE "${test}" "\\2" _suite "${_match}")
|
||||||
|
string(REGEX REPLACE "${test}" "\\3" _name "${_match}")
|
||||||
|
list(APPEND _tests "${_suite}:${_name}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(REGEX MATCHALL "${theory}" _matches "${_contents}")
|
||||||
|
list(LENGTH _matches _length)
|
||||||
|
if(_length)
|
||||||
|
foreach(_match ${_matches})
|
||||||
|
string(REGEX REPLACE "${theory}" "\\2" _suite "${_match}")
|
||||||
|
string(REGEX REPLACE "${theory}" "\\3" _name "${_match}")
|
||||||
|
list(APPEND _tests "${_suite}:${_name}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(REGEX MATCHALL "${paramtest}" _matches "${_contents}")
|
||||||
|
list(LENGTH _matches _length)
|
||||||
|
if(_length)
|
||||||
|
foreach(_match ${_matches})
|
||||||
|
string(REGEX REPLACE "${paramtest}" "\\2" _suite "${_match}")
|
||||||
|
string(REGEX REPLACE "${paramtest}" "\\3" _name "${_match}")
|
||||||
|
list(APPEND _tests "${_suite}:${_name}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_executable(${_target} "${_criterion_dir}/src/runner.c" ${_sources})
|
||||||
|
target_link_libraries(${_target} Criterion)
|
||||||
|
|
||||||
|
foreach(_entry ${_tests})
|
||||||
|
string(REPLACE ":" ";" _entry ${_entry})
|
||||||
|
list(GET _entry 0 _suite)
|
||||||
|
list(GET _entry 1 _name)
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME "Criterion_${_suite}_${_name}"
|
||||||
|
COMMAND ${_target} --suite ${_suite} --test ${_name} --cunit=${_suite}-${_name} --quiet)
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
474
src/cmake/modules/Criterion/src/runner.c
Normal file
474
src/cmake/modules/Criterion/src/runner.c
Normal file
|
|
@ -0,0 +1,474 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <criterion/criterion.h>
|
||||||
|
#include <criterion/hooks.h>
|
||||||
|
#include <criterion/internal/ordered-set.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define LF "\r\n"
|
||||||
|
#define NAME_MAX _MAX_FNAME
|
||||||
|
#else
|
||||||
|
#define LF "\n"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char *suitepat = "*";
|
||||||
|
static const char *testpat = "*";
|
||||||
|
static char runfn[NAME_MAX + 1] = { 0 };
|
||||||
|
static char listfn[NAME_MAX + 1] = { 0 };
|
||||||
|
static char stamp[64] = { 0 };
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_hdr[] =
|
||||||
|
"<?xml version=\"1.0\" ?>" LF
|
||||||
|
"<?xml-stylesheet type=\"text/xsl\" href=\"CUnit-Run.xsl\" ?>" LF
|
||||||
|
"<!DOCTYPE CUNIT_TEST_RUN_REPORT SYSTEM \"CUnit-Run.dtd\">" LF
|
||||||
|
"<CUNIT_TEST_RUN_REPORT>" LF
|
||||||
|
" <CUNIT_HEADER/>" LF;
|
||||||
|
|
||||||
|
/* TODO: Criterion version number is not available in any of the header files,
|
||||||
|
but print_version() is. The function prints a message along the lines
|
||||||
|
of: Tests compiled with Criterion v2.3.2. The version number therefore
|
||||||
|
can be retrieved by temporarily swapping out stdout for a FILE handle
|
||||||
|
opened by open_memstream. However, I don't consider the version number
|
||||||
|
important enough to go through all that trouble. */
|
||||||
|
static const char
|
||||||
|
run_ftr[] =
|
||||||
|
" <CUNIT_FOOTER> File Generated By Criterion - %s </CUNIT_FOOTER>" LF
|
||||||
|
"</CUNIT_TEST_RUN_REPORT>";
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_result_hdr[] =
|
||||||
|
" <CUNIT_RESULT_LISTING>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_result_ftr[] =
|
||||||
|
" </CUNIT_RESULT_LISTING>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_suite_hdr[] =
|
||||||
|
" <CUNIT_RUN_SUITE>" LF
|
||||||
|
" <CUNIT_RUN_SUITE_SUCCESS>" LF
|
||||||
|
" <SUITE_NAME> %s </SUITE_NAME>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_suite_ftr[] =
|
||||||
|
" </CUNIT_RUN_SUITE_SUCCESS>" LF
|
||||||
|
" </CUNIT_RUN_SUITE>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_test_hdr[] =
|
||||||
|
" <CUNIT_RUN_TEST_RECORD>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_test_ftr[] =
|
||||||
|
" </CUNIT_RUN_TEST_RECORD>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_test_ok[] =
|
||||||
|
" <CUNIT_RUN_TEST_SUCCESS>" LF
|
||||||
|
" <TEST_NAME> %s </TEST_NAME>" LF
|
||||||
|
" </CUNIT_RUN_TEST_SUCCESS>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_test_nok[] =
|
||||||
|
" <CUNIT_RUN_TEST_FAILURE>" LF
|
||||||
|
" <TEST_NAME> %s </TEST_NAME>" LF
|
||||||
|
" <FILE_NAME> %s </FILE_NAME>" LF
|
||||||
|
" <LINE_NUMBER> %u </LINE_NUMBER>" LF
|
||||||
|
" <CONDITION> %s </CONDITION>" LF
|
||||||
|
" </CUNIT_RUN_TEST_FAILURE>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
run_stats[] =
|
||||||
|
" <CUNIT_RUN_SUMMARY>" LF
|
||||||
|
" <CUNIT_RUN_SUMMARY_RECORD>" LF
|
||||||
|
" <TYPE> Suites </TYPE>" LF
|
||||||
|
" <TOTAL> %zu </TOTAL>" LF
|
||||||
|
" <RUN> %zu </RUN>" LF
|
||||||
|
" <SUCCEEDED> - NA - </SUCCEEDED>" LF
|
||||||
|
" <FAILED> %zu </FAILED>" LF
|
||||||
|
" <INACTIVE> %zu </INACTIVE>" LF
|
||||||
|
" </CUNIT_RUN_SUMMARY_RECORD>" LF
|
||||||
|
" <CUNIT_RUN_SUMMARY_RECORD>" LF
|
||||||
|
" <TYPE> Test Cases </TYPE>" LF
|
||||||
|
" <TOTAL> %zu </TOTAL>" LF
|
||||||
|
" <RUN> %zu </RUN>" LF
|
||||||
|
" <SUCCEEDED> %zu </SUCCEEDED>" LF
|
||||||
|
" <FAILED> %zu </FAILED>" LF
|
||||||
|
" <INACTIVE> %zu </INACTIVE>" LF
|
||||||
|
" </CUNIT_RUN_SUMMARY_RECORD>" LF
|
||||||
|
" <CUNIT_RUN_SUMMARY_RECORD>" LF
|
||||||
|
" <TYPE> Assertions </TYPE>" LF
|
||||||
|
" <TOTAL> %zu </TOTAL>" LF
|
||||||
|
" <RUN> %zu </RUN>" LF
|
||||||
|
" <SUCCEEDED> %zu </SUCCEEDED>" LF
|
||||||
|
" <FAILED> %zu </FAILED>" LF
|
||||||
|
" <INACTIVE> n/a </INACTIVE>" LF
|
||||||
|
" </CUNIT_RUN_SUMMARY_RECORD>" LF
|
||||||
|
" </CUNIT_RUN_SUMMARY>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
list_hdr[] =
|
||||||
|
"<?xml version=\"1.0\" ?>" LF
|
||||||
|
"<?xml-stylesheet type=\"text/xsl\" href=\"CUnit-List.xsl\" ?>" LF
|
||||||
|
"<!DOCTYPE CUNIT_TEST_LIST_REPORT SYSTEM \"CUnit-List.dtd\">" LF
|
||||||
|
"<CUNIT_TEST_LIST_REPORT>" LF
|
||||||
|
" <CUNIT_HEADER/>" LF;
|
||||||
|
|
||||||
|
/* TODO: Criterion version number not available. See previous comment. */
|
||||||
|
static const char
|
||||||
|
list_ftr[] =
|
||||||
|
" <CUNIT_FOOTER> File Generated By Criterion - %s </CUNIT_FOOTER>" LF
|
||||||
|
"</CUNIT_TEST_LIST_REPORT>";
|
||||||
|
|
||||||
|
static const char
|
||||||
|
list_stats[] =
|
||||||
|
" <CUNIT_LIST_TOTAL_SUMMARY>" LF
|
||||||
|
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD>" LF
|
||||||
|
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT> Total Number of Suites </CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT>" LF
|
||||||
|
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> %zu </CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE>" LF
|
||||||
|
" </CUNIT_LIST_TOTAL_SUMMARY_RECORD>" LF
|
||||||
|
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD>" LF
|
||||||
|
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT> Total Number of Test Cases </CUNIT_LIST_TOTAL_SUMMARY_RECORD_TEXT>" LF
|
||||||
|
" <CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE> %zu </CUNIT_LIST_TOTAL_SUMMARY_RECORD_VALUE>" LF
|
||||||
|
" </CUNIT_LIST_TOTAL_SUMMARY_RECORD>" LF
|
||||||
|
" </CUNIT_LIST_TOTAL_SUMMARY>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
list_suites_hdr[] =
|
||||||
|
" <CUNIT_ALL_TEST_LISTING_SUITE>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
list_suites_ftr[] =
|
||||||
|
" </CUNIT_ALL_TEST_LISTING_SUITE>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
list_suite_hdr[] =
|
||||||
|
" <CUNIT_ALL_TEST_LISTING_SUITE>" LF
|
||||||
|
" <CUNIT_ALL_TEST_LISTING_SUITE_DEFINITION>" LF
|
||||||
|
" <SUITE_NAME> %s </SUITE_NAME>" LF
|
||||||
|
" <INITIALIZE_VALUE> %s </INITIALIZE_VALUE>" LF
|
||||||
|
" <CLEANUP_VALUE> %s </CLEANUP_VALUE>" LF
|
||||||
|
" <ACTIVE_VALUE> %s </ACTIVE_VALUE>" LF
|
||||||
|
" <TEST_COUNT_VALUE> %zu </TEST_COUNT_VALUE>" LF
|
||||||
|
" </CUNIT_ALL_TEST_LISTING_SUITE_DEFINITION>" LF
|
||||||
|
" <CUNIT_ALL_TEST_LISTING_SUITE_TESTS>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
list_suite_ftr[] =
|
||||||
|
" </CUNIT_ALL_TEST_LISTING_SUITE_TESTS>" LF
|
||||||
|
" </CUNIT_ALL_TEST_LISTING_SUITE>" LF;
|
||||||
|
|
||||||
|
static const char
|
||||||
|
list_test[] =
|
||||||
|
" <TEST_CASE_DEFINITION>" LF
|
||||||
|
" <TEST_CASE_NAME> %s </TEST_CASE_NAME>" LF
|
||||||
|
" <TEST_ACTIVE_VALUE> %s </TEST_ACTIVE_VALUE>" LF
|
||||||
|
" </TEST_CASE_DEFINITION>" LF;
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_run_test_stats(FILE *file, struct criterion_test_stats *stats)
|
||||||
|
{
|
||||||
|
struct criterion_assert_stats *itr;
|
||||||
|
|
||||||
|
(void)fprintf(file, run_test_hdr);
|
||||||
|
if (stats->test_status == CR_STATUS_PASSED) {
|
||||||
|
(void)fprintf(file, run_test_ok, stats->test->name);
|
||||||
|
} else if (stats->test_status == CR_STATUS_FAILED) {
|
||||||
|
for (itr = stats->asserts; itr != NULL; itr = itr->next) {
|
||||||
|
if (!itr->passed) {
|
||||||
|
(void)fprintf(
|
||||||
|
file,
|
||||||
|
run_test_nok,
|
||||||
|
stats->test->name,
|
||||||
|
itr->file,
|
||||||
|
itr->line,
|
||||||
|
itr->message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(void)fprintf(file, run_test_ftr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_run_suite_stats(FILE *file, struct criterion_suite_stats *stats)
|
||||||
|
{
|
||||||
|
struct criterion_test_stats *itr;
|
||||||
|
|
||||||
|
(void)fprintf(file, run_suite_hdr, stats->suite->name);
|
||||||
|
for (itr = stats->tests; itr != NULL; itr = itr->next) {
|
||||||
|
if (itr->test_status != CR_STATUS_SKIPPED) {
|
||||||
|
print_run_test_stats(file, itr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(void)fprintf(file, run_suite_ftr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_run_stats(FILE *file, struct criterion_global_stats *stats)
|
||||||
|
{
|
||||||
|
size_t suites_failed = 0;
|
||||||
|
size_t suites_passed = 0;
|
||||||
|
struct criterion_suite_stats *itr;
|
||||||
|
|
||||||
|
(void)fprintf(file, run_hdr);
|
||||||
|
(void)fprintf(file, run_result_hdr);
|
||||||
|
for (itr = stats->suites; itr != NULL; itr = itr->next) {
|
||||||
|
if (itr->tests_skipped != itr->nb_tests) {
|
||||||
|
print_run_suite_stats(file, itr);
|
||||||
|
if (itr->tests_failed == itr->nb_tests) {
|
||||||
|
suites_failed++;
|
||||||
|
} else {
|
||||||
|
suites_passed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(void)fprintf(file, run_result_ftr);
|
||||||
|
(void)fprintf(
|
||||||
|
file,
|
||||||
|
run_stats,
|
||||||
|
stats->nb_suites,
|
||||||
|
suites_passed,
|
||||||
|
suites_failed,
|
||||||
|
(stats->nb_suites - (suites_passed - suites_failed)),
|
||||||
|
stats->nb_tests,
|
||||||
|
(stats->tests_passed + stats->tests_failed + stats->tests_crashed),
|
||||||
|
stats->tests_passed,
|
||||||
|
(stats->tests_failed + stats->tests_crashed),
|
||||||
|
stats->tests_skipped,
|
||||||
|
stats->nb_asserts,
|
||||||
|
(stats->asserts_passed + stats->asserts_failed),
|
||||||
|
stats->asserts_passed,
|
||||||
|
stats->asserts_failed);
|
||||||
|
(void)fprintf(file, run_ftr, stamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_list_test_stats(FILE *file, struct criterion_test_stats *stats)
|
||||||
|
{
|
||||||
|
(void)fprintf(
|
||||||
|
file,
|
||||||
|
list_test,
|
||||||
|
stats->test->name,
|
||||||
|
(stats->test_status == CR_STATUS_SKIPPED ? "No" : "Yes"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_list_suite_stats(FILE *file, struct criterion_suite_stats *stats)
|
||||||
|
{
|
||||||
|
struct criterion_test_stats *itr;
|
||||||
|
|
||||||
|
(void)fprintf(
|
||||||
|
file,
|
||||||
|
list_suite_hdr,
|
||||||
|
stats->suite->name,
|
||||||
|
"No", // <INITIALIZE_VALUE />
|
||||||
|
"No", // <CLEANUP_VALUE />
|
||||||
|
(stats->nb_tests == stats->tests_skipped ? "No" : "Yes"),
|
||||||
|
stats->nb_tests);
|
||||||
|
for (itr = stats->tests; itr != NULL; itr = itr->next) {
|
||||||
|
print_list_test_stats(file, itr);
|
||||||
|
}
|
||||||
|
(void)fprintf(file, list_suite_ftr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_list_stats(FILE *file, struct criterion_global_stats *stats)
|
||||||
|
{
|
||||||
|
struct criterion_suite_stats *itr;
|
||||||
|
|
||||||
|
(void)fprintf(file, list_hdr);
|
||||||
|
(void)fprintf(file, list_stats, stats->nb_suites, stats->nb_tests);
|
||||||
|
(void)fprintf(file, list_suites_hdr);
|
||||||
|
|
||||||
|
for (itr = stats->suites; itr != NULL; itr = itr->next) {
|
||||||
|
print_list_suite_stats(file, itr);
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)fprintf(file, list_suites_ftr);
|
||||||
|
(void)fprintf(file, list_ftr, stamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
patmatch(
|
||||||
|
const char *pat,
|
||||||
|
const char *str)
|
||||||
|
{
|
||||||
|
while (*pat) {
|
||||||
|
if (*pat == '?') {
|
||||||
|
/* any character will do */
|
||||||
|
if (*str++ == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pat++;
|
||||||
|
} else if (*pat == '*') {
|
||||||
|
/* collapse a sequence of wildcards, requiring as many
|
||||||
|
characters in str as there are ?s in the sequence */
|
||||||
|
while (*pat == '*' || *pat == '?') {
|
||||||
|
if (*pat == '?' && *str++ == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pat++;
|
||||||
|
}
|
||||||
|
/* try matching on all positions where str matches pat */
|
||||||
|
while (*str) {
|
||||||
|
if (*str == *pat && patmatch(pat+1, str+1)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
return *pat == 0;
|
||||||
|
} else {
|
||||||
|
/* only an exact match */
|
||||||
|
if (*str++ != *pat++) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *str == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Criterion actually prescribes */
|
||||||
|
ReportHook(POST_ALL)(struct criterion_global_stats *stats)
|
||||||
|
{
|
||||||
|
FILE *runfh, *listfh;
|
||||||
|
|
||||||
|
if (listfn[0] != '\0' && runfn[0] != '\0') {
|
||||||
|
runfh = NULL;
|
||||||
|
listfh = NULL;
|
||||||
|
|
||||||
|
if ((runfh = fopen(runfn, "w")) != NULL &&
|
||||||
|
(listfh = fopen(listfn, "w")) != NULL)
|
||||||
|
{
|
||||||
|
print_run_stats(runfh, stats);
|
||||||
|
print_list_stats(listfh, stats);
|
||||||
|
} else {
|
||||||
|
(void)fprintf(stderr, "Cannot write results in CUnit format\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runfh != NULL) {
|
||||||
|
(void)fclose(runfh);
|
||||||
|
}
|
||||||
|
if (listfh != NULL) {
|
||||||
|
(void)fclose(listfh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
__declspec(dllexport)
|
||||||
|
#endif
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
int argno, cr_argc, sz;
|
||||||
|
char *pfx, **cr_argv;
|
||||||
|
const char runfmt[] = "%s-Results.xml";
|
||||||
|
const char listfmt[] = "%s-Listing.xml";
|
||||||
|
const char stampfmt[] = "%a %b %e %H:%M:%S %Y";
|
||||||
|
time_t now;
|
||||||
|
|
||||||
|
/* Before handing over argc and argv over to criterion, go over the list to
|
||||||
|
extract the custom options. Note that these are meant to be "hidden" */
|
||||||
|
cr_argc = 0;
|
||||||
|
if ((cr_argv = calloc(argc, sizeof(*cr_argv))) == NULL) {
|
||||||
|
result = 1;
|
||||||
|
} else {
|
||||||
|
for (argno = 0; argno < argc; argno++) {
|
||||||
|
/* FIXME:
|
||||||
|
Eventually CUnit output format should be supported through an
|
||||||
|
actual logger implementation, but it will do for now.
|
||||||
|
See: http://criterion.readthedocs.io/en/master/output.html */
|
||||||
|
if (strncmp(argv[argno], "--cunit", 7) == 0) {
|
||||||
|
if ((pfx = strchr(argv[argno], '=')) != NULL) {
|
||||||
|
pfx++;
|
||||||
|
} else {
|
||||||
|
pfx = "CriterionAutomated";
|
||||||
|
}
|
||||||
|
|
||||||
|
sz = snprintf(runfn, sizeof(runfn), runfmt, pfx);
|
||||||
|
assert(sz > 0 && sz < sizeof(runfn));
|
||||||
|
sz = snprintf(listfn, sizeof(listfn), listfmt, pfx);
|
||||||
|
assert(sz > 0 && sz < sizeof(listfn));
|
||||||
|
now = time(NULL);
|
||||||
|
sz = (int)strftime(
|
||||||
|
stamp, sizeof(stamp), stampfmt, localtime(&now));
|
||||||
|
assert(sz != 0);
|
||||||
|
} else if (strncmp(argv[argno], "--suite", 7) == 0) {
|
||||||
|
if ((argno + 1) == argc) {
|
||||||
|
fprintf(stderr, "--suite requires an argument\n");
|
||||||
|
result = 1;
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
suitepat = (const char *)argv[++argno];
|
||||||
|
} else if (strncmp(argv[argno], "--test", 6) == 0) {
|
||||||
|
if ((argno + 1) == argc) {
|
||||||
|
fprintf(stderr, "--test requires an argument\n");
|
||||||
|
result = 1;
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
testpat = (const char *)argv[++argno];
|
||||||
|
} else {
|
||||||
|
cr_argv[cr_argc++] = argv[argno];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: Depending on internal knowledge is not very pretty, but it is
|
||||||
|
the only way to provide a filter that will work on both *nix
|
||||||
|
and non-*nix platforms. */
|
||||||
|
struct criterion_test_set *tests = criterion_initialize();
|
||||||
|
struct criterion_ordered_set_node *suite_itr, *test_itr;
|
||||||
|
struct criterion_suite_set *suite;
|
||||||
|
struct criterion_test *test;
|
||||||
|
|
||||||
|
for (suite_itr = tests->suites->first;
|
||||||
|
suite_itr != NULL;
|
||||||
|
suite_itr = suite_itr->next)
|
||||||
|
{
|
||||||
|
suite = (struct criterion_suite_set *)(suite_itr + 1);
|
||||||
|
for (test_itr = suite->tests->first;
|
||||||
|
test_itr != NULL;
|
||||||
|
test_itr = test_itr->next)
|
||||||
|
{
|
||||||
|
test = (struct criterion_test *)(test_itr + 1);
|
||||||
|
if (!patmatch(suitepat, test->category) ||
|
||||||
|
!patmatch(testpat, test->name))
|
||||||
|
{
|
||||||
|
test->data->disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criterion_handle_args(cr_argc, cr_argv, true)) {
|
||||||
|
result = !criterion_run_all_tests(tests);
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_finalize(tests);
|
||||||
|
|
||||||
|
bail:
|
||||||
|
free(cr_argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
146
src/cmake/modules/FileIDs.cmake
Normal file
146
src/cmake/modules/FileIDs.cmake
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
# To uniquely identify the origin of every error all source files must be
|
||||||
|
# assigned a pseudo unique identifier (or module). Because only 32 bits are
|
||||||
|
# available in the return code (for now) to store the sign bit (1), return
|
||||||
|
# code (4), line number (8) and file identifier, using a deterministic hash
|
||||||
|
# will likely lead to collisions. To work around this issue a static map is
|
||||||
|
# applied, which also ensures that file identifiers are persisted accross
|
||||||
|
# versions/branches. Of course one could choose to specify the module manually
|
||||||
|
# with every return, but that is tedious and error prone.
|
||||||
|
|
||||||
|
if(FILE_IDS_INCLUDED)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(FILE_IDS_INCLUDED true)
|
||||||
|
|
||||||
|
|
||||||
|
# Verify syntax for all .fileids files and ensure no source file id is used
|
||||||
|
# more than once.
|
||||||
|
file(GLOB_RECURSE fils__ LIST_DIRECTORIES false "${CMAKE_SOURCE_DIR}/.fileids")
|
||||||
|
|
||||||
|
set(ids__)
|
||||||
|
foreach(fil__ ${fils__})
|
||||||
|
file(READ "${fil__}" lines__)
|
||||||
|
string(REGEX REPLACE "\n" ";" lines__ ${lines__})
|
||||||
|
foreach(line__ ${lines__})
|
||||||
|
if("${line__}" MATCHES "^[ \t]*([0-9]+)[ \t]+.*$")
|
||||||
|
set(id__ "${CMAKE_MATCH_1}")
|
||||||
|
if(${id__} IN_LIST ids__)
|
||||||
|
set(dup__ true)
|
||||||
|
message(STATUS "Id ${id__} used more than once")
|
||||||
|
else()
|
||||||
|
list(APPEND ids__ ${id__})
|
||||||
|
endif()
|
||||||
|
elseif(NOT "${line__}" MATCHES "^[ \t]*#")
|
||||||
|
message(FATAL_ERROR "Syntax error in ${fil__}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(dup__)
|
||||||
|
message(FATAL_ERROR "Duplicate ids")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(JOIN lst glue var)
|
||||||
|
string(REPLACE ";" "${glue}" tmp "${${lst}}")
|
||||||
|
set(${var} "${tmp}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(FILE_ID src var) # private
|
||||||
|
# .fileids files may reside in subdirectories to keep them together with the
|
||||||
|
# files they assign an identifier to, much like .gitignore files
|
||||||
|
set(dir "${CMAKE_SOURCE_DIR}")
|
||||||
|
set(parts "${src}")
|
||||||
|
string(REGEX REPLACE "[/\\]+" ";" parts "${parts}")
|
||||||
|
while(parts)
|
||||||
|
set(map "${dir}/.fileids")
|
||||||
|
join(parts "/" fil)
|
||||||
|
list(APPEND maps "${map}^${fil}")
|
||||||
|
list(GET parts 0 part)
|
||||||
|
list(REMOVE_AT parts 0)
|
||||||
|
set(dir "${dir}/${part}")
|
||||||
|
endwhile()
|
||||||
|
|
||||||
|
set(id)
|
||||||
|
foreach(entry ${maps})
|
||||||
|
string(REPLACE "^" ";" entry "${entry}")
|
||||||
|
list(GET entry 0 map)
|
||||||
|
list(GET entry 1 fil)
|
||||||
|
if(EXISTS "${map}")
|
||||||
|
file(READ "${map}" contents)
|
||||||
|
string(REGEX REPLACE "\n" ";" lines "${contents}")
|
||||||
|
|
||||||
|
foreach(line ${lines})
|
||||||
|
if("${line}" MATCHES "^[ \t]*([0-9]+)[ \t]+(.*)$")
|
||||||
|
set(id "${CMAKE_MATCH_1}")
|
||||||
|
string(STRIP "${CMAKE_MATCH_2}" expr)
|
||||||
|
if("${fil}" STREQUAL "${expr}")
|
||||||
|
set(${var} ${id} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
elseif(NOT "${line}" MATCHES "^[ \t]*#")
|
||||||
|
message(FATAL_ERROR "Syntax error in ${map}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Source file properties are visible only to targets added in the same
|
||||||
|
# directory (CMakeLists.txt).
|
||||||
|
# https://cmake.org/cmake/help/latest/command/set_source_files_properties.html
|
||||||
|
function(SET_TARGET_FILE_IDS tgt)
|
||||||
|
get_target_property(external ${tgt} IMPORTED)
|
||||||
|
get_target_property(alias ${tgt} ALIASED_TARGET)
|
||||||
|
string(LENGTH "${CMAKE_SOURCE_DIR}" len)
|
||||||
|
math(EXPR len "${len} + 1") # strip slash following source dir too
|
||||||
|
|
||||||
|
if((NOT external) AND (NOT alias))
|
||||||
|
get_target_property(srcs ${tgt} SOURCES)
|
||||||
|
get_target_property(src_dir ${tgt} SOURCE_DIR)
|
||||||
|
foreach(src ${srcs})
|
||||||
|
set(id)
|
||||||
|
if(IS_ABSOLUTE "${src}")
|
||||||
|
set(fil "${src}")
|
||||||
|
else()
|
||||||
|
set(fil "${src_dir}/${src}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(fil "${fil}" ABSOLUTE)
|
||||||
|
|
||||||
|
string(FIND "${fil}" "${CMAKE_SOURCE_DIR}" pos)
|
||||||
|
if(${pos} EQUAL 0)
|
||||||
|
string(SUBSTRING "${fil}" ${len} -1 rel)
|
||||||
|
file_id("${rel}" id)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(id)
|
||||||
|
if(("${source_file_id_${id}}" STREQUAL "") OR
|
||||||
|
("${source_file_id_${id}}" STREQUAL "${rel}"))
|
||||||
|
set("source_file_id_${id}" "${rel}" CACHE INTERNAL "")
|
||||||
|
set_source_files_properties(
|
||||||
|
"${src}" PROPERTIES COMPILE_DEFINITIONS __FILE_ID__=${id})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Same file id for ${rel} and ${source_file_id_${id}}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
get_filename_component(ext "${rel}" EXT)
|
||||||
|
if (NOT "${ext}" MATCHES "\.h*")
|
||||||
|
message(FATAL_ERROR "No source file id for ${rel}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
42
src/cmake/modules/FindAbstraction.cmake
Normal file
42
src/cmake/modules/FindAbstraction.cmake
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
if (NOT TARGET Abstraction)
|
||||||
|
add_library(Abstraction INTERFACE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Link with the platform-specific threads library that find_package provides us
|
||||||
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
target_link_libraries(Abstraction INTERFACE Threads::Threads)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
# Link with WIN32 core-libraries
|
||||||
|
target_link_libraries(Abstraction INTERFACE wsock32 ws2_32 iphlpapi)
|
||||||
|
|
||||||
|
# Many of the secure versions provided by Microsoft have failure modes
|
||||||
|
# which are not supported by our abstraction layer, so efforts trying
|
||||||
|
# to use the _s versions aren't typically the proper solution and C11
|
||||||
|
# (which contains most of the secure versions) is 'too new'. So we rely
|
||||||
|
# on static detection of misuse instead of runtime detection, so all
|
||||||
|
# these warnings can be disabled on Windows.
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) #Disabled warnings for deprecated Winsock 2 API calls in general
|
||||||
|
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) #Disabled warnings for deprecated POSIX names
|
||||||
|
elseif(UNIX AND NOT APPLE)
|
||||||
|
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
|
||||||
|
# Shared libs will have this by default. Static libs need it too on x86_64.
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
endif()
|
||||||
|
find_package(GetTime REQUIRED)
|
||||||
|
target_link_libraries(Abstraction INTERFACE GetTime)
|
||||||
|
endif()
|
||||||
23
src/cmake/modules/FindCUnit.cmake
Normal file
23
src/cmake/modules/FindCUnit.cmake
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
find_path(CUNIT_INC CUnit/CUnit.h)
|
||||||
|
find_library(CUNIT_LIB cunit)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(CUnit DEFAULT_MSG CUNIT_LIB CUNIT_INC)
|
||||||
|
|
||||||
|
if(CUNIT_FOUND AND NOT TARGET CUnit)
|
||||||
|
add_library(CUnit INTERFACE IMPORTED)
|
||||||
|
|
||||||
|
set_property(TARGET CUnit PROPERTY INTERFACE_LINK_LIBRARIES "${CUNIT_LIB}")
|
||||||
|
set_property(TARGET CUnit PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CUNIT_INC}")
|
||||||
|
endif()
|
||||||
24
src/cmake/modules/FindCriterion.cmake
Normal file
24
src/cmake/modules/FindCriterion.cmake
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
find_path(CRITERION_INC criterion/criterion.h PATH_SUFFIXES criterion)
|
||||||
|
find_library(CRITERION_LIB criterion)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Criterion DEFAULT_MSG CRITERION_LIB CRITERION_INC)
|
||||||
|
|
||||||
|
if (CRITERION_FOUND AND NOT TARGET Criterion)
|
||||||
|
add_library(Criterion INTERFACE IMPORTED)
|
||||||
|
|
||||||
|
set_property(TARGET Criterion PROPERTY INTERFACE_LINK_LIBRARIES "${CRITERION_LIB}")
|
||||||
|
set_property(TARGET Criterion PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CRITERION_INC}")
|
||||||
|
endif()
|
||||||
|
|
||||||
28
src/cmake/modules/FindGetTime.cmake
Normal file
28
src/cmake/modules/FindGetTime.cmake
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
if (NOT TARGET GetTime)
|
||||||
|
add_library(GetTime INTERFACE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CheckLibraryExists)
|
||||||
|
|
||||||
|
# First check whether libc has clock_gettime
|
||||||
|
check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME_IN_C)
|
||||||
|
|
||||||
|
if(NOT HAVE_CLOCK_GETTIME_IN_C)
|
||||||
|
# Before glibc 2.17, clock_gettime was in librt
|
||||||
|
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_IN_RT)
|
||||||
|
if (HAVE_CLOCK_GETTIME_IN_RT)
|
||||||
|
target_link_libraries(GetTime INTERFACE rt)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
74
src/cmake/modules/FindMaven.cmake
Normal file
74
src/cmake/modules/FindMaven.cmake
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
if(DEFINED ENV{M2})
|
||||||
|
list(APPEND _mvn_hints "$ENV{M2}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED ENV{M2_HOME})
|
||||||
|
list(APPEND _mvn_hints "$ENV{M2_HOME}/bin")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Maven documentation mentions intalling maven under C:\Program Files on
|
||||||
|
# Windows and under /opt on *NIX platforms
|
||||||
|
if(WIN32)
|
||||||
|
set(_program_files_env "ProgramFiles")
|
||||||
|
set(_program_files $ENV{${_program_files_env}})
|
||||||
|
set(_program_files_x86_env "ProgramFiles(x86)")
|
||||||
|
set(_program_files_x86 $ENV{${_program_files_x86_env}})
|
||||||
|
|
||||||
|
if(_program_files)
|
||||||
|
list(APPEND _dirs "${_program_files}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(_program_files_x86)
|
||||||
|
list(APPEND _dirs "${_program_files_x86}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
list(APPEND _dirs "/opt")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(_dir ${_dirs})
|
||||||
|
file(GLOB _mvn_dirs "${_dir}/apache-maven-*")
|
||||||
|
foreach(_mvn_dir ${_mvn_dirs})
|
||||||
|
if((IS_DIRECTORY "${_mvn_dir}") AND (IS_DIRECTORY "${_mvn_dir}/bin"))
|
||||||
|
list(APPEND _mvn_paths "${_mvn_dir}/bin")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
find_program(Maven_EXECUTABLE
|
||||||
|
NAMES mvn
|
||||||
|
HINTS ${_mvn_hints}
|
||||||
|
PATHS ${_mvn_paths})
|
||||||
|
|
||||||
|
if(Maven_EXECUTABLE)
|
||||||
|
execute_process(COMMAND ${Maven_EXECUTABLE} -version
|
||||||
|
RESULT_VARIABLE result
|
||||||
|
OUTPUT_VARIABLE var
|
||||||
|
ERROR_VARIABLE var
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT res)
|
||||||
|
if(var MATCHES "Apache Maven ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
|
||||||
|
set(Maven_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Maven
|
||||||
|
FOUND_VAR Maven_FOUND
|
||||||
|
REQUIRED_VARS Maven_EXECUTABLE
|
||||||
|
VERSION_VAR Maven_VERSION)
|
||||||
|
|
||||||
|
mark_as_advanced(Maven_FOUND Maven_EXECUTABLE Maven_VERSION)
|
||||||
|
|
||||||
38
src/cmake/modules/Glob.cmake
Normal file
38
src/cmake/modules/Glob.cmake
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
function(glob variable extension)
|
||||||
|
set(dirname "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
foreach(filename ${ARGN})
|
||||||
|
unset(filenames)
|
||||||
|
|
||||||
|
if((NOT IS_ABSOLUTE "${filename}") AND
|
||||||
|
(EXISTS "${dirname}/${filename}"))
|
||||||
|
set(filename "${dirname}/${filename}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(IS_DIRECTORY "${filename}")
|
||||||
|
file(GLOB_RECURSE filenames "${filename}/*.${extension}")
|
||||||
|
elseif(EXISTS "${filename}")
|
||||||
|
if("${filename}" MATCHES "\.${extension}$")
|
||||||
|
set(filenames "${filename}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "File ${filename} does not exist")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND files ${filenames})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(${variable} "${files}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
170
src/cmake/modules/Packaging.cmake
Normal file
170
src/cmake/modules/Packaging.cmake
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
if(PACKAGING_INCLUDED)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(PACKAGING_INCLUDED true)
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
set(PACKAGING_MODULE_DIR "${PROJECT_SOURCE_DIR}/cmake/modules/Packaging")
|
||||||
|
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}")
|
||||||
|
|
||||||
|
# Generates <Package>Config.cmake.
|
||||||
|
configure_package_config_file(
|
||||||
|
"${PACKAGING_MODULE_DIR}/PackageConfig.cmake.in"
|
||||||
|
"${CMAKE_PROJECT_NAME}Config.cmake"
|
||||||
|
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}")
|
||||||
|
|
||||||
|
# Generates <Package>Version.cmake.
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_PROJECT_NAME}Version.cmake"
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Version.cmake"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" COMPONENT dev)
|
||||||
|
|
||||||
|
if(DDSC_SHARED AND ((NOT DEFINED BUILD_SHARED_LIBS) OR BUILD_SHARED_LIBS))
|
||||||
|
# Generates <Package>Targets.cmake file included by <Package>Config.cmake.
|
||||||
|
# The files are placed in CMakeFiles/Export in the build tree.
|
||||||
|
install(
|
||||||
|
EXPORT "${CMAKE_PROJECT_NAME}"
|
||||||
|
FILE "${CMAKE_PROJECT_NAME}Targets.cmake"
|
||||||
|
NAMESPACE "${CMAKE_PROJECT_NAME}::"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" COMPONENT dev)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||||
|
set(CPACK_PACKAGE_VERSION_TWEAK ${PROJECT_VERSION_TWEAK})
|
||||||
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||||
|
|
||||||
|
set(VENDOR_INSTALL_ROOT "ADLINK")
|
||||||
|
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
|
||||||
|
set(CPACK_PACKAGE_VENDOR "ADLINK Technology Inc.")
|
||||||
|
set(CPACK_PACKAGE_CONTACT "${CMAKE_PROJECT_NAME} core developers <info@adlinktech.com>")
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Leading OMG DDS implementation from ADLINK Technology")
|
||||||
|
set(CPACK_PACKAGE_ICON "${PACKAGING_MODULE_DIR}/vortex.ico")
|
||||||
|
|
||||||
|
# WiX requires a .txt file extension for CPACK_RESOURCE_FILE_LICENSE
|
||||||
|
file(COPY "${PROJECT_SOURCE_DIR}/../LICENSE" DESTINATION "${CMAKE_BINARY_DIR}")
|
||||||
|
file(RENAME "${CMAKE_BINARY_DIR}/LICENSE" "${CMAKE_BINARY_DIR}/license.txt")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/license.txt")
|
||||||
|
|
||||||
|
# Packages could be generated on alien systems. e.g. Debian packages could be
|
||||||
|
# created on Red Hat Enterprise Linux, but since packages also need to be
|
||||||
|
# verified on the target platform, please refrain from doing so. Another
|
||||||
|
# reason for building installer packages on the target platform is to ensure
|
||||||
|
# the binaries are linked to the libc version shipped with that platform. To
|
||||||
|
# support "generic" Linux distributions, eventually compressed tarballs will
|
||||||
|
# be shipped.
|
||||||
|
#
|
||||||
|
# NOTE: Settings for different platforms are in separate control branches.
|
||||||
|
# Although that does not make sense from a technical point-of-view, it
|
||||||
|
# does help to clearify which settings are required for a platform.
|
||||||
|
|
||||||
|
set(CPACK_COMPONENTS_ALL dev lib)
|
||||||
|
set(CPACK_COMPONENT_LIB_DISPLAY_NAME "${CMAKE_PROJECT_NAME_FULL} library")
|
||||||
|
set(CPACK_COMPONENT_LIB_DESCRIPTION "Library used to run programs with ${CMAKE_PROJECT_NAME_FULL}")
|
||||||
|
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "${CMAKE_PROJECT_NAME_FULL} development")
|
||||||
|
set(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for use with ${CMAKE_PROJECT_NAME_FULL}")
|
||||||
|
|
||||||
|
if(WIN32 AND NOT UNIX)
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
set(__arch "win64")
|
||||||
|
else()
|
||||||
|
set(__arch "win32")
|
||||||
|
endif()
|
||||||
|
mark_as_advanced(__arch)
|
||||||
|
|
||||||
|
set(CPACK_GENERATOR "WIX;ZIP;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}")
|
||||||
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${VENDOR_INSTALL_ROOT}/${CMAKE_PROJECT_NAME_FULL}")
|
||||||
|
|
||||||
|
set(CPACK_WIX_LIGHT_EXTENSIONS "WixUtilExtension")
|
||||||
|
set(CPACK_WIX_COMPONENT_INSTALL ON)
|
||||||
|
set(CPACK_WIX_ROOT_FEATURE_TITLE "${CMAKE_PROJECT_NAME_FULL}")
|
||||||
|
set(CPACK_WIX_PRODUCT_ICON "${PACKAGING_MODULE_DIR}/vortex.ico")
|
||||||
|
# Bitmap (.bmp) of size 493x58px
|
||||||
|
set(CPACK_WIX_UI_BANNER "${PACKAGING_MODULE_DIR}/banner.bmp")
|
||||||
|
# Bitmap (.bmp) of size 493x312px
|
||||||
|
set(CPACK_WIX_UI_DIALOG "${PACKAGING_MODULE_DIR}/dialog.png")
|
||||||
|
set(CPACK_WIX_PROGRAM_MENU_FOLDER "${CPACK_PACKAGE_NAME_FULL}")
|
||||||
|
set(CPACK_WIX_PATCH_FILE "${PACKAGING_MODULE_DIR}/examples.xml")
|
||||||
|
set(CPACK_WIX_PROPERTY_ARPHELPLINK "http://www.adlinktech.com/support")
|
||||||
|
set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "http://www.adlinktech.com/")
|
||||||
|
set(CPACK_WIX_PROPERTY_ARPURLUPDATEINFO "http://www.adlinktech.com/")
|
||||||
|
|
||||||
|
# A constant GUID allows installers to replace existing installations that use the same GUID.
|
||||||
|
set(CPACK_WIX_UPGRADE_GUID "1351F59A-972B-4624-A7F1-439381BFA41D")
|
||||||
|
|
||||||
|
include(InstallRequiredSystemLibraries)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
# CMake prior to v3.6 messes up the name of the packages. >= v3.6 understands CPACK_RPM/DEBIAN_<component>_FILE_NAME
|
||||||
|
cmake_minimum_required(VERSION 3.6)
|
||||||
|
|
||||||
|
set(CPACK_COMPONENTS_GROUPING "IGNORE")
|
||||||
|
|
||||||
|
# FIXME: Requiring lsb_release to be installed may be a viable option.
|
||||||
|
|
||||||
|
if(EXISTS "/etc/redhat-release")
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
set(__arch "x86_64")
|
||||||
|
else()
|
||||||
|
set(__arch "i686")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CPACK_GENERATOR "RPM;TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
|
||||||
|
|
||||||
|
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||||
|
# FIXME: The package file name must be updated to include the distribution.
|
||||||
|
# See Fedora and Red Hat packaging guidelines for details.
|
||||||
|
set(CPACK_RPM_LIB_PACKAGE_NAME "${CMAKE_PROJECT_NAME_DASHED}")
|
||||||
|
set(CPACK_RPM_LIB_FILE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}.rpm")
|
||||||
|
set(CPACK_RPM_DEV_PACKAGE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-devel")
|
||||||
|
set(CPACK_RPM_DEV_FILE_NAME "${CPACK_RPM_DEV_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}.rpm")
|
||||||
|
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "${CPACK_RPM_LIB_PACKAGE_NAME} = ${CPACK_PACKAGE_VERSION}")
|
||||||
|
elseif(EXISTS "/etc/debian_version")
|
||||||
|
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
set(__arch "amd64")
|
||||||
|
else()
|
||||||
|
set(__arch "i386")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CPACK_GENERATOR "DEB;TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
|
||||||
|
|
||||||
|
string(TOLOWER "${CMAKE_PROJECT_NAME_DASHED}" CPACK_DEBIAN_LIB_PACKAGE_NAME)
|
||||||
|
set(CPACK_DEBIAN_LIB_FILE_NAME "${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${__arch}.deb")
|
||||||
|
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "${CPACK_DEBIAN_LIB_PACKAGE_NAME} (= ${CPACK_PACKAGE_VERSION}), libc6 (>= 2.23)")
|
||||||
|
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "${CPACK_DEBIAN_LIB_PACKAGE_NAME}-dev")
|
||||||
|
set(CPACK_DEBIAN_DEV_FILE_NAME "${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${__arch}.deb")
|
||||||
|
else()
|
||||||
|
# Generic tgz package
|
||||||
|
set(CPACK_GENERATOR "TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
|
||||||
|
endif()
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "VxWorks")
|
||||||
|
# FIXME: Support for VxWorks packages must still be implemented (probably
|
||||||
|
# just a compressed tarball)
|
||||||
|
message(STATUS "Packaging for VxWorks is unsupported")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# This must always be last!
|
||||||
|
include(CPack)
|
||||||
|
|
||||||
16
src/cmake/modules/Packaging/PackageConfig.cmake.in
Normal file
16
src/cmake/modules/Packaging/PackageConfig.cmake.in
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/@CMAKE_PROJECT_NAME@Targets.cmake")
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/idlc/IdlcGenerate.cmake")
|
||||||
|
|
||||||
BIN
src/cmake/modules/Packaging/banner.bmp
Normal file
BIN
src/cmake/modules/Packaging/banner.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
BIN
src/cmake/modules/Packaging/dialog.png
Normal file
BIN
src/cmake/modules/Packaging/dialog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
228
src/cmake/modules/Packaging/examples.xml
Normal file
228
src/cmake/modules/Packaging/examples.xml
Normal file
|
|
@ -0,0 +1,228 @@
|
||||||
|
<!--
|
||||||
|
Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
|
||||||
|
This program and the accompanying materials are made available under the
|
||||||
|
terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
v. 1.0 which is available at
|
||||||
|
http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
Installing the Hello World! example at the USERPROFILE directory.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<CPackWiXPatch>
|
||||||
|
<CPackWiXFragment Id="#PRODUCT">
|
||||||
|
|
||||||
|
<DirectoryRef Id="TARGETDIR">
|
||||||
|
<Directory Id="PersonalFolder">
|
||||||
|
<Directory Id="CYCLONEUSERDIR" Name="Cyclone DDS">
|
||||||
|
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples" Name="examples">
|
||||||
|
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Name="helloworld">
|
||||||
|
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Name="vs"/>
|
||||||
|
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" Name="generated"/>
|
||||||
|
</Directory>
|
||||||
|
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Name="roundtrip" />
|
||||||
|
<Directory Id="CM_DP_dev.usr.CycloneDDS.examples.throughput" Name="throughput" />
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
</DirectoryRef>
|
||||||
|
|
||||||
|
<Feature Id="UserWritableExampleFeature" Display="expand" Absent="disallow" ConfigurableDirectory="CYCLONEUSERDIR" Title="Cyclone DDS Examples" Description="Example code to getting started with DDS development." Level="1">
|
||||||
|
<Feature Id="CM_C_usr" Title="Cyclone DDS Development Examples" Description="Example Development files for use with Cyclone DDS. Typically installed in the users 'Document' directory.">
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.Launcher.ApplicationShortcut" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.environment" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.cmake.prefix.path" />
|
||||||
|
<!-- helloworld -->
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.remove" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.sln" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.directories.props" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.publisher.c" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.subscriber.c" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" />
|
||||||
|
<!-- roundtrip -->
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.ping.c" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.pong.c" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" />
|
||||||
|
<!-- throughput -->
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.Throughput.idl" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.publisher.c" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.subscriber.c" />
|
||||||
|
<ComponentRef Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.CMakeLists.txt" />
|
||||||
|
</Feature>
|
||||||
|
</Feature>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.remove" Directory="CYCLONEUSERDIR" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="Remove.CM_CP_dev.usr.CycloneDDS.examples" Value="Remove.CM_CP_dev.usr.CycloneDDS.examples" KeyPath="yes" />
|
||||||
|
|
||||||
|
<!-- helloworld -->
|
||||||
|
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" On="uninstall"/>
|
||||||
|
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" On="uninstall"/>
|
||||||
|
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.helloworld" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" On="uninstall"/>
|
||||||
|
<!-- roundtrip -->
|
||||||
|
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" On="uninstall"/>
|
||||||
|
<!-- throughput -->
|
||||||
|
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples.throughput" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" On="uninstall"/>
|
||||||
|
|
||||||
|
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS.examples" Directory="CM_DP_dev.usr.CycloneDDS.examples" On="uninstall"/>
|
||||||
|
<RemoveFolder Id="Remove.CM_DP_dev.usr.CycloneDDS" Directory="CYCLONEUSERDIR" On="uninstall"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<!-- Hello World - files -->
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" Value="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.idl" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/HelloWorldData.idl" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.sln" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorld.sln" Value="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorld.sln" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorld.sln" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/HelloWorld.sln" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldPublisher.vcxproj" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/vs/HelloWorldPublisher.vcxproj" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldSubscriber.vcxproj" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/vs/HelloWorldSubscriber.vcxproj" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldType.vcxproj" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/vs/HelloWorldType.vcxproj" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.directories.props" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.vs" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.directories.props" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.directories.props" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.directories.props" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/vs/directories.props" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/generated/HelloWorldData.c" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld.generated" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.HelloWorldData.h" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/generated/HelloWorldData.h" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.publisher.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.publisher.c" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.publisher.c" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.publisher.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/publisher.c" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.subscriber.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.subscriber.c" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.subscriber.c" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.subscriber.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/subscriber.c" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" Directory="CM_DP_dev.usr.CycloneDDS.examples.helloworld" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" Value="CM_CP_dev.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.helloworld.CMakeLists.txt" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/helloworld/CMakeLists.txt" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<!-- RoundTrip - files -->
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" Value="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.roundtrip.CMakeLists.txt" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/roundtrip/CMakeLists.txt" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" Value="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.roundtrip.RoundTrip.idl" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/roundtrip/RoundTrip.idl" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.ping.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.ping.c" Value="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.ping.c" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.roundtrip.ping.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/roundtrip/ping.c" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.pong.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.roundtrip" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.pong.c" Value="CM_CP_dev.usr.CycloneDDS.examples.roundtrip.pong.c" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.roundtrip.pong.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/roundtrip/pong.c" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<!-- Throughput - files -->
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.CMakeLists.txt" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.throughput.CMakeLists.txt" Value="CM_CP_dev.usr.CycloneDDS.examples.throughput.CMakeLists.txt" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.throughput.CMakeLists.txt" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/throughput/CMakeLists.txt" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.Throughput.idl" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.throughput.Throughput.idl" Value="CM_CP_dev.usr.CycloneDDS.examples.throughput.Throughput.idl" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.throughput.Throughput.idl" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/throughput/Throughput.idl" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.publisher.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.throughput.publisher.c" Value="CM_CP_dev.usr.CycloneDDS.examples.throughput.publisher.c" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.throughput.publisher.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/throughput/publisher.c" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.throughput.subscriber.c" Directory="CM_DP_dev.usr.CycloneDDS.examples.throughput" Guid="">
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.examples.throughput.subscriber.c" Value="CM_CP_dev.usr.CycloneDDS.examples.throughput.subscriber.c" KeyPath="yes" />
|
||||||
|
<File Id="CM_FP_usr.usr.CycloneDDS.examples.throughput.subscriber.c" Source="$(sys.SOURCEFILEDIR)/$(var.CPACK_PACKAGE_NAME)-$(var.CPACK_PACKAGE_VERSION)-win64/dev/share/CycloneDDS/examples/throughput/subscriber.c" KeyPath="no"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<!-- Add the location of the ddsc.dll to the system path -->
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.examples.environment" Directory="CYCLONEUSERDIR" Guid="">
|
||||||
|
<!-- CreateFolder and RegistryValue are needed to keep Wix happy -->
|
||||||
|
<CreateFolder Directory="CYCLONEUSERDIR"/>
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.environment" Value="CM_CP_dev.usr.CycloneDDS.environment" KeyPath="yes" />
|
||||||
|
<Environment Action="set" Id="CycloneDDSPath" Name="PATH" Part="last" Permanent="yes" System="yes" Value="[INSTALL_ROOT]bin"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.cmake.prefix.path" Directory="CYCLONEUSERDIR" Guid="">
|
||||||
|
<!-- CreateFolder and RegistryValue are needed to keep Wix happy -->
|
||||||
|
<CreateFolder Directory="CYCLONEUSERDIR"/>
|
||||||
|
<RegistryValue Type="string" Root="HKCU" Key="Software\$(var.CPACK_PACKAGE_VENDOR)\$(var.CPACK_PACKAGE_NAME)" Name="CM_CP_dev.usr.CycloneDDS.cmake.prefix.path" Value="CM_CP_dev.usr.CycloneDDS.cmake.prefix.path" KeyPath="yes" />
|
||||||
|
<Environment Action="set" Id="CMakePrefixPath" Name="CMAKE_PREFIX_PATH" Permanent="no" Value="[INSTALL_ROOT]share/CycloneDDS"/>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<!-- Offer the user the ability the start the launcher -->
|
||||||
|
<Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="After clicking Finish, the Vortex DDS Launcher will start (if indicated below). The Vortex DDS Laucher will help to get started with Cyclone DDS." />
|
||||||
|
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1"/>
|
||||||
|
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Start the Vortex DDS Launcher" />
|
||||||
|
<Property Id="WixShellExecTarget" Value="[INSTALL_ROOT]/bin/vortexddslauncher.exe" />
|
||||||
|
<CustomAction Id="CM_CA_dev.user.CycloneDDS.Launcher.Launch" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
|
||||||
|
|
||||||
|
<UI>
|
||||||
|
<UIRef Id="$(var.CPACK_WIX_UI_REF)" />
|
||||||
|
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="CM_CA_dev.user.CycloneDDS.Launcher.Launch">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
|
||||||
|
</UI>
|
||||||
|
|
||||||
|
<!-- Create start-menu -->
|
||||||
|
<DirectoryRef Id="TARGETDIR">
|
||||||
|
<Directory Id="ProgramMenuFolder">
|
||||||
|
<Directory Id="ApplicationProgramsFolder" Name="Cyclone DDS"/>
|
||||||
|
</Directory>
|
||||||
|
</DirectoryRef>
|
||||||
|
<DirectoryRef Id="ApplicationProgramsFolder">
|
||||||
|
<Component Id="CM_CP_dev.usr.CycloneDDS.Launcher.ApplicationShortcut" Guid="C21831A3-FBCE-44D0-A098-A1F21FD4846F">
|
||||||
|
<Shortcut Id="ApplicationStartMenuShortcut"
|
||||||
|
Name="CycloneDDS Launcher"
|
||||||
|
Directory="ApplicationProgramsFolder"
|
||||||
|
Description="My Application Description"
|
||||||
|
Target="[INSTALL_ROOT]/bin/vortexddslauncher.exe"
|
||||||
|
Icon="ShortcutIcon"
|
||||||
|
IconIndex="0">
|
||||||
|
<Icon Id="ShortcutIcon" SourceFile="$(var.CPACK_WIX_PRODUCT_ICON)" />
|
||||||
|
</Shortcut>
|
||||||
|
<RemoveFolder Id="CleanUpShortCut" Directory="ApplicationProgramsFolder" On="uninstall"/>
|
||||||
|
<RegistryValue Root="HKCU" Key="Software\AdLink" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
|
||||||
|
</Component>
|
||||||
|
</DirectoryRef>
|
||||||
|
</CPackWiXFragment>
|
||||||
|
</CPackWiXPatch>
|
||||||
BIN
src/cmake/modules/Packaging/vortex.ico
Normal file
BIN
src/cmake/modules/Packaging/vortex.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
213
src/cmake/modules/Platform/VxWorks6.cmake
Normal file
213
src/cmake/modules/Platform/VxWorks6.cmake
Normal file
|
|
@ -0,0 +1,213 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# CMake Platform file for VxWorks
|
||||||
|
#
|
||||||
|
# This file will be used as platform file if CMAKE_SYSTEM_NAME is defined
|
||||||
|
# as VxWorks in the toolchain file.
|
||||||
|
#
|
||||||
|
# Most information is resolved by analyzing the absolute location of the
|
||||||
|
# compiler on the file system, but can be overridden if required.
|
||||||
|
#
|
||||||
|
# Setting CMAKE_SYSTEM_PROCESSOR is mandatory. The variable should be set to
|
||||||
|
# e.g. ARMARCH* if the target architecture is arm.
|
||||||
|
#
|
||||||
|
# NOTES:
|
||||||
|
# * For now support for VxWorks Diab compiler will NOT be implemented.
|
||||||
|
# * If certain settings are not explicitly defined, this platform file will
|
||||||
|
# try to deduce it from the installation path. It will, however, not go out
|
||||||
|
# of it's way to validate and cross-reference settings.
|
||||||
|
#
|
||||||
|
# https://cmake.org/Wiki/CMake_Cross_Compiling
|
||||||
|
#
|
||||||
|
|
||||||
|
if((NOT "${CMAKE_GENERATOR}" MATCHES "Makefiles") AND
|
||||||
|
(NOT "${CMAKE_GENERATOR}" MATCHES "Ninja"))
|
||||||
|
message(FATAL_ERROR "Cross compilation for VxWorks is not supported for "
|
||||||
|
"${CMAKE_GENERATOR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(WIND_PROCESSOR_TYPE_PATTERN ".*(cc|c\\+\\+)(arm|mips|pentium|ppc).*")
|
||||||
|
set(WIND_HOST_TYPE_PATTERN "^x86-(linux2|win32)$")
|
||||||
|
set(WIND_PLATFORM_PATTERN "^[0-9\.]+-vxworks-([0-9\.]+)$")
|
||||||
|
|
||||||
|
# Try to deduce the system architecture from either CMAKE_C_COMPILER or
|
||||||
|
# CMAKE_CXX_COMPILER (one of which must be specified).
|
||||||
|
#
|
||||||
|
# Path examples:
|
||||||
|
# <WindRiver>/gnu/4.3.3-vxworks-6.9/x86-linux2/bin
|
||||||
|
# <WindRiver>/gnu/4.1.2-vxworks-6.8/x86-win32/bin
|
||||||
|
foreach(COMPILER CMAKE_C_COMPILER CMAKE_CXX_COMPILER)
|
||||||
|
if("${${COMPILER}}" MATCHES "${WIND_PROCESSOR_TYPE_PATTERN}")
|
||||||
|
string(
|
||||||
|
REGEX REPLACE
|
||||||
|
"${WIND_PROCESSOR_TYPE_PATTERN}" "\\2"
|
||||||
|
PROCESSOR_TYPE
|
||||||
|
${${COMPILER}})
|
||||||
|
if(NOT WIND_PROCESSOR_TYPE)
|
||||||
|
set(WIND_PROCESSOR_TYPE ${PROCESSOR_TYPE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(COMPILER_NAME "${${COMPILER}}" NAME)
|
||||||
|
if((NOT "${COMPILER_NAME}" STREQUAL "${${COMPILER}}") AND
|
||||||
|
(NOT "${COMPILER_DIRECTORY}"))
|
||||||
|
get_filename_component(
|
||||||
|
COMPILER_PATH "${${COMPILER}}" REALPATH)
|
||||||
|
get_filename_component(
|
||||||
|
COMPILER_DIRECTORY "${COMPILER_PATH}" DIRECTORY)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "${COMPILER} did not conform to the expected "
|
||||||
|
"executable format. i.e. it did not end with "
|
||||||
|
"arm, mips, pentium, or ppc.")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
get_filename_component(C_COMPILER_NAME "${CMAKE_C_COMPILER}" NAME)
|
||||||
|
get_filename_component(CXX_COMPILER_NAME "${CMAKE_CXX_COMPILER}" NAME)
|
||||||
|
|
||||||
|
# Ideally the location of the compiler should be resolved at this, but invoke
|
||||||
|
# find_program as a last resort.
|
||||||
|
if(NOT COMPILER_DIRECTORY)
|
||||||
|
find_program(
|
||||||
|
COMPILER_PATH NAMES "${C_COMPILER_NAME}" "${CXX_COMPILER_NAME}")
|
||||||
|
if(COMPILER_PATH)
|
||||||
|
get_filename_component(
|
||||||
|
COMPILER_DIRECTORY "${COMPILER_PATH}" COMPILER_PATH)
|
||||||
|
else()
|
||||||
|
# The compiler must be successfully be detected by now.
|
||||||
|
message(FATAL_ERROR "Could not determine location of compiler path.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
get_filename_component(basename "${COMPILER_DIRECTORY}" NAME)
|
||||||
|
get_filename_component(basedir "${COMPILER_DIRECTORY}" DIRECTORY)
|
||||||
|
while(basename)
|
||||||
|
if("${basename}" MATCHES "${WIND_PLATFORM_PATTERN}")
|
||||||
|
string(
|
||||||
|
REGEX REPLACE "${WIND_PLATFORM_PATTERN}" "\\1" version ${basename})
|
||||||
|
if(NOT CMAKE_SYSTEM_VERSION)
|
||||||
|
set(CMAKE_SYSTEM_VERSION ${version})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The current base directory may be the WindRiver directory depending
|
||||||
|
# on wether a "gnu" directory exists or not, but that is evaluated in
|
||||||
|
# the next iteration.
|
||||||
|
set(WIND_HOME "${basedir}")
|
||||||
|
set(WIND_PLATFORM "${basename}")
|
||||||
|
elseif(CMAKE_SYSTEM_VERSION AND WIND_HOME AND WIND_HOST_TYPE)
|
||||||
|
# The "gnu" directory may not be part of the path. If it is, strip it.
|
||||||
|
if("${basename}" STREQUAL "gnu")
|
||||||
|
set(WIND_HOME "${basedir}")
|
||||||
|
endif()
|
||||||
|
break()
|
||||||
|
elseif("${basename}" MATCHES "${WIND_HOST_TYPE_PATTERN}")
|
||||||
|
set(WIND_HOST_TYPE "${basename}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(basename ${basedir} NAME)
|
||||||
|
get_filename_component(basedir ${basedir} DIRECTORY)
|
||||||
|
endwhile()
|
||||||
|
|
||||||
|
|
||||||
|
# VxWorks commands require the WIND_BASE environment variable, so this script
|
||||||
|
# will support it too. If the environment variable is not set, the necessary
|
||||||
|
# path information is deduced from the compiler path.
|
||||||
|
if(NOT WIND_BASE)
|
||||||
|
set(WIND_BASE $ENV{WIND_BASE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT WIND_BASE)
|
||||||
|
set(WIND_BASE "${WIND_HOME}/vxworks-${CMAKE_SYSTEM_VERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Verify the location WIND_BASE references actually exists.
|
||||||
|
if(NOT EXISTS ${WIND_BASE})
|
||||||
|
message(FATAL_ERROR "VxWorks base directory ${WIND_BASE} does not exist, "
|
||||||
|
"please ensure the toolchain information is correct.")
|
||||||
|
elseif(NOT ENV{WIND_BASE})
|
||||||
|
# WIND_BASE environment variable must be exported during generation
|
||||||
|
# otherwise compiler tests will fail.
|
||||||
|
set(ENV{WIND_BASE} "${WIND_BASE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if(NOT CMAKE_C_COMPILER_VERSION)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_C_COMPILER}" -dumpversion
|
||||||
|
OUTPUT_VARIABLE CMAKE_C_COMPILER_VERSION)
|
||||||
|
string(STRIP "${CMAKE_C_COMPILER_VERSION}" CMAKE_C_COMPILER_VERSION)
|
||||||
|
message(STATUS "VxWorks C compiler version ${CMAKE_C_COMPILER_VERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT CMAKE_CXX_COMPILER_VERSION)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_CXX_COMPILER}" -dumpversion
|
||||||
|
OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
|
||||||
|
string(STRIP "${CMAKE_CXX_COMPILER_VERSION}" CMAKE_CXX_COMPILER_VERSION)
|
||||||
|
message(STATUS "VxWorks CXX compiler version ${CMAKE_C_COMPILER_VERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER_ID GNU)
|
||||||
|
set(CMAKE_CXX_COMPILER_ID GNU)
|
||||||
|
|
||||||
|
|
||||||
|
# CMAKE_SOURCE_DIR does not resolve to the actual source directory because
|
||||||
|
# platform files are processed to early on in the process.
|
||||||
|
set(ROOT "${CMAKE_MODULE_PATH}/../")
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c.bat")
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx.bat")
|
||||||
|
configure_file(
|
||||||
|
"${ROOT}/launch-c.bat.in" "${CMAKE_C_COMPILER_LAUNCHER}" @ONLY)
|
||||||
|
configure_file(
|
||||||
|
"${ROOT}/launch-cxx.bat.in" "${CMAKE_CXX_COMPILER_LAUNCHER}" @ONLY)
|
||||||
|
else()
|
||||||
|
# Check if a directory like lmapi-* exists (VxWorks 6.9) and append it to
|
||||||
|
# LD_LIBRARY_PATH.
|
||||||
|
file(GLOB WIND_LMAPI LIST_DIRECTORIES true "${WIND_HOME}/lmapi-*")
|
||||||
|
if(WIND_LMAPI)
|
||||||
|
set(WIND_LMAPI "${WIND_LMAPI}/${WIND_HOST_TYPE}/lib")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c")
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||||
|
configure_file(
|
||||||
|
"${ROOT}/launch-c.in" "${CMAKE_C_COMPILER_LAUNCHER}" @ONLY)
|
||||||
|
configure_file(
|
||||||
|
"${ROOT}/launch-cxx.in" "${CMAKE_CXX_COMPILER_LAUNCHER}" @ONLY)
|
||||||
|
execute_process(COMMAND chmod a+rx "${CMAKE_C_COMPILER_LAUNCHER}")
|
||||||
|
execute_process(COMMAND chmod a+rx "${CMAKE_CXX_COMPILER_LAUNCHER}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
set(WIND_INCLUDE_DIRECTORY "${WIND_BASE}/target/h")
|
||||||
|
|
||||||
|
# Versions before 6.8 have a different path for common libs.
|
||||||
|
if("${CMAKE_SYSTEM_VERSION}" VERSION_GREATER "6.8")
|
||||||
|
set(WIND_LIBRARY_DIRECTORY "${WIND_BASE}/target/lib/usr/lib/${WIND_PROCESSOR_TYPE}/${CMAKE_SYSTEM_PROCESSOR}/common")
|
||||||
|
else()
|
||||||
|
set(WIND_LIBRARY_DIRECTORY "${WIND_BASE}/target/usr/lib/${WIND_PROCESSOR_TYPE}/${CMAKE_SYSTEM_PROCESSOR}/common")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS "${WIND_LIBRARY_DIRECTORY}")
|
||||||
|
message(FATAL_ERROR "${CMAKE_SYSTEM_PROCESSOR} is not part of the "
|
||||||
|
"${WIND_PROCESSOR_TYPE} processor family.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(BEFORE SYSTEM "${WIND_INCLUDE_DIRECTORY}")
|
||||||
|
link_directories("${WIND_LIBRARY_DIRECTORY}")
|
||||||
|
|
||||||
134
src/cmake/scripts/CoverageConvenience.cmake
Normal file
134
src/cmake/scripts/CoverageConvenience.cmake
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script will run all tests and generates various coverage reports.
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoverageConvenience.cmake
|
||||||
|
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||||
|
#
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
# Get Coverage configuration file
|
||||||
|
if(NOT COVERAGE_SETTINGS)
|
||||||
|
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
|
||||||
|
endif()
|
||||||
|
include(${COVERAGE_SETTINGS})
|
||||||
|
|
||||||
|
message(STATUS "Config file: ${COVERAGE_SETTINGS}")
|
||||||
|
message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
|
||||||
|
message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
|
||||||
|
message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
|
||||||
|
|
||||||
|
set(COVERAGE_SCRIPTS_DIR "${COVERAGE_SOURCE_DIR}/cmake/scripts")
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Detect generators
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
set(GENERATE_COVERAGE TRUE)
|
||||||
|
if(GENERATE_COVERAGE)
|
||||||
|
find_program(GCOV_PATH gcov PARENT_SCOPE)
|
||||||
|
if(NOT GCOV_PATH)
|
||||||
|
set(GENERATE_COVERAGE FALSE)
|
||||||
|
message(STATUS "[SKIP] Coverage generators - gcov (could not find gcov)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(GENERATE_COVERAGE)
|
||||||
|
message(STATUS "[ OK ] Coverage generators - gcov")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GENERATE_COVERAGE_HTML TRUE)
|
||||||
|
if(GENERATE_COVERAGE_HTML)
|
||||||
|
find_program(LCOV_PATH lcov PARENT_SCOPE)
|
||||||
|
if(NOT LCOV_PATH)
|
||||||
|
set(GENERATE_COVERAGE_HTML FALSE)
|
||||||
|
message(STATUS "[SKIP] Coverage generators - HTML (could not find lcov)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(GENERATE_COVERAGE_HTML)
|
||||||
|
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
|
||||||
|
if(NOT GENHTML_PATH)
|
||||||
|
set(GENERATE_COVERAGE_HTML FALSE)
|
||||||
|
message(STATUS "[SKIP] Coverage generators - HTML (could not find genhtml)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(GENERATE_COVERAGE_HTML)
|
||||||
|
message(STATUS "[ OK ] Coverage generators - HTML (lcov and genhtml)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GENERATE_COVERAGE_COBERTURA TRUE)
|
||||||
|
if(GENERATE_COVERAGE_COBERTURA)
|
||||||
|
find_program(GCOVR_PATH gcovr PARENT_SCOPE)
|
||||||
|
if(NOT GCOVR_PATH)
|
||||||
|
set(GENERATE_COVERAGE_COBERTURA FALSE)
|
||||||
|
message(STATUS "[SKIP] Coverage generators - Cobertura (could not find gcovr)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(GENERATE_COVERAGE_COBERTURA)
|
||||||
|
message(STATUS "[ OK ] Coverage generators - Cobertura (gcovr)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT GENERATE_COVERAGE)
|
||||||
|
message(FATAL_ERROR "Could not find the main coverage generator 'gcov'")
|
||||||
|
elseif(NOT GENERATE_COVERAGE_HTML AND NOT GENERATE_COVERAGE_COBERTURA)
|
||||||
|
message(FATAL_ERROR "Could not find either of the two coverage report generators")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Setup environment
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
message(STATUS "Setup environment")
|
||||||
|
if(GENERATE_COVERAGE_HTML)
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePreHtml.cmake
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
endif()
|
||||||
|
if(GENERATE_COVERAGE_COBERTURA)
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePreCobertura.cmake
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Generate coverage results by running all the tests
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
message(STATUS "Run all test to get coverage")
|
||||||
|
execute_process(COMMAND ctest ${COVERAGE_QUIET_FLAG} -T test
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
execute_process(COMMAND ctest ${COVERAGE_QUIET_FLAG} -T coverage
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Generate coverage reports
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
if(GENERATE_COVERAGE_HTML)
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePostHtml.cmake
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
endif()
|
||||||
|
if(GENERATE_COVERAGE_COBERTURA)
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePostCobertura.cmake
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
52
src/cmake/scripts/CoveragePostCobertura.cmake
Normal file
52
src/cmake/scripts/CoveragePostCobertura.cmake
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script assumes that all test have been run and gcov results are available.
|
||||||
|
# It will generate the Cobertura output from the gcov results.
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreCobertura.cmake
|
||||||
|
# $ ctest -T test
|
||||||
|
# $ ctest -T coverage
|
||||||
|
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostCobertura.cmake
|
||||||
|
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||||
|
#
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
# Get Coverage configuration file
|
||||||
|
if(NOT COVERAGE_SETTINGS)
|
||||||
|
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
|
||||||
|
endif()
|
||||||
|
include(${COVERAGE_SETTINGS})
|
||||||
|
|
||||||
|
# Some debug
|
||||||
|
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
|
||||||
|
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
|
||||||
|
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
|
||||||
|
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
|
||||||
|
|
||||||
|
# Find gcovr to generate Cobertura results
|
||||||
|
find_program(GCOVR_PATH gcovr PARENT_SCOPE)
|
||||||
|
if(NOT GCOVR_PATH)
|
||||||
|
message(FATAL_ERROR "Could not find gcovr to generate Cobertura coverage.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Create location to put the result file.
|
||||||
|
file(MAKE_DIRECTORY ${COVERAGE_OUTPUT_DIR})
|
||||||
|
|
||||||
|
execute_process(COMMAND ${GCOVR_PATH} -x -r ${COVERAGE_SOURCE_DIR} -e ".*/${COVERAGE_EXCLUDE_TESTS}/.*" -e ".*/${COVERAGE_EXCLUDE_EXAMPLES}/.*" -e ".*/${COVERAGE_EXCLUDE_BUILD_SUPPORT}/.*" -o ${COVERAGE_OUTPUT_DIR}/cobertura.xml
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
|
||||||
|
|
||||||
|
message(STATUS "The Cobertura report can be found here: ${COVERAGE_OUTPUT_DIR}/cobertura.xml")
|
||||||
|
|
||||||
71
src/cmake/scripts/CoveragePostHtml.cmake
Normal file
71
src/cmake/scripts/CoveragePostHtml.cmake
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script assumes that all test have been run and gcov results are available.
|
||||||
|
# It will generate the HTML output from the gcov results.
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreHtml.cmake
|
||||||
|
# $ ctest -T test
|
||||||
|
# $ ctest -T coverage
|
||||||
|
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostHtml.cmake
|
||||||
|
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||||
|
#
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
# Get Coverage configuration file
|
||||||
|
if(NOT COVERAGE_SETTINGS)
|
||||||
|
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
|
||||||
|
endif()
|
||||||
|
include(${COVERAGE_SETTINGS})
|
||||||
|
|
||||||
|
# Some debug
|
||||||
|
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
|
||||||
|
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
|
||||||
|
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
|
||||||
|
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
|
||||||
|
|
||||||
|
# Find tools to generate HTML coverage results
|
||||||
|
find_program(LCOV_PATH lcov PARENT_SCOPE)
|
||||||
|
if(NOT LCOV_PATH)
|
||||||
|
message(FATAL_ERROR "Could not find lcov to generate HTML coverage.")
|
||||||
|
endif()
|
||||||
|
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
|
||||||
|
if(NOT GENHTML_PATH)
|
||||||
|
message(FATAL_ERROR "Could not find genhtml to generate HTML coverage.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Create location to put the result file.
|
||||||
|
file(MAKE_DIRECTORY ${COVERAGE_OUTPUT_DIR})
|
||||||
|
set(COVERAGE_HTML_OUTPUT "${COVERAGE_OUTPUT_DIR}/html")
|
||||||
|
file(MAKE_DIRECTORY ${COVERAGE_HTML_OUTPUT})
|
||||||
|
|
||||||
|
# Setup tmp analysis files
|
||||||
|
set(COVERAGE_INFO "${COVERAGE_HTML_OUTPUT}/coverage_html.info")
|
||||||
|
set(COVERAGE_CLEANED "${COVERAGE_INFO}.cleaned")
|
||||||
|
|
||||||
|
# Execute lcov and genhtml commands to get HTML results
|
||||||
|
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --directory . --capture --output-file ${COVERAGE_INFO}
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --remove ${COVERAGE_INFO} "${COVERAGE_EXCLUDE_TESTS}/*" "${COVERAGE_EXCLUDE_EXAMPLES}/*" "${COVERAGE_EXCLUDE_BUILD_SUPPORT}/*" "/usr/*" --output-file ${COVERAGE_CLEANED}
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
execute_process(COMMAND ${GENHTML_PATH} ${COVERAGE_QUIET_FLAG} -o ${COVERAGE_HTML_OUTPUT} ${COVERAGE_CLEANED}
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
|
||||||
|
# Remove tmp analysis files
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${COVERAGE_INFO} ${COVERAGE_CLEANED}
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
|
||||||
|
|
||||||
|
message(STATUS "The HTML coverage report can be found here: ${COVERAGE_HTML_OUTPUT}/index.html")
|
||||||
|
|
||||||
30
src/cmake/scripts/CoveragePreCobertura.cmake
Normal file
30
src/cmake/scripts/CoveragePreCobertura.cmake
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script assumes that it is called before all tests are run and gcov results are available.
|
||||||
|
# It can be used to setup the environment needed to get proper Cobertura coverage results.
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreCobertura.cmake
|
||||||
|
# $ ctest -T test
|
||||||
|
# $ ctest -T coverage
|
||||||
|
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostCobertura.cmake
|
||||||
|
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||||
|
#
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Nothing to do really.
|
||||||
|
# This is just added to provide consistency between Coverage scripts.
|
||||||
|
#
|
||||||
|
|
||||||
52
src/cmake/scripts/CoveragePreHtml.cmake
Normal file
52
src/cmake/scripts/CoveragePreHtml.cmake
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script assumes that it is called before all tests are run and gcov results are available.
|
||||||
|
# It can be used to setup the environment needed to get proper HTML coverage results.
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreHtml.cmake
|
||||||
|
# $ ctest -T test
|
||||||
|
# $ ctest -T coverage
|
||||||
|
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostHtml.cmake
|
||||||
|
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
|
||||||
|
#
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
# Get Coverage configuration file
|
||||||
|
if(NOT COVERAGE_SETTINGS)
|
||||||
|
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
|
||||||
|
endif()
|
||||||
|
include(${COVERAGE_SETTINGS})
|
||||||
|
|
||||||
|
# Some debug
|
||||||
|
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
|
||||||
|
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
|
||||||
|
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
|
||||||
|
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
|
||||||
|
|
||||||
|
# Find tools to generate HTML coverage results
|
||||||
|
find_program(LCOV_PATH lcov PARENT_SCOPE)
|
||||||
|
if(NOT LCOV_PATH)
|
||||||
|
message(FATAL_ERROR "Could not find lcov to generate HTML coverage.")
|
||||||
|
endif()
|
||||||
|
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
|
||||||
|
if(NOT GENHTML_PATH)
|
||||||
|
message(FATAL_ERROR "Could not find genhtml to generate HTML coverage.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Reset LCOV environment
|
||||||
|
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --directory . --zerocounters
|
||||||
|
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
|
||||||
|
|
||||||
|
|
||||||
33
src/cmake/vxworks.example.cmake
Normal file
33
src/cmake/vxworks.example.cmake
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
set(CMAKE_SYSTEM_NAME VxWorks)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR PENTIUM4)
|
||||||
|
|
||||||
|
set(WIND_HOME "/path/to/WindRiver")
|
||||||
|
set(WIND_PROCESSOR_TYPE "pentium")
|
||||||
|
|
||||||
|
# Binaries are named e.g. ccpentium or ccarm
|
||||||
|
set(CMAKE_C_COMPILER ${WIND_HOME}/gnu/4.3.3-vxworks-6.9/x86-linux2/bin/cc${WIND_PROCESSOR_TYPE})
|
||||||
|
set(CMAKE_CXX_COMPILER ${WIND_HOME}/gnu/4.3.3-vxworks-6.9/x86-linux2/bin/c++${WIND_PROCESSOR_TYPE})
|
||||||
|
set(CMAKE_AR ${WIND_HOME}/gnu/4.3.3-vxworks-6.9/x86-linux2/bin/ar${WIND_PROCESSOR_TYPE})
|
||||||
|
|
||||||
|
set(WIND_PROGRAM_PATH ${WIND_HOME}/vxworks-6.9/host/x86-linux2/bin;${WIND_BASE}/gnu/4.3.3-vxworks-6.9/x86-linux2/bin)
|
||||||
|
set(WIND_LIBRARY_PATH ${WIND_HOME}/target/lib/${WIND_PROCESSOR_TYPE}/${CMAKE_SYSTEM_PROCESSOR}/common)
|
||||||
|
set(WIND_INCLUDE_PATH ${WIND_HOME}/vxworks-6.9/target/h)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH ${WIND_PROGRAM_PATH};${WIND_LIBRARY_PATH};${WIND_INCLUDE_PATH})
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
|
|
||||||
68
src/core/CMakeLists.txt
Normal file
68
src/core/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
find_package(Abstraction REQUIRED)
|
||||||
|
|
||||||
|
include (GenerateExportHeader)
|
||||||
|
|
||||||
|
FUNCTION(PREPEND var prefix)
|
||||||
|
SET(listVar "")
|
||||||
|
FOREACH(f ${ARGN})
|
||||||
|
LIST(APPEND listVar "${prefix}/${f}")
|
||||||
|
ENDFOREACH(f)
|
||||||
|
SET(${var} "${listVar}" PARENT_SCOPE)
|
||||||
|
ENDFUNCTION(PREPEND)
|
||||||
|
|
||||||
|
|
||||||
|
option(DDSC_SHARED "Build DDSC as a shared library" ON)
|
||||||
|
|
||||||
|
if(DDSC_SHARED AND ((NOT DEFINED BUILD_SHARED_LIBS) OR BUILD_SHARED_LIBS))
|
||||||
|
# BUILD_SHARED_LIBS is set to off by for example VxWorks DKM environment
|
||||||
|
add_library(ddsc SHARED "")
|
||||||
|
else()
|
||||||
|
if(DDSC_SHARED)
|
||||||
|
message(STATUS "Option DDSC_SHARED ignored. Only static libraries supported on this platform.")
|
||||||
|
endif()
|
||||||
|
add_library(ddsc "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(ddsi/CMakeLists.txt)
|
||||||
|
include(ddsc/CMakeLists.txt)
|
||||||
|
include(security/CMakeLists.txt)
|
||||||
|
|
||||||
|
target_link_libraries(ddsc PRIVATE util)
|
||||||
|
target_link_libraries(ddsc PRIVATE OSAPI)
|
||||||
|
|
||||||
|
# SOVERSION should increase on incompatible ABI change
|
||||||
|
set_target_properties(ddsc PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||||
|
|
||||||
|
get_target_property(os_api_src_dir OSAPI SOURCE_DIR)
|
||||||
|
# We need to expose some of the OS headers as well.
|
||||||
|
target_include_directories(ddsc
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${os_api_src_dir}/include>")
|
||||||
|
|
||||||
|
set_target_file_ids(ddsc)
|
||||||
|
|
||||||
|
# Create a pseudo-target that other targets (i.e. examples, tests) can depend
|
||||||
|
# on and can also be provided as import-target by a package-file when building
|
||||||
|
# those targets outside the regular Cyclone build-tree (i.e. the installed tree)
|
||||||
|
add_library(${CMAKE_PROJECT_NAME}::ddsc ALIAS ddsc)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS ddsc
|
||||||
|
EXPORT "${CMAKE_PROJECT_NAME}"
|
||||||
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT lib
|
||||||
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
||||||
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
32
src/core/ddsc/.fileids
Normal file
32
src/core/ddsc/.fileids
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# ddsc sources
|
||||||
|
40 src/dds_alloc.c
|
||||||
|
41 src/dds_coherent.c
|
||||||
|
42 src/dds_iid.c
|
||||||
|
43 src/dds_participant.c
|
||||||
|
44 src/dds_reader.c
|
||||||
|
45 src/dds_thread.c
|
||||||
|
46 src/dds_writer.c
|
||||||
|
47 src/dds_init.c
|
||||||
|
48 src/dds_publisher.c
|
||||||
|
49 src/dds_rhc.c
|
||||||
|
50 src/dds_time.c
|
||||||
|
51 src/q_osplser.c
|
||||||
|
52 src/dds_domain.c
|
||||||
|
53 src/dds_instance.c
|
||||||
|
54 src/dds_qos.c
|
||||||
|
55 src/dds_tkmap.c
|
||||||
|
56 src/dds_entity.c
|
||||||
|
57 src/dds_key.c
|
||||||
|
58 src/dds_querycond.c
|
||||||
|
59 src/dds_topic.c
|
||||||
|
60 src/dds_err.c
|
||||||
|
61 src/dds_listener.c
|
||||||
|
62 src/dds_read.c
|
||||||
|
63 src/dds_stream.c
|
||||||
|
64 src/dds_waitset.c
|
||||||
|
65 src/dds_log.c
|
||||||
|
66 src/dds_readcond.c
|
||||||
|
67 src/dds_subscriber.c
|
||||||
|
68 src/dds_write.c
|
||||||
|
69 src/dds_report.c
|
||||||
|
70 src/dds_builtin.c
|
||||||
146
src/core/ddsc/CMakeLists.txt
Normal file
146
src/core/ddsc/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
#
|
||||||
|
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
#
|
||||||
|
# This program and the accompanying materials are made available under the
|
||||||
|
# terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
# v. 1.0 which is available at
|
||||||
|
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
#
|
||||||
|
PREPEND(srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
||||||
|
dds_alloc.c
|
||||||
|
dds_builtin.c
|
||||||
|
dds_coherent.c
|
||||||
|
dds_iid.c
|
||||||
|
dds_participant.c
|
||||||
|
dds_reader.c
|
||||||
|
dds_writer.c
|
||||||
|
dds_init.c
|
||||||
|
dds_publisher.c
|
||||||
|
dds_rhc.c
|
||||||
|
dds_time.c
|
||||||
|
q_osplser.c
|
||||||
|
dds_domain.c
|
||||||
|
dds_instance.c
|
||||||
|
dds_qos.c
|
||||||
|
dds_tkmap.c
|
||||||
|
dds_entity.c
|
||||||
|
dds_key.c
|
||||||
|
dds_querycond.c
|
||||||
|
dds_topic.c
|
||||||
|
dds_report.c
|
||||||
|
dds_err.c
|
||||||
|
dds_listener.c
|
||||||
|
dds_read.c
|
||||||
|
dds_stream.c
|
||||||
|
dds_waitset.c
|
||||||
|
dds_log.c
|
||||||
|
dds_readcond.c
|
||||||
|
dds_subscriber.c
|
||||||
|
dds_write.c
|
||||||
|
)
|
||||||
|
|
||||||
|
PREPEND(hdrs_public_ddsc "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/ddsc>$<INSTALL_INTERFACE:include/ddsc>"
|
||||||
|
dds.h
|
||||||
|
dds_public_error.h
|
||||||
|
dds_public_impl.h
|
||||||
|
dds_public_listener.h
|
||||||
|
dds_public_log.h
|
||||||
|
dds_public_qos.h
|
||||||
|
dds_public_status.h
|
||||||
|
dds_public_stream.h
|
||||||
|
dds_public_time.h
|
||||||
|
)
|
||||||
|
|
||||||
|
PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
|
||||||
|
dds__alloc.h
|
||||||
|
dds__builtin.h
|
||||||
|
dds__domain.h
|
||||||
|
dds__entity.h
|
||||||
|
dds__iid.h
|
||||||
|
dds__init.h
|
||||||
|
dds__key.h
|
||||||
|
dds__listener.h
|
||||||
|
dds__participant.h
|
||||||
|
dds__publisher.h
|
||||||
|
dds__qos.h
|
||||||
|
dds__querycond.h
|
||||||
|
dds__readcond.h
|
||||||
|
dds__reader.h
|
||||||
|
dds__report.h
|
||||||
|
dds__rhc.h
|
||||||
|
dds__stream.h
|
||||||
|
dds__subscriber.h
|
||||||
|
dds__tkmap.h
|
||||||
|
dds__topic.h
|
||||||
|
dds__types.h
|
||||||
|
dds__write.h
|
||||||
|
dds__writer.h
|
||||||
|
q__osplser.h
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/cmake/ddsc_project.h.in"
|
||||||
|
"include/ddsc/ddsc_project.h")
|
||||||
|
|
||||||
|
generate_export_header(
|
||||||
|
ddsc
|
||||||
|
BASE_NAME DDS
|
||||||
|
EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/include/ddsc/dds_export.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(ddsc
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>")
|
||||||
|
|
||||||
|
# Generate builtin-topic sources
|
||||||
|
set(IDLC_ARGS "-dll" "FOO,ddsc/dds_export.h")
|
||||||
|
idlc_generate(BuiltinTypes ddsc/src/dds_dcps_builtintopics.idl ddsc/src/dds_builtinTopics.idl)
|
||||||
|
set(IDLC_ARGS)
|
||||||
|
target_link_libraries(ddsc PRIVATE BuiltinTypes)
|
||||||
|
|
||||||
|
target_include_directories(ddsc
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
|
||||||
|
|
||||||
|
target_sources(ddsc
|
||||||
|
PRIVATE
|
||||||
|
${srcs_ddsc}
|
||||||
|
${hdrs_private_ddsc}
|
||||||
|
"include/ddsc/ddsc_project.h"
|
||||||
|
PUBLIC
|
||||||
|
${hdrs_public_ddsc}
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>$<INSTALL_INTERFACE:include>/ddsc/dds_export.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(ddsc
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../security/include>"
|
||||||
|
PRIVATE
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/src")
|
||||||
|
|
||||||
|
install(
|
||||||
|
DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/include/ddsc"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
|
COMPONENT dev)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/include/ddsc/dds_export.h"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ddsc"
|
||||||
|
COMPONENT dev)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/dds_dcps_builtintopics.h"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/dds_builtinTopics.h"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ddsc"
|
||||||
|
COMPONENT dev)
|
||||||
|
|
||||||
|
# TODO: improve test inclusion.
|
||||||
|
if((BUILD_TESTING) AND ((NOT DEFINED MSVC_VERSION) OR (MSVC_VERSION GREATER "1800")))
|
||||||
|
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/tests")
|
||||||
|
endif()
|
||||||
|
|
||||||
25
src/core/ddsc/cmake/ddsc_project.h.in
Normal file
25
src/core/ddsc/cmake/ddsc_project.h.in
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef DDSC_PROJECT_H
|
||||||
|
#define DDSC_PROJECT_H
|
||||||
|
|
||||||
|
#define DDSC_VERSION "@CycloneDDS_VERSION@"
|
||||||
|
#define DDSC_VERSION_MAJOR @CycloneDDS_VERSION_MAJOR@
|
||||||
|
#define DDSC_VERSION_MINOR @CycloneDDS_VERSION_MINOR@
|
||||||
|
#define DDSC_VERSION_PATCH @CycloneDDS_VERSION_PATCH@
|
||||||
|
#define DDSC_VERSION_TWEAK @CycloneDDS_VERSION_TWEAK@
|
||||||
|
#define DDSC_PROJECT_NAME_NOSPACE_CAPS "@CMAKE_PROJECT_NAME_CAPS@"
|
||||||
|
#define DDSC_PROJECT_NAME_NOSPACE_SMALL "@CMAKE_PROJECT_NAME_SMALL@"
|
||||||
|
#define DDSC_PROJECT_NAME_NOSPACE "@CMAKE_PROJECT_NAME@"
|
||||||
|
#define DDSC_PROJECT_NAME "@CMAKE_PROJECT_NAME@"
|
||||||
|
|
||||||
|
#endif /* DDSC_PROJECT_H */
|
||||||
3144
src/core/ddsc/include/ddsc/dds.h
Normal file
3144
src/core/ddsc/include/ddsc/dds.h
Normal file
File diff suppressed because it is too large
Load diff
87
src/core/ddsc/include/ddsc/dds_public_alloc.h
Normal file
87
src/core/ddsc/include/ddsc/dds_public_alloc.h
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
/* TODO: do we really need to expose this as an API? */
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C Allocation API
|
||||||
|
*
|
||||||
|
* This header file defines the public API of allocation convenience functions
|
||||||
|
* in the CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef DDS_ALLOC_H
|
||||||
|
#define DDS_ALLOC_H
|
||||||
|
|
||||||
|
#include "os/os_public.h"
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct dds_topic_descriptor;
|
||||||
|
struct dds_sequence;
|
||||||
|
|
||||||
|
#define DDS_FREE_KEY_BIT 0x01
|
||||||
|
#define DDS_FREE_CONTENTS_BIT 0x02
|
||||||
|
#define DDS_FREE_ALL_BIT 0x04
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
DDS_FREE_ALL = DDS_FREE_KEY_BIT | DDS_FREE_CONTENTS_BIT | DDS_FREE_ALL_BIT,
|
||||||
|
DDS_FREE_CONTENTS = DDS_FREE_KEY_BIT | DDS_FREE_CONTENTS_BIT,
|
||||||
|
DDS_FREE_KEY = DDS_FREE_KEY_BIT
|
||||||
|
}
|
||||||
|
dds_free_op_t;
|
||||||
|
|
||||||
|
typedef struct dds_allocator
|
||||||
|
{
|
||||||
|
/* Behaviour as C library malloc, realloc and free */
|
||||||
|
|
||||||
|
void * (*malloc) (size_t size);
|
||||||
|
void * (*realloc) (void *ptr, size_t size); /* if needed */
|
||||||
|
void (*free) (void *ptr);
|
||||||
|
}
|
||||||
|
dds_allocator_t;
|
||||||
|
|
||||||
|
DDS_EXPORT void dds_set_allocator (const dds_allocator_t * __restrict n, dds_allocator_t * __restrict o);
|
||||||
|
|
||||||
|
typedef struct dds_aligned_allocator
|
||||||
|
{
|
||||||
|
/* size is a multiple of align, align is a power of 2 no less than
|
||||||
|
the machine's page size, returned pointer MUST be aligned to at
|
||||||
|
least align. */
|
||||||
|
void * (*alloc) (size_t size, size_t align);
|
||||||
|
void (*free) (size_t size, void *ptr);
|
||||||
|
}
|
||||||
|
dds_aligned_allocator_t;
|
||||||
|
|
||||||
|
DDS_EXPORT void dds_set_aligned_allocator (const dds_aligned_allocator_t * __restrict n, dds_aligned_allocator_t * __restrict o);
|
||||||
|
|
||||||
|
DDS_EXPORT void * dds_alloc (size_t size);
|
||||||
|
DDS_EXPORT void * dds_realloc (void * ptr, size_t size);
|
||||||
|
DDS_EXPORT void * dds_realloc_zero (void * ptr, size_t size);
|
||||||
|
DDS_EXPORT void dds_free (void * ptr);
|
||||||
|
|
||||||
|
typedef void * (*dds_alloc_fn_t) (size_t);
|
||||||
|
typedef void * (*dds_realloc_fn_t) (void *, size_t);
|
||||||
|
typedef void (*dds_free_fn_t) (void *);
|
||||||
|
|
||||||
|
DDS_EXPORT char * dds_string_alloc (size_t size);
|
||||||
|
DDS_EXPORT char * dds_string_dup (const char * str);
|
||||||
|
DDS_EXPORT void dds_string_free (char * str);
|
||||||
|
DDS_EXPORT void dds_sample_free (void * sample, const struct dds_topic_descriptor * desc, dds_free_op_t op);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
155
src/core/ddsc/include/ddsc/dds_public_error.h
Normal file
155
src/core/ddsc/include/ddsc/dds_public_error.h
Normal file
|
|
@ -0,0 +1,155 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C Error API
|
||||||
|
*
|
||||||
|
* This header file defines the public API of error values and convenience
|
||||||
|
* functions in the CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef DDS_ERROR_H
|
||||||
|
#define DDS_ERROR_H
|
||||||
|
|
||||||
|
#include "os/os_public.h"
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Error masks for returned status values */
|
||||||
|
|
||||||
|
#define DDS_ERR_NR_MASK 0x000000ff
|
||||||
|
#define DDS_ERR_LINE_MASK 0x003fff00
|
||||||
|
#define DDS_ERR_FILE_ID_MASK 0x7fc00000
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
State is unchanged following a function call returning an error
|
||||||
|
other than UNSPECIFIED, OUT_OF_RESOURCES and ALREADY_DELETED.
|
||||||
|
|
||||||
|
Error handling functions. Three components to returned int status value.
|
||||||
|
|
||||||
|
1 - The DDS_ERR_xxx error number
|
||||||
|
2 - The file identifier
|
||||||
|
3 - The line number
|
||||||
|
|
||||||
|
All functions return >= 0 on success, < 0 on error
|
||||||
|
*/
|
||||||
|
/** @name Return codes
|
||||||
|
@{**/
|
||||||
|
#define DDS_RETCODE_OK 0 /**< Success */
|
||||||
|
#define DDS_RETCODE_ERROR 1 /**< Non specific error */
|
||||||
|
#define DDS_RETCODE_UNSUPPORTED 2 /**< Feature unsupported */
|
||||||
|
#define DDS_RETCODE_BAD_PARAMETER 3 /**< Bad parameter value */
|
||||||
|
#define DDS_RETCODE_PRECONDITION_NOT_MET 4 /**< Precondition for operation not met */
|
||||||
|
#define DDS_RETCODE_OUT_OF_RESOURCES 5 /**< When an operation fails because of a lack of resources */
|
||||||
|
#define DDS_RETCODE_NOT_ENABLED 6 /**< When a configurable feature is not enabled */
|
||||||
|
#define DDS_RETCODE_IMMUTABLE_POLICY 7 /**< When an attempt is made to modify an immutable policy */
|
||||||
|
#define DDS_RETCODE_INCONSISTENT_POLICY 8 /**< When a policy is used with inconsistent values */
|
||||||
|
#define DDS_RETCODE_ALREADY_DELETED 9 /**< When an attempt is made to delete something more than once */
|
||||||
|
#define DDS_RETCODE_TIMEOUT 10 /**< When a timeout has occurred */
|
||||||
|
#define DDS_RETCODE_NO_DATA 11 /**< When expected data is not provided */
|
||||||
|
#define DDS_RETCODE_ILLEGAL_OPERATION 12 /**< When a function is called when it should not be */
|
||||||
|
#define DDS_RETCODE_NOT_ALLOWED_BY_SECURITY 13 /**< When credentials are not enough to use the function */
|
||||||
|
|
||||||
|
|
||||||
|
/** @}*/
|
||||||
|
|
||||||
|
/* For backwards compatability */
|
||||||
|
|
||||||
|
#define DDS_SUCCESS DDS_RETCODE_OK
|
||||||
|
|
||||||
|
/** @name DDS_Error_Type
|
||||||
|
@{**/
|
||||||
|
#define DDS_CHECK_REPORT 0x01
|
||||||
|
#define DDS_CHECK_FAIL 0x02
|
||||||
|
#define DDS_CHECK_EXIT 0x04
|
||||||
|
/** @}*/
|
||||||
|
|
||||||
|
/* Error code handling functions */
|
||||||
|
|
||||||
|
/** @name Macros for error handling
|
||||||
|
@{**/
|
||||||
|
#define DDS_TO_STRING(n) #n
|
||||||
|
#define DDS_INT_TO_STRING(n) DDS_TO_STRING(n)
|
||||||
|
/** @}*/
|
||||||
|
|
||||||
|
/** Macro to extract error number */
|
||||||
|
#define dds_err_nr(e) ((-(e)) & DDS_ERR_NR_MASK)
|
||||||
|
|
||||||
|
/** Macro to extract line number */
|
||||||
|
#define dds_err_line(e) (((-(e)) & DDS_ERR_LINE_MASK) >> 8)
|
||||||
|
|
||||||
|
/** Macro to extract file identifier */
|
||||||
|
#define dds_err_file_id(e) (((-(e)) & DDS_ERR_FILE_ID_MASK) >> 22)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Takes the error value and outputs a string corresponding to it.
|
||||||
|
*
|
||||||
|
* @param[in] err Error value to be converted to a string
|
||||||
|
* @returns String corresponding to the error value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT const char * dds_err_str (dds_return_t err);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Takes the error number, error type and filename and line number and formats it to
|
||||||
|
* a string which can be used for debugging.
|
||||||
|
*
|
||||||
|
* @param[in] err Error value
|
||||||
|
* @param[in] flags Indicates Fail, Exit or Report
|
||||||
|
* @param[in] where File and line number
|
||||||
|
* @returns true - True
|
||||||
|
* @returns false - False
|
||||||
|
*/
|
||||||
|
|
||||||
|
DDS_EXPORT bool dds_err_check (dds_return_t err, unsigned flags, const char * where);
|
||||||
|
|
||||||
|
/** Macro that defines dds_err_check function */
|
||||||
|
#define DDS_ERR_CHECK(e, f) (dds_err_check ((e), (f), __FILE__ ":" DDS_INT_TO_STRING(__LINE__)))
|
||||||
|
|
||||||
|
/* Failure handling */
|
||||||
|
|
||||||
|
/** Failure handler */
|
||||||
|
typedef void (*dds_fail_fn) (const char *, const char *);
|
||||||
|
|
||||||
|
/** Macro that defines dds_fail function */
|
||||||
|
#define DDS_FAIL(m) (dds_fail (m, __FILE__ ":" DDS_INT_TO_STRING (__LINE__)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the failure function
|
||||||
|
*
|
||||||
|
* @param[in] fn Function to invoke on failure
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_fail_set (dds_fail_fn fn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the failure function
|
||||||
|
*
|
||||||
|
* @returns Failure function
|
||||||
|
*/
|
||||||
|
DDS_EXPORT dds_fail_fn dds_fail_get (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handles failure through an installed failure handler
|
||||||
|
*
|
||||||
|
* @params[in] msg String containing failure message
|
||||||
|
* @params[in] where String containing file and location
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_fail (const char * msg, const char * where);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
210
src/core/ddsc/include/ddsc/dds_public_impl.h
Normal file
210
src/core/ddsc/include/ddsc/dds_public_impl.h
Normal file
|
|
@ -0,0 +1,210 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
/* TODO: do we really need to expose all of this as an API? maybe some, but all? */
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C Implementation API
|
||||||
|
*
|
||||||
|
* This header file defines the public API for all kinds of things in the
|
||||||
|
* CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef DDS_IMPL_H
|
||||||
|
#define DDS_IMPL_H
|
||||||
|
|
||||||
|
#include "ddsc/dds_public_alloc.h"
|
||||||
|
#include "ddsc/dds_public_stream.h"
|
||||||
|
#include "os/os_public.h"
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct dds_sequence
|
||||||
|
{
|
||||||
|
uint32_t _maximum;
|
||||||
|
uint32_t _length;
|
||||||
|
uint8_t * _buffer;
|
||||||
|
bool _release;
|
||||||
|
}
|
||||||
|
dds_sequence_t;
|
||||||
|
|
||||||
|
#define DDS_LENGTH_UNLIMITED -1
|
||||||
|
|
||||||
|
typedef struct dds_key_descriptor
|
||||||
|
{
|
||||||
|
const char * m_name;
|
||||||
|
uint32_t m_index;
|
||||||
|
}
|
||||||
|
dds_key_descriptor_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Topic definitions are output by a preprocessor and have an
|
||||||
|
implementation-private definition. The only thing exposed on the
|
||||||
|
API is a pointer to the "topic_descriptor_t" struct type.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct dds_topic_descriptor
|
||||||
|
{
|
||||||
|
const size_t m_size; /* Size of topic type */
|
||||||
|
const uint32_t m_align; /* Alignment of topic type */
|
||||||
|
const uint32_t m_flagset; /* Flags */
|
||||||
|
const uint32_t m_nkeys; /* Number of keys (can be 0) */
|
||||||
|
const char * m_typename; /* Type name */
|
||||||
|
const dds_key_descriptor_t * m_keys; /* Key descriptors (NULL iff m_nkeys 0) */
|
||||||
|
const uint32_t m_nops; /* Number of ops in m_ops */
|
||||||
|
const uint32_t * m_ops; /* Marshalling meta data */
|
||||||
|
const char * m_meta; /* XML topic description meta data */
|
||||||
|
}
|
||||||
|
dds_topic_descriptor_t;
|
||||||
|
|
||||||
|
/* Topic descriptor flag values */
|
||||||
|
|
||||||
|
#define DDS_TOPIC_NO_OPTIMIZE 0x0001
|
||||||
|
#define DDS_TOPIC_FIXED_KEY 0x0002
|
||||||
|
|
||||||
|
/*
|
||||||
|
Masks for read condition, read, take: there is only one mask here,
|
||||||
|
which combines the sample, view and instance states.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DDS_READ_SAMPLE_STATE 1u
|
||||||
|
#define DDS_NOT_READ_SAMPLE_STATE 2u
|
||||||
|
#define DDS_ANY_SAMPLE_STATE (1u | 2u)
|
||||||
|
|
||||||
|
#define DDS_NEW_VIEW_STATE 4u
|
||||||
|
#define DDS_NOT_NEW_VIEW_STATE 8u
|
||||||
|
#define DDS_ANY_VIEW_STATE (4u | 8u)
|
||||||
|
|
||||||
|
#define DDS_ALIVE_INSTANCE_STATE 16u
|
||||||
|
#define DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE 32u
|
||||||
|
#define DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE 64u
|
||||||
|
#define DDS_ANY_INSTANCE_STATE (16u | 32u | 64u)
|
||||||
|
|
||||||
|
#define DDS_ANY_STATE (DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE)
|
||||||
|
|
||||||
|
#define DDS_DOMAIN_DEFAULT -1
|
||||||
|
#define DDS_HANDLE_NIL 0
|
||||||
|
#define DDS_ENTITY_NIL 0
|
||||||
|
|
||||||
|
#define DDS_ENTITY_KIND_MASK (0x7F000000) /* Should be same as UT_HANDLE_KIND_MASK. */
|
||||||
|
typedef enum dds_entity_kind
|
||||||
|
{
|
||||||
|
DDS_KIND_DONTCARE = 0x00000000,
|
||||||
|
DDS_KIND_TOPIC = 0x01000000,
|
||||||
|
DDS_KIND_PARTICIPANT = 0x02000000,
|
||||||
|
DDS_KIND_READER = 0x03000000,
|
||||||
|
DDS_KIND_WRITER = 0x04000000,
|
||||||
|
DDS_KIND_SUBSCRIBER = 0x05000000,
|
||||||
|
DDS_KIND_PUBLISHER = 0x06000000,
|
||||||
|
DDS_KIND_COND_READ = 0x07000000,
|
||||||
|
DDS_KIND_COND_QUERY = 0x08000000,
|
||||||
|
DDS_KIND_WAITSET = 0x09000000,
|
||||||
|
DDS_KIND_INTERNAL = 0x0A000000,
|
||||||
|
}
|
||||||
|
dds_entity_kind_t;
|
||||||
|
|
||||||
|
/* Handles are opaque pointers to implementation types */
|
||||||
|
typedef uint64_t dds_instance_handle_t;
|
||||||
|
typedef int32_t dds_domainid_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* Topic encoding instruction types */
|
||||||
|
|
||||||
|
#define DDS_OP_RTS 0x00000000
|
||||||
|
#define DDS_OP_ADR 0x01000000
|
||||||
|
#define DDS_OP_JSR 0x02000000
|
||||||
|
#define DDS_OP_JEQ 0x03000000
|
||||||
|
|
||||||
|
/* Core type flags
|
||||||
|
|
||||||
|
1BY : One byte simple type
|
||||||
|
2BY : Two byte simple type
|
||||||
|
4BY : Four byte simple type
|
||||||
|
8BY : Eight byte simple type
|
||||||
|
STR : String
|
||||||
|
BST : Bounded string
|
||||||
|
SEQ : Sequence
|
||||||
|
ARR : Array
|
||||||
|
UNI : Union
|
||||||
|
STU : Struct
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DDS_OP_VAL_1BY 0x01
|
||||||
|
#define DDS_OP_VAL_2BY 0x02
|
||||||
|
#define DDS_OP_VAL_4BY 0x03
|
||||||
|
#define DDS_OP_VAL_8BY 0x04
|
||||||
|
#define DDS_OP_VAL_STR 0x05
|
||||||
|
#define DDS_OP_VAL_BST 0x06
|
||||||
|
#define DDS_OP_VAL_SEQ 0x07
|
||||||
|
#define DDS_OP_VAL_ARR 0x08
|
||||||
|
#define DDS_OP_VAL_UNI 0x09
|
||||||
|
#define DDS_OP_VAL_STU 0x0a
|
||||||
|
|
||||||
|
#define DDS_OP_TYPE_1BY (DDS_OP_VAL_1BY << 16)
|
||||||
|
#define DDS_OP_TYPE_2BY (DDS_OP_VAL_2BY << 16)
|
||||||
|
#define DDS_OP_TYPE_4BY (DDS_OP_VAL_4BY << 16)
|
||||||
|
#define DDS_OP_TYPE_8BY (DDS_OP_VAL_8BY << 16)
|
||||||
|
#define DDS_OP_TYPE_STR (DDS_OP_VAL_STR << 16)
|
||||||
|
#define DDS_OP_TYPE_SEQ (DDS_OP_VAL_SEQ << 16)
|
||||||
|
#define DDS_OP_TYPE_ARR (DDS_OP_VAL_ARR << 16)
|
||||||
|
#define DDS_OP_TYPE_UNI (DDS_OP_VAL_UNI << 16)
|
||||||
|
#define DDS_OP_TYPE_STU (DDS_OP_VAL_STU << 16)
|
||||||
|
#define DDS_OP_TYPE_BST (DDS_OP_VAL_BST << 16)
|
||||||
|
|
||||||
|
#define DDS_OP_TYPE_BOO DDS_OP_TYPE_1BY
|
||||||
|
#define DDS_OP_SUBTYPE_BOO DDS_OP_SUBTYPE_1BY
|
||||||
|
|
||||||
|
#define DDS_OP_SUBTYPE_1BY (DDS_OP_VAL_1BY << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_2BY (DDS_OP_VAL_2BY << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_4BY (DDS_OP_VAL_4BY << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_8BY (DDS_OP_VAL_8BY << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_STR (DDS_OP_VAL_STR << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_SEQ (DDS_OP_VAL_SEQ << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_ARR (DDS_OP_VAL_ARR << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_UNI (DDS_OP_VAL_UNI << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_STU (DDS_OP_VAL_STU << 8)
|
||||||
|
#define DDS_OP_SUBTYPE_BST (DDS_OP_VAL_BST << 8)
|
||||||
|
|
||||||
|
#define DDS_OP_FLAG_KEY 0x01
|
||||||
|
#define DDS_OP_FLAG_DEF 0x02
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description : Enable or disable write batching. Overrides default configuration
|
||||||
|
* setting for write batching (DDSI2E/Internal/WriteBatch).
|
||||||
|
*
|
||||||
|
* Arguments :
|
||||||
|
* -# enable Enables or disables write batching for all writers.
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_write_set_batch (bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description : Install tcp/ssl and encryption support. Depends on openssl.
|
||||||
|
*
|
||||||
|
* Arguments :
|
||||||
|
* -# None
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_ssl_plugin (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description : Install client durability support. Depends on OSPL server.
|
||||||
|
*
|
||||||
|
* Arguments :
|
||||||
|
* -# None
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_durability_plugin (void);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
323
src/core/ddsc/include/ddsc/dds_public_listener.h
Normal file
323
src/core/ddsc/include/ddsc/dds_public_listener.h
Normal file
|
|
@ -0,0 +1,323 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C Listener API
|
||||||
|
*
|
||||||
|
* This header file defines the public API of listeners in the
|
||||||
|
* CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_PUBLIC_LISTENER_H_
|
||||||
|
#define _DDS_PUBLIC_LISTENER_H_
|
||||||
|
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
#include "ddsc/dds_public_impl.h"
|
||||||
|
#include "ddsc/dds_public_status.h"
|
||||||
|
#include "os/os_public.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Listener callbacks */
|
||||||
|
typedef void (*dds_on_inconsistent_topic_fn) (dds_entity_t topic, const dds_inconsistent_topic_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_liveliness_lost_fn) (dds_entity_t writer, const dds_liveliness_lost_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_offered_deadline_missed_fn) (dds_entity_t writer, const dds_offered_deadline_missed_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_offered_incompatible_qos_fn) (dds_entity_t writer, const dds_offered_incompatible_qos_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_data_on_readers_fn) (dds_entity_t subscriber, void* arg);
|
||||||
|
typedef void (*dds_on_sample_lost_fn) (dds_entity_t reader, const dds_sample_lost_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_data_available_fn) (dds_entity_t reader, void* arg);
|
||||||
|
typedef void (*dds_on_sample_rejected_fn) (dds_entity_t reader, const dds_sample_rejected_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_liveliness_changed_fn) (dds_entity_t reader, const dds_liveliness_changed_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_requested_deadline_missed_fn) (dds_entity_t reader, const dds_requested_deadline_missed_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_requested_incompatible_qos_fn) (dds_entity_t reader, const dds_requested_incompatible_qos_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_publication_matched_fn) (dds_entity_t writer, const dds_publication_matched_status_t status, void* arg);
|
||||||
|
typedef void (*dds_on_subscription_matched_fn) (dds_entity_t reader, const dds_subscription_matched_status_t status, void* arg);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* TODO: Why use (*dds_on_any_fn) (); and DDS_LUNSET? Why not just set the callbacks to NULL? */
|
||||||
|
typedef void (*dds_on_any_fn) (); /**< Empty parameter list on purpose; should be assignable without cast to all of the above. @todo check with an actual compiler; I'm a sloppy compiler */
|
||||||
|
#define DDS_LUNSET ((dds_on_any_fn)1) /**< Callback indicating a callback isn't set */
|
||||||
|
#else
|
||||||
|
#define DDS_LUNSET (NULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct c_listener;
|
||||||
|
typedef struct c_listener dds_listener_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allocate memory and initializes to default values (::DDS_LUNSET) of a listener
|
||||||
|
*
|
||||||
|
* @param[in] arg optional pointer that will be passed on to the listener callbacks
|
||||||
|
*
|
||||||
|
* @return Returns a pointer to the allocated memory for dds_listener_t structure.
|
||||||
|
*/
|
||||||
|
_Ret_notnull_
|
||||||
|
DDS_EXPORT dds_listener_t* dds_listener_create (_In_opt_ void* arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delete the memory allocated to listener structure
|
||||||
|
*
|
||||||
|
* @param[in] listener pointer to the listener struct to delete
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_listener_delete (_In_ _Post_invalid_ dds_listener_t * __restrict listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset the listener structure contents to ::DDS_LUNSET
|
||||||
|
*
|
||||||
|
* @param[in,out] listener pointer to the listener struct to reset
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_listener_reset (_Out_ dds_listener_t * __restrict listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy the listener callbacks from source to destination
|
||||||
|
*
|
||||||
|
* @param[in,out] dst The pointer to the destination listener structure, where the content is to copied
|
||||||
|
* @param[in] src The pointer to the source listener structure to be copied
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_listener_copy (_Out_ dds_listener_t * __restrict dst, _In_ const dds_listener_t * __restrict src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy the listener callbacks from source to destination, unless already set
|
||||||
|
*
|
||||||
|
* Any listener callbacks already set in @p dst (including NULL) are skipped, only
|
||||||
|
* those set to DDS_LUNSET are copied from @p src.
|
||||||
|
*
|
||||||
|
* @param[in,out] dst The pointer to the destination listener structure, where the content is merged
|
||||||
|
* @param[in] src The pointer to the source listener structure to be copied
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_listener_merge (_Inout_ dds_listener_t * __restrict dst, _In_ const dds_listener_t * __restrict src);
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************************************
|
||||||
|
* Setters
|
||||||
|
************************************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the inconsistent_topic callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_inconsistent_topic (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_inconsistent_topic_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the liveliness_lost callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_liveliness_lost (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_liveliness_lost_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the offered_deadline_missed callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_offered_deadline_missed (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_offered_deadline_missed_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the offered_incompatible_qos callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_offered_incompatible_qos (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_offered_incompatible_qos_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the data_on_readers callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_data_on_readers (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_data_on_readers_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the sample_lost callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_sample_lost (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_sample_lost_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the data_available callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_data_available (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_data_available_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the sample_rejected callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_sample_rejected (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_sample_rejected_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the liveliness_changed callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_liveliness_changed (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_liveliness_changed_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the requested_deadline_missed callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_requested_deadline_missed (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_requested_deadline_missed_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the requested_incompatible_qos callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_requested_incompatible_qos (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_requested_incompatible_qos_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the publication_matched callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_publication_matched (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_publication_matched_fn callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the subscription_matched callback in the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be set
|
||||||
|
* @param[in] callback The callback to set in the listener, can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lset_subscription_matched (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_subscription_matched_fn callback);
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************************************
|
||||||
|
* Getters
|
||||||
|
************************************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the inconsistent_topic callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_inconsistent_topic (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_inconsistent_topic_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the liveliness_lost callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_liveliness_lost (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_liveliness_lost_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the offered_deadline_missed callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_offered_deadline_missed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_offered_deadline_missed_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the offered_incompatible_qos callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_offered_incompatible_qos (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_offered_incompatible_qos_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the data_on_readers callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_data_on_readers (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_data_on_readers_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the sample_lost callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_sample_lost (_In_ const dds_listener_t *__restrict listener, _Outptr_result_maybenull_ dds_on_sample_lost_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the data_available callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_data_available (_In_ const dds_listener_t *__restrict listener, _Outptr_result_maybenull_ dds_on_data_available_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the sample_rejected callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_sample_rejected (_In_ const dds_listener_t *__restrict listener, _Outptr_result_maybenull_ dds_on_sample_rejected_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the liveliness_changed callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_liveliness_changed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_liveliness_changed_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the requested_deadline_missed callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_requested_deadline_missed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_requested_deadline_missed_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the requested_incompatible_qos callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_requested_incompatible_qos (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_requested_incompatible_qos_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the publication_matched callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
* @param[in,out] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_publication_matched (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_publication_matched_fn *callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the subscription_matched callback from the listener structure.
|
||||||
|
*
|
||||||
|
* @param[in] callback Pointer where the retrieved callback can be stored; can be NULL, ::DDS_LUNSET or a valid callback pointer
|
||||||
|
* @param[in,out] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_lget_subscription_matched (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_subscription_matched_fn *callback);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_DDS_PUBLIC_LISTENER_H_*/
|
||||||
39
src/core/ddsc/include/ddsc/dds_public_log.h
Normal file
39
src/core/ddsc/include/ddsc/dds_public_log.h
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
/* TODO: do we really need to expose this as an API? */
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C Logging API
|
||||||
|
*
|
||||||
|
* This header file defines the public API for logging in the
|
||||||
|
* CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef DDS_LOG_H
|
||||||
|
#define DDS_LOG_H
|
||||||
|
|
||||||
|
#include "os/os_public.h"
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DDS_EXPORT void dds_log_info (const char * fmt, ...);
|
||||||
|
DDS_EXPORT void dds_log_warn (const char * fmt, ...);
|
||||||
|
DDS_EXPORT void dds_log_error (const char * fmt, ...);
|
||||||
|
DDS_EXPORT void dds_log_fatal (const char * fmt, ...);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
815
src/core/ddsc/include/ddsc/dds_public_qos.h
Normal file
815
src/core/ddsc/include/ddsc/dds_public_qos.h
Normal file
|
|
@ -0,0 +1,815 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C QoS API
|
||||||
|
*
|
||||||
|
* This header file defines the public API of QoS and Policies in the
|
||||||
|
* CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef DDS_QOS_H
|
||||||
|
#define DDS_QOS_H
|
||||||
|
|
||||||
|
#include "os/os_public.h"
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* QoS identifiers */
|
||||||
|
/** @name QoS identifiers
|
||||||
|
@{**/
|
||||||
|
#define DDS_INVALID_QOS_POLICY_ID 0
|
||||||
|
#define DDS_USERDATA_QOS_POLICY_ID 1
|
||||||
|
#define DDS_DURABILITY_QOS_POLICY_ID 2
|
||||||
|
#define DDS_PRESENTATION_QOS_POLICY_ID 3
|
||||||
|
#define DDS_DEADLINE_QOS_POLICY_ID 4
|
||||||
|
#define DDS_LATENCYBUDGET_QOS_POLICY_ID 5
|
||||||
|
#define DDS_OWNERSHIP_QOS_POLICY_ID 6
|
||||||
|
#define DDS_OWNERSHIPSTRENGTH_QOS_POLICY_ID 7
|
||||||
|
#define DDS_LIVELINESS_QOS_POLICY_ID 8
|
||||||
|
#define DDS_TIMEBASEDFILTER_QOS_POLICY_ID 9
|
||||||
|
#define DDS_PARTITION_QOS_POLICY_ID 10
|
||||||
|
#define DDS_RELIABILITY_QOS_POLICY_ID 11
|
||||||
|
#define DDS_DESTINATIONORDER_QOS_POLICY_ID 12
|
||||||
|
#define DDS_HISTORY_QOS_POLICY_ID 13
|
||||||
|
#define DDS_RESOURCELIMITS_QOS_POLICY_ID 14
|
||||||
|
#define DDS_ENTITYFACTORY_QOS_POLICY_ID 15
|
||||||
|
#define DDS_WRITERDATALIFECYCLE_QOS_POLICY_ID 16
|
||||||
|
#define DDS_READERDATALIFECYCLE_QOS_POLICY_ID 17
|
||||||
|
#define DDS_TOPICDATA_QOS_POLICY_ID 18
|
||||||
|
#define DDS_GROUPDATA_QOS_POLICY_ID 19
|
||||||
|
#define DDS_TRANSPORTPRIORITY_QOS_POLICY_ID 20
|
||||||
|
#define DDS_LIFESPAN_QOS_POLICY_ID 21
|
||||||
|
#define DDS_DURABILITYSERVICE_QOS_POLICY_ID 22
|
||||||
|
/** @}*/
|
||||||
|
|
||||||
|
|
||||||
|
/* QoS structure is opaque */
|
||||||
|
/** QoS structure */
|
||||||
|
typedef struct nn_xqos dds_qos_t;
|
||||||
|
|
||||||
|
/** Durability QoS: Applies to Topic, DataReader, DataWriter */
|
||||||
|
typedef enum dds_durability_kind
|
||||||
|
{
|
||||||
|
DDS_DURABILITY_VOLATILE,
|
||||||
|
DDS_DURABILITY_TRANSIENT_LOCAL,
|
||||||
|
DDS_DURABILITY_TRANSIENT,
|
||||||
|
DDS_DURABILITY_PERSISTENT
|
||||||
|
}
|
||||||
|
dds_durability_kind_t;
|
||||||
|
|
||||||
|
/** History QoS: Applies to Topic, DataReader, DataWriter */
|
||||||
|
typedef enum dds_history_kind
|
||||||
|
{
|
||||||
|
DDS_HISTORY_KEEP_LAST,
|
||||||
|
DDS_HISTORY_KEEP_ALL
|
||||||
|
}
|
||||||
|
dds_history_kind_t;
|
||||||
|
|
||||||
|
/** Ownership QoS: Applies to Topic, DataReader, DataWriter */
|
||||||
|
typedef enum dds_ownership_kind
|
||||||
|
{
|
||||||
|
DDS_OWNERSHIP_SHARED,
|
||||||
|
DDS_OWNERSHIP_EXCLUSIVE
|
||||||
|
}
|
||||||
|
dds_ownership_kind_t;
|
||||||
|
|
||||||
|
/** Liveliness QoS: Applies to Topic, DataReader, DataWriter */
|
||||||
|
typedef enum dds_liveliness_kind
|
||||||
|
{
|
||||||
|
DDS_LIVELINESS_AUTOMATIC,
|
||||||
|
DDS_LIVELINESS_MANUAL_BY_PARTICIPANT,
|
||||||
|
DDS_LIVELINESS_MANUAL_BY_TOPIC
|
||||||
|
}
|
||||||
|
dds_liveliness_kind_t;
|
||||||
|
|
||||||
|
/** Reliability QoS: Applies to Topic, DataReader, DataWriter */
|
||||||
|
typedef enum dds_reliability_kind
|
||||||
|
{
|
||||||
|
DDS_RELIABILITY_BEST_EFFORT,
|
||||||
|
DDS_RELIABILITY_RELIABLE
|
||||||
|
}
|
||||||
|
dds_reliability_kind_t;
|
||||||
|
|
||||||
|
/** DestinationOrder QoS: Applies to Topic, DataReader, DataWriter */
|
||||||
|
typedef enum dds_destination_order_kind
|
||||||
|
{
|
||||||
|
DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP,
|
||||||
|
DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP
|
||||||
|
}
|
||||||
|
dds_destination_order_kind_t;
|
||||||
|
|
||||||
|
/** History QoS: Applies to Topic, DataReader, DataWriter */
|
||||||
|
typedef struct dds_history_qospolicy
|
||||||
|
{
|
||||||
|
dds_history_kind_t kind;
|
||||||
|
int32_t depth;
|
||||||
|
}
|
||||||
|
dds_history_qospolicy_t;
|
||||||
|
|
||||||
|
/** ResourceLimits QoS: Applies to Topic, DataReader, DataWriter */
|
||||||
|
typedef struct dds_resource_limits_qospolicy
|
||||||
|
{
|
||||||
|
int32_t max_samples;
|
||||||
|
int32_t max_instances;
|
||||||
|
int32_t max_samples_per_instance;
|
||||||
|
}
|
||||||
|
dds_resource_limits_qospolicy_t;
|
||||||
|
|
||||||
|
/** Presentation QoS: Applies to Publisher, Subscriber */
|
||||||
|
typedef enum dds_presentation_access_scope_kind
|
||||||
|
{
|
||||||
|
DDS_PRESENTATION_INSTANCE,
|
||||||
|
DDS_PRESENTATION_TOPIC,
|
||||||
|
DDS_PRESENTATION_GROUP
|
||||||
|
}
|
||||||
|
dds_presentation_access_scope_kind_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allocate memory and initialize default QoS-policies
|
||||||
|
*
|
||||||
|
* @returns - Pointer to the initialized dds_qos_t structure, NULL if unsuccessful.
|
||||||
|
*/
|
||||||
|
_Ret_notnull_
|
||||||
|
DDS_EXPORT
|
||||||
|
dds_qos_t * dds_qos_create (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delete memory allocated to QoS-policies structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to dds_qos_t structure
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qos_delete (
|
||||||
|
_In_ _Post_invalid_ dds_qos_t * __restrict qos
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset a QoS-policies structure to default values
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to the dds_qos_t structure
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qos_reset (
|
||||||
|
_Out_ dds_qos_t * __restrict qos
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy all QoS-policies from one structure to another
|
||||||
|
*
|
||||||
|
* @param[in,out] dst - Pointer to the destination dds_qos_t structure
|
||||||
|
* @param[in] src - Pointer to the source dds_qos_t structure
|
||||||
|
*
|
||||||
|
* @returns - Return-code indicating success or failure
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
dds_return_t dds_qos_copy (
|
||||||
|
_Out_ dds_qos_t * __restrict dst,
|
||||||
|
_In_ const dds_qos_t * __restrict src
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy all QoS-policies from one structure to another, unless already set
|
||||||
|
*
|
||||||
|
* Policies are copied from src to dst, unless src already has the policy set to a non-default value.
|
||||||
|
*
|
||||||
|
* @param[in,out] dst - Pointer to the destination qos structure
|
||||||
|
* @param[in] src - Pointer to the source qos structure
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qos_merge
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict dst,
|
||||||
|
_In_ const dds_qos_t * __restrict src
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the userdata of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the userdata
|
||||||
|
* @param[in] value - Pointer to the userdata
|
||||||
|
* @param[in] sz - Size of userdata stored in value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_userdata
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_reads_bytes_opt_(sz) const void * __restrict value,
|
||||||
|
_In_ size_t sz
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the topicdata of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the topicdata
|
||||||
|
* @param[in] value - Pointer to the topicdata
|
||||||
|
* @param[in] sz - Size of the topicdata stored in value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_topicdata
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_reads_bytes_opt_(sz) const void * __restrict value,
|
||||||
|
_In_ size_t sz
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the groupdata of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the groupdata
|
||||||
|
* @param[in] value - Pointer to the group data
|
||||||
|
* @param[in] sz - Size of groupdata stored in value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_groupdata
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_reads_bytes_opt_(sz) const void * __restrict value,
|
||||||
|
_In_ size_t sz
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the durability policy of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] kind - Durability kind value \ref DCPS_QoS_Durability
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_durability
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_DURABILITY_VOLATILE, DDS_DURABILITY_PERSISTENT) dds_durability_kind_t kind
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the history policy of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] kind - History kind value \ref DCPS_QoS_History
|
||||||
|
* @param[in] depth - History depth value \ref DCPS_QoS_History
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_history
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_HISTORY_KEEP_LAST, DDS_HISTORY_KEEP_ALL) dds_history_kind_t kind,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t depth
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the resource limits policy of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] max_samples - Number of samples resource-limit value
|
||||||
|
* @param[in] max_instances - Number of instances resource-limit value
|
||||||
|
* @param[in] max_samples_per_instance - Number of samples per instance resource-limit value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_resource_limits
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_samples,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_instances,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_samples_per_instance
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the presentation policy of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] access_scope - Access-scope kind
|
||||||
|
* @param[in] coherent_access - Coherent access enable value
|
||||||
|
* @param[in] ordered_access - Ordered access enable value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_qset_presentation
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_PRESENTATION_INSTANCE, DDS_PRESENTATION_GROUP) dds_presentation_access_scope_kind_t access_scope,
|
||||||
|
_In_ bool coherent_access,
|
||||||
|
_In_ bool ordered_access
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the lifespan policy of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] lifespan - Lifespan duration (expiration time relative to source timestamp of a sample)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_lifespan
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t lifespan
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the deadline policy of a qos structure.
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] deadline - Deadline duration
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_deadline
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t deadline
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the latency-budget policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] duration - Latency budget duration
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_latency_budget
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t duration
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ownership policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] kind - Ownership kind
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_ownership
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_OWNERSHIP_SHARED, DDS_OWNERSHIP_EXCLUSIVE) dds_ownership_kind_t kind
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ownership strength policy of a qos structure
|
||||||
|
*
|
||||||
|
* param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* param[in] value - Ownership strength value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_ownership_strength
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_ int32_t value
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the liveliness policy of a qos structure
|
||||||
|
*
|
||||||
|
* param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* param[in] kind - Liveliness kind
|
||||||
|
* param[in[ lease_duration - Lease duration
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_liveliness
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_LIVELINESS_AUTOMATIC, DDS_LIVELINESS_MANUAL_BY_TOPIC) dds_liveliness_kind_t kind,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t lease_duration
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the time-based filter policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] minimum_separation - Minimum duration between sample delivery for an instance
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_time_based_filter
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t minimum_separation
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the partition policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] n - Number of partitions stored in ps
|
||||||
|
* @param[in[ ps - Pointer to string(s) storing partition name(s)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_partition
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_ uint32_t n,
|
||||||
|
_In_count_(n) _Deref_pre_z_ const char ** __restrict ps
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the reliability policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] kind - Reliability kind
|
||||||
|
* @param[in] max_blocking_time - Max blocking duration applied when kind is reliable.
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_reliability
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_RELIABILITY_BEST_EFFORT, DDS_RELIABILITY_RELIABLE) dds_reliability_kind_t kind,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t max_blocking_time
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the transport-priority policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] value - Priority value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_transport_priority
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_ int32_t value
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the destination-order policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] kind - Destination-order kind
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_destination_order
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP,
|
||||||
|
DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP) dds_destination_order_kind_t kind
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the writer data-lifecycle policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] autodispose_unregistered_instances - Automatic disposal of unregistered instances
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_writer_data_lifecycle
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_ bool autodispose
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the reader data-lifecycle policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] autopurge_nowriter_samples_delay - Delay for purging of samples from instances in a no-writers state
|
||||||
|
* @param[in] autopurge_disposed_samples_delay - Delay for purging of samples from disposed instances
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_reader_data_lifecycle
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t autopurge_nowriter_samples_delay,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t autopurge_disposed_samples_delay
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the durability-service policy of a qos structure
|
||||||
|
*
|
||||||
|
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||||
|
* @param[in] service_cleanup_delay - Delay for purging of abandoned instances from the durability service
|
||||||
|
* @param[in] history_kind - History policy kind applied by the durability service
|
||||||
|
* @param[in] history_depth - History policy depth applied by the durability service
|
||||||
|
* @param[in] max_samples - Number of samples resource-limit policy applied by the durability service
|
||||||
|
* @param[in] max_instances - Number of instances resource-limit policy applied by the durability service
|
||||||
|
* @param[in] max_samples_per_instance - Number of samples per instance resource-limit policy applied by the durability service
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qset_durability_service
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t service_cleanup_delay,
|
||||||
|
_In_range_(DDS_HISTORY_KEEP_LAST, DDS_HISTORY_KEEP_ALL) dds_history_kind_t history_kind,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t history_depth,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_samples,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_instances,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_samples_per_instance
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the userdata from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] value - Pointer that will store the userdata
|
||||||
|
* @param[in,out] sz - Pointer that will store the size of userdata
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_userdata
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Outptr_result_bytebuffer_maybenull_(*sz) void ** value,
|
||||||
|
_Out_ size_t * sz
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the topicdata from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] value - Pointer that will store the topicdata
|
||||||
|
* @param[in,out] sz - Pointer that will store the size of topicdata
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_topicdata
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Outptr_result_bytebuffer_maybenull_(*sz) void ** value,
|
||||||
|
_Out_ size_t * sz
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the groupdata from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] value - Pointer that will store the groupdata
|
||||||
|
* @param[in,out] sz - Pointer that will store the size of groupdata
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_groupdata
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Outptr_result_bytebuffer_maybenull_(*sz) void ** value,
|
||||||
|
_Out_ size_t * sz
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the durability policy from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] kind - Pointer that will store the durability kind
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_durability
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_durability_kind_t *kind
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the history policy from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] kind - Pointer that will store the history kind (optional)
|
||||||
|
* @param[in,out] depth - Pointer that will store the history depth (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_history
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_history_kind_t * kind,
|
||||||
|
_Out_opt_ int32_t *depth
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the resource-limits policy from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] max_samples - Pointer that will store the number of samples resource-limit (optional)
|
||||||
|
* @param[in,out] max_instances - Pointer that will store the number of instances resource-limit (optional)
|
||||||
|
* @param[in,out] max_samples_per_instance - Pointer that will store the number of samples per instance resource-limit (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_resource_limits
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ int32_t *max_samples,
|
||||||
|
_Out_opt_ int32_t *max_instances,
|
||||||
|
_Out_opt_ int32_t *max_samples_per_instance
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the presentation policy from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] access_scope - Pointer that will store access scope kind (optional)
|
||||||
|
* @param[in,out] coherent_access - Pointer that will store coherent access enable value (optional)
|
||||||
|
* @param[in,out] ordered_access - Pointer that will store orderede access enable value (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_presentation
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_presentation_access_scope_kind_t *access_scope,
|
||||||
|
_Out_opt_ bool *coherent_access,
|
||||||
|
_Out_opt_ bool *ordered_access
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the lifespan policy from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] lifespan - Pointer that will store lifespan duration
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_lifespan
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_duration_t * lifespan
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the deadline policy from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] deadline - Pointer that will store deadline duration
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_deadline
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_duration_t * deadline
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the latency-budget policy from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] duration - Pointer that will store latency-budget duration
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_latency_budget
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_duration_t *duration
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ownership policy from a qos structure
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] kind - Pointer that will store the ownership kind
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_ownership
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_ownership_kind_t *kind
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ownership strength qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] value - Pointer that will store the ownership strength value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_ownership_strength
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ int32_t *value
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the liveliness qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] kind - Pointer that will store the liveliness kind (optional)
|
||||||
|
* @param[in,out] lease_duration - Pointer that will store the liveliness lease duration (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_liveliness
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_liveliness_kind_t *kind,
|
||||||
|
_Out_opt_ dds_duration_t *lease_duration
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the time-based filter qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] minimum_separation - Pointer that will store the minimum separation duration (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_time_based_filter
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_duration_t *minimum_separation
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the partition qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] n - Pointer that will store the number of partitions (optional)
|
||||||
|
* @param[in,out] ps - Pointer that will store the string(s) containing partition name(s) (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_partition
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ uint32_t *n,
|
||||||
|
_Outptr_opt_result_buffer_all_maybenull_(*n) char *** ps
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the reliability qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] kind - Pointer that will store the reliability kind (optional)
|
||||||
|
* @param[in,out] max_blocking_time - Pointer that will store the max blocking time for reliable reliability (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_reliability
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_reliability_kind_t *kind,
|
||||||
|
_Out_opt_ dds_duration_t *max_blocking_time
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the transport priority qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] value - Pointer that will store the transport priority value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_transport_priority
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ int32_t *value
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the destination-order qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] kind - Pointer that will store the destination-order kind
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_destination_order
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_destination_order_kind_t *kind
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the writer data-lifecycle qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] autodispose_unregistered_instances - Pointer that will store the autodispose unregistered instances enable value
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_writer_data_lifecycle
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ bool * autodispose
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the reader data-lifecycle qos policy
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] autopurge_nowriter_samples_delay - Pointer that will store the delay for auto-purging samples from instances in a no-writer state (optional)
|
||||||
|
* @param[in,out] autopurge_disposed_samples_delay - Pointer that will store the delay for auto-purging of disposed instances (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT
|
||||||
|
void dds_qget_reader_data_lifecycle
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_duration_t *autopurge_nowriter_samples_delay,
|
||||||
|
_Out_opt_ dds_duration_t *autopurge_disposed_samples_delay
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the durability-service qos policy values.
|
||||||
|
*
|
||||||
|
* @param[in] qos - Pointer to a dds_qos_t structure storing the policy
|
||||||
|
* @param[in,out] service_cleanup_delay - Pointer that will store the delay for purging of abandoned instances from the durability service (optional)
|
||||||
|
* @param[in,out] history_kind - Pointer that will store history policy kind applied by the durability service (optional)
|
||||||
|
* @param[in,out] history_depth - Pointer that will store history policy depth applied by the durability service (optional)
|
||||||
|
* @param[in,out] max_samples - Pointer that will store number of samples resource-limit policy applied by the durability service (optional)
|
||||||
|
* @param[in,out] max_instances - Pointer that will store number of instances resource-limit policy applied by the durability service (optional)
|
||||||
|
* @param[in,out] max_samples_per_instance - Pointer that will store number of samples per instance resource-limit policy applied by the durability service (optional)
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_qget_durability_service
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * qos,
|
||||||
|
_Out_opt_ dds_duration_t * service_cleanup_delay,
|
||||||
|
_Out_opt_ dds_history_kind_t * history_kind,
|
||||||
|
_Out_opt_ int32_t * history_depth,
|
||||||
|
_Out_opt_ int32_t * max_samples,
|
||||||
|
_Out_opt_ int32_t * max_instances,
|
||||||
|
_Out_opt_ int32_t * max_samples_per_instance
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
491
src/core/ddsc/include/ddsc/dds_public_status.h
Normal file
491
src/core/ddsc/include/ddsc/dds_public_status.h
Normal file
|
|
@ -0,0 +1,491 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C Communication Status API
|
||||||
|
*
|
||||||
|
* This header file defines the public API of the Communication Status in the
|
||||||
|
* CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef DDS_STATUS_H
|
||||||
|
#define DDS_STATUS_H
|
||||||
|
|
||||||
|
#include "os/os_public.h"
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Listeners implemented as structs containing callback functions
|
||||||
|
that take listener status types as arguments.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Listener status types */
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_OfferedDeadlineMissed
|
||||||
|
*/
|
||||||
|
typedef struct dds_offered_deadline_missed_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
dds_instance_handle_t last_instance_handle;
|
||||||
|
}
|
||||||
|
dds_offered_deadline_missed_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_OfferedIncompatibleQoS
|
||||||
|
*/
|
||||||
|
typedef struct dds_offered_incompatible_qos_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
uint32_t last_policy_id;
|
||||||
|
}
|
||||||
|
dds_offered_incompatible_qos_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_PublicationMatched
|
||||||
|
*/
|
||||||
|
typedef struct dds_publication_matched_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
uint32_t current_count;
|
||||||
|
int32_t current_count_change;
|
||||||
|
dds_instance_handle_t last_subscription_handle;
|
||||||
|
}
|
||||||
|
dds_publication_matched_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_LivelinessLost
|
||||||
|
*/
|
||||||
|
typedef struct dds_liveliness_lost_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
}
|
||||||
|
dds_liveliness_lost_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_SubscriptionMatched
|
||||||
|
*/
|
||||||
|
typedef struct dds_subscription_matched_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
uint32_t current_count;
|
||||||
|
int32_t current_count_change;
|
||||||
|
dds_instance_handle_t last_publication_handle;
|
||||||
|
}
|
||||||
|
dds_subscription_matched_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dds_sample_rejected_status_kind
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
DDS_NOT_REJECTED,
|
||||||
|
DDS_REJECTED_BY_INSTANCES_LIMIT,
|
||||||
|
DDS_REJECTED_BY_SAMPLES_LIMIT,
|
||||||
|
DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT
|
||||||
|
}
|
||||||
|
dds_sample_rejected_status_kind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_SampleRejected
|
||||||
|
*/
|
||||||
|
typedef struct dds_sample_rejected_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
dds_sample_rejected_status_kind last_reason;
|
||||||
|
dds_instance_handle_t last_instance_handle;
|
||||||
|
}
|
||||||
|
dds_sample_rejected_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_LivelinessChanged
|
||||||
|
*/
|
||||||
|
typedef struct dds_liveliness_changed_status
|
||||||
|
{
|
||||||
|
uint32_t alive_count;
|
||||||
|
uint32_t not_alive_count;
|
||||||
|
int32_t alive_count_change;
|
||||||
|
int32_t not_alive_count_change;
|
||||||
|
dds_instance_handle_t last_publication_handle;
|
||||||
|
}
|
||||||
|
dds_liveliness_changed_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_RequestedDeadlineMissed
|
||||||
|
*/
|
||||||
|
typedef struct dds_requested_deadline_missed_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
dds_instance_handle_t last_instance_handle;
|
||||||
|
}
|
||||||
|
dds_requested_deadline_missed_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_RequestedIncompatibleQoS
|
||||||
|
*/
|
||||||
|
typedef struct dds_requested_incompatible_qos_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
uint32_t last_policy_id;
|
||||||
|
}
|
||||||
|
dds_requested_incompatible_qos_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_SampleLost
|
||||||
|
*/
|
||||||
|
typedef struct dds_sample_lost_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
}
|
||||||
|
dds_sample_lost_status_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ref DCPS_Status_InconsistentTopic
|
||||||
|
*/
|
||||||
|
typedef struct dds_inconsistent_topic_status
|
||||||
|
{
|
||||||
|
uint32_t total_count;
|
||||||
|
int32_t total_count_change;
|
||||||
|
}
|
||||||
|
dds_inconsistent_topic_status_t;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
get_<status> APIs return the status of an entity and resets the status
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get INCONSISTENT_TOPIC status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to INCONSISTENT_TOPIC
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] topic The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_InconsistentTopic to get the status
|
||||||
|
*
|
||||||
|
* @returns 0 - Success
|
||||||
|
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_((topic & DDS_ENTITY_KIND_MASK) == DDS_KIND_TOPIC)
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_inconsistent_topic_status (
|
||||||
|
_In_ dds_entity_t topic,
|
||||||
|
_Out_opt_ dds_inconsistent_topic_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get PUBLICATION_MATCHED status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to PUBLICATION_MATCHED
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] writer The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_PublicationMatched to get the status
|
||||||
|
*
|
||||||
|
* @returns 0 - Success
|
||||||
|
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_(((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER))
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_publication_matched_status (
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_Out_opt_ dds_publication_matched_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get LIVELINESS_LOST status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to LIVELINESS_LOST
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] writer The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_LivelinessLost to get the status
|
||||||
|
*
|
||||||
|
* @returns 0 - Success
|
||||||
|
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_(((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER))
|
||||||
|
DDS_EXPORT dds_return_t dds_get_liveliness_lost_status (
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_Out_opt_ dds_liveliness_lost_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get OFFERED_DEADLINE_MISSED status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to OFFERED_DEADLINE_MISSED
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] writer The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_OfferedDeadlineMissed to get the status
|
||||||
|
*
|
||||||
|
* @returns 0 - Success
|
||||||
|
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_(((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER))
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_offered_deadline_missed_status(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_Out_opt_ dds_offered_deadline_missed_status_t *status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get OFFERED_INCOMPATIBLE_QOS status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to OFFERED_INCOMPATIBLE_QOS
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] writer The writer entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_OfferedIncompatibleQoS to get the status
|
||||||
|
*
|
||||||
|
* @returns 0 - Success
|
||||||
|
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_(((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER))
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_offered_incompatible_qos_status (
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_Out_opt_ dds_offered_incompatible_qos_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get SUBSCRIPTION_MATCHED status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to SUBSCRIPTION_MATCHED
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] reader The reader entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_SubscriptionMatched to get the status
|
||||||
|
*
|
||||||
|
* @returns 0 - Success
|
||||||
|
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_subscription_matched_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_subscription_matched_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get LIVELINESS_CHANGED status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to LIVELINESS_CHANGED
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] reader The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_LivelinessChanged to get the status
|
||||||
|
*
|
||||||
|
* @returns 0 - Success
|
||||||
|
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_liveliness_changed_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_liveliness_changed_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get SAMPLE_REJECTED status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to SAMPLE_REJECTED
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] reader The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_SampleRejected to get the status
|
||||||
|
*
|
||||||
|
* @returns 0 - Success
|
||||||
|
* @returns <0 - Failure (use dds_err_nr() to get error value).
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_sample_rejected_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_sample_rejected_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get SAMPLE_LOST status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to SAMPLE_LOST
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] reader The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_SampleLost to get the status
|
||||||
|
*
|
||||||
|
* @returns A dds_return_t indicating success or failure
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_OK
|
||||||
|
* Success
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_sample_lost_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_sample_lost_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get REQUESTED_DEADLINE_MISSED status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to REQUESTED_DEADLINE_MISSED
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] reader The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_RequestedDeadlineMissed to get the status
|
||||||
|
*
|
||||||
|
* @returns A dds_return_t indicating success or failure
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_OK
|
||||||
|
* Success
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_requested_deadline_missed_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_requested_deadline_missed_status_t * status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get REQUESTED_INCOMPATIBLE_QOS status
|
||||||
|
*
|
||||||
|
* This operation gets the status value corresponding to REQUESTED_INCOMPATIBLE_QOS
|
||||||
|
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||||
|
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||||
|
*
|
||||||
|
* @param[in] reader The entity to get the status
|
||||||
|
* @param[out] status The pointer to \ref DCPS_Status_RequestedIncompatibleQoS to get the status
|
||||||
|
*
|
||||||
|
* @returns A dds_return_t indicating success or failure
|
||||||
|
*
|
||||||
|
* @retval DDS_RETCODE_OK
|
||||||
|
* Success
|
||||||
|
* @retval DDS_RETCODE_ERROR
|
||||||
|
* An internal error has occurred.
|
||||||
|
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||||
|
* One of the given arguments is not valid.
|
||||||
|
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||||
|
* The operation is invoked on an inappropriate object.
|
||||||
|
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||||
|
* The entity has already been deleted.
|
||||||
|
*/
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_get_requested_incompatible_qos_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_requested_incompatible_qos_status_t * status);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
101
src/core/ddsc/include/ddsc/dds_public_stream.h
Normal file
101
src/core/ddsc/include/ddsc/dds_public_stream.h
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C Stream API
|
||||||
|
*
|
||||||
|
* This header file defines the public API of the Streams in the
|
||||||
|
* CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef DDS_STREAM_H
|
||||||
|
#define DDS_STREAM_H
|
||||||
|
|
||||||
|
#include "os/os_public.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct dds_sequence;
|
||||||
|
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
uint8_t * p8;
|
||||||
|
uint16_t * p16;
|
||||||
|
uint32_t * p32;
|
||||||
|
uint64_t * p64;
|
||||||
|
float * pf;
|
||||||
|
double * pd;
|
||||||
|
void * pv;
|
||||||
|
}
|
||||||
|
dds_uptr_t;
|
||||||
|
|
||||||
|
typedef struct dds_stream
|
||||||
|
{
|
||||||
|
dds_uptr_t m_buffer; /* Union of pointers to start of buffer */
|
||||||
|
size_t m_size; /* Buffer size */
|
||||||
|
size_t m_index; /* Read/write offset from start of buffer */
|
||||||
|
bool m_endian; /* Endian: big (false) or little (true) */
|
||||||
|
bool m_failed; /* Attempt made to read beyond end of buffer */
|
||||||
|
}
|
||||||
|
dds_stream_t;
|
||||||
|
|
||||||
|
#define DDS_STREAM_BE false
|
||||||
|
#define DDS_STREAM_LE true
|
||||||
|
|
||||||
|
DDS_EXPORT dds_stream_t * dds_stream_create (size_t size);
|
||||||
|
DDS_EXPORT void dds_stream_delete (dds_stream_t * st);
|
||||||
|
DDS_EXPORT void dds_stream_fini (dds_stream_t * st);
|
||||||
|
DDS_EXPORT void dds_stream_reset (dds_stream_t * st);
|
||||||
|
DDS_EXPORT void dds_stream_init (dds_stream_t * st, size_t size);
|
||||||
|
DDS_EXPORT void dds_stream_grow (dds_stream_t * st, size_t size);
|
||||||
|
DDS_EXPORT bool dds_stream_endian (void);
|
||||||
|
|
||||||
|
DDS_EXPORT bool dds_stream_read_bool (dds_stream_t * is);
|
||||||
|
DDS_EXPORT uint8_t dds_stream_read_uint8 (dds_stream_t * is);
|
||||||
|
DDS_EXPORT uint16_t dds_stream_read_uint16 (dds_stream_t * is);
|
||||||
|
DDS_EXPORT uint32_t dds_stream_read_uint32 (dds_stream_t * is);
|
||||||
|
DDS_EXPORT uint64_t dds_stream_read_uint64 (dds_stream_t * is);
|
||||||
|
DDS_EXPORT float dds_stream_read_float (dds_stream_t * is);
|
||||||
|
DDS_EXPORT double dds_stream_read_double (dds_stream_t * is);
|
||||||
|
DDS_EXPORT char * dds_stream_read_string (dds_stream_t * is);
|
||||||
|
DDS_EXPORT void dds_stream_read_buffer (dds_stream_t * is, uint8_t * buffer, uint32_t len);
|
||||||
|
|
||||||
|
#define dds_stream_read_char(s) ((char) dds_stream_read_uint8 (s))
|
||||||
|
#define dds_stream_read_int8(s) ((int8_t) dds_stream_read_uint8 (s))
|
||||||
|
#define dds_stream_read_int16(s) ((int16_t) dds_stream_read_uint16 (s))
|
||||||
|
#define dds_stream_read_int32(s) ((int32_t) dds_stream_read_uint32 (s))
|
||||||
|
#define dds_stream_read_int64(s) ((int64_t) dds_stream_read_uint64 (s))
|
||||||
|
|
||||||
|
DDS_EXPORT void dds_stream_write_bool (dds_stream_t * os, bool val);
|
||||||
|
DDS_EXPORT void dds_stream_write_uint8 (dds_stream_t * os, uint8_t val);
|
||||||
|
DDS_EXPORT void dds_stream_write_uint16 (dds_stream_t * os, uint16_t val);
|
||||||
|
DDS_EXPORT void dds_stream_write_uint32 (dds_stream_t * os, uint32_t val);
|
||||||
|
DDS_EXPORT void dds_stream_write_uint64 (dds_stream_t * os, uint64_t val);
|
||||||
|
DDS_EXPORT void dds_stream_write_float (dds_stream_t * os, float val);
|
||||||
|
DDS_EXPORT void dds_stream_write_double (dds_stream_t * os, double val);
|
||||||
|
DDS_EXPORT void dds_stream_write_string (dds_stream_t * os, const char * val);
|
||||||
|
DDS_EXPORT void dds_stream_write_buffer (dds_stream_t * os, uint32_t len, uint8_t * buffer);
|
||||||
|
|
||||||
|
#define dds_stream_write_char(s,v) (dds_stream_write_uint8 ((s), (uint8_t)(v)))
|
||||||
|
#define dds_stream_write_int8(s,v) (dds_stream_write_uint8 ((s), (uint8_t)(v)))
|
||||||
|
#define dds_stream_write_int16(s,v) (dds_stream_write_uint16 ((s), (uint16_t)(v)))
|
||||||
|
#define dds_stream_write_int32(s,v) (dds_stream_write_uint32 ((s), (uint32_t)(v)))
|
||||||
|
#define dds_stream_write_int64(s,v) (dds_stream_write_uint64 ((s), (uint64_t)(v)))
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
96
src/core/ddsc/include/ddsc/dds_public_time.h
Normal file
96
src/core/ddsc/include/ddsc/dds_public_time.h
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* @brief DDS C Time support API
|
||||||
|
*
|
||||||
|
* This header file defines the public API of the in the
|
||||||
|
* CycloneDDS C language binding.
|
||||||
|
*/
|
||||||
|
#ifndef DDS_TIME_H
|
||||||
|
#define DDS_TIME_H
|
||||||
|
|
||||||
|
#include "os/os_public.h"
|
||||||
|
#include "ddsc/dds_export.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Times are represented using a 64-bit signed integer, encoding
|
||||||
|
nanoseconds since the epoch. Considering the nature of these
|
||||||
|
systems, one would best use TAI, International Atomic Time, rather
|
||||||
|
than something UTC, but availability may be limited.
|
||||||
|
|
||||||
|
Valid times are non-negative and times up to 2**63-2 can be
|
||||||
|
represented. 2**63-1 is defined to represent, essentially, "never".
|
||||||
|
This is good enough for a couple of centuries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Absolute Time definition */
|
||||||
|
typedef int64_t dds_time_t;
|
||||||
|
|
||||||
|
/** Relative Time definition */
|
||||||
|
typedef int64_t dds_duration_t;
|
||||||
|
|
||||||
|
/** @name Macro definition for time units in nanoseconds.
|
||||||
|
@{**/
|
||||||
|
#define DDS_NSECS_IN_SEC 1000000000LL
|
||||||
|
#define DDS_NSECS_IN_MSEC 1000000LL
|
||||||
|
#define DDS_NSECS_IN_USEC 1000LL
|
||||||
|
/** @}*/
|
||||||
|
|
||||||
|
/** @name Infinite timeout for indicate absolute time */
|
||||||
|
#define DDS_NEVER ((dds_time_t) INT64_MAX)
|
||||||
|
|
||||||
|
/** @name Infinite timeout for relative time */
|
||||||
|
#define DDS_INFINITY ((dds_duration_t) INT64_MAX)
|
||||||
|
|
||||||
|
/** @name Macro definition for time conversion from nanoseconds
|
||||||
|
@{**/
|
||||||
|
#define DDS_SECS(n) ((n) * DDS_NSECS_IN_SEC)
|
||||||
|
#define DDS_MSECS(n) ((n) * DDS_NSECS_IN_MSEC)
|
||||||
|
#define DDS_USECS(n) ((n) * DDS_NSECS_IN_USEC)
|
||||||
|
/** @}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description : This operation returns the current time (in nanoseconds)
|
||||||
|
*
|
||||||
|
* Arguments :
|
||||||
|
* -# Returns current time
|
||||||
|
*/
|
||||||
|
DDS_EXPORT dds_time_t dds_time (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description : This operation blocks the calling thread until the relative time
|
||||||
|
* n has elapsed
|
||||||
|
*
|
||||||
|
* Arguments :
|
||||||
|
* -# n Relative Time to block a thread
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_sleepfor (dds_duration_t n);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description : This operation blocks the calling thread until the absolute time
|
||||||
|
* n has elapsed
|
||||||
|
*
|
||||||
|
* Arguments :
|
||||||
|
* -# n absolute Time to block a thread
|
||||||
|
*/
|
||||||
|
DDS_EXPORT void dds_sleepuntil (dds_time_t n);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
2927
src/core/ddsc/include/ddsc/ddsv2.h
Normal file
2927
src/core/ddsc/include/ddsc/ddsv2.h
Normal file
File diff suppressed because it is too large
Load diff
26
src/core/ddsc/src/dds__alloc.h
Normal file
26
src/core/ddsc/src/dds__alloc.h
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_ALLOC_H_
|
||||||
|
#define _DDS_ALLOC_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void dds_sample_free_contents (char * data, const uint32_t * ops);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
72
src/core/ddsc/src/dds__builtin.h
Normal file
72
src/core/ddsc/src/dds__builtin.h
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_BUILTIN_H_
|
||||||
|
#define _DDS_BUILTIN_H_
|
||||||
|
|
||||||
|
#include "ddsi/q_time.h"
|
||||||
|
#include "dds_builtinTopics.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Get actual topic in related participant related to topic 'id'. */
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_topic(
|
||||||
|
_In_ dds_entity_t e,
|
||||||
|
_In_ dds_entity_t topic);
|
||||||
|
|
||||||
|
/* Global publisher singleton (publishes only locally). */
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_publisher(
|
||||||
|
void);
|
||||||
|
|
||||||
|
/* Subscriber singleton within related participant. */
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_subscriber(
|
||||||
|
_In_ dds_entity_t e);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialization and finalize functions. */
|
||||||
|
void
|
||||||
|
dds__builtin_init(
|
||||||
|
void);
|
||||||
|
|
||||||
|
void
|
||||||
|
dds__builtin_fini(
|
||||||
|
void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Callback functions that contain received builtin data. */
|
||||||
|
void
|
||||||
|
dds__builtin_participant_cb(
|
||||||
|
DDS_ParticipantBuiltinTopicData *data,
|
||||||
|
nn_wctime_t timestamp);
|
||||||
|
|
||||||
|
void
|
||||||
|
dds__builtin_cmparticipant_cb(
|
||||||
|
DDS_CMParticipantBuiltinTopicData *data,
|
||||||
|
nn_wctime_t timestamp);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _DDS_BUILTIN_H_ */
|
||||||
|
|
||||||
30
src/core/ddsc/src/dds__domain.h
Normal file
30
src/core/ddsc/src/dds__domain.h
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_DOMAIN_H_
|
||||||
|
#define _DDS_DOMAIN_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern const ut_avlTreedef_t dds_domaintree_def;
|
||||||
|
|
||||||
|
extern dds_domain * dds_domain_create (dds_domainid_t id);
|
||||||
|
extern void dds_domain_free (dds_domain * domain);
|
||||||
|
extern dds_domain * dds_domain_find_locked (dds_domainid_t id);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
114
src/core/ddsc/src/dds__entity.h
Normal file
114
src/core/ddsc/src/dds__entity.h
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_ENTITY_H_
|
||||||
|
#define _DDS_ENTITY_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
#include "ddsi/q_thread.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_Check_return_ dds_entity_t
|
||||||
|
dds_entity_init(
|
||||||
|
_In_ dds_entity * e,
|
||||||
|
_When_(kind != DDS_KIND_PARTICIPANT, _Notnull_)
|
||||||
|
_When_(kind == DDS_KIND_PARTICIPANT, _Null_)
|
||||||
|
_In_opt_ dds_entity * parent,
|
||||||
|
_In_ dds_entity_kind_t kind,
|
||||||
|
_In_opt_ dds_qos_t * qos,
|
||||||
|
_In_opt_ const dds_listener_t *listener,
|
||||||
|
_In_ uint32_t mask);
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_entity_add_ref(
|
||||||
|
_In_ dds_entity *e);
|
||||||
|
void
|
||||||
|
dds_entity_add_ref_nolock(
|
||||||
|
_In_ dds_entity *e);
|
||||||
|
|
||||||
|
_Check_return_ dds__retcode_t
|
||||||
|
dds_entity_listener_propagation(
|
||||||
|
_Inout_opt_ dds_entity *e,
|
||||||
|
_In_ dds_entity *src,
|
||||||
|
_In_ uint32_t status,
|
||||||
|
_In_opt_ void *metrics,
|
||||||
|
_In_ bool propagate);
|
||||||
|
|
||||||
|
#define dds_entity_is_enabled(e, k) (((dds_entity*)e)->m_flags & DDS_ENTITY_ENABLED)
|
||||||
|
|
||||||
|
#define dds_entity_status_set(e, t) (((dds_entity*)e)->m_trigger |= (((dds_entity*)e)->m_status_enable & t))
|
||||||
|
#define dds_entity_status_reset(e,t) (((dds_entity*)e)->m_trigger &= ~t)
|
||||||
|
#define dds_entity_status_match(e,t) (((dds_entity*)e)->m_trigger & t)
|
||||||
|
|
||||||
|
/* The mutex needs to be unlocked when calling this because the entity can be called
|
||||||
|
* within the signal callback from other contexts. That shouldn't deadlock. */
|
||||||
|
void
|
||||||
|
dds_entity_status_signal(
|
||||||
|
_In_ dds_entity *e);
|
||||||
|
|
||||||
|
_Check_return_ dds__retcode_t
|
||||||
|
dds_valid_hdl(
|
||||||
|
_In_ dds_entity_t hdl,
|
||||||
|
_In_ dds_entity_kind_t kind);
|
||||||
|
|
||||||
|
_Acquires_exclusive_lock_(*e)
|
||||||
|
_Check_return_ dds__retcode_t
|
||||||
|
dds_entity_lock(
|
||||||
|
_In_ dds_entity_t hdl,
|
||||||
|
_In_ dds_entity_kind_t kind,
|
||||||
|
_Out_ dds_entity **e);
|
||||||
|
|
||||||
|
_Releases_exclusive_lock_(e)
|
||||||
|
void
|
||||||
|
dds_entity_unlock(
|
||||||
|
_Inout_ dds_entity *e);
|
||||||
|
|
||||||
|
#define dds_entity_kind(hdl) ((hdl > 0) ? (hdl & DDS_ENTITY_KIND_MASK) : 0)
|
||||||
|
|
||||||
|
_Check_return_ dds__retcode_t
|
||||||
|
dds_entity_observer_register_nl(
|
||||||
|
_In_ dds_entity* observed,
|
||||||
|
_In_ dds_entity_t observer,
|
||||||
|
_In_ dds_entity_callback cb);
|
||||||
|
|
||||||
|
_Check_return_ dds__retcode_t
|
||||||
|
dds_entity_observer_register(
|
||||||
|
_In_ dds_entity_t observed,
|
||||||
|
_In_ dds_entity_t observer,
|
||||||
|
_In_ dds_entity_callback cb);
|
||||||
|
|
||||||
|
dds__retcode_t
|
||||||
|
dds_entity_observer_unregister_nl(
|
||||||
|
_In_ dds_entity* observed,
|
||||||
|
_In_ dds_entity_t observer);
|
||||||
|
|
||||||
|
dds__retcode_t
|
||||||
|
dds_entity_observer_unregister(
|
||||||
|
_In_ dds_entity_t observed,
|
||||||
|
_In_ dds_entity_t observer);
|
||||||
|
|
||||||
|
_Pre_satisfies_(entity & DDS_ENTITY_KIND_MASK)
|
||||||
|
dds_return_t
|
||||||
|
dds_delete_impl(
|
||||||
|
_In_ dds_entity_t entity,
|
||||||
|
_In_ bool keep_if_explicit);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
dds__entity_kind_str(
|
||||||
|
_In_ dds_entity_t e);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
41
src/core/ddsc/src/dds__err.h
Normal file
41
src/core/ddsc/src/dds__err.h
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_ERR_H_
|
||||||
|
#define _DDS_ERR_H_
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include "os/os.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* To construct return status
|
||||||
|
* Use '+' instead of '|'. Otherwise, the SAL checking doesn't
|
||||||
|
* understand when a return value is negative or positive and
|
||||||
|
* complains a lot about "A successful path through the function
|
||||||
|
* does not set the named _Out_ parameter." */
|
||||||
|
#if !defined(__FILE_ID__)
|
||||||
|
#error "__FILE_ID__ not defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DDS__FILE_ID__ (((__FILE_ID__ & 0x1ff)) << 22)
|
||||||
|
#define DDS__LINE__ ((__LINE__ & 0x3fff) << 8)
|
||||||
|
|
||||||
|
#define DDS_ERR_NO(err) -(DDS__FILE_ID__ + DDS__LINE__ + (err))
|
||||||
|
|
||||||
|
#define DDS_ERRNO(e,msg,...) (assert(e > DDS_RETCODE_OK), os_report(OS_REPORT_ERROR, OS_FUNCTION, __FILE__, __LINE__, DDS_ERR_NO(e), (msg), ##__VA_ARGS__), DDS_ERR_NO(e))
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
28
src/core/ddsc/src/dds__iid.h
Normal file
28
src/core/ddsc/src/dds__iid.h
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_IID_H_
|
||||||
|
#define _DDS_IID_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void dds_iid_init (void);
|
||||||
|
void dds_iid_fini (void);
|
||||||
|
uint64_t dds_iid_gen (void);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
78
src/core/ddsc/src/dds__init.h
Normal file
78
src/core/ddsc/src/dds__init.h
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_INIT_H_
|
||||||
|
#define _DDS_INIT_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds__check_domain(
|
||||||
|
_In_ dds_domainid_t domain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Description : Initialization function. This operation initializes all the
|
||||||
|
*required resources that are needed for the DDSC API process lifecycle
|
||||||
|
*(like the init mutex and os layer).
|
||||||
|
*A function will be registered that is called at the end of the process
|
||||||
|
*lifecycle and will destroy the resources initialized in this function.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
dds__startup(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Description : Initialization function, called from main. This operation
|
||||||
|
*initializes all the required DDS resources,
|
||||||
|
*handles configuration of domainid based on the input passed, parses and
|
||||||
|
*configures middleware from a xml file and initializes required resources.
|
||||||
|
*
|
||||||
|
*Arguments :
|
||||||
|
*-# Returns 0 on success or a non-zero error status
|
||||||
|
**/
|
||||||
|
dds_return_t
|
||||||
|
dds_init(void);
|
||||||
|
|
||||||
|
/* Finalization function, called from main */
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Description : Finalization function, called from main. This operation
|
||||||
|
*releases all the resources used by DDS.
|
||||||
|
*
|
||||||
|
*Arguments :
|
||||||
|
*-# None
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
dds_fini(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description : Function that provides the explicit ID of default domain
|
||||||
|
* It should be called after DDS initialization.
|
||||||
|
* @return Valid domain id. Undetermined behaviour if DDS is not initialized.
|
||||||
|
*/
|
||||||
|
dds_domainid_t dds_domain_default (void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description : Mutex used for initialization synchronization.
|
||||||
|
*/
|
||||||
|
extern os_mutex dds__init_mutex;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
35
src/core/ddsc/src/dds__key.h
Normal file
35
src/core/ddsc/src/dds__key.h
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_KEY_H_
|
||||||
|
#define _DDS_KEY_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
|
||||||
|
struct dds_key_hash;
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void dds_key_md5 (struct dds_key_hash * kh);
|
||||||
|
|
||||||
|
void dds_key_gen
|
||||||
|
(
|
||||||
|
const dds_topic_descriptor_t * const desc,
|
||||||
|
struct dds_key_hash * kh,
|
||||||
|
const char * sample
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
31
src/core/ddsc/src/dds__listener.h
Normal file
31
src/core/ddsc/src/dds__listener.h
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_LISTENER_H_
|
||||||
|
#define _DDS_LISTENER_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
#include "ddsc/dds_public_listener.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Listener API (internal & external) are present in
|
||||||
|
* dds__types.h
|
||||||
|
* ddsc/dds_public_listener.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
23
src/core/ddsc/src/dds__participant.h
Normal file
23
src/core/ddsc/src/dds__participant.h
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_PPANT_H_
|
||||||
|
#define _DDS_PPANT_H_
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
27
src/core/ddsc/src/dds__publisher.h
Normal file
27
src/core/ddsc/src/dds__publisher.h
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_PUBLISHER_H_
|
||||||
|
#define _DDS_PUBLISHER_H_
|
||||||
|
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dds_return_t dds_publisher_begin_coherent (dds_entity_t e);
|
||||||
|
dds_return_t dds_publisher_end_coherent (dds_entity_t e);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* _DDS_PUBLISHER_H_ */
|
||||||
37
src/core/ddsc/src/dds__qos.h
Normal file
37
src/core/ddsc/src/dds__qos.h
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_QOS_H_
|
||||||
|
#define _DDS_QOS_H_
|
||||||
|
|
||||||
|
#include "dds__entity.h"
|
||||||
|
#include "ddsi/q_xqos.h"
|
||||||
|
#include "ddsi/q_time.h"
|
||||||
|
#include "ddsi/q_plist.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool validate_deadline_and_timebased_filter (const nn_duration_t deadline, const nn_duration_t minimum_separation);
|
||||||
|
bool validate_entityfactory_qospolicy (const nn_entity_factory_qospolicy_t * entityfactory);
|
||||||
|
bool validate_octetseq (const nn_octetseq_t* seq);
|
||||||
|
bool validate_partition_qospolicy (_In_ const nn_partition_qospolicy_t * partition);
|
||||||
|
bool validate_reliability_qospolicy (const nn_reliability_qospolicy_t * reliability);
|
||||||
|
bool validate_stringseq (const nn_stringseq_t* seq);
|
||||||
|
|
||||||
|
bool dds_qos_validate_common (const dds_qos_t *qos);
|
||||||
|
dds_return_t dds_qos_validate_mutable_common (_In_ const dds_qos_t *qos);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
23
src/core/ddsc/src/dds__querycond.h
Normal file
23
src/core/ddsc/src/dds__querycond.h
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_QUERYCOND_H_
|
||||||
|
#define _DDS_QUERYCOND_H_
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
23
src/core/ddsc/src/dds__readcond.h
Normal file
23
src/core/ddsc/src/dds__readcond.h
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_READCOND_H_
|
||||||
|
#define _DDS_READCOND_H_
|
||||||
|
|
||||||
|
#include "dds__entity.h"
|
||||||
|
|
||||||
|
_Must_inspect_result_ dds_readcond*
|
||||||
|
dds_create_readcond(
|
||||||
|
_In_ dds_reader *rd,
|
||||||
|
_In_ dds_entity_kind_t kind,
|
||||||
|
_In_ uint32_t mask);
|
||||||
|
|
||||||
|
#endif
|
||||||
49
src/core/ddsc/src/dds__reader.h
Normal file
49
src/core/ddsc/src/dds__reader.h
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_READER_H_
|
||||||
|
#define _DDS_READER_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct status_cb_data;
|
||||||
|
|
||||||
|
void dds_reader_status_cb (void * entity, const struct status_cb_data * data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
dds_reader_lock_samples: Returns number of samples in read cache and locks the
|
||||||
|
reader cache to make sure that the samples content doesn't change.
|
||||||
|
Because the cache is locked, you should be able to read/take without having to
|
||||||
|
lock first. This is done by passing the DDS_READ_WITHOUT_LOCK value to the
|
||||||
|
read/take call as maxs. Then the read/take will not lock but still unlock.
|
||||||
|
|
||||||
|
See also CHAM-287, CHAM-306 and LITE-1183.
|
||||||
|
|
||||||
|
Used to support LENGTH_UNLIMITED in C++.
|
||||||
|
*/
|
||||||
|
#define DDS_READ_WITHOUT_LOCK (0xFFFFFFED)
|
||||||
|
DDS_EXPORT uint32_t dds_reader_lock_samples (dds_entity_t entity);
|
||||||
|
|
||||||
|
struct nn_rsample_info;
|
||||||
|
struct nn_rdata;
|
||||||
|
DDS_EXPORT void dds_reader_ddsi2direct (dds_entity_t entity, void (*cb) (const struct nn_rsample_info *sampleinfo, const struct nn_rdata *fragchain, void *arg), void *cbarg);
|
||||||
|
|
||||||
|
#define dds_reader_lock(hdl, obj) dds_entity_lock(hdl, DDS_KIND_READER, (dds_entity**)obj)
|
||||||
|
#define dds_reader_unlock(obj) dds_entity_unlock((dds_entity*)obj);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
78
src/core/ddsc/src/dds__report.h
Normal file
78
src/core/ddsc/src/dds__report.h
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef DDS_REPORT_H
|
||||||
|
#define DDS_REPORT_H
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "os/os_report.h"
|
||||||
|
|
||||||
|
#define DDS_REPORT_STACK() \
|
||||||
|
os_report_stack ()
|
||||||
|
|
||||||
|
#define DDS_CRITICAL(...) \
|
||||||
|
dds_report ( \
|
||||||
|
OS_REPORT_CRITICAL, \
|
||||||
|
__FILE__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_FUNCTION, \
|
||||||
|
DDS_RETCODE_ERROR, \
|
||||||
|
__VA_ARGS__)
|
||||||
|
|
||||||
|
#define DDS_ERROR(code,...) \
|
||||||
|
dds_report ( \
|
||||||
|
OS_REPORT_ERROR, \
|
||||||
|
__FILE__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_FUNCTION, \
|
||||||
|
(code), \
|
||||||
|
__VA_ARGS__)
|
||||||
|
|
||||||
|
#define DDS_INFO(...) \
|
||||||
|
dds_report ( \
|
||||||
|
OS_REPORT_INFO, \
|
||||||
|
__FILE__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_FUNCTION, \
|
||||||
|
DDS_RETCODE_OK, \
|
||||||
|
__VA_ARGS__)
|
||||||
|
|
||||||
|
#define DDS_WARNING(code,...) \
|
||||||
|
dds_report ( \
|
||||||
|
OS_REPORT_WARNING, \
|
||||||
|
__FILE__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_FUNCTION, \
|
||||||
|
(code), \
|
||||||
|
__VA_ARGS__)
|
||||||
|
|
||||||
|
#define DDS_REPORT(type, code,...) \
|
||||||
|
dds_report ( \
|
||||||
|
type, \
|
||||||
|
__FILE__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_FUNCTION, \
|
||||||
|
(code), \
|
||||||
|
__VA_ARGS__)
|
||||||
|
|
||||||
|
#define DDS_REPORT_FLUSH OS_REPORT_FLUSH
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_report(
|
||||||
|
os_reportType reportType,
|
||||||
|
const char *file,
|
||||||
|
int32_t line,
|
||||||
|
const char *function,
|
||||||
|
dds_return_t code,
|
||||||
|
const char *format,
|
||||||
|
...);
|
||||||
|
|
||||||
|
#endif
|
||||||
86
src/core/ddsc/src/dds__rhc.h
Normal file
86
src/core/ddsc/src/dds__rhc.h
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_RHC_H_
|
||||||
|
#define _DDS_RHC_H_
|
||||||
|
|
||||||
|
#include "os/os_defs.h"
|
||||||
|
|
||||||
|
#define NO_STATE_MASK_SET (DDS_ANY_STATE + 1)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct rhc;
|
||||||
|
struct nn_xqos;
|
||||||
|
struct serdata;
|
||||||
|
struct tkmap_instance;
|
||||||
|
struct tkmap;
|
||||||
|
struct nn_rsample_info;
|
||||||
|
struct proxy_writer_info;
|
||||||
|
|
||||||
|
struct rhc * dds_rhc_new (dds_reader * reader, const struct sertopic * topic);
|
||||||
|
void dds_rhc_free (struct rhc * rhc);
|
||||||
|
void dds_rhc_fini (struct rhc * rhc);
|
||||||
|
|
||||||
|
uint32_t dds_rhc_lock_samples (struct rhc * rhc);
|
||||||
|
|
||||||
|
DDS_EXPORT bool dds_rhc_store
|
||||||
|
(
|
||||||
|
struct rhc * __restrict rhc, const struct nn_rsample_info * __restrict sampleinfo,
|
||||||
|
struct serdata * __restrict sample, struct tkmap_instance * __restrict tk
|
||||||
|
);
|
||||||
|
void dds_rhc_unregister_wr (struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info);
|
||||||
|
void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t wr_iid);
|
||||||
|
|
||||||
|
int
|
||||||
|
dds_rhc_read(
|
||||||
|
struct rhc *rhc,
|
||||||
|
bool lock,
|
||||||
|
void ** values,
|
||||||
|
dds_sample_info_t *info_seq,
|
||||||
|
uint32_t max_samples,
|
||||||
|
uint32_t mask,
|
||||||
|
dds_instance_handle_t handle,
|
||||||
|
dds_readcond *cond);
|
||||||
|
int
|
||||||
|
dds_rhc_take(
|
||||||
|
struct rhc *rhc,
|
||||||
|
bool lock,
|
||||||
|
void ** values,
|
||||||
|
dds_sample_info_t *info_seq,
|
||||||
|
uint32_t max_samples,
|
||||||
|
uint32_t mask,
|
||||||
|
dds_instance_handle_t handle,
|
||||||
|
dds_readcond *cond);
|
||||||
|
|
||||||
|
void dds_rhc_set_qos (struct rhc * rhc, const struct nn_xqos * qos);
|
||||||
|
|
||||||
|
void dds_rhc_add_readcondition (dds_readcond * cond);
|
||||||
|
void dds_rhc_remove_readcondition (dds_readcond * cond);
|
||||||
|
|
||||||
|
bool dds_rhc_add_waitset (dds_readcond * cond, dds_waitset * waitset, dds_attach_t x);
|
||||||
|
int dds_rhc_remove_waitset (dds_readcond * cond, dds_waitset * waitset);
|
||||||
|
|
||||||
|
int dds_rhc_takecdr
|
||||||
|
(
|
||||||
|
struct rhc *rhc, bool lock, struct serdata **values, dds_sample_info_t *info_seq,
|
||||||
|
uint32_t max_samples, unsigned sample_states,
|
||||||
|
unsigned view_states, unsigned instance_states,
|
||||||
|
dds_instance_handle_t handle
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
88
src/core/ddsc/src/dds__stream.h
Normal file
88
src/core/ddsc/src/dds__stream.h
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_STREAM_H_
|
||||||
|
#define _DDS_STREAM_H_
|
||||||
|
|
||||||
|
#include "ddsi/ddsi_ser.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void dds_stream_write_sample
|
||||||
|
(
|
||||||
|
dds_stream_t * os,
|
||||||
|
const void * data,
|
||||||
|
const struct sertopic * topic
|
||||||
|
);
|
||||||
|
void dds_stream_read_sample
|
||||||
|
(
|
||||||
|
dds_stream_t * is,
|
||||||
|
void * data,
|
||||||
|
const struct sertopic * topic
|
||||||
|
);
|
||||||
|
|
||||||
|
size_t dds_stream_check_optimize (_In_ const dds_topic_descriptor_t * desc);
|
||||||
|
void dds_stream_from_serstate (_Out_ dds_stream_t * s, _In_ const serstate_t st);
|
||||||
|
void dds_stream_add_to_serstate (_Inout_ dds_stream_t * s, _Inout_ serstate_t st);
|
||||||
|
|
||||||
|
void dds_stream_write_key
|
||||||
|
(
|
||||||
|
dds_stream_t * os,
|
||||||
|
const char * sample,
|
||||||
|
const dds_topic_descriptor_t * desc
|
||||||
|
);
|
||||||
|
void dds_stream_read_key
|
||||||
|
(
|
||||||
|
dds_stream_t * is,
|
||||||
|
char * sample,
|
||||||
|
const dds_topic_descriptor_t * desc
|
||||||
|
);
|
||||||
|
void dds_stream_read_keyhash
|
||||||
|
(
|
||||||
|
dds_stream_t * is,
|
||||||
|
dds_key_hash_t * kh,
|
||||||
|
const dds_topic_descriptor_t * desc,
|
||||||
|
const bool just_key
|
||||||
|
);
|
||||||
|
char * dds_stream_reuse_string
|
||||||
|
(
|
||||||
|
dds_stream_t * is,
|
||||||
|
char * str,
|
||||||
|
const uint32_t bound
|
||||||
|
);
|
||||||
|
DDS_EXPORT void dds_stream_swap (void * buff, uint32_t size, uint32_t num);
|
||||||
|
|
||||||
|
extern const uint32_t dds_op_size[5];
|
||||||
|
|
||||||
|
/* For marshalling op code handling */
|
||||||
|
|
||||||
|
#define DDS_OP_MASK 0xff000000
|
||||||
|
#define DDS_OP_TYPE_MASK 0x00ff0000
|
||||||
|
#define DDS_OP_SUBTYPE_MASK 0x0000ff00
|
||||||
|
#define DDS_OP_JMP_MASK 0x0000ffff
|
||||||
|
#define DDS_OP_FLAGS_MASK 0x000000ff
|
||||||
|
#define DDS_JEQ_TYPE_MASK 0x00ff0000
|
||||||
|
|
||||||
|
#define DDS_OP(o) ((o) & DDS_OP_MASK)
|
||||||
|
#define DDS_OP_TYPE(o) (((o) & DDS_OP_TYPE_MASK) >> 16)
|
||||||
|
#define DDS_OP_SUBTYPE(o) (((o) & DDS_OP_SUBTYPE_MASK) >> 8)
|
||||||
|
#define DDS_OP_FLAGS(o) ((o) & DDS_OP_FLAGS_MASK)
|
||||||
|
#define DDS_OP_ADR_JSR(o) ((o) & DDS_OP_JMP_MASK)
|
||||||
|
#define DDS_OP_JUMP(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
|
||||||
|
#define DDS_OP_ADR_JMP(o) ((o) >> 16)
|
||||||
|
#define DDS_JEQ_TYPE(o) (((o) & DDS_JEQ_TYPE_MASK) >> 16)
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
41
src/core/ddsc/src/dds__subscriber.h
Normal file
41
src/core/ddsc/src/dds__subscriber.h
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_SUBSCRIBER_H_
|
||||||
|
#define _DDS_SUBSCRIBER_H_
|
||||||
|
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct dds_entity;
|
||||||
|
|
||||||
|
_Requires_exclusive_lock_held_(participant)
|
||||||
|
_Check_return_ dds_entity_t
|
||||||
|
dds__create_subscriber_l(
|
||||||
|
_Inout_ struct dds_entity *participant, /* entity-lock must be held */
|
||||||
|
_In_opt_ const dds_qos_t *qos,
|
||||||
|
_In_opt_ const dds_listener_t *listener);
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds_subscriber_begin_coherent(
|
||||||
|
_In_ dds_entity_t e);
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds_subscriber_end_coherent (
|
||||||
|
_In_ dds_entity_t e);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* _DDS_SUBSCRIBER_H_ */
|
||||||
53
src/core/ddsc/src/dds__tkmap.h
Normal file
53
src/core/ddsc/src/dds__tkmap.h
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_TKMAP_H_
|
||||||
|
#define _DDS_TKMAP_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
#include "os/os_atomics.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct tkmap;
|
||||||
|
struct serdata;
|
||||||
|
struct dds_topic;
|
||||||
|
|
||||||
|
struct tkmap_instance
|
||||||
|
{
|
||||||
|
struct serdata * m_sample;
|
||||||
|
struct tkmap * m_map;
|
||||||
|
uint64_t m_iid;
|
||||||
|
os_atomic_uint32_t m_refc;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct tkmap * dds_tkmap_new (void);
|
||||||
|
void dds_tkmap_free (_Inout_ _Post_invalid_ struct tkmap *tkmap);
|
||||||
|
void dds_tkmap_instance_ref (_In_ struct tkmap_instance *tk);
|
||||||
|
uint64_t dds_tkmap_lookup (_In_ struct tkmap *tkmap, _In_ const struct serdata *serdata);
|
||||||
|
_Check_return_ bool dds_tkmap_get_key (_In_ struct tkmap * map, _In_ uint64_t iid, _Out_ void * sample);
|
||||||
|
_Check_return_ struct tkmap_instance * dds_tkmap_find(
|
||||||
|
_In_opt_ const struct dds_topic * topic,
|
||||||
|
_In_ struct serdata * sd,
|
||||||
|
_In_ const bool rd,
|
||||||
|
_In_ const bool create);
|
||||||
|
_Check_return_ struct tkmap_instance * dds_tkmap_find_by_id (_In_ struct tkmap * map, _In_ uint64_t iid);
|
||||||
|
|
||||||
|
DDS_EXPORT _Check_return_ struct tkmap_instance * dds_tkmap_lookup_instance_ref (_In_ struct serdata * sd);
|
||||||
|
DDS_EXPORT void dds_tkmap_instance_unref (_In_ struct tkmap_instance * tk);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
41
src/core/ddsc/src/dds__topic.h
Normal file
41
src/core/ddsc/src/dds__topic.h
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_TOPIC_H_
|
||||||
|
#define _DDS_TOPIC_H_
|
||||||
|
|
||||||
|
#include "dds__types.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define dds_topic_lock(hdl, obj) dds_entity_lock(hdl, DDS_KIND_TOPIC, (dds_entity**)obj)
|
||||||
|
#define dds_topic_unlock(obj) dds_entity_unlock((dds_entity*)obj);
|
||||||
|
|
||||||
|
extern struct sertopic * dds_topic_lookup (dds_domain * domain, const char * name);
|
||||||
|
extern void dds_topic_free (dds_domainid_t domainid, struct sertopic * st);
|
||||||
|
|
||||||
|
#ifndef DDS_TOPIC_INTERN_FILTER_FN_DEFINED
|
||||||
|
#define DDS_TOPIC_INTERN_FILTER_FN_DEFINED
|
||||||
|
typedef bool (*dds_topic_intern_filter_fn) (const void * sample, void *ctx);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DDS_EXPORT void dds_topic_set_filter_with_ctx
|
||||||
|
(dds_entity_t topic, dds_topic_intern_filter_fn filter, void *ctx);
|
||||||
|
|
||||||
|
DDS_EXPORT dds_topic_intern_filter_fn dds_topic_get_filter_with_ctx
|
||||||
|
(dds_entity_t topic);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
273
src/core/ddsc/src/dds__types.h
Normal file
273
src/core/ddsc/src/dds__types.h
Normal file
|
|
@ -0,0 +1,273 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_TYPES_H_
|
||||||
|
#define _DDS_TYPES_H_
|
||||||
|
|
||||||
|
/* DDS internal type definitions */
|
||||||
|
|
||||||
|
#include "os/os.h"
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
#include "ddsi/q_rtps.h"
|
||||||
|
#include "util/ut_avl.h"
|
||||||
|
#include "util/ut_handleserver.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef _Return_type_success_(return == DDS_RETCODE_OK) int32_t dds__retcode_t;
|
||||||
|
|
||||||
|
struct dds_domain;
|
||||||
|
struct dds_entity;
|
||||||
|
struct dds_participant;
|
||||||
|
struct dds_reader;
|
||||||
|
struct dds_writer;
|
||||||
|
struct dds_publisher;
|
||||||
|
struct dds_subscriber;
|
||||||
|
struct dds_topic;
|
||||||
|
struct dds_readcond;
|
||||||
|
struct dds_guardcond;
|
||||||
|
|
||||||
|
struct sertopic;
|
||||||
|
struct rhc;
|
||||||
|
|
||||||
|
/* Internal entity status flags */
|
||||||
|
|
||||||
|
#define DDS_INTERNAL_STATUS_MASK (0xFF000000)
|
||||||
|
|
||||||
|
#define DDS_WAITSET_TRIGGER_STATUS (0x01000000)
|
||||||
|
#define DDS_DELETING_STATUS (0x02000000)
|
||||||
|
|
||||||
|
/* This can be used when polling for various states.
|
||||||
|
* Obviously, it is encouraged to use condition variables and such. But
|
||||||
|
* sometimes it wouldn't make that much of a difference and taking the
|
||||||
|
* easy route is somewhat pragmatic. */
|
||||||
|
#define DDS_HEADBANG_TIMEOUT_MS (10)
|
||||||
|
|
||||||
|
typedef bool (*dds_querycondition_filter_with_ctx_fn) (const void * sample, const void *ctx);
|
||||||
|
|
||||||
|
|
||||||
|
/* The listener struct. */
|
||||||
|
|
||||||
|
typedef struct c_listener {
|
||||||
|
dds_on_inconsistent_topic_fn on_inconsistent_topic;
|
||||||
|
dds_on_liveliness_lost_fn on_liveliness_lost;
|
||||||
|
dds_on_offered_deadline_missed_fn on_offered_deadline_missed;
|
||||||
|
dds_on_offered_incompatible_qos_fn on_offered_incompatible_qos;
|
||||||
|
dds_on_data_on_readers_fn on_data_on_readers;
|
||||||
|
dds_on_sample_lost_fn on_sample_lost;
|
||||||
|
dds_on_data_available_fn on_data_available;
|
||||||
|
dds_on_sample_rejected_fn on_sample_rejected;
|
||||||
|
dds_on_liveliness_changed_fn on_liveliness_changed;
|
||||||
|
dds_on_requested_deadline_missed_fn on_requested_deadline_missed;
|
||||||
|
dds_on_requested_incompatible_qos_fn on_requested_incompatible_qos;
|
||||||
|
dds_on_publication_matched_fn on_publication_matched;
|
||||||
|
dds_on_subscription_matched_fn on_subscription_matched;
|
||||||
|
void *arg;
|
||||||
|
} c_listener_t;
|
||||||
|
|
||||||
|
/* Entity flag values */
|
||||||
|
|
||||||
|
#define DDS_ENTITY_ENABLED 0x0001
|
||||||
|
#define DDS_ENTITY_IMPLICIT 0x0002
|
||||||
|
|
||||||
|
typedef struct dds_domain
|
||||||
|
{
|
||||||
|
ut_avlNode_t m_node;
|
||||||
|
dds_domainid_t m_id;
|
||||||
|
ut_avlTree_t m_topics;
|
||||||
|
uint32_t m_refc;
|
||||||
|
}
|
||||||
|
dds_domain;
|
||||||
|
|
||||||
|
struct dds_entity;
|
||||||
|
typedef struct dds_entity_deriver {
|
||||||
|
/* Close can be used to terminate (blocking) actions on a entity before actually deleting it. */
|
||||||
|
dds_return_t (*close)(struct dds_entity *e);
|
||||||
|
/* Delete is used to actually free the entity. */
|
||||||
|
dds_return_t (*delete)(struct dds_entity *e);
|
||||||
|
dds_return_t (*set_qos)(struct dds_entity *e, const dds_qos_t *qos, bool enabled);
|
||||||
|
dds_return_t (*validate_status)(uint32_t mask);
|
||||||
|
dds_return_t (*propagate_status)(struct dds_entity *e, uint32_t mask, bool set);
|
||||||
|
dds_return_t (*get_instance_hdl)(struct dds_entity *e, dds_instance_handle_t *i);
|
||||||
|
}
|
||||||
|
dds_entity_deriver;
|
||||||
|
|
||||||
|
typedef void (*dds_entity_callback)(dds_entity_t observer, dds_entity_t observed, uint32_t status);
|
||||||
|
|
||||||
|
typedef struct dds_entity_observer
|
||||||
|
{
|
||||||
|
dds_entity_callback m_cb;
|
||||||
|
dds_entity_t m_observer;
|
||||||
|
struct dds_entity_observer *m_next;
|
||||||
|
}
|
||||||
|
dds_entity_observer;
|
||||||
|
|
||||||
|
typedef struct dds_entity
|
||||||
|
{
|
||||||
|
ut_handle_t m_hdl;
|
||||||
|
dds_entity_deriver m_deriver;
|
||||||
|
uint32_t m_refc;
|
||||||
|
struct dds_entity * m_next;
|
||||||
|
struct dds_entity * m_parent;
|
||||||
|
struct dds_entity * m_children;
|
||||||
|
struct dds_entity * m_participant;
|
||||||
|
struct dds_domain * m_domain;
|
||||||
|
dds_qos_t * m_qos;
|
||||||
|
dds_domainid_t m_domainid;
|
||||||
|
nn_guid_t m_guid;
|
||||||
|
uint32_t m_status_enable;
|
||||||
|
uint32_t m_flags;
|
||||||
|
uint32_t m_cb_count;
|
||||||
|
os_mutex m_mutex;
|
||||||
|
os_cond m_cond;
|
||||||
|
c_listener_t m_listener;
|
||||||
|
uint32_t m_trigger;
|
||||||
|
dds_entity_observer *m_observers;
|
||||||
|
struct ut_handlelink *m_hdllink;
|
||||||
|
}
|
||||||
|
dds_entity;
|
||||||
|
|
||||||
|
extern const ut_avlTreedef_t dds_topictree_def;
|
||||||
|
|
||||||
|
typedef struct dds_subscriber
|
||||||
|
{
|
||||||
|
struct dds_entity m_entity;
|
||||||
|
}
|
||||||
|
dds_subscriber;
|
||||||
|
|
||||||
|
typedef struct dds_publisher
|
||||||
|
{
|
||||||
|
struct dds_entity m_entity;
|
||||||
|
}
|
||||||
|
dds_publisher;
|
||||||
|
|
||||||
|
typedef struct dds_participant
|
||||||
|
{
|
||||||
|
struct dds_entity m_entity;
|
||||||
|
struct dds_entity * m_dur_reader;
|
||||||
|
struct dds_entity * m_dur_writer;
|
||||||
|
dds_entity_t m_builtin_subscriber;
|
||||||
|
}
|
||||||
|
dds_participant;
|
||||||
|
|
||||||
|
typedef struct dds_reader
|
||||||
|
{
|
||||||
|
struct dds_entity m_entity;
|
||||||
|
const struct dds_topic * m_topic;
|
||||||
|
struct reader * m_rd;
|
||||||
|
bool m_data_on_readers;
|
||||||
|
bool m_loan_out;
|
||||||
|
char * m_loan;
|
||||||
|
uint32_t m_loan_size;
|
||||||
|
|
||||||
|
/* Status metrics */
|
||||||
|
|
||||||
|
dds_sample_rejected_status_t m_sample_rejected_status;
|
||||||
|
dds_liveliness_changed_status_t m_liveliness_changed_status;
|
||||||
|
dds_requested_deadline_missed_status_t m_requested_deadline_missed_status;
|
||||||
|
dds_requested_incompatible_qos_status_t m_requested_incompatible_qos_status;
|
||||||
|
dds_sample_lost_status_t m_sample_lost_status;
|
||||||
|
dds_subscription_matched_status_t m_subscription_matched_status;
|
||||||
|
}
|
||||||
|
dds_reader;
|
||||||
|
|
||||||
|
typedef struct dds_writer
|
||||||
|
{
|
||||||
|
struct dds_entity m_entity;
|
||||||
|
const struct dds_topic * m_topic;
|
||||||
|
struct nn_xpack * m_xp;
|
||||||
|
struct writer * m_wr;
|
||||||
|
os_mutex m_call_lock;
|
||||||
|
|
||||||
|
/* Status metrics */
|
||||||
|
|
||||||
|
dds_liveliness_lost_status_t m_liveliness_lost_status;
|
||||||
|
dds_offered_deadline_missed_status_t m_offered_deadline_missed_status;
|
||||||
|
dds_offered_incompatible_qos_status_t m_offered_incompatible_qos_status;
|
||||||
|
dds_publication_matched_status_t m_publication_matched_status;
|
||||||
|
}
|
||||||
|
dds_writer;
|
||||||
|
|
||||||
|
typedef struct dds_topic
|
||||||
|
{
|
||||||
|
struct dds_entity m_entity;
|
||||||
|
struct sertopic * m_stopic;
|
||||||
|
const dds_topic_descriptor_t * m_descriptor;
|
||||||
|
|
||||||
|
/* Status metrics */
|
||||||
|
|
||||||
|
dds_inconsistent_topic_status_t m_inconsistent_topic_status;
|
||||||
|
}
|
||||||
|
dds_topic;
|
||||||
|
|
||||||
|
typedef struct dds_readcond
|
||||||
|
{
|
||||||
|
dds_entity m_entity;
|
||||||
|
struct rhc * m_rhc;
|
||||||
|
uint32_t m_qminv;
|
||||||
|
uint32_t m_sample_states;
|
||||||
|
uint32_t m_view_states;
|
||||||
|
uint32_t m_instance_states;
|
||||||
|
nn_guid_t m_rd_guid;
|
||||||
|
struct dds_readcond * m_rhc_next;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
dds_querycondition_filter_fn m_filter;
|
||||||
|
} m_query;
|
||||||
|
}
|
||||||
|
dds_readcond;
|
||||||
|
|
||||||
|
typedef struct dds_attachment
|
||||||
|
{
|
||||||
|
dds_entity *entity;
|
||||||
|
dds_attach_t arg;
|
||||||
|
struct dds_attachment* next;
|
||||||
|
}
|
||||||
|
dds_attachment;
|
||||||
|
|
||||||
|
typedef struct dds_waitset
|
||||||
|
{
|
||||||
|
dds_entity m_entity;
|
||||||
|
dds_attachment *observed;
|
||||||
|
dds_attachment *triggered;
|
||||||
|
}
|
||||||
|
dds_waitset;
|
||||||
|
|
||||||
|
typedef struct dds_iid
|
||||||
|
{
|
||||||
|
uint64_t counter;
|
||||||
|
uint32_t key[4];
|
||||||
|
}
|
||||||
|
dds_iid;
|
||||||
|
|
||||||
|
/* Globals */
|
||||||
|
|
||||||
|
typedef struct dds_globals
|
||||||
|
{
|
||||||
|
dds_domainid_t m_default_domain;
|
||||||
|
int32_t m_init_count;
|
||||||
|
void (*m_dur_reader) (struct dds_reader * reader, struct rhc * rhc);
|
||||||
|
int (*m_dur_wait) (struct dds_reader * reader, dds_duration_t timeout);
|
||||||
|
void (*m_dur_init) (void);
|
||||||
|
void (*m_dur_fini) (void);
|
||||||
|
ut_avlTree_t m_domains;
|
||||||
|
os_mutex m_mutex;
|
||||||
|
}
|
||||||
|
dds_globals;
|
||||||
|
|
||||||
|
DDS_EXPORT extern dds_globals dds_global;
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
51
src/core/ddsc/src/dds__write.h
Normal file
51
src/core/ddsc/src/dds__write.h
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_WRITE_H_
|
||||||
|
#define _DDS_WRITE_H_
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DDS_WR_KEY_BIT 0x01
|
||||||
|
#define DDS_WR_DISPOSE_BIT 0x02
|
||||||
|
#define DDS_WR_UNREGISTER_BIT 0x04
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
DDS_WR_ACTION_WRITE = 0,
|
||||||
|
DDS_WR_ACTION_WRITE_DISPOSE = DDS_WR_DISPOSE_BIT,
|
||||||
|
DDS_WR_ACTION_DISPOSE = DDS_WR_KEY_BIT | DDS_WR_DISPOSE_BIT,
|
||||||
|
DDS_WR_ACTION_UNREGISTER = DDS_WR_KEY_BIT | DDS_WR_UNREGISTER_BIT
|
||||||
|
}
|
||||||
|
dds_write_action;
|
||||||
|
|
||||||
|
int
|
||||||
|
dds_write_impl(
|
||||||
|
_In_ dds_writer *wr,
|
||||||
|
_In_ const void *data,
|
||||||
|
_In_ dds_time_t tstamp,
|
||||||
|
_In_ dds_write_action action);
|
||||||
|
|
||||||
|
int
|
||||||
|
dds_writecdr_impl(
|
||||||
|
_In_ dds_writer *wr,
|
||||||
|
_In_ const void *cdr,
|
||||||
|
_In_ size_t sz,
|
||||||
|
_In_ dds_time_t tstamp,
|
||||||
|
_In_ dds_write_action action);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
27
src/core/ddsc/src/dds__writer.h
Normal file
27
src/core/ddsc/src/dds__writer.h
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef _DDS_WRITER_H_
|
||||||
|
#define _DDS_WRITER_H_
|
||||||
|
|
||||||
|
#include "dds__entity.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define dds_writer_lock(hdl, obj) dds_entity_lock(hdl, DDS_KIND_WRITER, (dds_entity**)obj)
|
||||||
|
#define dds_writer_unlock(obj) dds_entity_unlock((dds_entity*)obj);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
371
src/core/ddsc/src/dds_alloc.c
Normal file
371
src/core/ddsc/src/dds_alloc.c
Normal file
|
|
@ -0,0 +1,371 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "dds__alloc.h"
|
||||||
|
#include "dds__stream.h"
|
||||||
|
#include "os/os_heap.h"
|
||||||
|
#include "ddsi/q_config.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define OP_DEBUG_FREE 1
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined OP_DEBUG_FREE
|
||||||
|
static const char * stream_op_type[11] =
|
||||||
|
{
|
||||||
|
NULL, "1Byte", "2Byte", "4Byte", "8Byte", "String",
|
||||||
|
"BString", "Sequence", "Array", "Union", "Struct"
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static dds_allocator_t dds_allocator_fns = { os_malloc, os_realloc, os_free };
|
||||||
|
|
||||||
|
void * dds_alloc (size_t size)
|
||||||
|
{
|
||||||
|
void * ret = (dds_allocator_fns.malloc) (size);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
memset (ret, 0, size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DDS_FAIL ("dds_alloc");
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void * dds_realloc (void * ptr, size_t size)
|
||||||
|
{
|
||||||
|
void * ret = (dds_allocator_fns.realloc) (ptr, size);
|
||||||
|
if (ret == NULL) DDS_FAIL ("dds_realloc");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void * dds_realloc_zero (void * ptr, size_t size)
|
||||||
|
{
|
||||||
|
void * ret = dds_realloc (ptr, size);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
memset (ret, 0, size);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_free (void * ptr)
|
||||||
|
{
|
||||||
|
if (ptr) (dds_allocator_fns.free) (ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
char * dds_string_alloc (size_t size)
|
||||||
|
{
|
||||||
|
return (char*) dds_alloc (size + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
char * dds_string_dup (const char * str)
|
||||||
|
{
|
||||||
|
char * ret = NULL;
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
ret = dds_alloc (strlen (str) + 1);
|
||||||
|
strcpy (ret, str);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_string_free (char * str)
|
||||||
|
{
|
||||||
|
dds_free (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_sample_free_contents (char * data, const uint32_t * ops)
|
||||||
|
{
|
||||||
|
uint32_t op;
|
||||||
|
uint32_t type;
|
||||||
|
uint32_t num;
|
||||||
|
uint32_t subtype;
|
||||||
|
char * addr;
|
||||||
|
|
||||||
|
while ((op = *ops) != DDS_OP_RTS)
|
||||||
|
{
|
||||||
|
switch (DDS_OP_MASK & op)
|
||||||
|
{
|
||||||
|
case DDS_OP_ADR:
|
||||||
|
{
|
||||||
|
type = DDS_OP_TYPE (op);
|
||||||
|
#ifdef OP_DEBUG_FREE
|
||||||
|
TRACE (("F-ADR: %s offset %d\n", stream_op_type[type], ops[1]));
|
||||||
|
#endif
|
||||||
|
addr = data + ops[1];
|
||||||
|
ops += 2;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DDS_OP_VAL_1BY:
|
||||||
|
case DDS_OP_VAL_2BY:
|
||||||
|
case DDS_OP_VAL_4BY:
|
||||||
|
case DDS_OP_VAL_8BY:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_STR:
|
||||||
|
{
|
||||||
|
#ifdef OP_DEBUG_FREE
|
||||||
|
TRACE (("F-STR: @ %p %s\n", addr, *((char**) addr)));
|
||||||
|
#endif
|
||||||
|
dds_free (*((char**) addr));
|
||||||
|
*((char**) addr) = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_SEQ:
|
||||||
|
{
|
||||||
|
dds_sequence_t * seq = (dds_sequence_t*) addr;
|
||||||
|
subtype = DDS_OP_SUBTYPE (op);
|
||||||
|
num = (seq->_maximum > seq->_length) ? seq->_maximum : seq->_length;
|
||||||
|
|
||||||
|
#ifdef OP_DEBUG_FREE
|
||||||
|
TRACE (("F-SEQ: of %s\n", stream_op_type[subtype]));
|
||||||
|
#endif
|
||||||
|
if ((seq->_release && num) || (subtype > DDS_OP_VAL_STR))
|
||||||
|
{
|
||||||
|
switch (subtype)
|
||||||
|
{
|
||||||
|
case DDS_OP_VAL_1BY:
|
||||||
|
case DDS_OP_VAL_2BY:
|
||||||
|
case DDS_OP_VAL_4BY:
|
||||||
|
case DDS_OP_VAL_8BY:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_BST:
|
||||||
|
{
|
||||||
|
ops++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_STR:
|
||||||
|
{
|
||||||
|
char ** ptr = (char**) seq->_buffer;
|
||||||
|
while (num--)
|
||||||
|
{
|
||||||
|
dds_free (*ptr++);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
const uint32_t elem_size = *ops++;
|
||||||
|
const uint32_t * jsr_ops = ops + DDS_OP_ADR_JSR (*ops) - 3;
|
||||||
|
const uint32_t jmp = DDS_OP_ADR_JMP (*ops);
|
||||||
|
char * ptr = (char*) seq->_buffer;
|
||||||
|
|
||||||
|
while (num--)
|
||||||
|
{
|
||||||
|
dds_sample_free_contents (ptr, jsr_ops);
|
||||||
|
ptr += elem_size;
|
||||||
|
}
|
||||||
|
ops += jmp ? (jmp - 3) : 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (seq->_release)
|
||||||
|
{
|
||||||
|
dds_free (seq->_buffer);
|
||||||
|
seq->_buffer = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_ARR:
|
||||||
|
{
|
||||||
|
subtype = DDS_OP_SUBTYPE (op);
|
||||||
|
num = *ops++;
|
||||||
|
|
||||||
|
#ifdef OP_DEBUG_FREE
|
||||||
|
TRACE (("F-ARR: of %s size %d\n", stream_op_type[subtype], num));
|
||||||
|
#endif
|
||||||
|
switch (subtype)
|
||||||
|
{
|
||||||
|
case DDS_OP_VAL_1BY:
|
||||||
|
case DDS_OP_VAL_2BY:
|
||||||
|
case DDS_OP_VAL_4BY:
|
||||||
|
case DDS_OP_VAL_8BY:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_STR:
|
||||||
|
{
|
||||||
|
char ** ptr = (char**) addr;
|
||||||
|
while (num--)
|
||||||
|
{
|
||||||
|
dds_free (*ptr++);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_BST:
|
||||||
|
{
|
||||||
|
ops += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
const uint32_t * jsr_ops = ops + DDS_OP_ADR_JSR (*ops) - 3;
|
||||||
|
const uint32_t jmp = DDS_OP_ADR_JMP (*ops);
|
||||||
|
const uint32_t elem_size = ops[1];
|
||||||
|
|
||||||
|
while (num--)
|
||||||
|
{
|
||||||
|
dds_sample_free_contents (addr, jsr_ops);
|
||||||
|
addr += elem_size;
|
||||||
|
}
|
||||||
|
ops += jmp ? (jmp - 3) : 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_UNI:
|
||||||
|
{
|
||||||
|
const bool has_default = op & DDS_OP_FLAG_DEF;
|
||||||
|
subtype = DDS_OP_SUBTYPE (op);
|
||||||
|
num = ops[0];
|
||||||
|
const uint32_t * jeq_op = ops + DDS_OP_ADR_JSR (ops[1]) - 2;
|
||||||
|
uint32_t disc = 0;
|
||||||
|
|
||||||
|
assert (subtype <= DDS_OP_VAL_4BY);
|
||||||
|
|
||||||
|
#ifdef OP_DEBUG_FREE
|
||||||
|
TRACE (("F-UNI: switch %s cases %d\n", stream_op_type[subtype], num));
|
||||||
|
#endif
|
||||||
|
/* Get discriminant */
|
||||||
|
|
||||||
|
switch (subtype)
|
||||||
|
{
|
||||||
|
case DDS_OP_VAL_1BY:
|
||||||
|
{
|
||||||
|
disc = *((uint8_t*) addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_2BY:
|
||||||
|
{
|
||||||
|
disc = *((uint16_t*) addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_4BY:
|
||||||
|
{
|
||||||
|
disc = *((uint32_t*) addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: assert (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free case matching discriminant */
|
||||||
|
|
||||||
|
while (num--)
|
||||||
|
{
|
||||||
|
assert ((DDS_OP_MASK & jeq_op[0]) == DDS_OP_JEQ);
|
||||||
|
if ((jeq_op[1] == disc) || (has_default && (num == 0)))
|
||||||
|
{
|
||||||
|
subtype = DDS_JEQ_TYPE (jeq_op[0]);
|
||||||
|
addr = data + jeq_op[2];
|
||||||
|
|
||||||
|
switch (subtype)
|
||||||
|
{
|
||||||
|
case DDS_OP_VAL_1BY:
|
||||||
|
case DDS_OP_VAL_2BY:
|
||||||
|
case DDS_OP_VAL_4BY:
|
||||||
|
case DDS_OP_VAL_8BY:
|
||||||
|
case DDS_OP_VAL_BST:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_STR:
|
||||||
|
{
|
||||||
|
dds_free (*((char**) addr));
|
||||||
|
*((char**) addr) = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
dds_sample_free_contents (addr, jeq_op + DDS_OP_ADR_JSR (jeq_op[0]));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
jeq_op += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Jump to next instruction */
|
||||||
|
|
||||||
|
ops += DDS_OP_ADR_JMP (ops[1]) - 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_BST:
|
||||||
|
{
|
||||||
|
ops++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: assert (0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_JSR: /* Implies nested type */
|
||||||
|
{
|
||||||
|
#ifdef OP_DEBUG_FREE
|
||||||
|
TRACE (("F-JSR: %d\n", DDS_OP_JUMP (op)));
|
||||||
|
#endif
|
||||||
|
dds_sample_free_contents (data, ops + DDS_OP_JUMP (op));
|
||||||
|
ops++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: assert (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef OP_DEBUG_FREE
|
||||||
|
TRACE (("F-RTS:\n"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dds_sample_free_key (char * sample, const struct dds_topic_descriptor * desc)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
const uint32_t * op;
|
||||||
|
|
||||||
|
for (i = 0; i < desc->m_nkeys; i++)
|
||||||
|
{
|
||||||
|
op = desc->m_ops + desc->m_keys[i].m_index;
|
||||||
|
if (DDS_OP_TYPE (*op) == DDS_OP_VAL_STR)
|
||||||
|
{
|
||||||
|
dds_free (*(char**)(sample + op[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_sample_free (void * sample, const struct dds_topic_descriptor * desc, dds_free_op_t op)
|
||||||
|
{
|
||||||
|
assert (desc);
|
||||||
|
|
||||||
|
if (sample)
|
||||||
|
{
|
||||||
|
if (op & DDS_FREE_CONTENTS_BIT)
|
||||||
|
{
|
||||||
|
dds_sample_free_contents ((char*) sample, desc->m_ops);
|
||||||
|
}
|
||||||
|
else if (op & DDS_FREE_KEY_BIT)
|
||||||
|
{
|
||||||
|
dds_sample_free_key ((char*) sample, desc);
|
||||||
|
}
|
||||||
|
if (op & DDS_FREE_ALL_BIT)
|
||||||
|
{
|
||||||
|
dds_free (sample);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
440
src/core/ddsc/src/dds_builtin.c
Normal file
440
src/core/ddsc/src/dds_builtin.c
Normal file
|
|
@ -0,0 +1,440 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "ddsi/q_entity.h"
|
||||||
|
#include "ddsi/q_thread.h"
|
||||||
|
#include "ddsi/q_config.h"
|
||||||
|
#include "ddsi/q_builtin_topic.h"
|
||||||
|
#include "q__osplser.h"
|
||||||
|
#include "dds__init.h"
|
||||||
|
#include "dds__qos.h"
|
||||||
|
#include "dds__domain.h"
|
||||||
|
#include "dds__participant.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "dds__types.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
#include "dds__builtin.h"
|
||||||
|
#include "dds__subscriber.h"
|
||||||
|
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds__delete_builtin_participant(
|
||||||
|
dds_entity *e);
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__create_builtin_participant(
|
||||||
|
void);
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__create_builtin_publisher(
|
||||||
|
_In_ dds_entity_t participant);
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__create_builtin_writer(
|
||||||
|
_In_ dds_entity_t topic);
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_participant(
|
||||||
|
void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static os_mutex g_builtin_mutex;
|
||||||
|
static os_atomic_uint32_t m_call_count = OS_ATOMIC_UINT32_INIT(0);
|
||||||
|
|
||||||
|
/* Singletons are used to publish builtin data locally. */
|
||||||
|
static dds_entity_t g_builtin_local_participant = 0;
|
||||||
|
static dds_entity_t g_builtin_local_publisher = 0;
|
||||||
|
static dds_entity_t g_builtin_local_writers[] = {
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_DCPSPARTICIPANT - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_CMPARTICIPANT - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_DCPSTYPE - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_DCPSTOPIC - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_DCPSPUBLICATION - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_CMPUBLISHER - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_CMSUBSCRIBER - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_CMDATAWRITER - DDS_KIND_INTERNAL - 1 */
|
||||||
|
0, /* index DDS_BUILTIN_TOPIC_CMDATAREADER - DDS_KIND_INTERNAL - 1 */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds__delete_builtin_participant(
|
||||||
|
dds_entity *e)
|
||||||
|
{
|
||||||
|
struct thread_state1 * const thr = lookup_thread_state ();
|
||||||
|
const bool asleep = !vtime_awake_p (thr->vtime);
|
||||||
|
|
||||||
|
assert(e);
|
||||||
|
assert(thr);
|
||||||
|
assert(dds_entity_kind(e->m_hdl) == DDS_KIND_PARTICIPANT);
|
||||||
|
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_awake(thr);
|
||||||
|
}
|
||||||
|
dds_domain_free(e->m_domain);
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_asleep(thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We don't use the 'normal' create participant.
|
||||||
|
*
|
||||||
|
* This way, the application is not able to access the local builtin writers.
|
||||||
|
* Also, we can indicate that it should be a 'local only' participant, which
|
||||||
|
* means that none of the entities under the hierarchy of this participant will
|
||||||
|
* be exposed to the outside world. This is what we want, because these builtin
|
||||||
|
* writers are only applicable to local user readers.
|
||||||
|
*/
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__create_builtin_participant(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
int q_rc;
|
||||||
|
nn_plist_t plist;
|
||||||
|
struct thread_state1 * thr;
|
||||||
|
bool asleep;
|
||||||
|
nn_guid_t guid;
|
||||||
|
dds_entity_t participant;
|
||||||
|
dds_participant *pp;
|
||||||
|
|
||||||
|
nn_plist_init_empty (&plist);
|
||||||
|
|
||||||
|
thr = lookup_thread_state ();
|
||||||
|
asleep = !vtime_awake_p (thr->vtime);
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_awake (thr);
|
||||||
|
}
|
||||||
|
q_rc = new_participant (&guid, RTPS_PF_NO_BUILTIN_WRITERS | RTPS_PF_NO_BUILTIN_READERS | RTPS_PF_ONLY_LOCAL, &plist);
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_asleep (thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (q_rc != 0) {
|
||||||
|
participant = DDS_ERRNO(DDS_RETCODE_ERROR, "Internal builtin error");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
pp = dds_alloc (sizeof (*pp));
|
||||||
|
participant = dds_entity_init (&pp->m_entity, NULL, DDS_KIND_PARTICIPANT, NULL, NULL, 0);
|
||||||
|
if (participant < 0) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
pp->m_entity.m_guid = guid;
|
||||||
|
pp->m_entity.m_domain = dds_domain_create (config.domainId);
|
||||||
|
pp->m_entity.m_domainid = config.domainId;
|
||||||
|
pp->m_entity.m_deriver.delete = dds__delete_builtin_participant;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
return participant;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__create_builtin_publisher(
|
||||||
|
_In_ dds_entity_t participant)
|
||||||
|
{
|
||||||
|
dds_entity_t pub;
|
||||||
|
dds_qos_t *qos;
|
||||||
|
const char *partition = "__BUILT-IN PARTITION__";
|
||||||
|
|
||||||
|
qos = dds_qos_create();
|
||||||
|
dds_qset_partition(qos, 1, &partition);
|
||||||
|
|
||||||
|
pub = dds_create_publisher(participant, qos, NULL);
|
||||||
|
|
||||||
|
dds_qos_delete(qos);
|
||||||
|
|
||||||
|
return pub;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__create_builtin_subscriber(
|
||||||
|
_In_ dds_entity *participant)
|
||||||
|
{
|
||||||
|
dds_entity_t sub;
|
||||||
|
dds_qos_t *qos;
|
||||||
|
const char *partition = "__BUILT-IN PARTITION__";
|
||||||
|
|
||||||
|
qos = dds_qos_create();
|
||||||
|
dds_qset_partition(qos, 1, &partition);
|
||||||
|
|
||||||
|
/* Create builtin-subscriber */
|
||||||
|
sub = dds__create_subscriber_l(participant, qos, NULL);
|
||||||
|
dds_qos_delete(qos);
|
||||||
|
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__create_builtin_writer(
|
||||||
|
_In_ dds_entity_t topic)
|
||||||
|
{
|
||||||
|
dds_entity_t wr;
|
||||||
|
dds_entity_t pub = dds__get_builtin_publisher();
|
||||||
|
if (pub > 0) {
|
||||||
|
dds_entity_t top = dds__get_builtin_topic(pub, topic);
|
||||||
|
if (top > 0) {
|
||||||
|
dds_qos_t *qos;
|
||||||
|
// TODO: set builtin qos
|
||||||
|
qos = dds_qos_create();
|
||||||
|
dds_qset_durability(qos, DDS_DURABILITY_TRANSIENT_LOCAL);
|
||||||
|
dds_qset_reliability(qos, DDS_RELIABILITY_RELIABLE, DDS_MSECS(100));
|
||||||
|
wr = dds_create_writer(pub, top, qos, NULL);
|
||||||
|
dds_qos_delete(qos);
|
||||||
|
(void)dds_delete(top);
|
||||||
|
} else {
|
||||||
|
wr = top;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wr = pub;
|
||||||
|
}
|
||||||
|
return wr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_participant(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
if (g_builtin_local_participant == 0) {
|
||||||
|
g_builtin_local_participant = dds__create_builtin_participant();
|
||||||
|
}
|
||||||
|
return g_builtin_local_participant;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_publisher(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
if (g_builtin_local_publisher == 0) {
|
||||||
|
dds_entity_t par = dds__get_builtin_participant();
|
||||||
|
if (par > 0) {
|
||||||
|
g_builtin_local_publisher = dds__create_builtin_publisher(par);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return g_builtin_local_publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_subscriber(
|
||||||
|
_In_ dds_entity_t e)
|
||||||
|
{
|
||||||
|
dds_entity_t sub;
|
||||||
|
dds_return_t ret;
|
||||||
|
dds_entity_t participant;
|
||||||
|
dds_participant *p;
|
||||||
|
dds_entity *part_entity;
|
||||||
|
|
||||||
|
participant = dds_get_participant(e);
|
||||||
|
if (participant <= 0) {
|
||||||
|
/* error already in participant error; no need to repeat error */
|
||||||
|
ret = participant;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
ret = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, (dds_entity **)&part_entity);
|
||||||
|
if (ret != DDS_RETCODE_OK) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
p = (dds_participant *)part_entity;
|
||||||
|
if(p->m_builtin_subscriber <= 0) {
|
||||||
|
p->m_builtin_subscriber = dds__create_builtin_subscriber(part_entity);
|
||||||
|
}
|
||||||
|
sub = p->m_builtin_subscriber;
|
||||||
|
dds_entity_unlock(part_entity);
|
||||||
|
|
||||||
|
return sub;
|
||||||
|
|
||||||
|
/* Error handling */
|
||||||
|
error:
|
||||||
|
assert(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_topic(
|
||||||
|
_In_ dds_entity_t e,
|
||||||
|
_In_ dds_entity_t topic)
|
||||||
|
{
|
||||||
|
dds_entity_t participant;
|
||||||
|
dds_entity_t ret;
|
||||||
|
|
||||||
|
participant = dds_get_participant(e);
|
||||||
|
if (participant > 0) {
|
||||||
|
const dds_topic_descriptor_t *desc;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
if (topic == DDS_BUILTIN_TOPIC_DCPSPARTICIPANT) {
|
||||||
|
desc = &DDS_ParticipantBuiltinTopicData_desc;
|
||||||
|
name = "DCPSParticipant";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_CMPARTICIPANT) {
|
||||||
|
desc = &DDS_CMParticipantBuiltinTopicData_desc;
|
||||||
|
name = "CMParticipant";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_DCPSTYPE) {
|
||||||
|
desc = &DDS_TypeBuiltinTopicData_desc;
|
||||||
|
name = "DCPSType";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_DCPSTOPIC) {
|
||||||
|
desc = &DDS_TopicBuiltinTopicData_desc;
|
||||||
|
name = "DCPSTopic";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_DCPSPUBLICATION) {
|
||||||
|
desc = &DDS_PublicationBuiltinTopicData_desc;
|
||||||
|
name = "DCPSPublication";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_CMPUBLISHER) {
|
||||||
|
desc = &DDS_CMPublisherBuiltinTopicData_desc;
|
||||||
|
name = "CMPublisher";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION) {
|
||||||
|
desc = &DDS_SubscriptionBuiltinTopicData_desc;
|
||||||
|
name = "DCPSSubscription";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_CMSUBSCRIBER) {
|
||||||
|
desc = &DDS_CMSubscriberBuiltinTopicData_desc;
|
||||||
|
name = "CMSubscriber";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_CMDATAWRITER) {
|
||||||
|
desc = &DDS_CMDataWriterBuiltinTopicData_desc;
|
||||||
|
name = "CMDataWriter";
|
||||||
|
} else if (topic == DDS_BUILTIN_TOPIC_CMDATAREADER) {
|
||||||
|
desc = &DDS_CMDataReaderBuiltinTopicData_desc;
|
||||||
|
name = "CMDataReader";
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Invalid builtin-topic handle(%d)", topic);
|
||||||
|
goto err_invalid_topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = dds_find_topic(participant, name);
|
||||||
|
if (ret < 0 && dds_err_nr(ret) == DDS_RETCODE_PRECONDITION_NOT_MET) {
|
||||||
|
dds_qos_t *tqos;
|
||||||
|
|
||||||
|
/* drop the precondition-no-met error */
|
||||||
|
DDS_REPORT_FLUSH(0);
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
tqos = dds_qos_create();
|
||||||
|
dds_qset_durability(tqos, DDS_DURABILITY_TRANSIENT_LOCAL);
|
||||||
|
dds_qset_presentation(tqos, DDS_PRESENTATION_TOPIC, false, false);
|
||||||
|
dds_qset_reliability(tqos, DDS_RELIABILITY_RELIABLE, DDS_MSECS(100));
|
||||||
|
ret = dds_create_topic(participant, desc, name, tqos, NULL);
|
||||||
|
dds_qos_delete(tqos);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/* Failed to get participant of provided entity */
|
||||||
|
ret = participant;
|
||||||
|
}
|
||||||
|
|
||||||
|
err_invalid_topic:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static _Must_inspect_result_ dds_entity_t
|
||||||
|
dds__get_builtin_writer(
|
||||||
|
_In_ dds_entity_t topic)
|
||||||
|
{
|
||||||
|
dds_entity_t wr;
|
||||||
|
if ((topic >= DDS_BUILTIN_TOPIC_DCPSPARTICIPANT) && (topic <= DDS_BUILTIN_TOPIC_CMDATAREADER)) {
|
||||||
|
int index = (int)(topic - DDS_KIND_INTERNAL - 1);
|
||||||
|
os_mutexLock(&g_builtin_mutex);
|
||||||
|
wr = g_builtin_local_writers[index];
|
||||||
|
if (wr == 0) {
|
||||||
|
wr = dds__create_builtin_writer(topic);
|
||||||
|
if (wr > 0) {
|
||||||
|
g_builtin_local_writers[index] = wr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os_mutexUnlock(&g_builtin_mutex);
|
||||||
|
} else {
|
||||||
|
wr = DDS_ERRNO(DDS_RETCODE_ERROR, "Given topic is not a builtin topic.");
|
||||||
|
}
|
||||||
|
return wr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds__builtin_write(
|
||||||
|
_In_ dds_entity_t topic,
|
||||||
|
_In_ const void *data,
|
||||||
|
_In_ dds_time_t timestamp,
|
||||||
|
_In_ int alive)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
if (os_atomic_inc32_nv(&m_call_count) > 1) {
|
||||||
|
dds_entity_t wr;
|
||||||
|
wr = dds__get_builtin_writer(topic);
|
||||||
|
if (wr > 0) {
|
||||||
|
if (alive) {
|
||||||
|
ret = dds_write_ts(wr, data, timestamp);
|
||||||
|
} else {
|
||||||
|
ret = dds_dispose_ts(wr, data, timestamp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = wr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os_atomic_dec32(&m_call_count);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds__builtin_init(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
assert(os_atomic_ld32(&m_call_count) == 0);
|
||||||
|
os_mutexInit(&g_builtin_mutex);
|
||||||
|
os_atomic_inc32(&m_call_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds__builtin_fini(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
assert(os_atomic_ld32(&m_call_count) > 0);
|
||||||
|
while (os_atomic_dec32_nv(&m_call_count) > 0) {
|
||||||
|
os_atomic_inc32_nv(&m_call_count);
|
||||||
|
dds_sleepfor(DDS_MSECS(10));
|
||||||
|
}
|
||||||
|
(void)dds_delete(g_builtin_local_participant);
|
||||||
|
g_builtin_local_participant = 0;
|
||||||
|
g_builtin_local_publisher = 0;
|
||||||
|
memset(g_builtin_local_writers, 0, sizeof(g_builtin_local_writers));
|
||||||
|
os_mutexDestroy(&g_builtin_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
forward_builtin_participant(
|
||||||
|
_In_ DDS_ParticipantBuiltinTopicData *data,
|
||||||
|
_In_ nn_wctime_t timestamp,
|
||||||
|
_In_ int alive)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds__builtin_write(DDS_BUILTIN_TOPIC_DCPSPARTICIPANT, data, timestamp.v, alive);
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
forward_builtin_cmparticipant(
|
||||||
|
_In_ DDS_CMParticipantBuiltinTopicData *data,
|
||||||
|
_In_ nn_wctime_t timestamp,
|
||||||
|
_In_ int alive)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds__builtin_write(DDS_BUILTIN_TOPIC_CMPARTICIPANT, data, timestamp.v, alive);
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
}
|
||||||
371
src/core/ddsc/src/dds_builtinTopics.idl
Normal file
371
src/core/ddsc/src/dds_builtinTopics.idl
Normal file
|
|
@ -0,0 +1,371 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef OSPL_DDS_BUILTINTOPICS_IDL
|
||||||
|
#define OSPL_DDS_BUILTINTOPICS_IDL
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file was the one orginally in ./src/api/dcps/saj/code/.
|
||||||
|
(and therefore by implication ./src/api/dcps/cj/java/code).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BUILTIN_TOPIC_KEY_TYPE_NATIVE long
|
||||||
|
|
||||||
|
module DDS {
|
||||||
|
|
||||||
|
|
||||||
|
// Added octet sequence definition.
|
||||||
|
// Prevents IDL compiler warnings from deprecated anonymous types
|
||||||
|
// on composite type members.
|
||||||
|
typedef sequence<octet> octSeq;
|
||||||
|
|
||||||
|
typedef BUILTIN_TOPIC_KEY_TYPE_NATIVE BuiltinTopicKey_t[3];
|
||||||
|
typedef sequence<string> StringSeq;
|
||||||
|
typedef short DataRepresentationId_t;
|
||||||
|
|
||||||
|
const DataRepresentationId_t XCDR_REPRESENTATION = 0;
|
||||||
|
const DataRepresentationId_t XML_REPRESENTATION = 0x001;
|
||||||
|
const DataRepresentationId_t OSPL_REPRESENTATION = 0x400;
|
||||||
|
const DataRepresentationId_t GPB_REPRESENTATION = 0x401;
|
||||||
|
const DataRepresentationId_t INVALID_REPRESENTATION = 0x7FFF;
|
||||||
|
|
||||||
|
struct Duration_t {
|
||||||
|
long sec;
|
||||||
|
unsigned long nanosec;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UserDataQosPolicy {
|
||||||
|
octSeq value;
|
||||||
|
// replaced deprecated anonymous sequence<octet> value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TopicDataQosPolicy {
|
||||||
|
octSeq value;
|
||||||
|
// replaced deprecated anonymous sequence<octet> value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GroupDataQosPolicy {
|
||||||
|
octSeq value;
|
||||||
|
// replaced deprected anonymous sequence<octet> value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TransportPriorityQosPolicy {
|
||||||
|
long value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LifespanQosPolicy {
|
||||||
|
Duration_t duration;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DurabilityQosPolicyKind {
|
||||||
|
VOLATILE_DURABILITY_QOS,
|
||||||
|
TRANSIENT_LOCAL_DURABILITY_QOS,
|
||||||
|
TRANSIENT_DURABILITY_QOS,
|
||||||
|
PERSISTENT_DURABILITY_QOS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DurabilityQosPolicy {
|
||||||
|
DurabilityQosPolicyKind kind;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum PresentationQosPolicyAccessScopeKind {
|
||||||
|
INSTANCE_PRESENTATION_QOS,
|
||||||
|
TOPIC_PRESENTATION_QOS,
|
||||||
|
GROUP_PRESENTATION_QOS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PresentationQosPolicy {
|
||||||
|
PresentationQosPolicyAccessScopeKind access_scope;
|
||||||
|
boolean coherent_access;
|
||||||
|
boolean ordered_access;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DeadlineQosPolicy {
|
||||||
|
Duration_t period;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LatencyBudgetQosPolicy {
|
||||||
|
Duration_t duration;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum OwnershipQosPolicyKind {
|
||||||
|
SHARED_OWNERSHIP_QOS,
|
||||||
|
EXCLUSIVE_OWNERSHIP_QOS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OwnershipQosPolicy {
|
||||||
|
OwnershipQosPolicyKind kind;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OwnershipStrengthQosPolicy {
|
||||||
|
long value;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum LivelinessQosPolicyKind {
|
||||||
|
AUTOMATIC_LIVELINESS_QOS,
|
||||||
|
MANUAL_BY_PARTICIPANT_LIVELINESS_QOS,
|
||||||
|
MANUAL_BY_TOPIC_LIVELINESS_QOS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LivelinessQosPolicy {
|
||||||
|
LivelinessQosPolicyKind kind;
|
||||||
|
Duration_t lease_duration;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TimeBasedFilterQosPolicy {
|
||||||
|
Duration_t minimum_separation;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PartitionQosPolicy {
|
||||||
|
StringSeq name;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ReliabilityQosPolicyKind {
|
||||||
|
BEST_EFFORT_RELIABILITY_QOS,
|
||||||
|
RELIABLE_RELIABILITY_QOS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ReliabilityQosPolicy {
|
||||||
|
ReliabilityQosPolicyKind kind;
|
||||||
|
Duration_t max_blocking_time;
|
||||||
|
boolean synchronous;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DestinationOrderQosPolicyKind {
|
||||||
|
BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS,
|
||||||
|
BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DestinationOrderQosPolicy {
|
||||||
|
DestinationOrderQosPolicyKind kind;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum HistoryQosPolicyKind {
|
||||||
|
KEEP_LAST_HISTORY_QOS,
|
||||||
|
KEEP_ALL_HISTORY_QOS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HistoryQosPolicy {
|
||||||
|
HistoryQosPolicyKind kind;
|
||||||
|
long depth;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ResourceLimitsQosPolicy {
|
||||||
|
long max_samples;
|
||||||
|
long max_instances;
|
||||||
|
long max_samples_per_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DurabilityServiceQosPolicy {
|
||||||
|
Duration_t service_cleanup_delay;
|
||||||
|
HistoryQosPolicyKind history_kind;
|
||||||
|
long history_depth;
|
||||||
|
long max_samples;
|
||||||
|
long max_instances;
|
||||||
|
long max_samples_per_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ProductDataQosPolicy {
|
||||||
|
string value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EntityFactoryQosPolicy {
|
||||||
|
boolean autoenable_created_entities;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ShareQosPolicy {
|
||||||
|
string name;
|
||||||
|
boolean enable;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WriterDataLifecycleQosPolicy {
|
||||||
|
boolean autodispose_unregistered_instances;
|
||||||
|
Duration_t autopurge_suspended_samples_delay;
|
||||||
|
Duration_t autounregister_instance_delay;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum InvalidSampleVisibilityQosPolicyKind {
|
||||||
|
NO_INVALID_SAMPLES,
|
||||||
|
MINIMUM_INVALID_SAMPLES,
|
||||||
|
ALL_INVALID_SAMPLES
|
||||||
|
};
|
||||||
|
|
||||||
|
struct InvalidSampleVisibilityQosPolicy {
|
||||||
|
InvalidSampleVisibilityQosPolicyKind kind;
|
||||||
|
};
|
||||||
|
|
||||||
|
// @discrepancy The below QoS did not exist in ./etc/idlpp/dds_dcps.idl Retain ?
|
||||||
|
|
||||||
|
struct SubscriptionKeyQosPolicy {
|
||||||
|
boolean use_key_list;
|
||||||
|
StringSeq key_list;
|
||||||
|
};
|
||||||
|
|
||||||
|
// @discrepancy End of above discrepancy
|
||||||
|
|
||||||
|
struct ReaderDataLifecycleQosPolicy {
|
||||||
|
Duration_t autopurge_nowriter_samples_delay;
|
||||||
|
Duration_t autopurge_disposed_samples_delay;
|
||||||
|
boolean autopurge_dispose_all;
|
||||||
|
// @discrepancy The below member existed in this file but did not
|
||||||
|
// in ./etc/idlpp/dds_dcps.idl. Retain ?
|
||||||
|
boolean enable_invalid_samples; // @deprecated Will be replaced by invalid_sample_visibility in due time
|
||||||
|
InvalidSampleVisibilityQosPolicy invalid_sample_visibility;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UserKeyQosPolicy {
|
||||||
|
boolean enable;
|
||||||
|
string expression;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ReaderLifespanQosPolicy {
|
||||||
|
boolean use_lifespan;
|
||||||
|
Duration_t duration;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TypeHash {
|
||||||
|
unsigned long long msb;
|
||||||
|
unsigned long long lsb;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ParticipantBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
UserDataQosPolicy user_data;
|
||||||
|
};
|
||||||
|
#pragma keylist ParticipantBuiltinTopicData key
|
||||||
|
|
||||||
|
struct TopicBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
string name;
|
||||||
|
string type_name;
|
||||||
|
DurabilityQosPolicy durability;
|
||||||
|
DurabilityServiceQosPolicy durability_service;
|
||||||
|
DeadlineQosPolicy deadline;
|
||||||
|
LatencyBudgetQosPolicy latency_budget;
|
||||||
|
LivelinessQosPolicy liveliness;
|
||||||
|
ReliabilityQosPolicy reliability;
|
||||||
|
TransportPriorityQosPolicy transport_priority;
|
||||||
|
LifespanQosPolicy lifespan;
|
||||||
|
DestinationOrderQosPolicy destination_order;
|
||||||
|
HistoryQosPolicy history;
|
||||||
|
ResourceLimitsQosPolicy resource_limits;
|
||||||
|
OwnershipQosPolicy ownership;
|
||||||
|
TopicDataQosPolicy topic_data;
|
||||||
|
};
|
||||||
|
#pragma keylist TopicBuiltinTopicData key
|
||||||
|
|
||||||
|
struct TypeBuiltinTopicData {
|
||||||
|
string name;
|
||||||
|
DataRepresentationId_t data_representation_id;
|
||||||
|
TypeHash type_hash;
|
||||||
|
octSeq meta_data;
|
||||||
|
octSeq extentions;
|
||||||
|
};
|
||||||
|
#pragma keylist TypeBuiltinTopicData name data_representation_id type_hash.msb type_hash.lsb
|
||||||
|
|
||||||
|
struct PublicationBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
BuiltinTopicKey_t participant_key;
|
||||||
|
string topic_name;
|
||||||
|
string type_name;
|
||||||
|
DurabilityQosPolicy durability;
|
||||||
|
DeadlineQosPolicy deadline;
|
||||||
|
LatencyBudgetQosPolicy latency_budget;
|
||||||
|
LivelinessQosPolicy liveliness;
|
||||||
|
ReliabilityQosPolicy reliability;
|
||||||
|
LifespanQosPolicy lifespan;
|
||||||
|
DestinationOrderQosPolicy destination_order;
|
||||||
|
UserDataQosPolicy user_data;
|
||||||
|
OwnershipQosPolicy ownership;
|
||||||
|
OwnershipStrengthQosPolicy ownership_strength;
|
||||||
|
PresentationQosPolicy presentation;
|
||||||
|
PartitionQosPolicy partition;
|
||||||
|
TopicDataQosPolicy topic_data;
|
||||||
|
GroupDataQosPolicy group_data;
|
||||||
|
};
|
||||||
|
#pragma keylist PublicationBuiltinTopicData key
|
||||||
|
|
||||||
|
struct SubscriptionBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
BuiltinTopicKey_t participant_key;
|
||||||
|
string topic_name;
|
||||||
|
string type_name;
|
||||||
|
DurabilityQosPolicy durability;
|
||||||
|
DeadlineQosPolicy deadline;
|
||||||
|
LatencyBudgetQosPolicy latency_budget;
|
||||||
|
LivelinessQosPolicy liveliness;
|
||||||
|
ReliabilityQosPolicy reliability;
|
||||||
|
OwnershipQosPolicy ownership;
|
||||||
|
DestinationOrderQosPolicy destination_order;
|
||||||
|
UserDataQosPolicy user_data;
|
||||||
|
TimeBasedFilterQosPolicy time_based_filter;
|
||||||
|
PresentationQosPolicy presentation;
|
||||||
|
PartitionQosPolicy partition;
|
||||||
|
TopicDataQosPolicy topic_data;
|
||||||
|
GroupDataQosPolicy group_data;
|
||||||
|
};
|
||||||
|
#pragma keylist SubscriptionBuiltinTopicData key
|
||||||
|
|
||||||
|
struct CMParticipantBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
ProductDataQosPolicy product;
|
||||||
|
};
|
||||||
|
#pragma keylist CMParticipantBuiltinTopicData key
|
||||||
|
|
||||||
|
struct CMPublisherBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
ProductDataQosPolicy product;
|
||||||
|
BuiltinTopicKey_t participant_key;
|
||||||
|
string name;
|
||||||
|
EntityFactoryQosPolicy entity_factory;
|
||||||
|
PartitionQosPolicy partition;
|
||||||
|
};
|
||||||
|
#pragma keylist CMPublisherBuiltinTopicData key
|
||||||
|
|
||||||
|
struct CMSubscriberBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
ProductDataQosPolicy product;
|
||||||
|
BuiltinTopicKey_t participant_key;
|
||||||
|
string name;
|
||||||
|
EntityFactoryQosPolicy entity_factory;
|
||||||
|
ShareQosPolicy share;
|
||||||
|
PartitionQosPolicy partition;
|
||||||
|
};
|
||||||
|
#pragma keylist CMSubscriberBuiltinTopicData key
|
||||||
|
|
||||||
|
struct CMDataWriterBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
ProductDataQosPolicy product;
|
||||||
|
BuiltinTopicKey_t publisher_key;
|
||||||
|
string name;
|
||||||
|
HistoryQosPolicy history;
|
||||||
|
ResourceLimitsQosPolicy resource_limits;
|
||||||
|
WriterDataLifecycleQosPolicy writer_data_lifecycle;
|
||||||
|
};
|
||||||
|
#pragma keylist CMDataWriterBuiltinTopicData key
|
||||||
|
|
||||||
|
struct CMDataReaderBuiltinTopicData {
|
||||||
|
BuiltinTopicKey_t key;
|
||||||
|
ProductDataQosPolicy product;
|
||||||
|
BuiltinTopicKey_t subscriber_key;
|
||||||
|
string name;
|
||||||
|
HistoryQosPolicy history;
|
||||||
|
ResourceLimitsQosPolicy resource_limits;
|
||||||
|
ReaderDataLifecycleQosPolicy reader_data_lifecycle;
|
||||||
|
UserKeyQosPolicy subscription_keys;
|
||||||
|
ReaderLifespanQosPolicy reader_lifespan;
|
||||||
|
ShareQosPolicy share;
|
||||||
|
};
|
||||||
|
#pragma keylist CMDataReaderBuiltinTopicData key
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* OSPL_DDS_BUILTINTOPICS_IDL */
|
||||||
79
src/core/ddsc/src/dds_coherent.c
Normal file
79
src/core/ddsc/src/dds_coherent.c
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
#include "dds__entity.h"
|
||||||
|
#include "dds__subscriber.h"
|
||||||
|
#include "dds__publisher.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
_Pre_satisfies_(((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) || \
|
||||||
|
((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_SUBSCRIBER) || \
|
||||||
|
((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER ) || \
|
||||||
|
((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_SUBSCRIBER) )
|
||||||
|
dds_return_t
|
||||||
|
dds_begin_coherent(
|
||||||
|
_In_ dds_entity_t entity)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
switch(dds_entity_kind(entity)) {
|
||||||
|
case DDS_KIND_READER:
|
||||||
|
case DDS_KIND_WRITER:
|
||||||
|
/* Invoking on a writer/reader behaves as if invoked on
|
||||||
|
* its parent publisher/subscriber. */
|
||||||
|
ret = dds_begin_coherent(dds_get_parent(entity));
|
||||||
|
break;
|
||||||
|
case DDS_KIND_PUBLISHER:
|
||||||
|
ret = dds_publisher_begin_coherent(entity);
|
||||||
|
break;
|
||||||
|
case DDS_KIND_SUBSCRIBER:
|
||||||
|
ret = dds_subscriber_begin_coherent(entity);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Given entity can not control coherency");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) || \
|
||||||
|
((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_SUBSCRIBER) || \
|
||||||
|
((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER ) || \
|
||||||
|
((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_SUBSCRIBER) )
|
||||||
|
dds_return_t
|
||||||
|
dds_end_coherent(
|
||||||
|
_In_ dds_entity_t entity)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
switch(dds_entity_kind(entity)) {
|
||||||
|
case DDS_KIND_READER:
|
||||||
|
case DDS_KIND_WRITER:
|
||||||
|
/* Invoking on a writer/reader behaves as if invoked on
|
||||||
|
* its parent publisher/subscriber. */
|
||||||
|
ret = dds_end_coherent(dds_get_parent(entity));
|
||||||
|
break;
|
||||||
|
case DDS_KIND_PUBLISHER:
|
||||||
|
ret = dds_publisher_end_coherent(entity);
|
||||||
|
break;
|
||||||
|
case DDS_KIND_SUBSCRIBER:
|
||||||
|
ret = dds_subscriber_end_coherent(entity);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Given entity can not control coherency");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
130
src/core/ddsc/src/dds_dcps_builtintopics.idl
Normal file
130
src/core/ddsc/src/dds_dcps_builtintopics.idl
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#ifndef OSPL_DDS_DCPS_BUILTINTOPICS_IDL
|
||||||
|
#define OSPL_DDS_DCPS_BUILTINTOPICS_IDL
|
||||||
|
|
||||||
|
/**
|
||||||
|
*This file (name) was orginally in ./src/api/dcps/ccpp/idl/.
|
||||||
|
*It's been modified to include from another file the base definitions
|
||||||
|
*required for this 'built in topics' superset... :
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dds_builtinTopics.idl"
|
||||||
|
|
||||||
|
module DDS {
|
||||||
|
|
||||||
|
struct Time_t {
|
||||||
|
long sec;
|
||||||
|
unsigned long nanosec;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SchedulingClassQosPolicyKind {
|
||||||
|
SCHEDULE_DEFAULT,
|
||||||
|
SCHEDULE_TIMESHARING,
|
||||||
|
SCHEDULE_REALTIME
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SchedulingClassQosPolicy {
|
||||||
|
SchedulingClassQosPolicyKind kind;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SchedulingPriorityQosPolicyKind {
|
||||||
|
PRIORITY_RELATIVE,
|
||||||
|
PRIORITY_ABSOLUTE
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SchedulingPriorityQosPolicy {
|
||||||
|
SchedulingPriorityQosPolicyKind kind;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SchedulingQosPolicy {
|
||||||
|
SchedulingClassQosPolicy scheduling_class;
|
||||||
|
SchedulingPriorityQosPolicy scheduling_priority_kind;
|
||||||
|
long scheduling_priority;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DomainParticipantQos {
|
||||||
|
UserDataQosPolicy user_data;
|
||||||
|
EntityFactoryQosPolicy entity_factory;
|
||||||
|
SchedulingQosPolicy watchdog_scheduling;
|
||||||
|
SchedulingQosPolicy listener_scheduling;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TopicQos {
|
||||||
|
TopicDataQosPolicy topic_data;
|
||||||
|
DurabilityQosPolicy durability;
|
||||||
|
DurabilityServiceQosPolicy durability_service;
|
||||||
|
DeadlineQosPolicy deadline;
|
||||||
|
LatencyBudgetQosPolicy latency_budget;
|
||||||
|
LivelinessQosPolicy liveliness;
|
||||||
|
ReliabilityQosPolicy reliability;
|
||||||
|
DestinationOrderQosPolicy destination_order;
|
||||||
|
HistoryQosPolicy history;
|
||||||
|
ResourceLimitsQosPolicy resource_limits;
|
||||||
|
TransportPriorityQosPolicy transport_priority;
|
||||||
|
LifespanQosPolicy lifespan;
|
||||||
|
OwnershipQosPolicy ownership;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DataWriterQos {
|
||||||
|
DurabilityQosPolicy durability;
|
||||||
|
DeadlineQosPolicy deadline;
|
||||||
|
LatencyBudgetQosPolicy latency_budget;
|
||||||
|
LivelinessQosPolicy liveliness;
|
||||||
|
ReliabilityQosPolicy reliability;
|
||||||
|
DestinationOrderQosPolicy destination_order;
|
||||||
|
HistoryQosPolicy history;
|
||||||
|
ResourceLimitsQosPolicy resource_limits;
|
||||||
|
TransportPriorityQosPolicy transport_priority;
|
||||||
|
LifespanQosPolicy lifespan;
|
||||||
|
UserDataQosPolicy user_data;
|
||||||
|
OwnershipQosPolicy ownership;
|
||||||
|
OwnershipStrengthQosPolicy ownership_strength;
|
||||||
|
WriterDataLifecycleQosPolicy writer_data_lifecycle;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PublisherQos {
|
||||||
|
PresentationQosPolicy presentation;
|
||||||
|
PartitionQosPolicy partition;
|
||||||
|
GroupDataQosPolicy group_data;
|
||||||
|
EntityFactoryQosPolicy entity_factory;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DataReaderQos {
|
||||||
|
DurabilityQosPolicy durability;
|
||||||
|
DeadlineQosPolicy deadline;
|
||||||
|
LatencyBudgetQosPolicy latency_budget;
|
||||||
|
LivelinessQosPolicy liveliness;
|
||||||
|
ReliabilityQosPolicy reliability;
|
||||||
|
DestinationOrderQosPolicy destination_order;
|
||||||
|
HistoryQosPolicy history;
|
||||||
|
ResourceLimitsQosPolicy resource_limits;
|
||||||
|
UserDataQosPolicy user_data;
|
||||||
|
OwnershipQosPolicy ownership;
|
||||||
|
TimeBasedFilterQosPolicy time_based_filter;
|
||||||
|
ReaderDataLifecycleQosPolicy reader_data_lifecycle;
|
||||||
|
SubscriptionKeyQosPolicy subscription_keys;
|
||||||
|
ReaderLifespanQosPolicy reader_lifespan;
|
||||||
|
ShareQosPolicy share;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SubscriberQos {
|
||||||
|
PresentationQosPolicy presentation;
|
||||||
|
PartitionQosPolicy partition;
|
||||||
|
GroupDataQosPolicy group_data;
|
||||||
|
EntityFactoryQosPolicy entity_factory;
|
||||||
|
ShareQosPolicy share;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* DDS_DCPS_BUILTINTOPICS_IDL */
|
||||||
59
src/core/ddsc/src/dds_domain.c
Normal file
59
src/core/ddsc/src/dds_domain.c
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include "dds__domain.h"
|
||||||
|
#include "dds__tkmap.h"
|
||||||
|
|
||||||
|
static int dds_domain_compare (const int32_t * a, const int32_t * b)
|
||||||
|
{
|
||||||
|
return (*a == *b) ? 0 : (*a < *b) ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ut_avlTreedef_t dds_domaintree_def = UT_AVL_TREEDEF_INITIALIZER
|
||||||
|
(
|
||||||
|
offsetof (dds_domain, m_node),
|
||||||
|
offsetof (dds_domain, m_id),
|
||||||
|
(int (*) (const void *, const void *)) dds_domain_compare,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
dds_domain * dds_domain_find_locked (dds_domainid_t id)
|
||||||
|
{
|
||||||
|
return (dds_domain*) ut_avlLookup (&dds_domaintree_def, &dds_global.m_domains, &id);
|
||||||
|
}
|
||||||
|
|
||||||
|
dds_domain * dds_domain_create (dds_domainid_t id)
|
||||||
|
{
|
||||||
|
dds_domain * domain;
|
||||||
|
os_mutexLock (&dds_global.m_mutex);
|
||||||
|
domain = dds_domain_find_locked (id);
|
||||||
|
if (domain == NULL)
|
||||||
|
{
|
||||||
|
domain = dds_alloc (sizeof (*domain));
|
||||||
|
domain->m_id = id;
|
||||||
|
ut_avlInit (&dds_topictree_def, &domain->m_topics);
|
||||||
|
ut_avlInsert (&dds_domaintree_def, &dds_global.m_domains, domain);
|
||||||
|
}
|
||||||
|
domain->m_refc++;
|
||||||
|
os_mutexUnlock (&dds_global.m_mutex);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_domain_free (dds_domain * domain)
|
||||||
|
{
|
||||||
|
os_mutexLock (&dds_global.m_mutex);
|
||||||
|
if (--domain->m_refc == 0)
|
||||||
|
{
|
||||||
|
ut_avlDelete (&dds_domaintree_def, &dds_global.m_domains, domain);
|
||||||
|
dds_free (domain);
|
||||||
|
}
|
||||||
|
os_mutexUnlock (&dds_global.m_mutex);
|
||||||
|
}
|
||||||
1291
src/core/ddsc/src/dds_entity.c
Normal file
1291
src/core/ddsc/src/dds_entity.c
Normal file
File diff suppressed because it is too large
Load diff
102
src/core/ddsc/src/dds_err.c
Normal file
102
src/core/ddsc/src/dds_err.c
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "os/os.h"
|
||||||
|
#include "dds__types.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
|
||||||
|
#define DDS_ERR_CODE_NUM 12
|
||||||
|
#define DDS_ERR_MSG_MAX 128
|
||||||
|
|
||||||
|
#define DDS_ERR_NR_INDEX(e) (((-e) & DDS_ERR_NR_MASK) -1)
|
||||||
|
|
||||||
|
static const char * dds_err_code_array[DDS_ERR_CODE_NUM] =
|
||||||
|
{
|
||||||
|
"Error",
|
||||||
|
"Unsupported",
|
||||||
|
"Bad Parameter",
|
||||||
|
"Precondition Not Met",
|
||||||
|
"Out Of Resources",
|
||||||
|
"Not Enabled",
|
||||||
|
"Immutable Policy",
|
||||||
|
"Inconsistent Policy",
|
||||||
|
"Already Deleted",
|
||||||
|
"Timeout",
|
||||||
|
"No Data",
|
||||||
|
"Illegal Operation"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char * dds_err_str (dds_return_t err)
|
||||||
|
{
|
||||||
|
unsigned index = DDS_ERR_NR_INDEX (err);
|
||||||
|
if (err >= 0)
|
||||||
|
{
|
||||||
|
return "Success";
|
||||||
|
}
|
||||||
|
if (index >= DDS_ERR_CODE_NUM)
|
||||||
|
{
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
return dds_err_code_array[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dds_err_check (dds_return_t err, unsigned flags, const char * where)
|
||||||
|
{
|
||||||
|
if (err < 0)
|
||||||
|
{
|
||||||
|
if (flags & (DDS_CHECK_REPORT | DDS_CHECK_FAIL))
|
||||||
|
{
|
||||||
|
char msg[DDS_ERR_MSG_MAX];
|
||||||
|
(void) snprintf (msg, DDS_ERR_MSG_MAX, "Error %d:M%d:%s", dds_err_file_id(err), dds_err_line(err), dds_err_str(err));
|
||||||
|
if (flags & DDS_CHECK_REPORT)
|
||||||
|
{
|
||||||
|
printf ("%s: %s\n", where, msg);
|
||||||
|
}
|
||||||
|
if (flags & DDS_CHECK_FAIL)
|
||||||
|
{
|
||||||
|
dds_fail (msg, where);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flags & DDS_CHECK_EXIT)
|
||||||
|
{
|
||||||
|
exit (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (err >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void dds_fail_default (const char * msg, const char * where)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Aborting Failure: %s %s\n", where, msg);
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_fail_fn dds_fail_func = dds_fail_default;
|
||||||
|
|
||||||
|
void dds_fail_set (dds_fail_fn fn)
|
||||||
|
{
|
||||||
|
dds_fail_func = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
dds_fail_fn dds_fail_get (void)
|
||||||
|
{
|
||||||
|
return dds_fail_func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_fail (const char * msg, const char * where)
|
||||||
|
{
|
||||||
|
if (dds_fail_func)
|
||||||
|
{
|
||||||
|
(dds_fail_func) (msg, where);
|
||||||
|
}
|
||||||
|
}
|
||||||
79
src/core/ddsc/src/dds_iid.c
Normal file
79
src/core/ddsc/src/dds_iid.c
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include "dds__iid.h"
|
||||||
|
#include "ddsi/q_time.h"
|
||||||
|
#include "ddsi/q_globals.h"
|
||||||
|
|
||||||
|
static os_mutex dds_iid_lock_g;
|
||||||
|
static dds_iid dds_iid_g;
|
||||||
|
|
||||||
|
static void dds_tea_encrypt (uint32_t v[2], const uint32_t k[4])
|
||||||
|
{
|
||||||
|
/* TEA encryption straight from Wikipedia */
|
||||||
|
uint32_t v0=v[0], v1=v[1], sum=0, i; /* set up */
|
||||||
|
uint32_t delta=0x9e3779b9; /* a key schedule constant */
|
||||||
|
uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */
|
||||||
|
for (i=0; i < 32; i++) { /* basic cycle start */
|
||||||
|
sum += delta;
|
||||||
|
v0 += ((v1<<4) + k0) ^ (v1 + sum) ^ ((v1>>5) + k1);
|
||||||
|
v1 += ((v0<<4) + k2) ^ (v0 + sum) ^ ((v0>>5) + k3);
|
||||||
|
} /* end cycle */
|
||||||
|
v[0]=v0; v[1]=v1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dds_tea_decrypt (uint32_t v[2], const uint32_t k[4])
|
||||||
|
{
|
||||||
|
uint32_t v0=v[0], v1=v[1], sum=0xC6EF3720, i; /* set up */
|
||||||
|
uint32_t delta=0x9e3779b9; /* a key schedule constant */
|
||||||
|
uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */
|
||||||
|
for (i=0; i<32; i++) { /* basic cycle start */
|
||||||
|
v1 -= ((v0<<4) + k2) ^ (v0 + sum) ^ ((v0>>5) + k3);
|
||||||
|
v0 -= ((v1<<4) + k0) ^ (v1 + sum) ^ ((v1>>5) + k1);
|
||||||
|
sum -= delta;
|
||||||
|
} /* end cycle */
|
||||||
|
v[0]=v0; v[1]=v1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t dds_iid_gen (void)
|
||||||
|
{
|
||||||
|
uint64_t iid;
|
||||||
|
union { uint64_t u64; uint32_t u32[2]; } tmp;
|
||||||
|
|
||||||
|
os_mutexLock (&dds_iid_lock_g);
|
||||||
|
tmp.u64 = ++dds_iid_g.counter;
|
||||||
|
dds_tea_encrypt (tmp.u32, dds_iid_g.key);
|
||||||
|
iid = tmp.u64;
|
||||||
|
os_mutexUnlock (&dds_iid_lock_g);
|
||||||
|
return iid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_iid_init (void)
|
||||||
|
{
|
||||||
|
union { uint64_t u64; uint32_t u32[2]; } tmp;
|
||||||
|
nn_wctime_t tnow = now ();
|
||||||
|
|
||||||
|
os_mutexInit (&dds_iid_lock_g);
|
||||||
|
|
||||||
|
dds_iid_g.key[0] = (uint32_t) ((uintptr_t) &dds_iid_g);
|
||||||
|
dds_iid_g.key[1] = (uint32_t) tnow.v;
|
||||||
|
dds_iid_g.key[2] = (uint32_t) (tnow.v >> 32);
|
||||||
|
dds_iid_g.key[3] = 0xdeadbeef;
|
||||||
|
|
||||||
|
tmp.u64 = 0;
|
||||||
|
dds_tea_decrypt (tmp.u32, dds_iid_g.key);
|
||||||
|
dds_iid_g.counter = tmp.u64;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_iid_fini (void)
|
||||||
|
{
|
||||||
|
os_mutexDestroy (&dds_iid_lock_g);
|
||||||
|
}
|
||||||
305
src/core/ddsc/src/dds_init.c
Normal file
305
src/core/ddsc/src/dds_init.c
Normal file
|
|
@ -0,0 +1,305 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <os/os.h>
|
||||||
|
#include <os/os_report.h>
|
||||||
|
#include "dds__init.h"
|
||||||
|
#include "dds__rhc.h"
|
||||||
|
#include "dds__tkmap.h"
|
||||||
|
#include "dds__iid.h"
|
||||||
|
#include "dds__domain.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "dds__builtin.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
#include "ddsi/ddsi_ser.h"
|
||||||
|
#include "ddsi/q_servicelease.h"
|
||||||
|
#include "ddsi/q_entity.h"
|
||||||
|
#include <ddsi/q_config.h>
|
||||||
|
#include "ddsc/ddsc_project.h"
|
||||||
|
|
||||||
|
#ifdef _WRS_KERNEL
|
||||||
|
char *os_environ[] = { NULL };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DOMAIN_ID_MIN 0
|
||||||
|
#define DOMAIN_ID_MAX 230
|
||||||
|
|
||||||
|
struct q_globals gv;
|
||||||
|
|
||||||
|
dds_globals dds_global =
|
||||||
|
{
|
||||||
|
DDS_DOMAIN_DEFAULT, 0,
|
||||||
|
NULL, NULL, NULL, NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct cfgst * dds_cfgst = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
os_mutex dds__init_mutex;
|
||||||
|
|
||||||
|
static void
|
||||||
|
dds__fini_once(void)
|
||||||
|
{
|
||||||
|
os_mutexDestroy(&dds__init_mutex);
|
||||||
|
os_osExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dds__init_once(void)
|
||||||
|
{
|
||||||
|
os_osInit();
|
||||||
|
os_mutexInit(&dds__init_mutex);
|
||||||
|
os_procAtExit(dds__fini_once);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
dds__startup(void)
|
||||||
|
{
|
||||||
|
static os_once_t dds__init_control = OS_ONCE_T_STATIC_INIT;
|
||||||
|
os_once(&dds__init_control, dds__init_once);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds_init(void)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
const char * uri;
|
||||||
|
char progname[50];
|
||||||
|
char hostname[64];
|
||||||
|
uint32_t len;
|
||||||
|
|
||||||
|
/* Be sure the DDS lifecycle resources are initialized. */
|
||||||
|
dds__startup();
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
os_mutexLock(&dds__init_mutex);
|
||||||
|
|
||||||
|
dds_global.m_init_count++;
|
||||||
|
if (dds_global.m_init_count > 1)
|
||||||
|
{
|
||||||
|
goto skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ut_handleserver_init() != UT_HANDLE_OK)
|
||||||
|
{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to initialize internal handle server");
|
||||||
|
goto fail_handleserver;
|
||||||
|
}
|
||||||
|
|
||||||
|
gv.tstart = now ();
|
||||||
|
gv.exception = false;
|
||||||
|
gv.static_logbuf_lock_inited = 0;
|
||||||
|
logbuf_init (&gv.static_logbuf);
|
||||||
|
os_mutexInit (&gv.static_logbuf_lock);
|
||||||
|
gv.static_logbuf_lock_inited = 1;
|
||||||
|
os_mutexInit (&dds_global.m_mutex);
|
||||||
|
|
||||||
|
uri = os_getenv (DDSC_PROJECT_NAME_NOSPACE_CAPS"_URI");
|
||||||
|
dds_cfgst = config_init (uri);
|
||||||
|
if (dds_cfgst == NULL)
|
||||||
|
{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to parse configuration XML file %s", uri);
|
||||||
|
goto fail_config;
|
||||||
|
}
|
||||||
|
/* The config.domainId can change internally in DDSI. So, remember what the
|
||||||
|
* main configured domain id is. */
|
||||||
|
dds_global.m_default_domain = config.domainId;
|
||||||
|
|
||||||
|
dds__builtin_init();
|
||||||
|
|
||||||
|
if (rtps_config_prep(dds_cfgst) != 0)
|
||||||
|
{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to configure RTPS.");
|
||||||
|
goto fail_rtps_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
ut_avlInit(&dds_domaintree_def, &dds_global.m_domains);
|
||||||
|
|
||||||
|
/* Start monitoring the liveliness of all threads and renewing the
|
||||||
|
service lease if everything seems well. */
|
||||||
|
|
||||||
|
gv.servicelease = nn_servicelease_new(0, 0);
|
||||||
|
if (gv.servicelease == NULL)
|
||||||
|
{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_OUT_OF_RESOURCES, "Failed to create a servicelease.");
|
||||||
|
goto fail_servicelease_new;
|
||||||
|
}
|
||||||
|
if (nn_servicelease_start_renewing(gv.servicelease) < 0)
|
||||||
|
{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to start the servicelease.");
|
||||||
|
goto fail_servicelease_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rtps_init() < 0)
|
||||||
|
{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Failed to initialize RTPS.");
|
||||||
|
goto fail_rtps_init;
|
||||||
|
}
|
||||||
|
upgrade_main_thread();
|
||||||
|
|
||||||
|
/* Set additional default participant properties */
|
||||||
|
|
||||||
|
gv.default_plist_pp.process_id = (unsigned)os_procIdSelf();
|
||||||
|
gv.default_plist_pp.present |= PP_PRISMTECH_PROCESS_ID;
|
||||||
|
if (os_procName(progname, sizeof(progname)) > 0)
|
||||||
|
{
|
||||||
|
gv.default_plist_pp.exec_name = dds_string_dup(progname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gv.default_plist_pp.exec_name = dds_string_alloc(32);
|
||||||
|
(void) snprintf(gv.default_plist_pp.exec_name, 32, "%s: %u", DDSC_PROJECT_NAME, gv.default_plist_pp.process_id);
|
||||||
|
}
|
||||||
|
len = (uint32_t) (13 + strlen(gv.default_plist_pp.exec_name));
|
||||||
|
gv.default_plist_pp.present |= PP_PRISMTECH_EXEC_NAME;
|
||||||
|
if (os_gethostname(hostname, sizeof(hostname)) == os_resultSuccess)
|
||||||
|
{
|
||||||
|
gv.default_plist_pp.node_name = dds_string_dup(hostname);
|
||||||
|
gv.default_plist_pp.present |= PP_PRISMTECH_NODE_NAME;
|
||||||
|
}
|
||||||
|
gv.default_plist_pp.entity_name = dds_alloc(len);
|
||||||
|
(void) snprintf(gv.default_plist_pp.entity_name, len, "%s<%u>", progname,
|
||||||
|
gv.default_plist_pp.process_id);
|
||||||
|
gv.default_plist_pp.present |= PP_ENTITY_NAME;
|
||||||
|
|
||||||
|
skip:
|
||||||
|
os_mutexUnlock(&dds__init_mutex);
|
||||||
|
DDS_REPORT_FLUSH(false);
|
||||||
|
return DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
fail_rtps_init:
|
||||||
|
fail_servicelease_start:
|
||||||
|
nn_servicelease_free (gv.servicelease);
|
||||||
|
gv.servicelease = NULL;
|
||||||
|
fail_servicelease_new:
|
||||||
|
thread_states_fini();
|
||||||
|
fail_rtps_config:
|
||||||
|
dds__builtin_fini();
|
||||||
|
dds_global.m_default_domain = DDS_DOMAIN_DEFAULT;
|
||||||
|
config_fini (dds_cfgst);
|
||||||
|
dds_cfgst = NULL;
|
||||||
|
fail_config:
|
||||||
|
gv.static_logbuf_lock_inited = 0;
|
||||||
|
os_mutexDestroy (&gv.static_logbuf_lock);
|
||||||
|
os_mutexDestroy (&dds_global.m_mutex);
|
||||||
|
ut_handleserver_fini();
|
||||||
|
fail_handleserver:
|
||||||
|
dds_global.m_init_count--;
|
||||||
|
os_mutexUnlock(&dds__init_mutex);
|
||||||
|
DDS_REPORT_FLUSH(true);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern void dds_fini (void)
|
||||||
|
{
|
||||||
|
os_mutexLock(&dds__init_mutex);
|
||||||
|
assert(dds_global.m_init_count > 0);
|
||||||
|
dds_global.m_init_count--;
|
||||||
|
if (dds_global.m_init_count == 0)
|
||||||
|
{
|
||||||
|
dds__builtin_fini();
|
||||||
|
|
||||||
|
ut_handleserver_fini();
|
||||||
|
rtps_term ();
|
||||||
|
nn_servicelease_free (gv.servicelease);
|
||||||
|
gv.servicelease = NULL;
|
||||||
|
downgrade_main_thread ();
|
||||||
|
thread_states_fini ();
|
||||||
|
|
||||||
|
config_fini (dds_cfgst);
|
||||||
|
dds_cfgst = NULL;
|
||||||
|
os_mutexDestroy (&gv.static_logbuf_lock);
|
||||||
|
os_mutexDestroy (&dds_global.m_mutex);
|
||||||
|
dds_global.m_default_domain = DDS_DOMAIN_DEFAULT;
|
||||||
|
}
|
||||||
|
os_mutexUnlock(&dds__init_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int dds__init_plugin (void)
|
||||||
|
{
|
||||||
|
os_mutexInit (&gv.attach_lock);
|
||||||
|
dds_iid_init ();
|
||||||
|
if (dds_global.m_dur_init) (dds_global.m_dur_init) ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dds__fini_plugin (void)
|
||||||
|
{
|
||||||
|
os_mutexDestroy (&gv.attach_lock);
|
||||||
|
if (dds_global.m_dur_fini) (dds_global.m_dur_fini) ();
|
||||||
|
dds_iid_fini ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ddsi_plugin_init (void)
|
||||||
|
{
|
||||||
|
/* Register initialization/clean functions */
|
||||||
|
|
||||||
|
ddsi_plugin.init_fn = dds__init_plugin;
|
||||||
|
ddsi_plugin.fini_fn = dds__fini_plugin;
|
||||||
|
|
||||||
|
/* Register read cache functions */
|
||||||
|
|
||||||
|
ddsi_plugin.rhc_free_fn = dds_rhc_free;
|
||||||
|
ddsi_plugin.rhc_fini_fn = dds_rhc_fini;
|
||||||
|
ddsi_plugin.rhc_store_fn = dds_rhc_store;
|
||||||
|
ddsi_plugin.rhc_unregister_wr_fn = dds_rhc_unregister_wr;
|
||||||
|
ddsi_plugin.rhc_relinquish_ownership_fn = dds_rhc_relinquish_ownership;
|
||||||
|
ddsi_plugin.rhc_set_qos_fn = dds_rhc_set_qos;
|
||||||
|
ddsi_plugin.rhc_lookup_fn = dds_tkmap_lookup_instance_ref;
|
||||||
|
ddsi_plugin.rhc_unref_fn = dds_tkmap_instance_unref;
|
||||||
|
|
||||||
|
/* Register iid generator */
|
||||||
|
|
||||||
|
ddsi_plugin.iidgen_fn = dds_iid_gen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//provides explicit default domain id.
|
||||||
|
dds_domainid_t dds_domain_default (void)
|
||||||
|
{
|
||||||
|
return dds_global.m_default_domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds__check_domain(
|
||||||
|
_In_ dds_domainid_t domain)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
/* If domain is default: use configured id. */
|
||||||
|
if (domain != DDS_DOMAIN_DEFAULT)
|
||||||
|
{
|
||||||
|
/* Specific domain has to be the same as the configured domain. */
|
||||||
|
if (domain != dds_global.m_default_domain)
|
||||||
|
{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR,
|
||||||
|
"Inconsistent domain configuration detected: domain on configuration: %d, domain %d",
|
||||||
|
dds_global.m_default_domain, domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
468
src/core/ddsc/src/dds_instance.c
Normal file
468
src/core/ddsc/src/dds_instance.c
Normal file
|
|
@ -0,0 +1,468 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
#include "dds__entity.h"
|
||||||
|
#include "dds__write.h"
|
||||||
|
#include "dds__writer.h"
|
||||||
|
#include "dds__rhc.h"
|
||||||
|
#include "dds__tkmap.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "ddsi/ddsi_ser.h"
|
||||||
|
#include "ddsi/q_entity.h"
|
||||||
|
#include "ddsi/q_thread.h"
|
||||||
|
#include "q__osplser.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_writedispose(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_ const void *data)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds_writedispose_ts(writer, data, dds_time());
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_dispose(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_ const void *data)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds_dispose_ts(writer, data, dds_time());
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_dispose_ih(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_ dds_instance_handle_t handle)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds_dispose_ih_ts(writer, handle, dds_time());
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct tkmap_instance*
|
||||||
|
dds_instance_find(
|
||||||
|
_In_ const dds_topic *topic,
|
||||||
|
_In_ const void *data,
|
||||||
|
_In_ const bool create)
|
||||||
|
{
|
||||||
|
serdata_t sd = serialize_key (gv.serpool, topic->m_stopic, data);
|
||||||
|
struct tkmap_instance * inst = dds_tkmap_find (topic, sd, false, create);
|
||||||
|
ddsi_serdata_unref (sd);
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dds_instance_remove(
|
||||||
|
_In_ const dds_topic *topic,
|
||||||
|
_In_opt_ const void *data,
|
||||||
|
_In_ dds_instance_handle_t handle)
|
||||||
|
{
|
||||||
|
struct tkmap_instance * inst;
|
||||||
|
|
||||||
|
if (handle != DDS_HANDLE_NIL) {
|
||||||
|
inst = dds_tkmap_find_by_id (gv.m_tkmap, handle);
|
||||||
|
} else {
|
||||||
|
assert (data);
|
||||||
|
inst = dds_instance_find (topic, data, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inst) {
|
||||||
|
struct thread_state1 * const thr = lookup_thread_state();
|
||||||
|
const bool asleep = thr ? !vtime_awake_p(thr->vtime) : false;
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_awake(thr);
|
||||||
|
}
|
||||||
|
dds_tkmap_instance_unref (inst);
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_asleep(thr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const dds_topic*
|
||||||
|
dds_instance_info(
|
||||||
|
_In_ dds_entity *e)
|
||||||
|
{
|
||||||
|
const dds_topic *topic = NULL;
|
||||||
|
|
||||||
|
assert (e);
|
||||||
|
assert ((dds_entity_kind(e->m_hdl) == DDS_KIND_READER) || (dds_entity_kind(e->m_hdl) == DDS_KIND_WRITER));
|
||||||
|
|
||||||
|
if (dds_entity_kind(e->m_hdl) == DDS_KIND_READER) {
|
||||||
|
topic = ((dds_reader*)e)->m_topic;
|
||||||
|
} else {
|
||||||
|
topic = ((dds_writer*)e)->m_topic;
|
||||||
|
}
|
||||||
|
return topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const dds_topic * dds_instance_info_by_hdl (dds_entity_t e)
|
||||||
|
{
|
||||||
|
const dds_topic * topic = NULL;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_entity *w_or_r;
|
||||||
|
|
||||||
|
rc = dds_entity_lock(e, DDS_KIND_WRITER, &w_or_r);
|
||||||
|
if (rc == DDS_RETCODE_ILLEGAL_OPERATION) {
|
||||||
|
rc = dds_entity_lock(e, DDS_KIND_READER, &w_or_r);
|
||||||
|
}
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
topic = dds_instance_info(w_or_r);
|
||||||
|
dds_entity_unlock(w_or_r);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DDS_ERROR(rc, "Error occurred on locking entity");
|
||||||
|
}
|
||||||
|
return topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_register_instance(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_Out_ dds_instance_handle_t *handle,
|
||||||
|
_In_ const void *data)
|
||||||
|
{
|
||||||
|
struct tkmap_instance * inst;
|
||||||
|
dds_entity *wr;
|
||||||
|
dds_return_t ret;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if(data == NULL){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data is NULL");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if(handle == NULL){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument handle is NULL");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
rc = dds_entity_lock(writer, DDS_KIND_WRITER, &wr);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking writer");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
inst = dds_instance_find (((dds_writer*) wr)->m_topic, data, true);
|
||||||
|
if(inst != NULL){
|
||||||
|
*handle = inst->m_iid;
|
||||||
|
ret = DDS_RETCODE_OK;
|
||||||
|
} else{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Unable to create instance");
|
||||||
|
}
|
||||||
|
dds_entity_unlock(wr);
|
||||||
|
err:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_unregister_instance(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_opt_ const void *data)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds_unregister_instance_ts (writer, data, dds_time());
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_unregister_instance_ih(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_opt_ dds_instance_handle_t handle)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds_unregister_instance_ih_ts(writer, handle, dds_time());
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_unregister_instance_ts(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_opt_ const void *data,
|
||||||
|
_In_ dds_time_t timestamp)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
bool autodispose = true;
|
||||||
|
dds_write_action action = DDS_WR_ACTION_UNREGISTER;
|
||||||
|
void * sample = (void*) data;
|
||||||
|
dds_entity *wr;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (data == NULL){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data is NULL");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if(timestamp < 0){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument timestamp has negative value");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
rc = dds_entity_lock(writer, DDS_KIND_WRITER, &wr);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking writer");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wr->m_qos) {
|
||||||
|
dds_qget_writer_data_lifecycle (wr->m_qos, &autodispose);
|
||||||
|
}
|
||||||
|
if (autodispose) {
|
||||||
|
dds_instance_remove (((dds_writer*) wr)->m_topic, data, DDS_HANDLE_NIL);
|
||||||
|
action |= DDS_WR_DISPOSE_BIT;
|
||||||
|
}
|
||||||
|
ret = dds_write_impl ((dds_writer*)wr, sample, timestamp, action);
|
||||||
|
dds_entity_unlock(wr);
|
||||||
|
err:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_unregister_instance_ih_ts(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_opt_ dds_instance_handle_t handle,
|
||||||
|
_In_ dds_time_t timestamp)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
bool autodispose = true;
|
||||||
|
dds_write_action action = DDS_WR_ACTION_UNREGISTER;
|
||||||
|
dds_entity *wr;
|
||||||
|
struct tkmap *map;
|
||||||
|
const dds_topic *topic;
|
||||||
|
void *sample;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_entity_lock(writer, DDS_KIND_WRITER, &wr);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking writer");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wr->m_qos) {
|
||||||
|
dds_qget_writer_data_lifecycle (wr->m_qos, &autodispose);
|
||||||
|
}
|
||||||
|
if (autodispose) {
|
||||||
|
dds_instance_remove (((dds_writer*) wr)->m_topic, NULL, handle);
|
||||||
|
action |= DDS_WR_DISPOSE_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
map = gv.m_tkmap;
|
||||||
|
topic = dds_instance_info((dds_entity*)wr);
|
||||||
|
sample = dds_alloc (topic->m_descriptor->m_size);
|
||||||
|
if (dds_tkmap_get_key (map, handle, sample)) {
|
||||||
|
ret = dds_write_impl ((dds_writer*)wr, sample, timestamp, action);
|
||||||
|
} else{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "No instance related with the provided handle is found");
|
||||||
|
}
|
||||||
|
dds_sample_free (sample, topic->m_descriptor, DDS_FREE_ALL);
|
||||||
|
|
||||||
|
dds_entity_unlock(wr);
|
||||||
|
err:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_writedispose_ts(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_ const void *data,
|
||||||
|
_In_ dds_time_t timestamp)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_writer *wr;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_writer_lock(writer, &wr);
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
ret = dds_write_impl (wr, data, timestamp, DDS_WR_ACTION_WRITE_DISPOSE);
|
||||||
|
if (ret == DDS_RETCODE_OK) {
|
||||||
|
dds_instance_remove (wr->m_topic, data, DDS_HANDLE_NIL);
|
||||||
|
}
|
||||||
|
dds_writer_unlock(wr);
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking writer");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_dispose_impl(
|
||||||
|
_In_ dds_writer *wr,
|
||||||
|
_In_ const void *data,
|
||||||
|
_In_ dds_instance_handle_t handle,
|
||||||
|
_In_ dds_time_t timestamp)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
assert(wr);
|
||||||
|
ret = dds_write_impl(wr, data, timestamp, DDS_WR_ACTION_DISPOSE);
|
||||||
|
if (ret == DDS_RETCODE_OK) {
|
||||||
|
dds_instance_remove (wr->m_topic, data, handle);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_dispose_ts(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_ const void *data,
|
||||||
|
_In_ dds_time_t timestamp)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_writer *wr;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_writer_lock(writer, &wr);
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
ret = dds_dispose_impl(wr, data, DDS_HANDLE_NIL, timestamp);
|
||||||
|
dds_writer_unlock(wr);
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking writer");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
|
||||||
|
dds_return_t
|
||||||
|
dds_dispose_ih_ts(
|
||||||
|
_In_ dds_entity_t writer,
|
||||||
|
_In_ dds_instance_handle_t handle,
|
||||||
|
_In_ dds_time_t timestamp)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_writer *wr;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_writer_lock(writer, &wr);
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
struct tkmap *map = gv.m_tkmap;
|
||||||
|
const dds_topic *topic = dds_instance_info((dds_entity*)wr);
|
||||||
|
void *sample = dds_alloc (topic->m_descriptor->m_size);
|
||||||
|
if (dds_tkmap_get_key (map, handle, sample)) {
|
||||||
|
ret = dds_dispose_impl(wr, sample, handle, timestamp);
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "No instance related with the provided handle is found");
|
||||||
|
}
|
||||||
|
dds_free(sample);
|
||||||
|
dds_writer_unlock(wr);
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking writer");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(entity & DDS_ENTITY_KIND_MASK)
|
||||||
|
dds_instance_handle_t
|
||||||
|
dds_instance_lookup(
|
||||||
|
dds_entity_t entity,
|
||||||
|
const void *data)
|
||||||
|
{
|
||||||
|
dds_instance_handle_t ih = DDS_HANDLE_NIL;
|
||||||
|
const dds_topic * topic;
|
||||||
|
struct tkmap * map = gv.m_tkmap;
|
||||||
|
serdata_t sd;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if(data == NULL){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data is NULL");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
topic = dds_instance_info_by_hdl (entity);
|
||||||
|
if (topic) {
|
||||||
|
sd = serialize_key (gv.serpool, topic->m_stopic, data);
|
||||||
|
ih = dds_tkmap_lookup (map, sd);
|
||||||
|
ddsi_serdata_unref (sd);
|
||||||
|
ret = DDS_RETCODE_OK;
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Acquired topic is NULL");
|
||||||
|
}
|
||||||
|
err:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ih;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(entity & DDS_ENTITY_KIND_MASK)
|
||||||
|
int
|
||||||
|
dds_instance_get_key(
|
||||||
|
dds_entity_t entity,
|
||||||
|
dds_instance_handle_t inst,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
const dds_topic * topic;
|
||||||
|
struct tkmap * map = gv.m_tkmap;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if(data == NULL){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument data is NULL");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
topic = dds_instance_info_by_hdl (entity);
|
||||||
|
if(topic == NULL){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Could not find topic related to the given entity");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
memset (data, 0, topic->m_descriptor->m_size);
|
||||||
|
|
||||||
|
if (dds_tkmap_get_key (map, inst, data)) {
|
||||||
|
ret = DDS_RETCODE_OK;
|
||||||
|
} else{
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "No instance related with the provided entity is found");
|
||||||
|
}
|
||||||
|
|
||||||
|
err:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
166
src/core/ddsc/src/dds_key.c
Normal file
166
src/core/ddsc/src/dds_key.c
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "dds__key.h"
|
||||||
|
#include "dds__stream.h"
|
||||||
|
#include "ddsi/ddsi_ser.h"
|
||||||
|
#include "ddsi/q_bswap.h"
|
||||||
|
#include "ddsi/q_md5.h"
|
||||||
|
|
||||||
|
void dds_key_md5 (dds_key_hash_t * kh)
|
||||||
|
{
|
||||||
|
md5_state_t md5st;
|
||||||
|
md5_init (&md5st);
|
||||||
|
md5_append (&md5st, (md5_byte_t*) kh->m_key_buff, kh->m_key_len);
|
||||||
|
md5_finish (&md5st, (unsigned char *) kh->m_hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
dds_key_gen: Generates key and keyhash for a sample.
|
||||||
|
See section 9.6.3.3 of DDSI spec.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void dds_key_gen
|
||||||
|
(
|
||||||
|
const dds_topic_descriptor_t * const desc,
|
||||||
|
dds_key_hash_t * kh,
|
||||||
|
const char * sample
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const char * src;
|
||||||
|
const uint32_t * op;
|
||||||
|
uint32_t i;
|
||||||
|
uint32_t len = 0;
|
||||||
|
char * dst;
|
||||||
|
|
||||||
|
assert (desc->m_nkeys);
|
||||||
|
assert (kh->m_hash[0] == 0 && kh->m_hash[15] == 0);
|
||||||
|
|
||||||
|
kh->m_flags = DDS_KEY_SET | DDS_KEY_HASH_SET;
|
||||||
|
|
||||||
|
/* Select key buffer to use */
|
||||||
|
|
||||||
|
if (desc->m_flagset & DDS_TOPIC_FIXED_KEY)
|
||||||
|
{
|
||||||
|
kh->m_flags |= DDS_KEY_IS_HASH;
|
||||||
|
kh->m_key_len = sizeof (kh->m_hash);
|
||||||
|
dst = kh->m_hash;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Calculate key length */
|
||||||
|
|
||||||
|
for (i = 0; i < desc->m_nkeys; i++)
|
||||||
|
{
|
||||||
|
op = desc->m_ops + desc->m_keys[i].m_index;
|
||||||
|
src = sample + op[1];
|
||||||
|
|
||||||
|
switch (DDS_OP_TYPE (*op))
|
||||||
|
{
|
||||||
|
case DDS_OP_VAL_1BY: len += 1; break;
|
||||||
|
case DDS_OP_VAL_2BY: len += 2; break;
|
||||||
|
case DDS_OP_VAL_4BY: len += 4; break;
|
||||||
|
case DDS_OP_VAL_8BY: len += 8; break;
|
||||||
|
case DDS_OP_VAL_STR: src = *((char**) src); /* Fall-through intentional */
|
||||||
|
case DDS_OP_VAL_BST: len += (uint32_t) (5 + strlen (src)); break;
|
||||||
|
case DDS_OP_VAL_ARR:
|
||||||
|
len += op[2] * dds_op_size[DDS_OP_SUBTYPE (*op)];
|
||||||
|
break;
|
||||||
|
default: assert (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kh->m_key_len = len;
|
||||||
|
if (len > kh->m_key_buff_size)
|
||||||
|
{
|
||||||
|
kh->m_key_buff = dds_realloc_zero (kh->m_key_buff, len);
|
||||||
|
kh->m_key_buff_size = len;
|
||||||
|
}
|
||||||
|
dst = kh->m_key_buff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write keys to buffer (Big Endian CDR encoded with no padding) */
|
||||||
|
|
||||||
|
for (i = 0; i < desc->m_nkeys; i++)
|
||||||
|
{
|
||||||
|
op = desc->m_ops + desc->m_keys[i].m_index;
|
||||||
|
src = sample + op[1];
|
||||||
|
assert ((*op & DDS_OP_FLAG_KEY) && ((DDS_OP_MASK & *op) == DDS_OP_ADR));
|
||||||
|
|
||||||
|
switch (DDS_OP_TYPE (*op))
|
||||||
|
{
|
||||||
|
case DDS_OP_VAL_1BY:
|
||||||
|
{
|
||||||
|
*dst = *src;
|
||||||
|
dst++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_2BY:
|
||||||
|
{
|
||||||
|
uint16_t u16 = toBE2u (*((const uint16_t*) src));
|
||||||
|
memcpy (dst, &u16, sizeof (u16));
|
||||||
|
dst += sizeof (u16);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_4BY:
|
||||||
|
{
|
||||||
|
uint32_t u32 = toBE4u (*((const uint32_t*) src));
|
||||||
|
memcpy (dst, &u32, sizeof (u32));
|
||||||
|
dst += sizeof (u32);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_8BY:
|
||||||
|
{
|
||||||
|
uint64_t u64 = toBE8u (*((const uint64_t*) src));
|
||||||
|
memcpy (dst, &u64, sizeof (u64));
|
||||||
|
dst += sizeof (u64);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_STR:
|
||||||
|
{
|
||||||
|
src = *((char**) src);
|
||||||
|
} /* Fall-through intentional */
|
||||||
|
case DDS_OP_VAL_BST:
|
||||||
|
{
|
||||||
|
uint32_t u32;
|
||||||
|
len = (uint32_t) (strlen (src) + 1);
|
||||||
|
u32 = toBE4u (len);
|
||||||
|
memcpy (dst, &u32, sizeof (u32));
|
||||||
|
dst += sizeof (u32);
|
||||||
|
memcpy (dst, src, len);
|
||||||
|
dst += len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_OP_VAL_ARR:
|
||||||
|
{
|
||||||
|
uint32_t size = dds_op_size[DDS_OP_SUBTYPE (*op)];
|
||||||
|
len = size * op[2];
|
||||||
|
memcpy (dst, src, len);
|
||||||
|
if (dds_stream_endian () && (size != 1u))
|
||||||
|
{
|
||||||
|
dds_stream_swap (dst, size, op[2]);
|
||||||
|
}
|
||||||
|
dst += len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: assert (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hash is md5 of key */
|
||||||
|
|
||||||
|
if ((kh->m_flags & DDS_KEY_IS_HASH) == 0)
|
||||||
|
{
|
||||||
|
dds_key_md5 (kh);
|
||||||
|
}
|
||||||
|
}
|
||||||
462
src/core/ddsc/src/dds_listener.c
Normal file
462
src/core/ddsc/src/dds_listener.c
Normal file
|
|
@ -0,0 +1,462 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
#include "dds__listener.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_Ret_notnull_
|
||||||
|
dds_listener_t*
|
||||||
|
dds_listener_create(_In_opt_ void* arg)
|
||||||
|
{
|
||||||
|
c_listener_t *l = dds_alloc(sizeof(*l));
|
||||||
|
dds_listener_reset(l);
|
||||||
|
l->arg = arg;
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_listener_delete(_In_ _Post_invalid_ dds_listener_t * __restrict listener)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
dds_free(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_listener_reset(_Out_ dds_listener_t * __restrict listener)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
c_listener_t *l = listener;
|
||||||
|
l->on_data_available = DDS_LUNSET;
|
||||||
|
l->on_data_on_readers = DDS_LUNSET;
|
||||||
|
l->on_inconsistent_topic = DDS_LUNSET;
|
||||||
|
l->on_liveliness_changed = DDS_LUNSET;
|
||||||
|
l->on_liveliness_lost = DDS_LUNSET;
|
||||||
|
l->on_offered_deadline_missed = DDS_LUNSET;
|
||||||
|
l->on_offered_incompatible_qos = DDS_LUNSET;
|
||||||
|
l->on_publication_matched = DDS_LUNSET;
|
||||||
|
l->on_requested_deadline_missed = DDS_LUNSET;
|
||||||
|
l->on_requested_incompatible_qos = DDS_LUNSET;
|
||||||
|
l->on_sample_lost = DDS_LUNSET;
|
||||||
|
l->on_sample_rejected = DDS_LUNSET;
|
||||||
|
l->on_subscription_matched = DDS_LUNSET;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_listener_copy(_Out_ dds_listener_t * __restrict dst, _In_ const dds_listener_t * __restrict src)
|
||||||
|
{
|
||||||
|
const c_listener_t *srcl = src;
|
||||||
|
c_listener_t *dstl = dst;
|
||||||
|
|
||||||
|
if(!src){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument source(src) is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!dst){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument destination(dst) is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
dstl->on_data_available = srcl->on_data_available;
|
||||||
|
dstl->on_data_on_readers = srcl->on_data_on_readers;
|
||||||
|
dstl->on_inconsistent_topic = srcl->on_inconsistent_topic;
|
||||||
|
dstl->on_liveliness_changed = srcl->on_liveliness_changed;
|
||||||
|
dstl->on_liveliness_lost = srcl->on_liveliness_lost;
|
||||||
|
dstl->on_offered_deadline_missed = srcl->on_offered_deadline_missed;
|
||||||
|
dstl->on_offered_incompatible_qos = srcl->on_offered_incompatible_qos;
|
||||||
|
dstl->on_publication_matched = srcl->on_publication_matched;
|
||||||
|
dstl->on_requested_deadline_missed = srcl->on_requested_deadline_missed;
|
||||||
|
dstl->on_requested_incompatible_qos = srcl->on_requested_incompatible_qos;
|
||||||
|
dstl->on_sample_lost = srcl->on_sample_lost;
|
||||||
|
dstl->on_sample_rejected = srcl->on_sample_rejected;
|
||||||
|
dstl->on_subscription_matched = srcl->on_subscription_matched;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_listener_merge (_Inout_ dds_listener_t * __restrict dst, _In_ const dds_listener_t * __restrict src)
|
||||||
|
{
|
||||||
|
const c_listener_t *srcl = src;
|
||||||
|
c_listener_t *dstl = dst;
|
||||||
|
|
||||||
|
if(!src){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument source(src) is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!dst){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument destination(dst) is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (dstl->on_data_available == DDS_LUNSET) {
|
||||||
|
dstl->on_data_available = srcl->on_data_available;
|
||||||
|
}
|
||||||
|
if (dstl->on_data_on_readers == DDS_LUNSET) {
|
||||||
|
dstl->on_data_on_readers = srcl->on_data_on_readers;
|
||||||
|
}
|
||||||
|
if (dstl->on_inconsistent_topic == DDS_LUNSET) {
|
||||||
|
dstl->on_inconsistent_topic = srcl->on_inconsistent_topic;
|
||||||
|
}
|
||||||
|
if (dstl->on_liveliness_changed == DDS_LUNSET) {
|
||||||
|
dstl->on_liveliness_changed = srcl->on_liveliness_changed;
|
||||||
|
}
|
||||||
|
if (dstl->on_liveliness_lost == DDS_LUNSET) {
|
||||||
|
dstl->on_liveliness_lost = srcl->on_liveliness_lost;
|
||||||
|
}
|
||||||
|
if (dstl->on_offered_deadline_missed == DDS_LUNSET) {
|
||||||
|
dstl->on_offered_deadline_missed = srcl->on_offered_deadline_missed;
|
||||||
|
}
|
||||||
|
if (dstl->on_offered_incompatible_qos == DDS_LUNSET) {
|
||||||
|
dstl->on_offered_incompatible_qos = srcl->on_offered_incompatible_qos;
|
||||||
|
}
|
||||||
|
if (dstl->on_publication_matched == DDS_LUNSET) {
|
||||||
|
dstl->on_publication_matched = srcl->on_publication_matched;
|
||||||
|
}
|
||||||
|
if (dstl->on_requested_deadline_missed == DDS_LUNSET) {
|
||||||
|
dstl->on_requested_deadline_missed = srcl->on_requested_deadline_missed;
|
||||||
|
}
|
||||||
|
if (dstl->on_requested_incompatible_qos == DDS_LUNSET) {
|
||||||
|
dstl->on_requested_incompatible_qos = srcl->on_requested_incompatible_qos;
|
||||||
|
}
|
||||||
|
if (dstl->on_sample_lost == DDS_LUNSET) {
|
||||||
|
dstl->on_sample_lost = srcl->on_sample_lost;
|
||||||
|
}
|
||||||
|
if (dstl->on_sample_rejected == DDS_LUNSET) {
|
||||||
|
dstl->on_sample_rejected = srcl->on_sample_rejected;
|
||||||
|
}
|
||||||
|
if (dstl->on_subscription_matched == DDS_LUNSET) {
|
||||||
|
dstl->on_subscription_matched = srcl->on_subscription_matched;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************************************
|
||||||
|
* Setters
|
||||||
|
************************************************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_data_available (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_data_available_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_data_available = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_data_on_readers (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_data_on_readers_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_data_on_readers = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_inconsistent_topic (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_inconsistent_topic_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_inconsistent_topic = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_liveliness_changed (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_liveliness_changed_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_liveliness_changed = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_liveliness_lost (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_liveliness_lost_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_liveliness_lost = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_offered_deadline_missed (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_offered_deadline_missed_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_offered_deadline_missed = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_offered_incompatible_qos (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_offered_incompatible_qos_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_offered_incompatible_qos = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_publication_matched (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_publication_matched_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_publication_matched = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_requested_deadline_missed (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_requested_deadline_missed_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_requested_deadline_missed = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_requested_incompatible_qos (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_requested_incompatible_qos_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_requested_incompatible_qos = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_sample_lost (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_sample_lost_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_sample_lost = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_sample_rejected (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_sample_rejected_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_sample_rejected = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lset_subscription_matched (_Inout_ dds_listener_t * __restrict listener, _In_opt_ dds_on_subscription_matched_fn callback)
|
||||||
|
{
|
||||||
|
if (listener) {
|
||||||
|
((c_listener_t*)listener)->on_subscription_matched = callback;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************************************
|
||||||
|
* Getters
|
||||||
|
************************************************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_data_available (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_data_available_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_data_available;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_data_on_readers (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_data_on_readers_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_data_on_readers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_lget_inconsistent_topic (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_inconsistent_topic_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_inconsistent_topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_liveliness_changed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_liveliness_changed_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_liveliness_changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_liveliness_lost (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_liveliness_lost_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_liveliness_lost;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_offered_deadline_missed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_offered_deadline_missed_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_offered_deadline_missed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_offered_incompatible_qos (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_offered_incompatible_qos_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_offered_incompatible_qos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_publication_matched (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_publication_matched_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_publication_matched;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_requested_deadline_missed (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_requested_deadline_missed_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_requested_deadline_missed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_requested_incompatible_qos (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_requested_incompatible_qos_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_requested_incompatible_qos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_sample_lost (_In_ const dds_listener_t *__restrict listener, _Outptr_result_maybenull_ dds_on_sample_lost_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_sample_lost;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_sample_rejected (_In_ const dds_listener_t *__restrict listener, _Outptr_result_maybenull_ dds_on_sample_rejected_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_sample_rejected;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_lget_subscription_matched (_In_ const dds_listener_t * __restrict listener, _Outptr_result_maybenull_ dds_on_subscription_matched_fn *callback)
|
||||||
|
{
|
||||||
|
if(!callback) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument callback is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (!listener) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument listener is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*callback = ((c_listener_t*)listener)->on_subscription_matched;
|
||||||
|
}
|
||||||
73
src/core/ddsc/src/dds_log.c
Normal file
73
src/core/ddsc/src/dds_log.c
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
#include "ddsi/q_log.h"
|
||||||
|
|
||||||
|
#define DDS_FMT_MAX 128
|
||||||
|
|
||||||
|
void dds_log_info (const char * fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start (args, fmt);
|
||||||
|
nn_vlog (LC_INFO, fmt, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_log_warn (const char * fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
char fmt2 [DDS_FMT_MAX];
|
||||||
|
|
||||||
|
strcpy (fmt2, "<Warning> ");
|
||||||
|
strncat (fmt2, fmt, DDS_FMT_MAX - 11);
|
||||||
|
fmt2[DDS_FMT_MAX-1] = 0;
|
||||||
|
fmt = fmt2;
|
||||||
|
|
||||||
|
va_start (args, fmt);
|
||||||
|
nn_vlog (LC_WARNING, fmt, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_log_error (const char * fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
char fmt2 [DDS_FMT_MAX];
|
||||||
|
|
||||||
|
strcpy (fmt2, "<Error> ");
|
||||||
|
strncat (fmt2, fmt, DDS_FMT_MAX - 9);
|
||||||
|
fmt2[DDS_FMT_MAX-1] = 0;
|
||||||
|
fmt = fmt2;
|
||||||
|
|
||||||
|
va_start (args, fmt);
|
||||||
|
nn_vlog (LC_ERROR, fmt, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_log_fatal (const char * fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
char fmt2 [DDS_FMT_MAX];
|
||||||
|
|
||||||
|
strcpy (fmt2, "<Fatal> ");
|
||||||
|
strncat (fmt2, fmt, DDS_FMT_MAX - 9);
|
||||||
|
fmt2[DDS_FMT_MAX-1] = 0;
|
||||||
|
fmt = fmt2;
|
||||||
|
|
||||||
|
va_start (args, fmt);
|
||||||
|
nn_vlog (LC_FATAL, fmt, args);
|
||||||
|
va_end (args);
|
||||||
|
DDS_FAIL (fmt);
|
||||||
|
}
|
||||||
289
src/core/ddsc/src/dds_participant.c
Normal file
289
src/core/ddsc/src/dds_participant.c
Normal file
|
|
@ -0,0 +1,289 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include "ddsi/q_entity.h"
|
||||||
|
#include "ddsi/q_thread.h"
|
||||||
|
#include "ddsi/q_config.h"
|
||||||
|
#include "q__osplser.h"
|
||||||
|
#include "dds__init.h"
|
||||||
|
#include "dds__qos.h"
|
||||||
|
#include "dds__domain.h"
|
||||||
|
#include "dds__participant.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
#define DDS_PARTICIPANT_STATUS_MASK 0
|
||||||
|
|
||||||
|
/* List of created participants */
|
||||||
|
|
||||||
|
static dds_entity * dds_pp_head = NULL;
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_participant_status_validate(
|
||||||
|
uint32_t mask)
|
||||||
|
{
|
||||||
|
return (mask & ~(DDS_PARTICIPANT_STATUS_MASK)) ?
|
||||||
|
DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument mask is invalid") :
|
||||||
|
DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_participant_delete(
|
||||||
|
dds_entity *e)
|
||||||
|
{
|
||||||
|
struct thread_state1 * const thr = lookup_thread_state ();
|
||||||
|
const bool asleep = !vtime_awake_p (thr->vtime);
|
||||||
|
dds_entity *prev = NULL;
|
||||||
|
dds_entity *iter;
|
||||||
|
|
||||||
|
assert(e);
|
||||||
|
assert(thr);
|
||||||
|
assert(dds_entity_kind(e->m_hdl) == DDS_KIND_PARTICIPANT);
|
||||||
|
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_awake(thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
dds_domain_free (e->m_domain);
|
||||||
|
|
||||||
|
os_mutexLock (&dds_global.m_mutex);
|
||||||
|
iter = dds_pp_head;
|
||||||
|
while (iter) {
|
||||||
|
if (iter == e) {
|
||||||
|
if (prev) {
|
||||||
|
prev->m_next = iter->m_next;
|
||||||
|
} else {
|
||||||
|
dds_pp_head = iter->m_next;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prev = iter;
|
||||||
|
iter = iter->m_next;
|
||||||
|
}
|
||||||
|
os_mutexUnlock (&dds_global.m_mutex);
|
||||||
|
|
||||||
|
assert (iter);
|
||||||
|
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_asleep(thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Every dds_init needs a dds_fini. */
|
||||||
|
dds_fini();
|
||||||
|
|
||||||
|
return DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_participant_instance_hdl(
|
||||||
|
dds_entity *e,
|
||||||
|
dds_instance_handle_t *i)
|
||||||
|
{
|
||||||
|
assert(e);
|
||||||
|
assert(i);
|
||||||
|
*i = (dds_instance_handle_t)participant_instance_id(&e->m_guid);
|
||||||
|
return DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_participant_qos_validate(
|
||||||
|
const dds_qos_t *qos,
|
||||||
|
bool enabled)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
assert(qos);
|
||||||
|
|
||||||
|
/* Check consistency. */
|
||||||
|
if ((qos->present & QP_USER_DATA) && !validate_octetseq(&qos->user_data)) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "User data QoS policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if ((qos->present & QP_PRISMTECH_ENTITY_FACTORY) && !validate_entityfactory_qospolicy(&qos->entity_factory)) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Prismtech entity factory QoS policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_participant_qos_set(
|
||||||
|
dds_entity *e,
|
||||||
|
const dds_qos_t *qos,
|
||||||
|
bool enabled)
|
||||||
|
{
|
||||||
|
dds_return_t ret = dds_participant_qos_validate(qos, enabled);
|
||||||
|
if (ret == DDS_RETCODE_OK) {
|
||||||
|
if (enabled) {
|
||||||
|
/* TODO: CHAM-95: DDSI does not support changing QoS policies. */
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Changing the participant QoS is not supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds_create_participant(
|
||||||
|
_In_ const dds_domainid_t domain,
|
||||||
|
_In_opt_ const dds_qos_t *qos,
|
||||||
|
_In_opt_ const dds_listener_t *listener)
|
||||||
|
{
|
||||||
|
int q_rc;
|
||||||
|
dds_return_t ret;
|
||||||
|
dds_entity_t e;
|
||||||
|
nn_guid_t guid;
|
||||||
|
dds_participant * pp;
|
||||||
|
nn_plist_t plist;
|
||||||
|
dds_qos_t * new_qos = NULL;
|
||||||
|
struct thread_state1 * thr;
|
||||||
|
bool asleep;
|
||||||
|
|
||||||
|
/* Be sure the DDS lifecycle resources are initialized. */
|
||||||
|
dds__startup();
|
||||||
|
|
||||||
|
/* Make sure DDS instance is initialized. */
|
||||||
|
ret = dds_init();
|
||||||
|
if (ret != DDS_RETCODE_OK) {
|
||||||
|
e = (dds_entity_t)ret;
|
||||||
|
goto fail_dds_init;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Report stack is only useful after dds (and thus os) init. */
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
/* Check domain id */
|
||||||
|
ret = dds__check_domain (domain);
|
||||||
|
if (ret != DDS_RETCODE_OK) {
|
||||||
|
e = (dds_entity_t)ret;
|
||||||
|
goto fail_domain_check;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate qos */
|
||||||
|
if (qos) {
|
||||||
|
ret = dds_participant_qos_validate (qos, false);
|
||||||
|
if (ret != DDS_RETCODE_OK) {
|
||||||
|
e = (dds_entity_t)ret;
|
||||||
|
goto fail_qos_validation;
|
||||||
|
}
|
||||||
|
new_qos = dds_qos_create ();
|
||||||
|
/* Only returns failure when one of the qos args is NULL, which
|
||||||
|
* is not the case here. */
|
||||||
|
(void)dds_qos_copy(new_qos, qos);
|
||||||
|
} else {
|
||||||
|
/* Use default qos. */
|
||||||
|
new_qos = dds_qos_create ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Translate qos */
|
||||||
|
nn_plist_init_empty(&plist);
|
||||||
|
dds_qos_merge (&plist.qos, new_qos);
|
||||||
|
|
||||||
|
thr = lookup_thread_state ();
|
||||||
|
asleep = !vtime_awake_p (thr->vtime);
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_awake (thr);
|
||||||
|
}
|
||||||
|
q_rc = new_participant (&guid, 0, &plist);
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_asleep (thr);
|
||||||
|
}
|
||||||
|
nn_plist_fini (&plist);
|
||||||
|
if (q_rc != 0) {
|
||||||
|
e = DDS_ERRNO(DDS_RETCODE_ERROR, "Internal error");
|
||||||
|
goto fail_new_participant;
|
||||||
|
}
|
||||||
|
|
||||||
|
pp = dds_alloc (sizeof (*pp));
|
||||||
|
e = dds_entity_init (&pp->m_entity, NULL, DDS_KIND_PARTICIPANT, new_qos, listener, DDS_PARTICIPANT_STATUS_MASK);
|
||||||
|
if (e < 0) {
|
||||||
|
goto fail_entity_init;
|
||||||
|
}
|
||||||
|
|
||||||
|
pp->m_entity.m_guid = guid;
|
||||||
|
pp->m_entity.m_domain = dds_domain_create (dds_domain_default());
|
||||||
|
pp->m_entity.m_domainid = dds_domain_default();
|
||||||
|
pp->m_entity.m_deriver.delete = dds_participant_delete;
|
||||||
|
pp->m_entity.m_deriver.set_qos = dds_participant_qos_set;
|
||||||
|
pp->m_entity.m_deriver.get_instance_hdl = dds_participant_instance_hdl;
|
||||||
|
pp->m_entity.m_deriver.validate_status = dds_participant_status_validate;
|
||||||
|
pp->m_builtin_subscriber = 0;
|
||||||
|
|
||||||
|
/* Add participant to extent */
|
||||||
|
os_mutexLock (&dds_global.m_mutex);
|
||||||
|
pp->m_entity.m_next = dds_pp_head;
|
||||||
|
dds_pp_head = &pp->m_entity;
|
||||||
|
os_mutexUnlock (&dds_global.m_mutex);
|
||||||
|
|
||||||
|
DDS_REPORT_FLUSH(false);
|
||||||
|
return e;
|
||||||
|
|
||||||
|
fail_entity_init:
|
||||||
|
dds_free(pp);
|
||||||
|
fail_new_participant:
|
||||||
|
dds_qos_delete(new_qos);
|
||||||
|
fail_qos_validation:
|
||||||
|
fail_domain_check:
|
||||||
|
DDS_REPORT_FLUSH(true);
|
||||||
|
dds_fini();
|
||||||
|
fail_dds_init:
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Check_return_ dds_return_t
|
||||||
|
dds_lookup_participant(
|
||||||
|
_In_ dds_domainid_t domain_id,
|
||||||
|
_Out_opt_ dds_entity_t *participants,
|
||||||
|
_In_ size_t size)
|
||||||
|
{
|
||||||
|
dds_return_t ret = 0;
|
||||||
|
|
||||||
|
/* Be sure the DDS lifecycle resources are initialized. */
|
||||||
|
dds__startup();
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if ((participants != NULL) && ((size <= 0) || (size >= INT32_MAX))) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Array is given, but with invalid size");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if ((participants == NULL) && (size != 0)) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Size is given, but no array");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(participants){
|
||||||
|
participants[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_mutexLock (&dds__init_mutex);
|
||||||
|
|
||||||
|
/* Check if dds is intialized. */
|
||||||
|
if (dds_global.m_init_count > 0) {
|
||||||
|
dds_entity* iter;
|
||||||
|
os_mutexLock (&dds_global.m_mutex);
|
||||||
|
iter = dds_pp_head;
|
||||||
|
while (iter) {
|
||||||
|
if(iter->m_domainid == domain_id) {
|
||||||
|
if((size_t)ret < size) {
|
||||||
|
participants[ret] = iter->m_hdl;
|
||||||
|
}
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
iter = iter->m_next;
|
||||||
|
}
|
||||||
|
os_mutexUnlock (&dds_global.m_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
os_mutexUnlock (&dds__init_mutex);
|
||||||
|
|
||||||
|
err:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
220
src/core/ddsc/src/dds_publisher.c
Normal file
220
src/core/ddsc/src/dds_publisher.c
Normal file
|
|
@ -0,0 +1,220 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "dds__listener.h"
|
||||||
|
#include "dds__qos.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "ddsi/q_entity.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
#include "ddsc/ddsc_project.h"
|
||||||
|
|
||||||
|
#define DDS_PUBLISHER_STATUS_MASK 0
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_publisher_instance_hdl(
|
||||||
|
dds_entity *e,
|
||||||
|
dds_instance_handle_t *i)
|
||||||
|
{
|
||||||
|
assert(e);
|
||||||
|
assert(i);
|
||||||
|
/* TODO: Get/generate proper handle. */
|
||||||
|
return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Getting publisher instance handle is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_publisher_qos_validate(
|
||||||
|
_In_ const dds_qos_t *qos,
|
||||||
|
_In_ bool enabled)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
assert(qos);
|
||||||
|
|
||||||
|
/* Check consistency. */
|
||||||
|
if((qos->present & QP_GROUP_DATA) && !validate_octetseq(&qos->group_data)){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Group data policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if((qos->present & QP_PRESENTATION) && (validate_presentation_qospolicy(&qos->presentation) != 0)){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Presentation policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if((qos->present & QP_PARTITION) && !validate_stringseq(&qos->partition)){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Partition policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if((qos->present & QP_PRISMTECH_ENTITY_FACTORY) && !validate_entityfactory_qospolicy(&qos->entity_factory)){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Prismtech entity factory policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if(ret == DDS_RETCODE_OK && enabled && (qos->present & QP_PRESENTATION)){
|
||||||
|
/* TODO: Improve/check immutable check. */
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Presentation policy is immutable");
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_publisher_qos_set(
|
||||||
|
dds_entity *e,
|
||||||
|
const dds_qos_t *qos,
|
||||||
|
bool enabled)
|
||||||
|
{
|
||||||
|
dds_return_t ret = dds_publisher_qos_validate(qos, enabled);
|
||||||
|
if (ret == DDS_RETCODE_OK) {
|
||||||
|
if (enabled) {
|
||||||
|
/* TODO: CHAM-95: DDSI does not support changing QoS policies. */
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, DDSC_PROJECT_NAME" does not support changing QoS policies yet");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t dds_publisher_status_validate (uint32_t mask)
|
||||||
|
{
|
||||||
|
return (mask & ~(DDS_PUBLISHER_STATUS_MASK)) ?
|
||||||
|
DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Invalid status mask") :
|
||||||
|
DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((participant & DDS_ENTITY_KIND_MASK) == DDS_KIND_PARTICIPANT)
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds_create_publisher(
|
||||||
|
_In_ dds_entity_t participant,
|
||||||
|
_In_opt_ const dds_qos_t *qos,
|
||||||
|
_In_opt_ const dds_listener_t *listener)
|
||||||
|
{
|
||||||
|
dds_entity * par;
|
||||||
|
dds_publisher * pub;
|
||||||
|
dds_entity_t hdl;
|
||||||
|
dds_qos_t * new_qos = NULL;
|
||||||
|
dds_return_t ret;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_entity_lock(participant, DDS_KIND_PARTICIPANT, &par);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
hdl = DDS_ERRNO(rc, "Error occurred on locking participant");
|
||||||
|
goto lock_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate qos */
|
||||||
|
if (qos) {
|
||||||
|
ret = dds_publisher_qos_validate(qos, false);
|
||||||
|
if (ret != DDS_RETCODE_OK) {
|
||||||
|
hdl = ret;
|
||||||
|
goto qos_err;
|
||||||
|
}
|
||||||
|
new_qos = dds_qos_create ();
|
||||||
|
/* Only returns failure when one of the qos args is NULL, which
|
||||||
|
* is not the case here. */
|
||||||
|
(void)dds_qos_copy(new_qos, qos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create publisher */
|
||||||
|
pub = dds_alloc (sizeof (*pub));
|
||||||
|
hdl = dds_entity_init (&pub->m_entity, par, DDS_KIND_PUBLISHER, new_qos, listener, DDS_PUBLISHER_STATUS_MASK);
|
||||||
|
pub->m_entity.m_deriver.set_qos = dds_publisher_qos_set;
|
||||||
|
pub->m_entity.m_deriver.get_instance_hdl = dds_publisher_instance_hdl;
|
||||||
|
pub->m_entity.m_deriver.validate_status = dds_publisher_status_validate;
|
||||||
|
|
||||||
|
qos_err:
|
||||||
|
dds_entity_unlock(par);
|
||||||
|
lock_err:
|
||||||
|
DDS_REPORT_FLUSH(hdl <= 0);
|
||||||
|
return hdl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_((publisher & DDS_ENTITY_KIND_MASK) == DDS_KIND_PUBLISHER)
|
||||||
|
DDS_EXPORT dds_return_t
|
||||||
|
dds_suspend(
|
||||||
|
_In_ dds_entity_t publisher)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if(dds_entity_kind(publisher) != DDS_KIND_PUBLISHER) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Provided entity is not a publisher kind");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* TODO: CHAM-123 Currently unsupported. */
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Suspend publication operation does not being supported yet");
|
||||||
|
err:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_((publisher & DDS_ENTITY_KIND_MASK) == DDS_KIND_PUBLISHER)
|
||||||
|
dds_return_t
|
||||||
|
dds_resume(
|
||||||
|
_In_ dds_entity_t publisher)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if(dds_entity_kind(publisher) != DDS_KIND_PUBLISHER) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER,"Provided entity is not a publisher kind");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* TODO: CHAM-123 Currently unsupported. */
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Suspend publication operation does not being supported yet");
|
||||||
|
err:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_(((publisher_or_writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER ) ||\
|
||||||
|
((publisher_or_writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_PUBLISHER) )
|
||||||
|
dds_return_t
|
||||||
|
dds_wait_for_acks(
|
||||||
|
_In_ dds_entity_t publisher_or_writer,
|
||||||
|
_In_ dds_duration_t timeout)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
/* TODO: CHAM-125 Currently unsupported. */
|
||||||
|
OS_UNUSED_ARG(timeout);
|
||||||
|
|
||||||
|
switch(dds_entity_kind(publisher_or_writer)) {
|
||||||
|
case DDS_KIND_WRITER:
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Wait for acknowledgments on a writer is not being supported yet");
|
||||||
|
break;
|
||||||
|
case DDS_KIND_PUBLISHER:
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Wait for acknowledgments on a publisher is not being supported yet");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Provided entity is not a publisher nor a writer");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds_publisher_begin_coherent(
|
||||||
|
_In_ dds_entity_t e)
|
||||||
|
{
|
||||||
|
/* TODO: CHAM-124 Currently unsupported. */
|
||||||
|
return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not being supported yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds_publisher_end_coherent(
|
||||||
|
_In_ dds_entity_t e)
|
||||||
|
{
|
||||||
|
/* TODO: CHAM-124 Currently unsupported. */
|
||||||
|
return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not being supported yet");
|
||||||
|
}
|
||||||
|
|
||||||
996
src/core/ddsc/src/dds_qos.c
Normal file
996
src/core/ddsc/src/dds_qos.c
Normal file
|
|
@ -0,0 +1,996 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "dds__qos.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "ddsi/q_config.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
/* TODO: dd_duration_t is converted to nn_ddsi_time_t declared in q_time.h
|
||||||
|
This structure contain seconds and fractions.
|
||||||
|
Revisit on the conversion as default values are { 0x7fffffff, 0xffffffff }
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
dds_qos_data_copy_in(
|
||||||
|
_Inout_ nn_octetseq_t * data,
|
||||||
|
_In_reads_bytes_opt_(sz) const void * __restrict value,
|
||||||
|
_In_ size_t sz)
|
||||||
|
{
|
||||||
|
if (data->value) {
|
||||||
|
dds_free (data->value);
|
||||||
|
data->value = NULL;
|
||||||
|
}
|
||||||
|
data->length = (uint32_t) sz;
|
||||||
|
if (sz && value) {
|
||||||
|
data->value = dds_alloc (sz);
|
||||||
|
memcpy (data->value, value, sz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dds_qos_data_copy_out(
|
||||||
|
_In_ const nn_octetseq_t * data,
|
||||||
|
_When_(*sz == 0, _At_(*value, _Post_null_))
|
||||||
|
_When_(*sz > 0, _At_(*value, _Post_notnull_))
|
||||||
|
_Outptr_result_bytebuffer_all_maybenull_(*sz) void ** value,
|
||||||
|
_Out_ size_t * sz)
|
||||||
|
{
|
||||||
|
if ((*sz = data->length) != 0) {
|
||||||
|
assert(data->value);
|
||||||
|
*value = dds_alloc(data->length);
|
||||||
|
memcpy(*value, data->value, data->length);
|
||||||
|
} else {
|
||||||
|
*value = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
validate_octetseq(
|
||||||
|
const nn_octetseq_t* seq)
|
||||||
|
{
|
||||||
|
/* default value is NULL with length 0 */
|
||||||
|
return (((seq->length == 0) && (seq->value == NULL)) || (seq->length > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
validate_stringseq(
|
||||||
|
const nn_stringseq_t* seq)
|
||||||
|
{
|
||||||
|
if (seq->n != 0) {
|
||||||
|
unsigned i;
|
||||||
|
for (i = 0; i < seq->n; i++) {
|
||||||
|
if (!seq->strs[i]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (seq->n == i);
|
||||||
|
} else {
|
||||||
|
return (seq->strs == NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
validate_entityfactory_qospolicy(
|
||||||
|
const nn_entity_factory_qospolicy_t * entityfactory)
|
||||||
|
{
|
||||||
|
/* Bools must be 0 or 1, i.e., only the lsb may be set */
|
||||||
|
return !(entityfactory->autoenable_created_entities & ~1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
validate_reliability_qospolicy(
|
||||||
|
const nn_reliability_qospolicy_t * reliability)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
(reliability->kind == NN_BEST_EFFORT_RELIABILITY_QOS || reliability->kind == NN_RELIABLE_RELIABILITY_QOS) &&
|
||||||
|
(validate_duration(&reliability->max_blocking_time) == 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
validate_deadline_and_timebased_filter(
|
||||||
|
const nn_duration_t deadline,
|
||||||
|
const nn_duration_t minimum_separation)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
(validate_duration(&deadline) == 0) &&
|
||||||
|
(validate_duration(&minimum_separation) == 0) &&
|
||||||
|
(nn_from_ddsi_duration(minimum_separation) <= nn_from_ddsi_duration(deadline))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
dds_qos_validate_common (
|
||||||
|
const dds_qos_t *qos)
|
||||||
|
{
|
||||||
|
return !(
|
||||||
|
((qos->present & QP_DURABILITY) && (validate_durability_qospolicy (&qos->durability) != 0)) ||
|
||||||
|
((qos->present & QP_DEADLINE) && (validate_duration (&qos->deadline.deadline) != 0)) ||
|
||||||
|
((qos->present & QP_LATENCY_BUDGET) && (validate_duration (&qos->latency_budget.duration) != 0)) ||
|
||||||
|
((qos->present & QP_OWNERSHIP) && (validate_ownership_qospolicy (&qos->ownership) != 0)) ||
|
||||||
|
((qos->present & QP_LIVELINESS) && (validate_liveliness_qospolicy (&qos->liveliness) != 0)) ||
|
||||||
|
((qos->present & QP_RELIABILITY) && ! validate_reliability_qospolicy (&qos->reliability)) ||
|
||||||
|
((qos->present & QP_DESTINATION_ORDER) && (validate_destination_order_qospolicy (&qos->destination_order) != 0)) ||
|
||||||
|
((qos->present & QP_HISTORY) && (validate_history_qospolicy (&qos->history) != 0)) ||
|
||||||
|
((qos->present & QP_RESOURCE_LIMITS) && (validate_resource_limits_qospolicy (&qos->resource_limits) != 0))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds_qos_validate_mutable_common (
|
||||||
|
_In_ const dds_qos_t *qos)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
/* TODO: Check whether immutable QoS are changed should actually incorporate change to current QoS */
|
||||||
|
if (qos->present & QP_DEADLINE) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Deadline QoS policy caused immutable error");
|
||||||
|
}
|
||||||
|
if (qos->present & QP_OWNERSHIP) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Ownership QoS policy caused immutable error");
|
||||||
|
}
|
||||||
|
if (qos->present & QP_LIVELINESS) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Liveliness QoS policy caused immutable error");
|
||||||
|
}
|
||||||
|
if (qos->present & QP_RELIABILITY) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Reliability QoS policy caused immutable error");
|
||||||
|
}
|
||||||
|
if (qos->present & QP_DESTINATION_ORDER) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Destination order QoS policy caused immutable error");
|
||||||
|
}
|
||||||
|
if (qos->present & QP_HISTORY) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "History QoS policy caused immutable error");
|
||||||
|
}
|
||||||
|
if (qos->present & QP_RESOURCE_LIMITS) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_IMMUTABLE_POLICY, "Resource limits QoS policy caused immutable error");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dds_qos_init_defaults (
|
||||||
|
_Inout_ dds_qos_t * __restrict qos)
|
||||||
|
{
|
||||||
|
assert (qos);
|
||||||
|
memset (qos, 0, sizeof (*qos));
|
||||||
|
qos->durability.kind = (nn_durability_kind_t) DDS_DURABILITY_VOLATILE;
|
||||||
|
qos->deadline.deadline = nn_to_ddsi_duration (DDS_INFINITY);
|
||||||
|
qos->durability_service.service_cleanup_delay = nn_to_ddsi_duration (0);
|
||||||
|
qos->durability_service.history.kind = (nn_history_kind_t) DDS_HISTORY_KEEP_LAST;
|
||||||
|
qos->durability_service.history.depth = 1;
|
||||||
|
qos->durability_service.resource_limits.max_samples = DDS_LENGTH_UNLIMITED;
|
||||||
|
qos->durability_service.resource_limits.max_instances = DDS_LENGTH_UNLIMITED;
|
||||||
|
qos->durability_service.resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED;
|
||||||
|
qos->presentation.access_scope = (nn_presentation_access_scope_kind_t) DDS_PRESENTATION_INSTANCE;
|
||||||
|
qos->latency_budget.duration = nn_to_ddsi_duration (0);
|
||||||
|
qos->ownership.kind = (nn_ownership_kind_t) DDS_OWNERSHIP_SHARED;
|
||||||
|
qos->liveliness.kind = (nn_liveliness_kind_t) DDS_LIVELINESS_AUTOMATIC;
|
||||||
|
qos->liveliness.lease_duration = nn_to_ddsi_duration (DDS_INFINITY);
|
||||||
|
qos->time_based_filter.minimum_separation = nn_to_ddsi_duration (0);
|
||||||
|
qos->reliability.kind = (nn_reliability_kind_t) DDS_RELIABILITY_BEST_EFFORT;
|
||||||
|
qos->reliability.max_blocking_time = nn_to_ddsi_duration (DDS_MSECS (100));
|
||||||
|
qos->lifespan.duration = nn_to_ddsi_duration (DDS_INFINITY);
|
||||||
|
qos->destination_order.kind = (nn_destination_order_kind_t) DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP;
|
||||||
|
qos->history.kind = (nn_history_kind_t) DDS_HISTORY_KEEP_LAST;
|
||||||
|
qos->history.depth = 1;
|
||||||
|
qos->resource_limits.max_samples = DDS_LENGTH_UNLIMITED;
|
||||||
|
qos->resource_limits.max_instances = DDS_LENGTH_UNLIMITED;
|
||||||
|
qos->resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED;
|
||||||
|
qos->writer_data_lifecycle.autodispose_unregistered_instances = true;
|
||||||
|
qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = nn_to_ddsi_duration (DDS_INFINITY);
|
||||||
|
qos->reader_data_lifecycle.autopurge_disposed_samples_delay = nn_to_ddsi_duration (DDS_INFINITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Ret_notnull_
|
||||||
|
dds_qos_t * dds_qos_create (void)
|
||||||
|
{
|
||||||
|
dds_qos_t *qos = dds_alloc (sizeof (dds_qos_t));
|
||||||
|
dds_qos_init_defaults (qos);
|
||||||
|
return qos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_qos_reset(
|
||||||
|
_Out_ dds_qos_t * __restrict qos)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
nn_xqos_fini (qos);
|
||||||
|
dds_qos_init_defaults (qos);
|
||||||
|
} else {
|
||||||
|
DDS_WARNING(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_qos_delete(
|
||||||
|
_In_ _Post_invalid_ dds_qos_t * __restrict qos)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
dds_qos_reset(qos);
|
||||||
|
dds_free(qos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dds_return_t
|
||||||
|
dds_qos_copy (
|
||||||
|
_Out_ dds_qos_t * __restrict dst,
|
||||||
|
_In_ const dds_qos_t * __restrict src)
|
||||||
|
{
|
||||||
|
if(!src){
|
||||||
|
return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument source(src) is NULL");
|
||||||
|
}
|
||||||
|
if(!dst){
|
||||||
|
return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument destination(dst) is NULL");
|
||||||
|
}
|
||||||
|
nn_xqos_copy (dst, src);
|
||||||
|
return DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qos_merge (
|
||||||
|
_Inout_ dds_qos_t * __restrict dst,
|
||||||
|
_In_ const dds_qos_t * __restrict src)
|
||||||
|
{
|
||||||
|
if(!src){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument source(src) is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!dst){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument destination(dst) is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
/* Copy qos from source to destination unless already set */
|
||||||
|
nn_xqos_mergein_missing (dst, src);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_userdata(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_reads_bytes_opt_(sz) const void * __restrict value,
|
||||||
|
_In_ size_t sz)
|
||||||
|
{
|
||||||
|
if (!qos) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
dds_qos_data_copy_in(&qos->user_data, value, sz);
|
||||||
|
qos->present |= QP_USER_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_topicdata(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_reads_bytes_opt_(sz) const void * __restrict value,
|
||||||
|
_In_ size_t sz)
|
||||||
|
{
|
||||||
|
if (!qos) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
dds_qos_data_copy_in (&qos->topic_data, value, sz);
|
||||||
|
qos->present |= QP_TOPIC_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_groupdata(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_reads_bytes_opt_(sz) const void * __restrict value,
|
||||||
|
_In_ size_t sz)
|
||||||
|
{
|
||||||
|
if (!qos) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
dds_qos_data_copy_in (&qos->group_data, value, sz);
|
||||||
|
qos->present |= QP_GROUP_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_durability
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_DURABILITY_VOLATILE, DDS_DURABILITY_PERSISTENT) dds_durability_kind_t kind
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->durability.kind = (nn_durability_kind_t) kind;
|
||||||
|
qos->present |= QP_DURABILITY;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_history
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_HISTORY_KEEP_LAST, DDS_HISTORY_KEEP_ALL) dds_history_kind_t kind,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t depth
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->history.kind = (nn_history_kind_t) kind;
|
||||||
|
qos->history.depth = depth;
|
||||||
|
qos->present |= QP_HISTORY;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_resource_limits
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_samples,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_instances,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_samples_per_instance
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->resource_limits.max_samples = max_samples;
|
||||||
|
qos->resource_limits.max_instances = max_instances;
|
||||||
|
qos->resource_limits.max_samples_per_instance = max_samples_per_instance;
|
||||||
|
qos->present |= QP_RESOURCE_LIMITS;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_presentation
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_PRESENTATION_INSTANCE, DDS_PRESENTATION_GROUP) dds_presentation_access_scope_kind_t access_scope,
|
||||||
|
_In_ bool coherent_access,
|
||||||
|
_In_ bool ordered_access
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->presentation.access_scope = (nn_presentation_access_scope_kind_t) access_scope;
|
||||||
|
qos->presentation.coherent_access = coherent_access;
|
||||||
|
qos->presentation.ordered_access = ordered_access;
|
||||||
|
qos->present |= QP_PRESENTATION;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_lifespan
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t lifespan
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->lifespan.duration = nn_to_ddsi_duration (lifespan);
|
||||||
|
qos->present |= QP_LIFESPAN;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_deadline
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t deadline
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->deadline.deadline = nn_to_ddsi_duration (deadline);
|
||||||
|
qos->present |= QP_DEADLINE;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_latency_budget
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t duration
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->latency_budget.duration = nn_to_ddsi_duration (duration);
|
||||||
|
qos->present |= QP_LATENCY_BUDGET;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_ownership
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_OWNERSHIP_SHARED, DDS_OWNERSHIP_EXCLUSIVE) dds_ownership_kind_t kind
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->ownership.kind = (nn_ownership_kind_t) kind;
|
||||||
|
qos->present |= QP_OWNERSHIP;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_ownership_strength
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_ int32_t value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->ownership_strength.value = value;
|
||||||
|
qos->present |= QP_OWNERSHIP_STRENGTH;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_liveliness
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_LIVELINESS_AUTOMATIC, DDS_LIVELINESS_MANUAL_BY_TOPIC) dds_liveliness_kind_t kind,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t lease_duration
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->liveliness.kind = (nn_liveliness_kind_t) kind;
|
||||||
|
qos->liveliness.lease_duration = nn_to_ddsi_duration (lease_duration);
|
||||||
|
qos->present |= QP_LIVELINESS;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_time_based_filter
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t minimum_separation
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->time_based_filter.minimum_separation = nn_to_ddsi_duration (minimum_separation);
|
||||||
|
qos->present |= QP_TIME_BASED_FILTER;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_partition
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_ uint32_t n,
|
||||||
|
_In_count_(n) _Deref_pre_z_ const char ** __restrict ps
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if(!qos) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos may not be NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(n && !ps) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument ps is NULL, but n (%u) > 0", n);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qos->partition.strs != NULL){
|
||||||
|
for (i = 0; i < qos->partition.n; i++) {
|
||||||
|
dds_free(qos->partition.strs[i]);
|
||||||
|
}
|
||||||
|
dds_free(qos->partition.strs);
|
||||||
|
qos->partition.strs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
qos->partition.n = n;
|
||||||
|
if(n){
|
||||||
|
qos->partition.strs = dds_alloc (sizeof (char*) * n);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
len = strlen (ps[i]) + 1;
|
||||||
|
qos->partition.strs[i] = dds_alloc (len);
|
||||||
|
strncpy (qos->partition.strs[i], ps[i], len);
|
||||||
|
}
|
||||||
|
qos->present |= QP_PARTITION;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_reliability
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_RELIABILITY_BEST_EFFORT, DDS_RELIABILITY_RELIABLE) dds_reliability_kind_t kind,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t max_blocking_time
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->reliability.kind = (nn_reliability_kind_t) kind;
|
||||||
|
qos->reliability.max_blocking_time = nn_to_ddsi_duration (max_blocking_time);
|
||||||
|
qos->present |= QP_RELIABILITY;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_transport_priority
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_ int32_t value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->transport_priority.value = value;
|
||||||
|
qos->present |= QP_TRANSPORT_PRIORITY;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_destination_order
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP,
|
||||||
|
DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP) dds_destination_order_kind_t kind
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->destination_order.kind = (nn_destination_order_kind_t) kind;
|
||||||
|
qos->present |= QP_DESTINATION_ORDER;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_writer_data_lifecycle
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_ bool autodispose
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(qos) {
|
||||||
|
qos->writer_data_lifecycle.autodispose_unregistered_instances = autodispose;
|
||||||
|
qos->present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_reader_data_lifecycle
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t autopurge_nowriter_samples_delay,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t autopurge_disposed_samples_delay
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = \
|
||||||
|
nn_to_ddsi_duration (autopurge_nowriter_samples_delay);
|
||||||
|
qos->reader_data_lifecycle.autopurge_disposed_samples_delay = \
|
||||||
|
nn_to_ddsi_duration (autopurge_disposed_samples_delay);
|
||||||
|
qos->present |= QP_PRISMTECH_READER_DATA_LIFECYCLE;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qset_durability_service
|
||||||
|
(
|
||||||
|
_Inout_ dds_qos_t * __restrict qos,
|
||||||
|
_In_range_(0, DDS_INFINITY) dds_duration_t service_cleanup_delay,
|
||||||
|
_In_range_(DDS_HISTORY_KEEP_LAST, DDS_HISTORY_KEEP_ALL) dds_history_kind_t history_kind,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t history_depth,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_samples,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_instances,
|
||||||
|
_In_range_(>=, DDS_LENGTH_UNLIMITED) int32_t max_samples_per_instance
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
qos->durability_service.service_cleanup_delay = nn_to_ddsi_duration (service_cleanup_delay);
|
||||||
|
qos->durability_service.history.kind = (nn_history_kind_t) history_kind;
|
||||||
|
qos->durability_service.history.depth = history_depth;
|
||||||
|
qos->durability_service.resource_limits.max_samples = max_samples;
|
||||||
|
qos->durability_service.resource_limits.max_instances = max_instances;
|
||||||
|
qos->durability_service.resource_limits.max_samples_per_instance = max_samples_per_instance;
|
||||||
|
qos->present |= QP_DURABILITY_SERVICE;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_userdata
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Outptr_result_bytebuffer_maybenull_(*sz) void ** value,
|
||||||
|
_Out_ size_t * sz
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!value) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!sz) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument sz is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
dds_qos_data_copy_out (&qos->user_data, value, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_topicdata
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Outptr_result_bytebuffer_maybenull_(*sz) void ** value,
|
||||||
|
_Out_ size_t * sz
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!value) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!sz) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument sz is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
dds_qos_data_copy_out (&qos->topic_data, value, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_groupdata
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Outptr_result_bytebuffer_maybenull_(*sz) void ** value,
|
||||||
|
_Out_ size_t * sz
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!value) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!sz) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument sz is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
dds_qos_data_copy_out (&qos->group_data, value, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_durability
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_durability_kind_t *kind
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument QoS is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!kind) {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument kind is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*kind = (dds_durability_kind_t) qos->durability.kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_history
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_history_kind_t * kind,
|
||||||
|
_Out_opt_ int32_t *depth
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
if (kind) *kind = (dds_history_kind_t) qos->history.kind;
|
||||||
|
if (depth) *depth = qos->history.depth;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_resource_limits
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ int32_t *max_samples,
|
||||||
|
_Out_opt_ int32_t *max_instances,
|
||||||
|
_Out_opt_ int32_t *max_samples_per_instance
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
if (max_samples) *max_samples = qos->resource_limits.max_samples;
|
||||||
|
if (max_instances) *max_instances = qos->resource_limits.max_instances;
|
||||||
|
if (max_samples_per_instance) {
|
||||||
|
*max_samples_per_instance = qos->resource_limits.max_samples_per_instance;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_presentation
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_presentation_access_scope_kind_t *access_scope,
|
||||||
|
_Out_opt_ bool *coherent_access,
|
||||||
|
_Out_opt_ bool *ordered_access
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
if (access_scope) *access_scope = (dds_presentation_access_scope_kind_t) qos->presentation.access_scope;
|
||||||
|
if (coherent_access) *coherent_access = qos->presentation.coherent_access;
|
||||||
|
if (ordered_access) *ordered_access = qos->presentation.ordered_access;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_lifespan
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_duration_t * lifespan
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!lifespan){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument lifespan is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*lifespan = nn_from_ddsi_duration (qos->lifespan.duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_deadline
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_duration_t * deadline
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!deadline){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument deadline is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*deadline = nn_from_ddsi_duration (qos->deadline.deadline);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_latency_budget
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_duration_t *duration
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!duration){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument duration is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*duration = nn_from_ddsi_duration (qos->latency_budget.duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_ownership
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_ownership_kind_t *kind
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!kind){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument kind is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*kind = (dds_ownership_kind_t) qos->ownership.kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_ownership_strength
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ int32_t *value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!value){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*value = qos->ownership_strength.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_liveliness
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_liveliness_kind_t *kind,
|
||||||
|
_Out_opt_ dds_duration_t *lease_duration
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
if (kind) *kind = (dds_liveliness_kind_t) qos->liveliness.kind;
|
||||||
|
if (lease_duration) *lease_duration = nn_from_ddsi_duration (qos->liveliness.lease_duration);
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_time_based_filter
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_duration_t *minimum_separation
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!minimum_separation){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument minimum_separation is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*minimum_separation = nn_from_ddsi_duration (qos->time_based_filter.minimum_separation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_partition
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ uint32_t *n,
|
||||||
|
_Outptr_opt_result_buffer_all_maybenull_(*n) char *** ps
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!n){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument n is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
*n = qos->partition.n;
|
||||||
|
if ( ps ) {
|
||||||
|
if ( qos->partition.n != 0 ) {
|
||||||
|
*ps = dds_alloc(sizeof(char*) * qos->partition.n);
|
||||||
|
for ( i = 0; i < qos->partition.n; i++ ) {
|
||||||
|
len = strlen(qos->partition.strs[i]) + 1;
|
||||||
|
(*ps)[i] = dds_alloc(len);
|
||||||
|
strncpy((*ps)[i], qos->partition.strs[i], len);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*ps = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_reliability
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_reliability_kind_t *kind,
|
||||||
|
_Out_opt_ dds_duration_t *max_blocking_time
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
if (kind) *kind = (dds_reliability_kind_t) qos->reliability.kind;
|
||||||
|
if (max_blocking_time) *max_blocking_time = nn_from_ddsi_duration (qos->reliability.max_blocking_time);
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_transport_priority
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ int32_t *value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!value){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument value is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*value = qos->transport_priority.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_destination_order
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ dds_destination_order_kind_t *kind
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!kind){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument kind is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*kind = (dds_destination_order_kind_t) qos->destination_order.kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_writer_data_lifecycle
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_ bool * autodispose
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!qos){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if(!autodispose){
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument autodispose is NULL");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
*autodispose = qos->writer_data_lifecycle.autodispose_unregistered_instances;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_reader_data_lifecycle
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * __restrict qos,
|
||||||
|
_Out_opt_ dds_duration_t *autopurge_nowriter_samples_delay,
|
||||||
|
_Out_opt_ dds_duration_t *autopurge_disposed_samples_delay
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
if (autopurge_nowriter_samples_delay) {
|
||||||
|
*autopurge_nowriter_samples_delay = \
|
||||||
|
nn_from_ddsi_duration (qos->reader_data_lifecycle.autopurge_nowriter_samples_delay);
|
||||||
|
}
|
||||||
|
if (autopurge_disposed_samples_delay) {
|
||||||
|
*autopurge_disposed_samples_delay = \
|
||||||
|
nn_from_ddsi_duration (qos->reader_data_lifecycle.autopurge_disposed_samples_delay);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dds_qget_durability_service
|
||||||
|
(
|
||||||
|
_In_ const dds_qos_t * qos,
|
||||||
|
_Out_opt_ dds_duration_t * service_cleanup_delay,
|
||||||
|
_Out_opt_ dds_history_kind_t * history_kind,
|
||||||
|
_Out_opt_ int32_t * history_depth,
|
||||||
|
_Out_opt_ int32_t * max_samples,
|
||||||
|
_Out_opt_ int32_t * max_instances,
|
||||||
|
_Out_opt_ int32_t * max_samples_per_instance
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (qos) {
|
||||||
|
if (service_cleanup_delay) *service_cleanup_delay = nn_from_ddsi_duration (qos->durability_service.service_cleanup_delay);
|
||||||
|
if (history_kind) *history_kind = (dds_history_kind_t) qos->durability_service.history.kind;
|
||||||
|
if (history_depth) *history_depth = qos->durability_service.history.depth;
|
||||||
|
if (max_samples) *max_samples = qos->durability_service.resource_limits.max_samples;
|
||||||
|
if (max_instances) *max_instances = qos->durability_service.resource_limits.max_instances;
|
||||||
|
if (max_samples_per_instance) *max_samples_per_instance = qos->durability_service.resource_limits.max_samples_per_instance;
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(DDS_RETCODE_BAD_PARAMETER, "Argument qos is NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/core/ddsc/src/dds_querycond.c
Normal file
60
src/core/ddsc/src/dds_querycond.c
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include "dds__entity.h"
|
||||||
|
#include "dds__reader.h"
|
||||||
|
#include "dds__topic.h"
|
||||||
|
#include "dds__querycond.h"
|
||||||
|
#include "dds__readcond.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "ddsi/ddsi_ser.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
DDS_EXPORT dds_entity_t
|
||||||
|
dds_create_querycondition(
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_In_ uint32_t mask,
|
||||||
|
_In_ dds_querycondition_filter_fn filter)
|
||||||
|
{
|
||||||
|
dds_entity_t topic;
|
||||||
|
dds_entity_t hdl;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_reader *r;
|
||||||
|
dds_topic *t;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_reader_lock(reader, &r);
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
dds_readcond *cond = dds_create_readcond(r, DDS_KIND_COND_QUERY, mask);
|
||||||
|
assert(cond);
|
||||||
|
hdl = cond->m_entity.m_hdl;
|
||||||
|
cond->m_query.m_filter = filter;
|
||||||
|
topic = r->m_topic->m_entity.m_hdl;
|
||||||
|
dds_reader_unlock(r);
|
||||||
|
rc = dds_topic_lock(topic, &t);
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
if (t->m_stopic->filter_sample == NULL) {
|
||||||
|
t->m_stopic->filter_sample = dds_alloc(t->m_descriptor->m_size);
|
||||||
|
}
|
||||||
|
dds_topic_unlock(t);
|
||||||
|
} else {
|
||||||
|
(void)dds_delete(hdl);
|
||||||
|
hdl = DDS_ERRNO(rc, "Error occurred on locking topic");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hdl = DDS_ERRNO(rc, "Error occurred on locking reader");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(hdl <= 0);
|
||||||
|
return hdl;
|
||||||
|
}
|
||||||
865
src/core/ddsc/src/dds_read.c
Normal file
865
src/core/ddsc/src/dds_read.c
Normal file
|
|
@ -0,0 +1,865 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "dds__entity.h"
|
||||||
|
#include "dds__reader.h"
|
||||||
|
#include "dds__tkmap.h"
|
||||||
|
#include "dds__rhc.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "ddsi/q_thread.h"
|
||||||
|
#include "ddsi/q_ephash.h"
|
||||||
|
#include "ddsi/q_entity.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
|
||||||
|
static _Check_return_ dds__retcode_t
|
||||||
|
dds_read_lock(
|
||||||
|
_In_ dds_entity_t hdl,
|
||||||
|
_Out_ dds_reader **reader,
|
||||||
|
_Out_ dds_readcond **condition,
|
||||||
|
_In_ bool only_reader)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc = hdl;
|
||||||
|
assert(reader);
|
||||||
|
assert(condition);
|
||||||
|
*reader = NULL;
|
||||||
|
*condition = NULL;
|
||||||
|
|
||||||
|
rc = dds_entity_lock(hdl, DDS_KIND_READER, (dds_entity**)reader);
|
||||||
|
if (rc == DDS_RETCODE_ILLEGAL_OPERATION) {
|
||||||
|
if (!only_reader) {
|
||||||
|
if ((dds_entity_kind(hdl) == DDS_KIND_COND_READ ) || (dds_entity_kind(hdl) == DDS_KIND_COND_QUERY) ){
|
||||||
|
rc = dds_entity_lock(hdl, DDS_KIND_DONTCARE, (dds_entity**)condition);
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
dds_entity *parent = ((dds_entity*)*condition)->m_parent;
|
||||||
|
assert(parent);
|
||||||
|
rc = dds_entity_lock(parent->m_hdl, DDS_KIND_READER, (dds_entity**)reader);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
dds_entity_unlock((dds_entity*)*condition);
|
||||||
|
DDS_ERROR(rc, "Failed to lock condition reader.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(rc, "Failed to lock condition.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(rc, "Given entity is not a reader nor a condition.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(rc, "Given entity is not a reader.");
|
||||||
|
}
|
||||||
|
} else if (rc != DDS_RETCODE_OK) {
|
||||||
|
DDS_ERROR(rc, "Failed to lock reader.");
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dds_read_unlock(
|
||||||
|
_In_ dds_reader *reader,
|
||||||
|
_In_ dds_readcond *condition)
|
||||||
|
{
|
||||||
|
assert(reader);
|
||||||
|
dds_entity_unlock((dds_entity*)reader);
|
||||||
|
if (condition) {
|
||||||
|
dds_entity_unlock((dds_entity*)condition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
dds_read_impl: Core read/take function. Usually maxs is size of buf and si
|
||||||
|
into which samples/status are written, when set to zero is special case
|
||||||
|
indicating that size set from number of samples in cache and also that cache
|
||||||
|
has been locked. This is used to support C++ API reading length unlimited
|
||||||
|
which is interpreted as "all relevant samples in cache".
|
||||||
|
*/
|
||||||
|
static dds_return_t
|
||||||
|
dds_read_impl(
|
||||||
|
_In_ bool take,
|
||||||
|
_In_ dds_entity_t reader_or_condition,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ uint32_t mask,
|
||||||
|
_In_ dds_instance_handle_t hand,
|
||||||
|
_In_ bool lock,
|
||||||
|
_In_ bool only_reader)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
struct dds_reader * rd;
|
||||||
|
struct dds_readcond * cond;
|
||||||
|
struct thread_state1 * const thr = lookup_thread_state ();
|
||||||
|
const bool asleep = !vtime_awake_p (thr->vtime);
|
||||||
|
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_awake (thr);
|
||||||
|
}
|
||||||
|
if (buf == NULL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The provided buffer is NULL");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (si == NULL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Provided pointer to an array of dds_sample_info_t is NULL");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (maxs == 0) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The maximum number of samples to read is zero");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (bufsz == 0) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The size of buffer is zero");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (bufsz < maxs) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "The provided size of buffer is smaller than the maximum number of samples to read");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = dds_read_lock(reader_or_condition, &rd, &cond, only_reader);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking entity");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (hand != DDS_HANDLE_NIL) {
|
||||||
|
if (dds_tkmap_find_by_id(gv.m_tkmap, hand) == NULL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "Could not find instance");
|
||||||
|
dds_read_unlock(rd, cond);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Allocate samples if not provided (assuming all or none provided) */
|
||||||
|
if (buf[0] == NULL) {
|
||||||
|
char * loan;
|
||||||
|
const size_t sz = rd->m_topic->m_descriptor->m_size;
|
||||||
|
const uint32_t loan_size = (uint32_t) (sz * maxs);
|
||||||
|
/* Allocate, use or reallocate loan cached on reader */
|
||||||
|
if (rd->m_loan_out) {
|
||||||
|
loan = dds_alloc (loan_size);
|
||||||
|
} else {
|
||||||
|
if (rd->m_loan) {
|
||||||
|
if (rd->m_loan_size < loan_size) {
|
||||||
|
rd->m_loan = dds_realloc_zero (rd->m_loan, loan_size);
|
||||||
|
rd->m_loan_size = loan_size;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rd->m_loan = dds_alloc (loan_size);
|
||||||
|
rd->m_loan_size = loan_size;
|
||||||
|
}
|
||||||
|
loan = rd->m_loan;
|
||||||
|
rd->m_loan_out = true;
|
||||||
|
}
|
||||||
|
for (i = 0; i < maxs; i++) {
|
||||||
|
buf[i] = loan;
|
||||||
|
loan += sz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (take) {
|
||||||
|
ret = (dds_return_t)dds_rhc_take(rd->m_rd->rhc, lock, buf, si, maxs, mask, hand, cond);
|
||||||
|
} else {
|
||||||
|
ret = (dds_return_t)dds_rhc_read(rd->m_rd->rhc, lock, buf, si, maxs, mask, hand, cond);
|
||||||
|
}
|
||||||
|
/* read/take resets data available status */
|
||||||
|
dds_entity_status_reset(rd, DDS_DATA_AVAILABLE_STATUS);
|
||||||
|
/* reset DATA_ON_READERS status on subscriber after successful read/take */
|
||||||
|
if (dds_entity_kind(((dds_entity*)rd)->m_parent->m_hdl) == DDS_KIND_SUBSCRIBER) {
|
||||||
|
dds_entity_status_reset(((dds_entity*)rd)->m_parent, DDS_DATA_ON_READERS_STATUS);
|
||||||
|
}
|
||||||
|
dds_read_unlock(rd, cond);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_asleep (thr);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_readcdr_impl(
|
||||||
|
_In_ bool take,
|
||||||
|
_In_ dds_entity_t reader_or_condition,
|
||||||
|
_Out_ struct serdata ** buf,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ uint32_t mask,
|
||||||
|
_In_ dds_instance_handle_t hand,
|
||||||
|
_In_ bool lock)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
struct dds_reader * rd;
|
||||||
|
struct dds_readcond * cond;
|
||||||
|
struct thread_state1 * const thr = lookup_thread_state ();
|
||||||
|
const bool asleep = !vtime_awake_p (thr->vtime);
|
||||||
|
|
||||||
|
assert (take);
|
||||||
|
assert (buf);
|
||||||
|
assert (si);
|
||||||
|
assert (hand == DDS_HANDLE_NIL);
|
||||||
|
assert (maxs > 0);
|
||||||
|
|
||||||
|
if (asleep)
|
||||||
|
{
|
||||||
|
thread_state_awake (thr);
|
||||||
|
}
|
||||||
|
rc = dds_read_lock(reader_or_condition, &rd, &cond, false);
|
||||||
|
if (rc >= DDS_RETCODE_OK) {
|
||||||
|
ret = dds_rhc_takecdr
|
||||||
|
(
|
||||||
|
rd->m_rd->rhc, lock, buf, si, maxs,
|
||||||
|
mask & DDS_ANY_SAMPLE_STATE,
|
||||||
|
mask & DDS_ANY_VIEW_STATE,
|
||||||
|
mask & DDS_ANY_INSTANCE_STATE,
|
||||||
|
hand
|
||||||
|
);
|
||||||
|
|
||||||
|
/* read/take resets data available status */
|
||||||
|
dds_entity_status_reset(rd, DDS_DATA_AVAILABLE_STATUS);
|
||||||
|
|
||||||
|
/* reset DATA_ON_READERS status on subscriber after successful read/take */
|
||||||
|
|
||||||
|
if (dds_entity_kind(((dds_entity*)rd)->m_parent->m_hdl) == DDS_KIND_SUBSCRIBER)
|
||||||
|
{
|
||||||
|
dds_entity_status_reset(((dds_entity*)rd)->m_parent, DDS_DATA_ON_READERS_STATUS);
|
||||||
|
}
|
||||||
|
dds_read_unlock(rd, cond);
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking entity");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (asleep)
|
||||||
|
{
|
||||||
|
thread_state_asleep (thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_read(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void ** buf,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs, so use bufsz instead.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = (uint32_t)bufsz;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl (false, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false);
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_read_wl(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void ** buf,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ uint32_t maxs)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl (false, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false);
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_read_mask(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void ** buf,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs, so use bufsz instead.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = (uint32_t)bufsz;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl (false, rd_or_cnd, buf, bufsz, maxs, si, mask, DDS_HANDLE_NIL, lock, false);
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_read_mask_wl(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void ** buf,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl (false, rd_or_cnd, buf, maxs, maxs, si, mask, DDS_HANDLE_NIL, lock, false);
|
||||||
|
DDS_REPORT_FLUSH(ret < 0 );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_read_instance(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ dds_instance_handle_t handle)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
bool lock = true;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (handle == DDS_HANDLE_NIL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl(false, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, handle, lock, false);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret < 0 );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_read_instance_wl(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ dds_instance_handle_t handle)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
bool lock = true;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (handle == DDS_HANDLE_NIL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl(false, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, handle, lock, false);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_read_instance_mask(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ dds_instance_handle_t handle,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
bool lock = true;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (handle == DDS_HANDLE_NIL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl(false, rd_or_cnd, buf, bufsz, maxs, si, mask, handle, lock, false);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_read_instance_mask_wl(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ dds_instance_handle_t handle,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
bool lock = true;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (handle == DDS_HANDLE_NIL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl(false, rd_or_cnd, buf, maxs, maxs, si, mask, handle, lock, false);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER )
|
||||||
|
dds_return_t
|
||||||
|
dds_read_next(
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si)
|
||||||
|
{
|
||||||
|
uint32_t mask = DDS_NOT_READ_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
ret = dds_read_impl (false, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true);
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER )
|
||||||
|
dds_return_t
|
||||||
|
dds_read_next_wl(
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si)
|
||||||
|
{
|
||||||
|
uint32_t mask = DDS_NOT_READ_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds_read_impl (false, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true);
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_take(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void ** buf,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs, so use bufsz instead.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = (uint32_t)bufsz;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl (true, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false);
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_take_wl(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void ** buf,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ uint32_t maxs)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl (true, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, DDS_HANDLE_NIL, lock, false);
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_take_mask(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void ** buf,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs, so use bufsz instead.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = (uint32_t)bufsz;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl (true, rd_or_cnd, buf, bufsz, maxs, si, mask, DDS_HANDLE_NIL, lock, false);
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_take_mask_wl(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void ** buf,
|
||||||
|
_Out_ dds_sample_info_t * si,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
dds_return_t ret;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl (true, rd_or_cnd, buf, maxs, maxs, si, mask, DDS_HANDLE_NIL, lock, false);
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dds_takecdr(
|
||||||
|
dds_entity_t rd_or_cnd,
|
||||||
|
struct serdata **buf,
|
||||||
|
uint32_t maxs,
|
||||||
|
dds_sample_info_t *si,
|
||||||
|
uint32_t mask)
|
||||||
|
{
|
||||||
|
bool lock = true;
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
return dds_readcdr_impl (true, rd_or_cnd, buf, maxs, si, mask, DDS_HANDLE_NIL, lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_take_instance(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ dds_instance_handle_t handle)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
bool lock = true;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (handle == DDS_HANDLE_NIL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl(true, rd_or_cnd, buf, bufsz, maxs, si, NO_STATE_MASK_SET, handle, lock, false);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_take_instance_wl(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ dds_instance_handle_t handle)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
bool lock = true;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (handle == DDS_HANDLE_NIL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl(true, rd_or_cnd, buf, maxs, maxs, si, NO_STATE_MASK_SET, handle, lock, false);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_take_instance_mask(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ size_t bufsz,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ dds_instance_handle_t handle,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
bool lock = true;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (handle == DDS_HANDLE_NIL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl(true, rd_or_cnd, buf, bufsz, maxs, si, mask, handle, lock, false);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_(((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((rd_or_cnd & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
dds_return_t
|
||||||
|
dds_take_instance_mask_wl(
|
||||||
|
_In_ dds_entity_t rd_or_cnd,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si,
|
||||||
|
_In_ uint32_t maxs,
|
||||||
|
_In_ dds_instance_handle_t handle,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
bool lock = true;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (handle == DDS_HANDLE_NIL) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "DDS_HANDLE_NIL was provided");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (maxs == DDS_READ_WITHOUT_LOCK) {
|
||||||
|
lock = false;
|
||||||
|
/* Use a more sensible maxs. Just an arbitrarily number.
|
||||||
|
* CHAM-306 will remove this ugly piece of code. */
|
||||||
|
maxs = 100;
|
||||||
|
}
|
||||||
|
ret = dds_read_impl(true, rd_or_cnd, buf, maxs, maxs, si, mask, handle, lock, false);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret < 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER )
|
||||||
|
dds_return_t
|
||||||
|
dds_take_next(
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si)
|
||||||
|
{
|
||||||
|
uint32_t mask = DDS_NOT_READ_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds_read_impl (true, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true);
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER )
|
||||||
|
dds_return_t
|
||||||
|
dds_take_next_wl(
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Inout_ void **buf,
|
||||||
|
_Out_ dds_sample_info_t *si)
|
||||||
|
{
|
||||||
|
uint32_t mask = DDS_NOT_READ_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||||
|
dds_return_t ret;
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
ret = dds_read_impl (true, reader, buf, 1u, 1u, si, mask, DDS_HANDLE_NIL, true, true);
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((reader_or_condition & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) ||\
|
||||||
|
((reader_or_condition & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((reader_or_condition & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY ))
|
||||||
|
_Must_inspect_result_ dds_return_t
|
||||||
|
dds_return_loan(
|
||||||
|
_In_ dds_entity_t reader_or_condition,
|
||||||
|
_Inout_updates_(bufsz) void **buf,
|
||||||
|
_In_ size_t bufsz)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc;
|
||||||
|
const dds_topic_descriptor_t * desc;
|
||||||
|
dds_reader *rd;
|
||||||
|
dds_readcond *cond;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (!buf ) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument buf is NULL");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if(*buf == NULL && bufsz > 0){
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument buf is NULL");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = dds_read_lock(reader_or_condition, &rd, &cond, false);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking entity");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
desc = rd->m_topic->m_descriptor;
|
||||||
|
|
||||||
|
/* Only free sample contents if they have been allocated */
|
||||||
|
if (desc->m_flagset & DDS_TOPIC_NO_OPTIMIZE) {
|
||||||
|
size_t i = 0;
|
||||||
|
for (i = 0; i < bufsz; i++) {
|
||||||
|
dds_sample_free(buf[i], desc, DDS_FREE_CONTENTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If possible return loan buffer to reader */
|
||||||
|
if (rd->m_loan != 0 && (buf[0] == rd->m_loan)) {
|
||||||
|
rd->m_loan_out = false;
|
||||||
|
memset (rd->m_loan, 0, rd->m_loan_size);
|
||||||
|
buf[0] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dds_read_unlock(rd, cond);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
129
src/core/ddsc/src/dds_readcond.c
Normal file
129
src/core/ddsc/src/dds_readcond.c
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include "dds__reader.h"
|
||||||
|
#include "dds__readcond.h"
|
||||||
|
#include "dds__rhc.h"
|
||||||
|
#include "dds__entity.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "ddsi/q_ephash.h"
|
||||||
|
#include "ddsi/q_entity.h"
|
||||||
|
#include "ddsi/q_thread.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_readcond_delete(
|
||||||
|
dds_entity *e)
|
||||||
|
{
|
||||||
|
dds_rhc_remove_readcondition((dds_readcond*)e);
|
||||||
|
return DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Must_inspect_result_ dds_readcond*
|
||||||
|
dds_create_readcond(
|
||||||
|
_In_ dds_reader *rd,
|
||||||
|
_In_ dds_entity_kind_t kind,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
dds_readcond * cond = dds_alloc(sizeof(*cond));
|
||||||
|
assert(kind == DDS_KIND_COND_READ || kind == DDS_KIND_COND_QUERY);
|
||||||
|
cond->m_entity.m_hdl = dds_entity_init(&cond->m_entity, (dds_entity*)rd, kind, NULL, NULL, 0);
|
||||||
|
cond->m_entity.m_deriver.delete = dds_readcond_delete;
|
||||||
|
cond->m_rhc = rd->m_rd->rhc;
|
||||||
|
cond->m_sample_states = mask & DDS_ANY_SAMPLE_STATE;
|
||||||
|
cond->m_view_states = mask & DDS_ANY_VIEW_STATE;
|
||||||
|
cond->m_instance_states = mask & DDS_ANY_INSTANCE_STATE;
|
||||||
|
cond->m_rd_guid = ((dds_entity*)rd)->m_guid;
|
||||||
|
dds_rhc_add_readcondition (cond);
|
||||||
|
return cond;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
_Must_inspect_result_ dds_entity_t
|
||||||
|
dds_create_readcondition(
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_In_ uint32_t mask)
|
||||||
|
{
|
||||||
|
dds_entity_t hdl;
|
||||||
|
dds_reader * rd;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_reader_lock(reader, &rd);
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
dds_readcond *cond = dds_create_readcond(rd, DDS_KIND_COND_READ, mask);
|
||||||
|
assert(cond);
|
||||||
|
hdl = cond->m_entity.m_hdl;
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
} else {
|
||||||
|
hdl = DDS_ERRNO(rc, "Error occurred on locking reader");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(hdl <= 0);
|
||||||
|
return hdl;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((condition & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((condition & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY) )
|
||||||
|
dds_entity_t
|
||||||
|
dds_get_datareader(
|
||||||
|
_In_ dds_entity_t condition)
|
||||||
|
{
|
||||||
|
dds_entity_t hdl;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
if (dds_entity_kind(condition) == DDS_KIND_COND_READ) {
|
||||||
|
hdl = dds_get_parent(condition);
|
||||||
|
} else if (dds_entity_kind(condition) == DDS_KIND_COND_QUERY) {
|
||||||
|
hdl = dds_get_parent(condition);
|
||||||
|
} else {
|
||||||
|
hdl = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_READ), "Argument condition is not valid");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(hdl <= 0);
|
||||||
|
return hdl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_(((condition & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((condition & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY) )
|
||||||
|
_Check_return_ dds_return_t
|
||||||
|
dds_get_mask(
|
||||||
|
_In_ dds_entity_t condition,
|
||||||
|
_Out_ uint32_t *mask)
|
||||||
|
{
|
||||||
|
dds_return_t ret;
|
||||||
|
dds_readcond *cond;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (mask != NULL) {
|
||||||
|
*mask = 0;
|
||||||
|
if ((dds_entity_kind(condition) == DDS_KIND_COND_READ ) ||
|
||||||
|
(dds_entity_kind(condition) == DDS_KIND_COND_QUERY) ){
|
||||||
|
rc = dds_entity_lock(condition, DDS_KIND_DONTCARE, (dds_entity**)&cond);
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
*mask = (cond->m_sample_states | cond->m_view_states | cond->m_instance_states);
|
||||||
|
dds_entity_unlock((dds_entity*)cond);
|
||||||
|
ret = DDS_RETCODE_OK;
|
||||||
|
} else{
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking condition");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(dds_valid_hdl(condition, DDS_KIND_COND_READ), "Argument condition is not valid");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Argument mask is NULL");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
791
src/core/ddsc/src/dds_reader.c
Normal file
791
src/core/ddsc/src/dds_reader.c
Normal file
|
|
@ -0,0 +1,791 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
#include "dds__subscriber.h"
|
||||||
|
#include "dds__reader.h"
|
||||||
|
#include "dds__listener.h"
|
||||||
|
#include "dds__qos.h"
|
||||||
|
#include "dds__init.h"
|
||||||
|
#include "dds__rhc.h"
|
||||||
|
#include "dds__err.h"
|
||||||
|
#include "ddsi/q_entity.h"
|
||||||
|
#include "ddsi/q_thread.h"
|
||||||
|
#include "dds__report.h"
|
||||||
|
#include "dds__builtin.h"
|
||||||
|
#include "ddsc/ddsc_project.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "os/os.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define DDS_READER_STATUS_MASK \
|
||||||
|
DDS_SAMPLE_REJECTED_STATUS |\
|
||||||
|
DDS_LIVELINESS_CHANGED_STATUS |\
|
||||||
|
DDS_REQUESTED_DEADLINE_MISSED_STATUS |\
|
||||||
|
DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS |\
|
||||||
|
DDS_DATA_AVAILABLE_STATUS |\
|
||||||
|
DDS_SAMPLE_LOST_STATUS |\
|
||||||
|
DDS_SUBSCRIPTION_MATCHED_STATUS
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_reader_instance_hdl(
|
||||||
|
dds_entity *e,
|
||||||
|
dds_instance_handle_t *i)
|
||||||
|
{
|
||||||
|
assert(e);
|
||||||
|
assert(i);
|
||||||
|
*i = (dds_instance_handle_t)reader_instance_id(&e->m_guid);
|
||||||
|
return DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_reader_close(
|
||||||
|
dds_entity *e)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
struct thread_state1 * const thr = lookup_thread_state();
|
||||||
|
const bool asleep = !vtime_awake_p(thr->vtime);
|
||||||
|
|
||||||
|
assert(e);
|
||||||
|
assert(thr);
|
||||||
|
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_awake(thr);
|
||||||
|
}
|
||||||
|
if (delete_reader(&e->m_guid) != 0) {
|
||||||
|
rc = DDS_RETCODE_ERROR;
|
||||||
|
ret = DDS_ERRNO(rc, "Internal error");
|
||||||
|
}
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_asleep(thr);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_reader_delete(
|
||||||
|
dds_entity *e)
|
||||||
|
{
|
||||||
|
dds_reader *rd = (dds_reader*)e;
|
||||||
|
dds_return_t ret;
|
||||||
|
assert(e);
|
||||||
|
ret = dds_delete(rd->m_topic->m_entity.m_hdl);
|
||||||
|
if(ret == DDS_RETCODE_OK){
|
||||||
|
ret = dds_delete_impl(e->m_parent->m_hdl, true);
|
||||||
|
if(dds_err_nr(ret) == DDS_RETCODE_ALREADY_DELETED){
|
||||||
|
ret = DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dds_free(rd->m_loan);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_reader_qos_validate(
|
||||||
|
const dds_qos_t *qos,
|
||||||
|
bool enabled)
|
||||||
|
{
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
assert(qos);
|
||||||
|
|
||||||
|
/* Check consistency. */
|
||||||
|
if(!dds_qos_validate_common(qos)) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Argument Qos is not valid");
|
||||||
|
}
|
||||||
|
if((qos->present & QP_USER_DATA) && !(validate_octetseq (&qos->user_data))) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "User data policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if((qos->present & QP_PRISMTECH_READER_DATA_LIFECYCLE) && (validate_reader_data_lifecycle (&qos->reader_data_lifecycle) != 0)) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Prismtech reader data lifecycle policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if((qos->present & QP_TIME_BASED_FILTER) && (validate_duration (&qos->time_based_filter.minimum_separation) != 0)) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Time based filter policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && (validate_history_and_resource_limits (&qos->history, &qos->resource_limits) != 0)) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "History and resource limits policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if((qos->present & QP_TIME_BASED_FILTER) && (qos->present & QP_DEADLINE) && !(validate_deadline_and_timebased_filter (qos->deadline.deadline, qos->time_based_filter.minimum_separation))) {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Time based filter and deadline policy is inconsistent and caused an error");
|
||||||
|
}
|
||||||
|
if(ret == DDS_RETCODE_OK && enabled) {
|
||||||
|
ret = dds_qos_validate_mutable_common(qos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_reader_qos_set(
|
||||||
|
dds_entity *e,
|
||||||
|
const dds_qos_t *qos,
|
||||||
|
bool enabled)
|
||||||
|
{
|
||||||
|
dds_return_t ret = dds_reader_qos_validate(qos, enabled);
|
||||||
|
if (ret == DDS_RETCODE_OK) {
|
||||||
|
if (enabled) {
|
||||||
|
/* TODO: CHAM-95: DDSI does not support changing QoS policies. */
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, DDSC_PROJECT_NAME" does not support changing QoS policies");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dds_return_t
|
||||||
|
dds_reader_status_validate(
|
||||||
|
uint32_t mask)
|
||||||
|
{
|
||||||
|
return (mask & ~(DDS_READER_STATUS_MASK)) ?
|
||||||
|
DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "Invalid status mask") :
|
||||||
|
DDS_RETCODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_reader_status_cb(
|
||||||
|
void *entity,
|
||||||
|
const status_cb_data_t *data)
|
||||||
|
{
|
||||||
|
dds_reader *rd;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
void *metrics = NULL;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
/* When data is NULL, it means that the DDSI reader is deleted. */
|
||||||
|
if (data == NULL) {
|
||||||
|
/* Release the initial claim that was done during the create. This
|
||||||
|
* will indicate that further API deletion is now possible. */
|
||||||
|
ut_handle_release(((dds_entity*)entity)->m_hdl, ((dds_entity*)entity)->m_hdllink);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dds_reader_lock(((dds_entity*)entity)->m_hdl, &rd) != DDS_RETCODE_OK) {
|
||||||
|
/* There's a deletion or closing going on. */
|
||||||
|
DDS_REPORT_FLUSH(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assert(rd == entity);
|
||||||
|
|
||||||
|
/* Reset the status for possible Listener call.
|
||||||
|
* When a listener is not called, the status will be set (again). */
|
||||||
|
dds_entity_status_reset(entity, data->status);
|
||||||
|
|
||||||
|
/* Update status metrics. */
|
||||||
|
switch (data->status) {
|
||||||
|
case DDS_REQUESTED_DEADLINE_MISSED_STATUS: {
|
||||||
|
rd->m_requested_deadline_missed_status.total_count++;
|
||||||
|
rd->m_requested_deadline_missed_status.total_count_change++;
|
||||||
|
rd->m_requested_deadline_missed_status.last_instance_handle = data->handle;
|
||||||
|
metrics = (void*)&(rd->m_requested_deadline_missed_status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS: {
|
||||||
|
rd->m_requested_incompatible_qos_status.total_count++;
|
||||||
|
rd->m_requested_incompatible_qos_status.total_count_change++;
|
||||||
|
rd->m_requested_incompatible_qos_status.last_policy_id = data->extra;
|
||||||
|
metrics = (void*)&(rd->m_requested_incompatible_qos_status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_SAMPLE_LOST_STATUS: {
|
||||||
|
rd->m_sample_lost_status.total_count++;
|
||||||
|
rd->m_sample_lost_status.total_count_change++;
|
||||||
|
metrics = (void*)&(rd->m_sample_lost_status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_SAMPLE_REJECTED_STATUS: {
|
||||||
|
rd->m_sample_rejected_status.total_count++;
|
||||||
|
rd->m_sample_rejected_status.total_count_change++;
|
||||||
|
rd->m_sample_rejected_status.last_reason = data->extra;
|
||||||
|
rd->m_sample_rejected_status.last_instance_handle = data->handle;
|
||||||
|
metrics = (void*)&(rd->m_sample_rejected_status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_DATA_AVAILABLE_STATUS: {
|
||||||
|
metrics = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_LIVELINESS_CHANGED_STATUS: {
|
||||||
|
if (data->add) {
|
||||||
|
rd->m_liveliness_changed_status.alive_count++;
|
||||||
|
rd->m_liveliness_changed_status.alive_count_change++;
|
||||||
|
if (rd->m_liveliness_changed_status.not_alive_count > 0) {
|
||||||
|
rd->m_liveliness_changed_status.not_alive_count--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rd->m_liveliness_changed_status.alive_count--;
|
||||||
|
rd->m_liveliness_changed_status.not_alive_count++;
|
||||||
|
rd->m_liveliness_changed_status.not_alive_count_change++;
|
||||||
|
}
|
||||||
|
rd->m_liveliness_changed_status.last_publication_handle = data->handle;
|
||||||
|
metrics = (void*)&(rd->m_liveliness_changed_status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_SUBSCRIPTION_MATCHED_STATUS: {
|
||||||
|
if (data->add) {
|
||||||
|
rd->m_subscription_matched_status.total_count++;
|
||||||
|
rd->m_subscription_matched_status.total_count_change++;
|
||||||
|
rd->m_subscription_matched_status.current_count++;
|
||||||
|
rd->m_subscription_matched_status.current_count_change++;
|
||||||
|
} else {
|
||||||
|
rd->m_subscription_matched_status.current_count--;
|
||||||
|
rd->m_subscription_matched_status.current_count_change--;
|
||||||
|
}
|
||||||
|
rd->m_subscription_matched_status.last_publication_handle = data->handle;
|
||||||
|
metrics = (void*)&(rd->m_subscription_matched_status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: assert (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The reader needs to be unlocked when propagating the (possible) listener
|
||||||
|
* call because the application should be able to call this reader within
|
||||||
|
* the callback function. */
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
|
||||||
|
/* DATA_AVAILABLE is handled differently to normal status changes. */
|
||||||
|
if (data->status == DDS_DATA_AVAILABLE_STATUS) {
|
||||||
|
dds_entity *parent = rd->m_entity.m_parent;
|
||||||
|
/* First, try to ship it off to its parent(s) DDS_DATA_ON_READERS_STATUS. */
|
||||||
|
rc = dds_entity_listener_propagation(parent, parent, DDS_DATA_ON_READERS_STATUS, NULL, true);
|
||||||
|
|
||||||
|
if (rc == DDS_RETCODE_NO_DATA) {
|
||||||
|
/* No parent was interested (NO_DATA == NO_CALL).
|
||||||
|
* What about myself with DDS_DATA_AVAILABLE_STATUS? */
|
||||||
|
rc = dds_entity_listener_propagation(entity, entity, DDS_DATA_AVAILABLE_STATUS, NULL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( rc == DDS_RETCODE_NO_DATA ) {
|
||||||
|
/* Nobody was interested (NO_DATA == NO_CALL). Set the status on the subscriber. */
|
||||||
|
dds_entity_status_set(parent, DDS_DATA_ON_READERS_STATUS);
|
||||||
|
/* Notify possible interested observers of the subscriber. */
|
||||||
|
dds_entity_status_signal(parent);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Is anybody interested within the entity hierarchy through listeners? */
|
||||||
|
rc = dds_entity_listener_propagation(entity, entity, data->status, metrics, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc == DDS_RETCODE_OK) {
|
||||||
|
/* Event was eaten by a listener. */
|
||||||
|
if (dds_reader_lock(((dds_entity*)entity)->m_hdl, &rd) == DDS_RETCODE_OK) {
|
||||||
|
assert(rd == entity);
|
||||||
|
|
||||||
|
/* Reset the change counts of the metrics. */
|
||||||
|
switch (data->status) {
|
||||||
|
case DDS_REQUESTED_DEADLINE_MISSED_STATUS: {
|
||||||
|
rd->m_requested_deadline_missed_status.total_count_change = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS: {
|
||||||
|
rd->m_requested_incompatible_qos_status.total_count_change = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_SAMPLE_LOST_STATUS: {
|
||||||
|
rd->m_sample_lost_status.total_count_change = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_SAMPLE_REJECTED_STATUS: {
|
||||||
|
rd->m_sample_rejected_status.total_count_change = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_DATA_AVAILABLE_STATUS: {
|
||||||
|
/* Nothing to reset. */;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_LIVELINESS_CHANGED_STATUS: {
|
||||||
|
rd->m_liveliness_changed_status.alive_count_change = 0;
|
||||||
|
rd->m_liveliness_changed_status.not_alive_count_change = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DDS_SUBSCRIPTION_MATCHED_STATUS: {
|
||||||
|
rd->m_subscription_matched_status.total_count_change = 0;
|
||||||
|
rd->m_subscription_matched_status.current_count_change = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: assert (0);
|
||||||
|
}
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
} else {
|
||||||
|
/* There's a deletion or closing going on. */
|
||||||
|
}
|
||||||
|
} else if (rc == DDS_RETCODE_NO_DATA) {
|
||||||
|
/* Nobody was interested through a listener (NO_DATA == NO_CALL): set the status. */
|
||||||
|
dds_entity_status_set(entity, data->status);
|
||||||
|
/* Notify possible interested observers. */
|
||||||
|
dds_entity_status_signal(entity);
|
||||||
|
rc = DDS_RETCODE_OK;
|
||||||
|
} else if (rc == DDS_RETCODE_ALREADY_DELETED) {
|
||||||
|
/* An entity up the hierarchy is being deleted. */
|
||||||
|
rc = DDS_RETCODE_OK;
|
||||||
|
} else {
|
||||||
|
/* Something went wrong up the hierarchy. */
|
||||||
|
}
|
||||||
|
|
||||||
|
DDS_REPORT_FLUSH(rc != DDS_RETCODE_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_Pre_satisfies_(((participant_or_subscriber & DDS_ENTITY_KIND_MASK) == DDS_KIND_SUBSCRIBER ) ||\
|
||||||
|
((participant_or_subscriber & DDS_ENTITY_KIND_MASK) == DDS_KIND_PARTICIPANT) )
|
||||||
|
_Pre_satisfies_(((topic & DDS_ENTITY_KIND_MASK) == DDS_KIND_TOPIC ) ||\
|
||||||
|
((topic & DDS_ENTITY_KIND_MASK) == DDS_KIND_INTERNAL) )
|
||||||
|
dds_entity_t
|
||||||
|
dds_create_reader(
|
||||||
|
_In_ dds_entity_t participant_or_subscriber,
|
||||||
|
_In_ dds_entity_t topic,
|
||||||
|
_In_opt_ const dds_qos_t *qos,
|
||||||
|
_In_opt_ const dds_listener_t *listener)
|
||||||
|
{
|
||||||
|
dds_qos_t * rqos;
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_entity * sub = NULL;
|
||||||
|
dds_entity_t subscriber;
|
||||||
|
dds_reader * rd;
|
||||||
|
struct rhc * rhc;
|
||||||
|
dds_entity * tp;
|
||||||
|
dds_entity_t reader;
|
||||||
|
dds_entity_t t;
|
||||||
|
struct thread_state1 * const thr = lookup_thread_state ();
|
||||||
|
const bool asleep = !vtime_awake_p (thr->vtime);
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (dds_entity_kind(topic) != DDS_KIND_INTERNAL) {
|
||||||
|
/* Try claiming a participant. If that's not working, then it could be a subscriber. */
|
||||||
|
if (dds_entity_kind(participant_or_subscriber) == DDS_KIND_PARTICIPANT) {
|
||||||
|
subscriber = dds_create_subscriber(participant_or_subscriber, qos, NULL);
|
||||||
|
} else {
|
||||||
|
subscriber = participant_or_subscriber;
|
||||||
|
}
|
||||||
|
t = topic;
|
||||||
|
} else {
|
||||||
|
/* TODO If qos is provided, we need to compare with writer qos to determine compatibility */
|
||||||
|
subscriber = dds__get_builtin_subscriber(participant_or_subscriber);
|
||||||
|
t = dds__get_builtin_topic(subscriber, topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = dds_entity_lock(subscriber, DDS_KIND_SUBSCRIBER, &sub);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
reader = DDS_ERRNO(rc, "Error occurred on locking subscriber");
|
||||||
|
goto err_sub_lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((subscriber != participant_or_subscriber) &&
|
||||||
|
(dds_entity_kind(topic) != DDS_KIND_INTERNAL)) {
|
||||||
|
/* Delete implicit subscriber if reader creation fails */
|
||||||
|
sub->m_flags |= DDS_ENTITY_IMPLICIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = dds_entity_lock(t, DDS_KIND_TOPIC, &tp);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
reader = DDS_ERRNO(rc, "Error occurred on locking topic");
|
||||||
|
goto err_tp_lock;
|
||||||
|
}
|
||||||
|
assert (((dds_topic*)tp)->m_stopic);
|
||||||
|
assert (sub->m_domain == tp->m_domain);
|
||||||
|
|
||||||
|
/* Merge qos from topic and subscriber */
|
||||||
|
rqos = dds_qos_create ();
|
||||||
|
if (qos) {
|
||||||
|
/* Only returns failure when one of the qos args is NULL, which
|
||||||
|
* is not the case here. */
|
||||||
|
(void)dds_qos_copy(rqos, qos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sub->m_qos){
|
||||||
|
dds_qos_merge (rqos, sub->m_qos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tp->m_qos) {
|
||||||
|
dds_qos_merge (rqos, tp->m_qos);
|
||||||
|
|
||||||
|
/* reset the following qos policies if set during topic qos merge as they aren't applicable for reader */
|
||||||
|
rqos->present &= ~(QP_DURABILITY_SERVICE | QP_TRANSPORT_PRIORITY | QP_LIFESPAN);
|
||||||
|
}
|
||||||
|
nn_xqos_mergein_missing (rqos, &gv.default_xqos_rd);
|
||||||
|
|
||||||
|
ret = dds_reader_qos_validate (rqos, false);
|
||||||
|
if (ret != 0) {
|
||||||
|
dds_qos_delete(rqos);
|
||||||
|
reader = ret;
|
||||||
|
goto err_bad_qos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create reader and associated read cache */
|
||||||
|
rd = dds_alloc (sizeof (*rd));
|
||||||
|
reader = dds_entity_init (&rd->m_entity, sub, DDS_KIND_READER, rqos, listener, DDS_READER_STATUS_MASK);
|
||||||
|
rd->m_sample_rejected_status.last_reason = DDS_NOT_REJECTED;
|
||||||
|
rd->m_topic = (dds_topic*)tp;
|
||||||
|
rhc = dds_rhc_new (rd, ((dds_topic*)tp)->m_stopic);
|
||||||
|
dds_entity_add_ref_nolock (tp);
|
||||||
|
rd->m_entity.m_deriver.close = dds_reader_close;
|
||||||
|
rd->m_entity.m_deriver.delete = dds_reader_delete;
|
||||||
|
rd->m_entity.m_deriver.set_qos = dds_reader_qos_set;
|
||||||
|
rd->m_entity.m_deriver.validate_status = dds_reader_status_validate;
|
||||||
|
rd->m_entity.m_deriver.get_instance_hdl = dds_reader_instance_hdl;
|
||||||
|
|
||||||
|
/* Extra claim of this reader to make sure that the delete waits until DDSI
|
||||||
|
* has deleted its reader as well. This can be known through the callback. */
|
||||||
|
if (ut_handle_claim(rd->m_entity.m_hdl, rd->m_entity.m_hdllink, DDS_KIND_READER, NULL) != UT_HANDLE_OK) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
os_mutexUnlock(&tp->m_mutex);
|
||||||
|
os_mutexUnlock(&sub->m_mutex);
|
||||||
|
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_awake (thr);
|
||||||
|
}
|
||||||
|
rd->m_rd = new_reader(&rd->m_entity.m_guid, NULL, &sub->m_participant->m_guid, ((dds_topic*)tp)->m_stopic,
|
||||||
|
rqos, rhc, dds_reader_status_cb, rd);
|
||||||
|
os_mutexLock(&sub->m_mutex);
|
||||||
|
os_mutexLock(&tp->m_mutex);
|
||||||
|
assert (rd->m_rd);
|
||||||
|
if (asleep) {
|
||||||
|
thread_state_asleep (thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For persistent data register reader with durability */
|
||||||
|
if (dds_global.m_dur_reader && (rd->m_entity.m_qos->durability.kind > NN_TRANSIENT_LOCAL_DURABILITY_QOS)) {
|
||||||
|
(dds_global.m_dur_reader) (rd, rhc);
|
||||||
|
}
|
||||||
|
dds_entity_unlock(tp);
|
||||||
|
dds_entity_unlock(sub);
|
||||||
|
|
||||||
|
if (dds_entity_kind(topic) == DDS_KIND_INTERNAL) {
|
||||||
|
/* If topic is builtin, then the topic entity is local and should
|
||||||
|
* be deleted because the application won't. */
|
||||||
|
dds_delete(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
DDS_REPORT_FLUSH(reader <= 0);
|
||||||
|
return reader;
|
||||||
|
|
||||||
|
err_bad_qos:
|
||||||
|
dds_entity_unlock(tp);
|
||||||
|
err_tp_lock:
|
||||||
|
dds_entity_unlock(sub);
|
||||||
|
if((sub->m_flags & DDS_ENTITY_IMPLICIT) != 0){
|
||||||
|
(void)dds_delete(subscriber);
|
||||||
|
}
|
||||||
|
err_sub_lock:
|
||||||
|
DDS_REPORT_FLUSH(reader <= 0);
|
||||||
|
return reader;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_reader_ddsi2direct(
|
||||||
|
dds_entity_t entity,
|
||||||
|
ddsi2direct_directread_cb_t cb,
|
||||||
|
void *cbarg)
|
||||||
|
{
|
||||||
|
dds_reader *dds_rd;
|
||||||
|
|
||||||
|
if (ut_handle_claim(entity, NULL, DDS_KIND_READER, (void**)&dds_rd) == UT_HANDLE_OK)
|
||||||
|
{
|
||||||
|
struct reader *rd = dds_rd->m_rd;
|
||||||
|
nn_guid_t pwrguid;
|
||||||
|
struct proxy_writer *pwr;
|
||||||
|
struct rd_pwr_match *m;
|
||||||
|
memset (&pwrguid, 0, sizeof (pwrguid));
|
||||||
|
os_mutexLock (&rd->e.lock);
|
||||||
|
|
||||||
|
rd->ddsi2direct_cb = cb;
|
||||||
|
rd->ddsi2direct_cbarg = cbarg;
|
||||||
|
while ((m = ut_avlLookupSuccEq (&rd_writers_treedef, &rd->writers, &pwrguid)) != NULL)
|
||||||
|
{
|
||||||
|
/* have to be careful walking the tree -- pretty is different, but
|
||||||
|
I want to check this before I write a lookup_succ function. */
|
||||||
|
struct rd_pwr_match *m_next;
|
||||||
|
nn_guid_t pwrguid_next;
|
||||||
|
pwrguid = m->pwr_guid;
|
||||||
|
if ((m_next = ut_avlFindSucc (&rd_writers_treedef, &rd->writers, m)) != NULL)
|
||||||
|
pwrguid_next = m_next->pwr_guid;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset (&pwrguid_next, 0xff, sizeof (pwrguid_next));
|
||||||
|
pwrguid_next.entityid.u = (pwrguid_next.entityid.u & ~0xff) | NN_ENTITYID_KIND_WRITER_NO_KEY;
|
||||||
|
}
|
||||||
|
os_mutexUnlock (&rd->e.lock);
|
||||||
|
if ((pwr = ephash_lookup_proxy_writer_guid (&pwrguid)) != NULL)
|
||||||
|
{
|
||||||
|
os_mutexLock (&pwr->e.lock);
|
||||||
|
pwr->ddsi2direct_cb = cb;
|
||||||
|
pwr->ddsi2direct_cbarg = cbarg;
|
||||||
|
os_mutexUnlock (&pwr->e.lock);
|
||||||
|
}
|
||||||
|
pwrguid = pwrguid_next;
|
||||||
|
os_mutexLock (&rd->e.lock);
|
||||||
|
}
|
||||||
|
os_mutexUnlock (&rd->e.lock);
|
||||||
|
ut_handle_release(entity, ((dds_entity*)rd)->m_hdllink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
dds_reader_lock_samples(
|
||||||
|
dds_entity_t reader)
|
||||||
|
{
|
||||||
|
uint32_t ret = 0;
|
||||||
|
dds_reader *rd;
|
||||||
|
|
||||||
|
ret = dds_reader_lock(reader, &rd);
|
||||||
|
if (ret == DDS_RETCODE_OK) {
|
||||||
|
ret = dds_rhc_lock_samples(rd->m_rd->rhc);
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
} else {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
int
|
||||||
|
dds_reader_wait_for_historical_data(
|
||||||
|
dds_entity_t reader,
|
||||||
|
dds_duration_t max_wait)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
dds_reader *rd;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
assert (reader);
|
||||||
|
|
||||||
|
ret = dds_reader_lock(reader, &rd);
|
||||||
|
if (ret == DDS_RETCODE_OK) {
|
||||||
|
if (((dds_entity*)rd)->m_qos->durability.kind > NN_TRANSIENT_LOCAL_DURABILITY_QOS) {
|
||||||
|
ret = (dds_global.m_dur_wait) (rd, max_wait);
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(DDS_RETCODE_ERROR, "Can not wait for historical data on a reader with volatile durability");
|
||||||
|
}
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
} else {
|
||||||
|
ret = DDS_ERRNO(ret, "Error occurred on locking reader");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_(((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER ) || \
|
||||||
|
((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_READ ) || \
|
||||||
|
((entity & DDS_ENTITY_KIND_MASK) == DDS_KIND_COND_QUERY) )
|
||||||
|
dds_entity_t
|
||||||
|
dds_get_subscriber(
|
||||||
|
_In_ dds_entity_t entity)
|
||||||
|
{
|
||||||
|
dds_entity_t hdl;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
if (dds_entity_kind(entity) == DDS_KIND_READER) {
|
||||||
|
hdl = dds_get_parent(entity);
|
||||||
|
} else if (dds_entity_kind(entity) == DDS_KIND_COND_READ || dds_entity_kind(entity) == DDS_KIND_COND_QUERY) {
|
||||||
|
hdl = dds_get_parent(entity);
|
||||||
|
if(hdl > 0){
|
||||||
|
hdl = dds_get_subscriber(hdl);
|
||||||
|
} else {
|
||||||
|
DDS_ERROR(hdl, "Reader of this condition is already deleted");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hdl = DDS_ERRNO(dds_valid_hdl(entity, DDS_KIND_READER), "Provided entity is not a reader nor a condition");
|
||||||
|
}
|
||||||
|
DDS_REPORT_FLUSH(hdl <= 0);
|
||||||
|
return hdl;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
dds_return_t
|
||||||
|
dds_get_subscription_matched_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_subscription_matched_status_t * status)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_reader *rd;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_reader_lock(reader, &rd);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking reader");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
/* status = NULL, application do not need the status, but reset the counter & triggered bit */
|
||||||
|
if (status) {
|
||||||
|
*status = rd->m_subscription_matched_status;
|
||||||
|
}
|
||||||
|
if (((dds_entity*)rd)->m_status_enable & DDS_SUBSCRIPTION_MATCHED_STATUS) {
|
||||||
|
rd->m_subscription_matched_status.total_count_change = 0;
|
||||||
|
rd->m_subscription_matched_status.current_count_change = 0;
|
||||||
|
dds_entity_status_reset(rd, DDS_SUBSCRIPTION_MATCHED_STATUS);
|
||||||
|
}
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
dds_return_t
|
||||||
|
dds_get_liveliness_changed_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_liveliness_changed_status_t * status)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_reader *rd;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_reader_lock(reader, &rd);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking reader");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
/* status = NULL, application do not need the status, but reset the counter & triggered bit */
|
||||||
|
if (status) {
|
||||||
|
*status = rd->m_liveliness_changed_status;
|
||||||
|
}
|
||||||
|
if (((dds_entity*)rd)->m_status_enable & DDS_LIVELINESS_CHANGED_STATUS) {
|
||||||
|
rd->m_liveliness_changed_status.alive_count_change = 0;
|
||||||
|
rd->m_liveliness_changed_status.not_alive_count_change = 0;
|
||||||
|
dds_entity_status_reset(rd, DDS_LIVELINESS_CHANGED_STATUS);
|
||||||
|
}
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
dds_return_t dds_get_sample_rejected_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_sample_rejected_status_t * status)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_reader *rd;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_reader_lock(reader, &rd);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking reader");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
/* status = NULL, application do not need the status, but reset the counter & triggered bit */
|
||||||
|
if (status) {
|
||||||
|
*status = rd->m_sample_rejected_status;
|
||||||
|
}
|
||||||
|
if (((dds_entity*)rd)->m_status_enable & DDS_SAMPLE_REJECTED_STATUS) {
|
||||||
|
rd->m_sample_rejected_status.total_count_change = 0;
|
||||||
|
rd->m_sample_rejected_status.last_reason = DDS_NOT_REJECTED;
|
||||||
|
dds_entity_status_reset(rd, DDS_SAMPLE_REJECTED_STATUS);
|
||||||
|
}
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
dds_return_t dds_get_sample_lost_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_sample_lost_status_t * status)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_reader *rd;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_reader_lock(reader, &rd);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking reader");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
/* status = NULL, application do not need the status, but reset the counter & triggered bit */
|
||||||
|
if (status) {
|
||||||
|
*status = rd->m_sample_lost_status;
|
||||||
|
}
|
||||||
|
if (((dds_entity*)rd)->m_status_enable & DDS_SAMPLE_LOST_STATUS) {
|
||||||
|
rd->m_sample_lost_status.total_count_change = 0;
|
||||||
|
dds_entity_status_reset(rd, DDS_SAMPLE_LOST_STATUS);
|
||||||
|
}
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
dds_return_t dds_get_requested_deadline_missed_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_requested_deadline_missed_status_t * status)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_reader *rd;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
rc = dds_reader_lock(reader, &rd);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking reader");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
/* status = NULL, application do not need the status, but reset the counter & triggered bit */
|
||||||
|
if (status) {
|
||||||
|
*status = rd->m_requested_deadline_missed_status;
|
||||||
|
}
|
||||||
|
if (((dds_entity*)rd)->m_status_enable & DDS_REQUESTED_DEADLINE_MISSED_STATUS) {
|
||||||
|
rd->m_requested_deadline_missed_status.total_count_change = 0;
|
||||||
|
dds_entity_status_reset(rd, DDS_REQUESTED_DEADLINE_MISSED_STATUS);
|
||||||
|
}
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
|
||||||
|
dds_return_t dds_get_requested_incompatible_qos_status (
|
||||||
|
_In_ dds_entity_t reader,
|
||||||
|
_Out_opt_ dds_requested_incompatible_qos_status_t * status)
|
||||||
|
{
|
||||||
|
dds__retcode_t rc;
|
||||||
|
dds_reader *rd;
|
||||||
|
dds_return_t ret = DDS_RETCODE_OK;
|
||||||
|
|
||||||
|
DDS_REPORT_STACK();
|
||||||
|
|
||||||
|
rc = dds_reader_lock(reader, &rd);
|
||||||
|
if (rc != DDS_RETCODE_OK) {
|
||||||
|
ret = DDS_ERRNO(rc, "Error occurred on locking reader");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
/* status = NULL, application do not need the status, but reset the counter & triggered bit */
|
||||||
|
if (status) {
|
||||||
|
*status = rd->m_requested_incompatible_qos_status;
|
||||||
|
}
|
||||||
|
if (((dds_entity*)rd)->m_status_enable & DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS) {
|
||||||
|
rd->m_requested_incompatible_qos_status.total_count_change = 0;
|
||||||
|
dds_entity_status_reset(rd, DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS);
|
||||||
|
}
|
||||||
|
dds_reader_unlock(rd);
|
||||||
|
fail:
|
||||||
|
DDS_REPORT_FLUSH(ret != DDS_RETCODE_OK);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
53
src/core/ddsc/src/dds_report.c
Normal file
53
src/core/ddsc/src/dds_report.c
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||||
|
* v. 1.0 which is available at
|
||||||
|
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include "ddsc/dds.h"
|
||||||
|
#include "os/os.h"
|
||||||
|
#include "os/os_report.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "dds__report.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
dds_report(
|
||||||
|
os_reportType reportType,
|
||||||
|
const char *function,
|
||||||
|
int32_t line,
|
||||||
|
const char *file,
|
||||||
|
dds_return_t code,
|
||||||
|
const char *format,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
const char *retcode = NULL;
|
||||||
|
/* os_report truncates messages to <OS_REPORT_BUFLEN> bytes */
|
||||||
|
char buffer[OS_REPORT_BUFLEN];
|
||||||
|
size_t offset = 0;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
assert (function != NULL);
|
||||||
|
assert (file != NULL);
|
||||||
|
assert (format != NULL);
|
||||||
|
/* probably never happens, but you can never be to sure */
|
||||||
|
assert (OS_REPORT_BUFLEN > 0);
|
||||||
|
|
||||||
|
retcode = dds_err_str(code*-1);
|
||||||
|
offset = strlen(retcode);
|
||||||
|
assert (offset < OS_REPORT_BUFLEN);
|
||||||
|
(void)memcpy(buffer, retcode, offset);
|
||||||
|
buffer[offset] = ' ';
|
||||||
|
offset++;
|
||||||
|
|
||||||
|
va_start (args, format);
|
||||||
|
(void)os_vsnprintf (buffer + offset, sizeof(buffer) - offset, format, args);
|
||||||
|
va_end (args);
|
||||||
|
os_report (reportType, function, file, line, code, "%s", buffer);
|
||||||
|
}
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue