Gazebo Physics

API Reference

8.0.0~pre2
CompositeData.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17
18#ifndef GZ_PHYSICS_COMPOSITEDATA_HH_
19#define GZ_PHYSICS_COMPOSITEDATA_HH_
20
21#include <string>
22#include <map>
23#include <set>
24
25#include <gz/utils/SuppressWarning.hh>
26
28#include "gz/physics/Export.hh"
29
30namespace gz
31{
32 namespace physics
33 {
34 // Forward declarations
35 namespace detail
36 {
37 template <typename> class PrivateExpectData;
38 template <typename> class PrivateRequireData;
39 }
40
43 class GZ_PHYSICS_VISIBLE CompositeData
44 {
46 public: CompositeData();
47
49 public: virtual ~CompositeData() = default;
50
99 public: template <typename Data>
100 Data &Get();
101
105 public: template <typename Data>
107 {
110 public: Data &data;
111
118 public: const bool inserted;
119
120 // We explicitly delete the copy assignment operator, because we don't
121 // want someone to inadvertently assign a value to the data that's being
122 // referenced (users must do so explicitly by calling on the `data`
123 // member variable). Note that this operator is already implicitly
124 // deleted by having the const bool member variable, but we are also
125 // deleting it explicitly for clarity.
126 public: InsertResult &operator=(const InsertResult&) = delete;
127 };
128
211 public: template <typename Data, typename... Args>
212 InsertResult<Data> Insert(Args &&..._args);
213
288 public: template <typename Data, typename... Args>
290
352 public: template <typename Data>
353 bool Remove();
354
359 enum class QueryMode : int
360 {
364 NORMAL = 0,
365
368 SILENT
369 };
370
465 public: template <typename Data>
466 Data *Query(const QueryMode _mode = QueryMode::NORMAL);
467
539 public: template <typename Data>
540 const Data *Query(const QueryMode mode = QueryMode::NORMAL) const;
541
550 public: template <typename Data>
551 bool Has() const;
552
554 struct GZ_PHYSICS_VISIBLE DataStatus
555 {
558 public: bool exists;
559
563 public: bool queried;
564
567 public: bool required;
568
571 };
572
580 public: template <typename Data>
582
640 public: template <typename Data>
641 bool Unquery() const;
642
697 public: template <typename Data, typename... Args>
698 Data &MakeRequired(Args &&..._args);
699
710 public: template <typename Data>
711 bool Requires() const;
712
723 public: template <typename Data>
724 static constexpr bool Expects();
725
743 public: template <typename Data>
744 static constexpr bool AlwaysRequires();
745
751 public: std::size_t EntryCount() const;
752
760
770 public: void ResetQueries() const;
771
823
901
916 public: CompositeData &Copy(const CompositeData &_other,
917 const bool _mergeRequirements = false);
918
922 const bool _mergeRequirements = false);
923
937 public: CompositeData &Merge(const CompositeData &_other,
938 const bool _mergeRequirements = false);
939
943 const bool _mergeRequirements = false);
944
946 public: CompositeData(const CompositeData &_other);
947
949 public: CompositeData(CompositeData &&_other);
950
952 public: CompositeData &operator=(const CompositeData &_other);
953
956
962 public: struct DataEntry;
963
964 // We make this typedef public so that helper functions can use it without
965 // being friends of the class.
967
968 GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
970 protected: MapOfData dataMap;
971 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
972
977
980 protected: mutable std::size_t numQueries;
981
982 // Declare friendship
983 template <typename> friend class detail::PrivateExpectData;
984 template <typename> friend class detail::PrivateRequireData;
985 };
986 }
987}
988
989#include "gz/physics/detail/CompositeData.hh"
990
991#endif