aas-core3.1 0.0.1-alpha.1
Manipulate, verify and de/serialize asset administration shells V3.1 in C++.
Loading...
Searching...
No Matches
verification.hpp
Go to the documentation of this file.
1#ifndef AAS_CORE_AAS_3_1_VERIFICATION_GUARD_
2#define AAS_CORE_AAS_3_1_VERIFICATION_GUARD_
3
4// This code has been automatically generated by aas-core-codegen.
5// Do NOT edit or append.
6
11
12#pragma warning(push, 0)
13#include <set>
14#pragma warning(pop)
15
16namespace aas_core {
17namespace aas_3_1 {
18
23namespace verification {
24
25// region Forward declarations
26class Iterator;
27class IVerification;
28
29namespace impl {
30class IVerificator;
31} // namespace impl
32// endregion Forward declarations
33
37struct Error {
41 std::wstring cause;
42
47
48 explicit Error(std::wstring a_cause);
49 Error(std::wstring a_cause, iteration::Path a_path);
50}; // struct Error
51
76class Iterator {
77 using iterator_category = std::forward_iterator_tag;
79 using difference_type = std::ptrdiff_t;
80 using value_type = Error;
81 using pointer = const Error*;
82 using reference = const Error&;
83
84 public:
85 explicit Iterator(
86 std::unique_ptr<impl::IVerificator> verificator
87 ) :
88 verificator_(std::move(verificator)) {
89 // Intentionally empty.
90 }
91
92 Iterator(const Iterator& other);
94
95 Iterator& operator=(const Iterator& other);
97
100
101 // Prefix increment
103
104 // Postfix increment
106
107 friend bool operator==(const Iterator& a, const Iterator& b);
108 friend bool operator!=(const Iterator& a, const Iterator& b);
109
110 private:
111 std::unique_ptr<impl::IVerificator> verificator_;
112};
113
114bool operator==(const Iterator& a, const Iterator& b);
115
116bool operator!=(const Iterator& a, const Iterator& b);
117
119namespace impl {
120class IVerificator {
121 public:
122 virtual void Start() = 0;
123 virtual void Next() = 0;
124 virtual bool Done() const = 0;
125
126 virtual const Error& Get() const = 0;
127 virtual Error& GetMutable() = 0;
128 virtual long Index() const = 0;
129
130 virtual std::unique_ptr<IVerificator> Clone() const = 0;
131
132 virtual ~IVerificator() = default;
133}; // class IVerificator
134} // namespace impl
136
138 public:
139 virtual Iterator begin() const = 0;
140 virtual const Iterator& end() const = 0;
141 virtual ~IVerification() = default;
142}; // class IVerification
143
167 public:
169 const std::shared_ptr<types::IClass>& instance
170 );
171
172 Iterator begin() const override;
173 const Iterator& end() const override;
174
175 ~NonRecursiveVerification() override = default;
176 private:
177 const std::shared_ptr<types::IClass>& instance_;
178}; // class NonRecursiveVerification
179
203 public:
205 const std::shared_ptr<types::IClass>& instance
206 );
207
208 Iterator begin() const override;
209 const Iterator& end() const override;
210
211 ~RecursiveVerification() override = default;
212 private:
213 const std::shared_ptr<types::IClass>& instance_;
214}; // class RecursiveVerification
215
216// region Verification functions
217
220 const std::wstring& text
221);
222
225 const std::wstring& text
226);
227
230 const std::wstring& text
231);
232
241 const std::wstring& text
242);
243
254 const std::wstring& text
255);
256
264 const std::wstring& text
265);
266
276 const std::wstring& text
277);
278
283 const std::wstring& text
284);
285
288template<
289 typename LangStringT,
290 typename std::enable_if<
291 std::is_base_of<types::IAbstractLangString, LangStringT>::value
292 >::type* = nullptr
293>
295 const std::vector<
296 std::shared_ptr<LangStringT>
297 >& lang_strings
298) {
299 // NOTE (mristin):
300 // See: https://stackoverflow.com/questions/1349734/why-would-anyone-use-set-instead-of-unordered-set
301 // For small sets, std::set is often faster than std::unordered_set.
302 std::set<std::wstring> language_set;
303
304 for (const std::shared_ptr<LangStringT>& lang_string : lang_strings) {
305 const std::wstring& language = lang_string->language();
306
307 if (language_set.find(language) != language_set.end()) {
308 return false;
309 }
310 language_set.insert(language);
311 }
312
313 return true;
314}
315
318 const std::vector<
319 std::shared_ptr<types::IQualifier>
320 >& qualifiers
321);
322
328 const std::wstring& text
329);
330
343 const std::wstring& text
344);
345
350 const std::wstring& text
351);
352
357 const std::wstring& text
358);
359
364 const std::wstring& text
365);
366
371 const std::wstring& text
372);
373
382 const std::wstring& text
383);
384
389 const std::wstring& text
390);
391
396 const std::wstring& text
397);
398
403 const std::wstring& text
404);
405
410 const std::wstring& text
411);
412
417 const std::wstring& text
418);
419
424 const std::wstring& text
425);
426
431 const std::wstring& text
432);
433
438 const std::wstring& text
439);
440
445 const std::wstring& text
446);
447
452 const std::wstring& text
453);
454
459 const std::wstring& text
460);
461
466 const std::wstring& text
467);
468
473 const std::wstring& text
474);
475
480 const std::wstring& text
481);
482
487 const std::wstring& text
488);
489
494 const std::wstring& text
495);
496
501 const std::wstring& text
502);
503
508 const std::wstring& text
509);
510
515 const std::wstring& text
516);
517
522 const std::wstring& text
523);
524
529 const std::wstring& text
530);
531
536 const std::wstring& text
537);
538
543 const std::wstring& text
544);
545
550 const std::wstring& text
551);
552
557 const std::wstring& text
558);
559
562 const std::wstring& value,
563 types::DataTypeDefXsd value_type
564);
565
575bool IsXsDate(const std::wstring& text);
576
583bool IsXsDouble(const std::wstring& value);
584
591bool IsXsFloat(const std::wstring& value);
592
599bool IsXsGMonthDay(const std::wstring& value);
600
607bool IsXsLong(const std::wstring& value);
608
615bool IsXsInt(const std::wstring& value);
616
623bool IsXsShort(const std::wstring& value);
624
631bool IsXsByte(const std::wstring& value);
632
639bool IsXsUnsignedLong(const std::wstring& value);
640
647bool IsXsUnsignedInt(const std::wstring& value);
648
655bool IsXsUnsignedShort(const std::wstring& value);
656
663bool IsXsUnsignedByte(const std::wstring& value);
664
667 const std::shared_ptr<types::IReference>& reference,
668 types::KeyTypes expected_type
669);
670
673 const std::shared_ptr<types::IReference>& reference
674);
675
678template<
679 typename ReferableT,
680 typename std::enable_if<
681 std::is_base_of<types::IReferable, ReferableT>::value
682 >::type* = nullptr
684 const std::vector<
685 std::shared_ptr<ReferableT>
686 >& referables
687) {
688 std::set<std::wstring> id_short_set;
689
690 for (const std::shared_ptr<types::IReferable> referable : referables) {
691 const common::optional<std::wstring>& id_short = referable->id_short();
692
693 if (id_short.has_value()) {
694 if (id_short_set.find(*id_short) != id_short_set.end()) {
695 return false;
696 }
697
698 id_short_set.insert(*id_short);
699 }
700 }
701
702 return true;
703}
704
709 const common::optional<
710 std::vector<
711 std::shared_ptr<types::IOperationVariable>
712 >
713 >& input_variables,
714 const common::optional<
715 std::vector<
716 std::shared_ptr<types::IOperationVariable>
717 >
718 >& output_variables,
719 const common::optional<
720 std::vector<
721 std::shared_ptr<types::IOperationVariable>
722 >
723 >& inoutput_variables
724);
725
728 const std::vector<
729 std::shared_ptr<types::IExtension>
730 >& extensions
731);
732
735 const std::vector<
736 std::shared_ptr<types::ISubmodelElement>
737 >& elements
738);
739
743 const std::shared_ptr<types::ISubmodelElement>& element,
744 types::AasSubmodelElements element_type
745);
746
749 const std::vector<
750 std::shared_ptr<types::ISubmodelElement>
751 >& elements,
752 types::DataTypeDefXsd value_type
753);
754
757 const std::shared_ptr<types::IReference>& that,
758 const std::shared_ptr<types::IReference>& other
759);
760
764 const std::vector<
765 std::shared_ptr<types::IEmbeddedDataSpecification>
766 >& embedded_data_specifications
767);
768
772 const std::vector<
773 std::shared_ptr<types::IEmbeddedDataSpecification>
774 >& embedded_data_specifications
775);
776
780 const std::vector<
781 std::shared_ptr<types::IEmbeddedDataSpecification>
782 >& embedded_data_specifications
783);
784
788 const std::vector<
789 std::shared_ptr<types::IEmbeddedDataSpecification>
790 >& embedded_data_specifications
791);
792
796 const std::vector<
797 std::shared_ptr<types::IEmbeddedDataSpecification>
798 >& embedded_data_specifications
799);
800
804 const std::vector<
805 std::shared_ptr<types::IEmbeddedDataSpecification>
806 >& embedded_data_specifications
807);
808
811 const std::wstring& text
812);
813
814// endregion Verification functions
815
816// region Verification of constrained primitives
817
826std::unique_ptr<IVerification> VerifyXmlSerializableString(
827 const std::wstring& that
828);
829
838std::unique_ptr<IVerification> VerifyNonEmptyXmlSerializableString(
839 const std::wstring& that
840);
841
850std::unique_ptr<IVerification> VerifyDateTimeUtc(
851 const std::wstring& that
852);
853
862std::unique_ptr<IVerification> VerifyDuration(
863 const std::wstring& that
864);
865
874std::unique_ptr<IVerification> VerifyBlobType(
875 const std::vector<std::uint8_t>& that
876);
877
886std::unique_ptr<IVerification> VerifyIdentifier(
887 const std::wstring& that
888);
889
898std::unique_ptr<IVerification> VerifyValueTypeIec61360(
899 const std::wstring& that
900);
901
910std::unique_ptr<IVerification> VerifyNameType(
911 const std::wstring& that
912);
913
922std::unique_ptr<IVerification> VerifyVersionType(
923 const std::wstring& that
924);
925
934std::unique_ptr<IVerification> VerifyRevisionType(
935 const std::wstring& that
936);
937
946std::unique_ptr<IVerification> VerifyLabelType(
947 const std::wstring& that
948);
949
958std::unique_ptr<IVerification> VerifyMessageTopicType(
959 const std::wstring& that
960);
961
970std::unique_ptr<IVerification> VerifyBcp47LanguageTag(
971 const std::wstring& that
972);
973
982std::unique_ptr<IVerification> VerifyContentType(
983 const std::wstring& that
984);
985
994std::unique_ptr<IVerification> VerifyPathType(
995 const std::wstring& that
996);
997
1006std::unique_ptr<IVerification> VerifyQualifierType(
1007 const std::wstring& that
1008);
1009
1018std::unique_ptr<IVerification> VerifyValueDataType(
1019 const std::wstring& that
1020);
1021
1030std::unique_ptr<IVerification> VerifyIdShortType(
1031 const std::wstring& that
1032);
1033
1034// endregion Verification of constrained primitives
1035
1036} // namespace verification
1039} // namespace aas_3_1
1040} // namespace aas_core
1041
1042// This code has been automatically generated by aas-core-codegen.
1043// Do NOT edit or append.
1044
1045#endif // AAS_CORE_AAS_3_1_VERIFICATION_GUARD_
Definition verification.hpp:137
virtual const Iterator & end() const =0
Iterate over the verification errors.
Definition verification.hpp:76
Iterator(std::unique_ptr< impl::IVerificator > verificator)
Definition verification.hpp:85
friend bool operator!=(const Iterator &a, const Iterator &b)
Iterator & operator=(Iterator &&other)
friend bool operator==(const Iterator &a, const Iterator &b)
Iterator & operator=(const Iterator &other)
Verify that the instance conforms to the meta-model constraints.
Definition verification.hpp:166
NonRecursiveVerification(const std::shared_ptr< types::IClass > &instance)
Verify that the instance conforms to the meta-model constraints.
Definition verification.hpp:202
RecursiveVerification(const std::shared_ptr< types::IClass > &instance)
KeyTypes
Enumeration of different key value types within a key.
Definition types.hpp:182
DataTypeDefXsd
Enumeration listing all XSD anySimpleTypes.
Definition types.hpp:233
AasSubmodelElements
Enumeration of all possible elements of a ISubmodelElementList.
Definition types.hpp:118
bool MatchesXsLong(const std::wstring &text)
Check that text conforms to the pattern of an xs:long.
bool MatchesXsByte(const std::wstring &text)
Check that text conforms to the pattern of an xs:byte.
bool IsXsDouble(const std::wstring &value)
Check that value is a valid xs:double.
bool MatchesXsHexBinary(const std::wstring &text)
Check that text conforms to the pattern of an xs:hexBinary.
bool IsXsDateTimeUtc(const std::wstring &text)
Check that text is a xs:dateTime with time zone set to UTC.
bool MatchesXsGMonthDay(const std::wstring &text)
Check that text conforms to the pattern of an xs:gMonthDay.
bool MatchesXsNonNegativeInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:nonNegativeInteger.
bool IsXsUnsignedShort(const std::wstring &value)
Check that value is a valid xs:unsignedShort.
bool IsXsShort(const std::wstring &value)
Check that value is a valid xs:short.
bool MatchesXsGDay(const std::wstring &text)
Check that text conforms to the pattern of an xs:gDay.
bool MatchesXsTime(const std::wstring &text)
Check that text conforms to the pattern of an xs:time.
bool SubmodelElementIsOfType(const std::shared_ptr< types::ISubmodelElement > &element, types::AasSubmodelElements element_type)
Check that the run-time type of the element coincides with element_type.
bool MatchesXsFloat(const std::wstring &text)
Check that text conforms to the pattern of an xs:float.
bool MatchesXsUnsignedInt(const std::wstring &text)
Check that text conforms to the pattern of an xs:unsignedInt.
bool MatchesRevisionType(const std::wstring &text)
Check that text is a valid revision string.
bool DataSpecificationIec61360sHaveDefinitionAtLeastInEnglish(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::definition is defined for all data specifications w...
bool MatchesXsDuration(const std::wstring &text)
Check that text conforms to the pattern of an xs:duration.
bool PropertiesOrRangesHaveValueType(const std::vector< std::shared_ptr< types::ISubmodelElement > > &elements, types::DataTypeDefXsd value_type)
Check that all the elements have the value_type.
bool MatchesVersionType(const std::wstring &text)
Check that text is a valid version string.
std::unique_ptr< IVerification > VerifyMessageTopicType(const std::wstring &that)
Verify that the invariants hold for that value.
std::unique_ptr< IVerification > VerifyRevisionType(const std::wstring &that)
Verify that the invariants hold for that value.
bool IsXsLong(const std::wstring &value)
Check that value is a valid xs:long.
bool DataSpecificationIec61360sForPropertyOrValueHaveAppropriateDataType(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::data_type is defined appropriately for all data spe...
bool MatchesXsUnsignedShort(const std::wstring &text)
Check that text conforms to the pattern of an xs:unsignedShort.
bool MatchesXsGYearMonth(const std::wstring &text)
Check that text conforms to the pattern of an xs:gYearMonth.
bool DataSpecificationIec61360sHaveDataType(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::data_type is defined for all data specifications wh...
bool MatchesXsUnsignedByte(const std::wstring &text)
Check that text conforms to the pattern of an xs:unsignedByte.
bool IsXsDate(const std::wstring &text)
Check that value is a valid xs:date.
bool ValueConsistentWithXsdType(const std::wstring &value, types::DataTypeDefXsd value_type)
Check that the value conforms to its value_type.
std::unique_ptr< IVerification > VerifyVersionType(const std::wstring &that)
Verify that the invariants hold for that value.
bool IsXsByte(const std::wstring &value)
Check that value is a valid xs:byte.
std::unique_ptr< IVerification > VerifyContentType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsAnyUri(const std::wstring &text)
Check that text conforms to the pattern of an xs:anyURI.
bool operator!=(const Iterator &a, const Iterator &b)
std::unique_ptr< IVerification > VerifyQualifierType(const std::wstring &that)
Verify that the invariants hold for that value.
bool IdShortsOfVariablesAreUnique(const common::optional< std::vector< std::shared_ptr< types::IOperationVariable > > > &input_variables, const common::optional< std::vector< std::shared_ptr< types::IOperationVariable > > > &output_variables, const common::optional< std::vector< std::shared_ptr< types::IOperationVariable > > > &inoutput_variables)
Check that the types::IReferable::id_short's among all the input_variables, output_variables and inou...
bool ReferenceKeyValuesEqual(const std::shared_ptr< types::IReference > &that, const std::shared_ptr< types::IReference > &other)
Check that the two references are equal by comparing their key values.
bool MatchesXsDate(const std::wstring &text)
Check that text conforms to the pattern of an xs:date.
bool MatchesXsDouble(const std::wstring &text)
Check that text conforms to the pattern of an xs:double.
bool ExtensionNamesAreUnique(const std::vector< std::shared_ptr< types::IExtension > > &extensions)
Check that the extension names are unique.
bool IdShortsAreUnique(const std::vector< std::shared_ptr< ReferableT > > &referables)
Check that the types::IReferable::id_short's among the referables are unique.
Definition verification.hpp:683
std::unique_ptr< IVerification > VerifyDuration(const std::wstring &that)
Verify that the invariants hold for that value.
bool IsXsDateTime(const std::wstring &text)
Check that text is a xs:dateTime with time zone set to UTC.
bool IsXsUnsignedByte(const std::wstring &value)
Check that value is a valid xs:unsignedByte.
bool IsXsUnsignedLong(const std::wstring &value)
Check that value is a valid xs:unsignedLong.
bool LangStringsHaveUniqueLanguages(const std::vector< std::shared_ptr< LangStringT > > &lang_strings)
Check that the lang_strings do not have overlapping types::IAbstractLangString::language's.
Definition verification.hpp:294
bool MatchesXsBoolean(const std::wstring &text)
Check that text conforms to the pattern of an xs:boolean.
bool operator==(const Iterator &a, const Iterator &b)
bool IsXsUnsignedInt(const std::wstring &value)
Check that value is a valid xs:unsignedInt.
bool MatchesXsInt(const std::wstring &text)
Check that text conforms to the pattern of an xs:int.
bool MatchesXsDecimal(const std::wstring &text)
Check that text conforms to the pattern of an xs:decimal.
bool MatchesXmlSerializableString(const std::wstring &text)
Check that text conforms to the pattern of the Constraint AASd-130.
bool SubmodelElementsHaveIdenticalSemanticIds(const std::vector< std::shared_ptr< types::ISubmodelElement > > &elements)
Check that all semantic IDs are identical, if specified.
bool IsModelReferenceToReferable(const std::shared_ptr< types::IReference > &reference)
Check that the target of the reference matches a constants::kAasReferables.
bool IsXsGMonthDay(const std::wstring &value)
Check that value is a valid xs:gMonthDay.
bool MatchesXsNonPositiveInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:nonPositiveInteger.
bool IsXsInt(const std::wstring &value)
Check that value is a valid xs:int.
bool IsModelReferenceTo(const std::shared_ptr< types::IReference > &reference, types::KeyTypes expected_type)
Check that the target of the model reference matches the expected_type.
bool MatchesXsDateTime(const std::wstring &text)
Check that text conforms to the pattern of an xs:dateTime.
bool MatchesMimeType(const std::wstring &text)
Check that text conforms to the pattern of MIME type.
std::unique_ptr< IVerification > VerifyPathType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsUnsignedLong(const std::wstring &text)
Check that text conforms to the pattern of an xs:unsignedLong.
std::unique_ptr< IVerification > VerifyBlobType(const std::vector< std::uint8_t > &that)
Verify that the invariants hold for that value.
std::unique_ptr< IVerification > VerifyXmlSerializableString(const std::wstring &that)
Verify that the invariants hold for that value.
bool DataSpecificationIec61360sForDocumentHaveAppropriateDataType(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::data_type is defined appropriately for all data spe...
bool MatchesXsNegativeInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:negativeInteger.
std::unique_ptr< IVerification > VerifyDateTimeUtc(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsDateTimeUtc(const std::wstring &text)
Check that text conforms to the pattern of an xs:dateTime.
bool MatchesXsInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:integer.
std::unique_ptr< IVerification > VerifyNonEmptyXmlSerializableString(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesBcp47(const std::wstring &text)
Check that text is a valid BCP 47 language tag.
std::unique_ptr< IVerification > VerifyValueTypeIec61360(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsGYear(const std::wstring &text)
Check that text conforms to the pattern of an xs:gYear.
bool MatchesXsShort(const std::wstring &text)
Check that text conforms to the pattern of an xs:short.
std::unique_ptr< IVerification > VerifyIdShortType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesXsGMonth(const std::wstring &text)
Check that text conforms to the pattern of an xs:gMonth.
bool IsBcp47ForEnglish(const std::wstring &text)
Check that the text corresponds to a BCP47 code for english.
std::unique_ptr< IVerification > VerifyValueDataType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesRfc2396(const std::wstring &text)
Check that text matches to the URI pattern defined in RFC 2396.
std::unique_ptr< IVerification > VerifyNameType(const std::wstring &that)
Verify that the invariants hold for that value.
std::unique_ptr< IVerification > VerifyBcp47LanguageTag(const std::wstring &that)
Verify that the invariants hold for that value.
bool IsXsFloat(const std::wstring &value)
Check that value is a valid xs:float.
bool MatchesXsString(const std::wstring &text)
Check that text conforms to the pattern of an xs:string.
bool MatchesXsPositiveInteger(const std::wstring &text)
Check that text conforms to the pattern of an xs:positiveInteger.
std::unique_ptr< IVerification > VerifyLabelType(const std::wstring &that)
Verify that the invariants hold for that value.
bool MatchesIdShort(const std::wstring &text)
Check that text is a valid short ID.
bool QualifierTypesAreUnique(const std::vector< std::shared_ptr< types::IQualifier > > &qualifiers)
Check that types::IQualifier::type's of qualifiers are unique.
bool DataSpecificationIec61360sHaveValue(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::value is defined for all data specifications whose ...
bool MatchesXsBase64Binary(const std::wstring &text)
Check that text conforms to the pattern of an xs:base64Binary.
bool DataSpecificationIec61360sForReferenceHaveAppropriateDataType(const std::vector< std::shared_ptr< types::IEmbeddedDataSpecification > > &embedded_data_specifications)
Check that the types::IDataSpecificationIec61360::data_type is defined appropriately for all data spe...
std::unique_ptr< IVerification > VerifyIdentifier(const std::wstring &that)
Verify that the invariants hold for that value.
Definition common.hpp:50
Represent a path to some value.
Definition iteration.hpp:181
Definition verification.hpp:37
iteration::Path path
Definition verification.hpp:46
std::wstring cause
Definition verification.hpp:41
Error(std::wstring a_cause, iteration::Path a_path)