-
Notifications
You must be signed in to change notification settings - Fork 0
/
oaas-proxy.h
1964 lines (1798 loc) · 100 KB
/
oaas-proxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// To parse this JSON data, first install
//
// json.hpp https://github.com/nlohmann/json
//
// Then include this file, and then do
//
// OntoumlSchema data = nlohmann::json::parse(jsonString);
#pragma once
#include <optional>
#include <variant>
#include "json.hpp"
#include <optional>
#include <stdexcept>
#include <regex>
#include <unordered_map>
#ifndef NLOHMANN_OPT_HELPER
#define NLOHMANN_OPT_HELPER
namespace nlohmann {
template <typename T>
struct adl_serializer<std::shared_ptr<T>> {
static void to_json(json & j, const std::shared_ptr<T> & opt) {
if (!opt) j = nullptr; else j = *opt;
}
static std::shared_ptr<T> from_json(const json & j) {
if (j.is_null()) return std::make_shared<T>(); else return std::make_shared<T>(j.get<T>());
}
};
template <typename T>
struct adl_serializer<std::optional<T>> {
static void to_json(json & j, const std::optional<T> & opt) {
if (!opt) j = nullptr; else j = *opt;
}
static std::optional<T> from_json(const json & j) {
if (j.is_null()) return std::make_optional<T>(); else return std::make_optional<T>(j.get<T>());
}
};
}
#endif
namespace quicktype {
using nlohmann::json;
class ClassMemberConstraints {
private:
std::optional<int64_t> min_int_value;
std::optional<int64_t> max_int_value;
std::optional<double> min_double_value;
std::optional<double> max_double_value;
std::optional<size_t> min_length;
std::optional<size_t> max_length;
std::optional<std::string> pattern;
public:
ClassMemberConstraints(
std::optional<int64_t> min_int_value,
std::optional<int64_t> max_int_value,
std::optional<double> min_double_value,
std::optional<double> max_double_value,
std::optional<size_t> min_length,
std::optional<size_t> max_length,
std::optional<std::string> pattern
) : min_int_value(min_int_value), max_int_value(max_int_value), min_double_value(min_double_value), max_double_value(max_double_value), min_length(min_length), max_length(max_length), pattern(pattern) {}
ClassMemberConstraints() = default;
virtual ~ClassMemberConstraints() = default;
void set_min_int_value(int64_t min_int_value) { this->min_int_value = min_int_value; }
auto get_min_int_value() const { return min_int_value; }
void set_max_int_value(int64_t max_int_value) { this->max_int_value = max_int_value; }
auto get_max_int_value() const { return max_int_value; }
void set_min_double_value(double min_double_value) { this->min_double_value = min_double_value; }
auto get_min_double_value() const { return min_double_value; }
void set_max_double_value(double max_double_value) { this->max_double_value = max_double_value; }
auto get_max_double_value() const { return max_double_value; }
void set_min_length(size_t min_length) { this->min_length = min_length; }
auto get_min_length() const { return min_length; }
void set_max_length(size_t max_length) { this->max_length = max_length; }
auto get_max_length() const { return max_length; }
void set_pattern(const std::string & pattern) { this->pattern = pattern; }
auto get_pattern() const { return pattern; }
};
class ClassMemberConstraintException : public std::runtime_error {
public:
ClassMemberConstraintException(const std::string & msg) : std::runtime_error(msg) {}
};
class ValueTooLowException : public ClassMemberConstraintException {
public:
ValueTooLowException(const std::string & msg) : ClassMemberConstraintException(msg) {}
};
class ValueTooHighException : public ClassMemberConstraintException {
public:
ValueTooHighException(const std::string & msg) : ClassMemberConstraintException(msg) {}
};
class ValueTooShortException : public ClassMemberConstraintException {
public:
ValueTooShortException(const std::string & msg) : ClassMemberConstraintException(msg) {}
};
class ValueTooLongException : public ClassMemberConstraintException {
public:
ValueTooLongException(const std::string & msg) : ClassMemberConstraintException(msg) {}
};
class InvalidPatternException : public ClassMemberConstraintException {
public:
InvalidPatternException(const std::string & msg) : ClassMemberConstraintException(msg) {}
};
inline void CheckConstraint(const std::string & name, const ClassMemberConstraints & c, int64_t value) {
if (c.get_min_int_value() != std::nullopt && value < *c.get_min_int_value()) {
throw ValueTooLowException ("Value too low for " + name + " (" + std::to_string(value) + "<" + std::to_string(*c.get_min_int_value()) + ")");
}
if (c.get_max_int_value() != std::nullopt && value > *c.get_max_int_value()) {
throw ValueTooHighException ("Value too high for " + name + " (" + std::to_string(value) + ">" + std::to_string(*c.get_max_int_value()) + ")");
}
}
inline void CheckConstraint(const std::string & name, const ClassMemberConstraints & c, double value) {
if (c.get_min_double_value() != std::nullopt && value < *c.get_min_double_value()) {
throw ValueTooLowException ("Value too low for " + name + " (" + std::to_string(value) + "<" + std::to_string(*c.get_min_double_value()) + ")");
}
if (c.get_max_double_value() != std::nullopt && value > *c.get_max_double_value()) {
throw ValueTooHighException ("Value too high for " + name + " (" + std::to_string(value) + ">" + std::to_string(*c.get_max_double_value()) + ")");
}
}
inline void CheckConstraint(const std::string & name, const ClassMemberConstraints & c, const std::string & value) {
if (c.get_min_length() != std::nullopt && value.length() < *c.get_min_length()) {
throw ValueTooShortException ("Value too short for " + name + " (" + std::to_string(value.length()) + "<" + std::to_string(*c.get_min_length()) + ")");
}
if (c.get_max_length() != std::nullopt && value.length() > *c.get_max_length()) {
throw ValueTooLongException ("Value too long for " + name + " (" + std::to_string(value.length()) + ">" + std::to_string(*c.get_max_length()) + ")");
}
if (c.get_pattern() != std::nullopt) {
std::smatch result;
std::regex_search(value, result, std::regex( *c.get_pattern() ));
if (result.empty()) {
throw InvalidPatternException ("Value doesn't match pattern for " + name + " (" + value +" != " + *c.get_pattern() + ")");
}
}
}
#ifndef NLOHMANN_UNTYPED_quicktype_HELPER
#define NLOHMANN_UNTYPED_quicktype_HELPER
inline json get_untyped(const json & j, const char * property) {
if (j.find(property) != j.end()) {
return j.at(property).get<json>();
}
return json();
}
inline json get_untyped(const json & j, std::string property) {
return get_untyped(j, property.data());
}
#endif
#ifndef NLOHMANN_OPTIONAL_quicktype_HELPER
#define NLOHMANN_OPTIONAL_quicktype_HELPER
template <typename T>
inline std::shared_ptr<T> get_heap_optional(const json & j, const char * property) {
auto it = j.find(property);
if (it != j.end() && !it->is_null()) {
return j.at(property).get<std::shared_ptr<T>>();
}
return std::shared_ptr<T>();
}
template <typename T>
inline std::shared_ptr<T> get_heap_optional(const json & j, std::string property) {
return get_heap_optional<T>(j, property.data());
}
template <typename T>
inline std::optional<T> get_stack_optional(const json & j, const char * property) {
auto it = j.find(property);
if (it != j.end() && !it->is_null()) {
return j.at(property).get<std::optional<T>>();
}
return std::optional<T>();
}
template <typename T>
inline std::optional<T> get_stack_optional(const json & j, std::string property) {
return get_stack_optional<T>(j, property.data());
}
#endif
/**
* An object that represents a reference to a resource by its name and its URI allowing
* references to resources in the semantic web.
*/
class Resource {
public:
Resource() = default;
virtual ~Resource() = default;
private:
std::optional<std::map<std::string, std::string>> name;
std::optional<std::string> uri;
public:
/**
* Determines the name of the resource using a language string.
*/
std::optional<std::map<std::string, std::string>> get_name() const { return name; }
void set_name(std::optional<std::map<std::string, std::string>> value) { this->name = value; }
/**
* Determines the Uniform Resource Identifier (URI) of the resource using a string.
*/
std::optional<std::string> get_uri() const { return uri; }
void set_uri(std::optional<std::string> value) { this->uri = value; }
};
enum class AggregationKind : int { COMPOSITE, NONE, SHARED };
enum class RestrictedTo : int { ABSTRACT, COLLECTIVE, EVENT, EXTRINSIC_MODE, FUNCTIONAL_COMPLEX, INTRINSIC_MODE, QUALITY, QUANTITY, RELATOR, SITUATION, TYPE };
using Text = std::variant<std::map<std::string, std::string>, std::string>;
enum class ElementType : int { BINARY_RELATION, BINARY_RELATION_VIEW, CLASS, CLASS_VIEW, DIAGRAM, GENERALIZATION, GENERALIZATION_SET, GENERALIZATION_SET_VIEW, GENERALIZATION_VIEW, LINK, LINK_VIEW, NARY_RELATION, NARY_RELATION_VIEW, NOTE, NOTE_VIEW, PACKAGE_VIEW };
/**
* A named element that contains the visual representation (i.e., the concrete syntax) of an
* OntoUML model or of a portion of it.
*
* An OntoUML element that represents a single model element in a diagram.
*
* A view element connects a model element to the shapes in a diagram necessary to represent
* a single occurrence of it. For example, an n-ary relation view connects a single relation
* element to one diamond and a set of paths that represent a single occurrence of it in a
* diagram. Multiple views can represent multiple occurrences of an element in the same
* diagram.
*
* A view element is responsible for what portions of a model element are present in a
* single diagram representation (e.g., whether the cardinality of a property is shown),
* unlike a shape, which is responsible for aspects of the actual drawing (e.g., how to
* render a portion of a view, in which position, and with which dimensions).
*
* A view element that represents the single occurrence of a class in a diagram.
*
* A view element that represents the single occurrence of a generalization set in a
* diagram.
*
* A view element that represents the single occurrence of a n-ary relation in a diagram.
*
* A view element that represents the single occurrence of a note in a diagram.
*
* A view element that represents the single occurrence of a package in a diagram.
*
* A view element that represents the single occurrence of a binary connector (e.g., a
* binary relation, or a generalization) in a diagram.
*
* A view element that represents the single occurrence of a binary relation in a diagram.
*
* A view element that represents the single occurrence of a link in a diagram.
*
* A model element that can be grouped into a package.
*
* A decoratable element (either a class or a relation) that defines properties exhibited by
* its instances.
*
* A classifier that defines the properties of a set of "individualized" entities (i.e.,
* non-relational) of the subject domain.
*
* Examples include "Person", "Enrollment", and "Grade".
*
* The instances of a class may include entities such as objects (e.g., people,
* organizations, vehicles), reified properties (e.g., leafs' colors, agents' intentions,
* enrollments), and bare values (e.g., a number or a literal).
*
* A relation that defines the properties of a set of binary relations of the subject
* domain.
*
* Examples include "studies in", and derivation relations (e.g., between material relations
* and relators).
*
* A binary relation may either connect two classes, or a relation (as source) and a class
* (as target) in the case of derivation relations connecting descriptive relations to the
* classes that serve as their truthmakers (as in the relation between the material relation
* "studies in" and the "Enrollment" relator).
*
* A relation that defines the properties of a set of relations of the subject domain that
* connect more than two members.
*
* Examples include "studies in", "buys product from" (ternary relation), and derivation
* relations (e.g., between material relations and relators).
*
* A model element that represents the generalization of a specific classifier into a
* general classifier. When read in the inverse direction, a generalization is referred to
* as a specialization.
*
* Examples include the generalization of a specific class "Student" into a general class
* "Person," and the generalization of a specific relation "close friends with" into a
* general relation "friends with".
*
* A generalization can only connect two classifiers of the same type, i.e., it can either
* connect two class elements or two relation elements.
*
* A model element that represents a group of connected generalization elements. A
* generalization set can define disjoint and/or complete constraints over the
* generalizations it groups.
*
* Examples include the incomplete (i.e., non-complete) and overlapping (i.e., non-disjoint)
* generalization set of "Person" into "Student" and "Teacher", and the disjoint and
* complete generalization set of "Person" into "Child" and "Adult".
*
* All generalizations in the generalization set must share a common general classifier.
*
* A model element that connects a note to a model element it concerns.
*
* A model element that contains an annotation about the ontology or some of its elements. A
* note can also be used to represent a constraint in both natural or structured language
* (i.e., first-order logic, or OCL).
*/
class Element {
public:
Element() :
is_view_of_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
rectangle_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
diamond_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
path_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
source_view_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
target_view_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
general_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
specific_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
element_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
note_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt)
{}
virtual ~Element() = default;
private:
std::optional<std::string> owner;
ElementType type;
std::optional<std::vector<std::string>> views;
std::optional<std::string> is_view_of;
ClassMemberConstraints is_view_of_constraint;
std::optional<std::string> rectangle;
ClassMemberConstraints rectangle_constraint;
std::optional<std::vector<std::string>> generalizations;
std::optional<Text> text;
std::optional<std::string> diamond;
ClassMemberConstraints diamond_constraint;
std::optional<std::vector<std::string>> members;
std::optional<std::vector<std::string>> paths;
std::optional<std::string> path;
ClassMemberConstraints path_constraint;
std::optional<std::string> source_view;
ClassMemberConstraints source_view_constraint;
std::optional<std::string> target_view;
ClassMemberConstraints target_view_constraint;
std::optional<bool> is_abstract;
std::optional<std::vector<std::string>> properties;
std::optional<bool> is_powertype;
std::optional<std::vector<std::string>> literals;
std::optional<std::string> order;
std::optional<std::vector<RestrictedTo>> restricted_to;
std::optional<std::string> general;
ClassMemberConstraints general_constraint;
std::optional<std::string> specific;
ClassMemberConstraints specific_constraint;
std::optional<std::string> categorizer;
std::optional<bool> is_complete;
std::optional<bool> is_disjoint;
std::optional<std::string> element;
ClassMemberConstraints element_constraint;
std::optional<std::string> note;
ClassMemberConstraints note_constraint;
public:
/**
* Identifies the model element that is the owner of a diagram.
*/
std::optional<std::string> get_owner() const { return owner; }
void set_owner(std::optional<std::string> value) { this->owner = value; }
/**
* Determines the type of a diagram object.
*
* Determines the type of a class view object.
*
* Determines the type of a generalization set view object.
*
* Determines the type of a n-ary relation view object.
*
* Determines the type of a note view object.
*
* Determines the type of a package view object.
*
* Determines the type of a generalization view object.
*
* Determines the type of a link view object.
*
* Determines the type of a binary relation view object.
*
* Determines the type of a class object.
*
* Determines the type of a binary relation object.
*
* Determines the type of a n-ary relation object.
*
* Determines the type of a generalization object.
*
* Determines the type of a generalization set object.
*
* Determines the type of a link object.
*
* Determines the type of a note object.
*/
const ElementType & get_type() const { return type; }
ElementType & get_mutable_type() { return type; }
void set_type(const ElementType & value) { this->type = value; }
/**
* Identifies the views contained in the diagram.
*/
std::optional<std::vector<std::string>> get_views() const { return views; }
void set_views(std::optional<std::vector<std::string>> value) { this->views = value; }
/**
* Identifies the model element that the view represents in the diagram.
*/
std::optional<std::string> get_is_view_of() const { return is_view_of; }
void set_is_view_of(std::optional<std::string> value) { if (value) CheckConstraint("is_view_of", is_view_of_constraint, *value); this->is_view_of = value; }
/**
* Identifies the rectangle shape that renders the class view in the diagram.
*
* Identifies the rectangle shape that renders the package view in the diagram.
*/
std::optional<std::string> get_rectangle() const { return rectangle; }
void set_rectangle(std::optional<std::string> value) { if (value) CheckConstraint("rectangle", rectangle_constraint, *value); this->rectangle = value; }
/**
* Identifies the generalization views that are grouped by the generalization set view in
* the diagram.
*
* Identifies all generalizations that are involved by the generalization set.
*/
std::optional<std::vector<std::string>> get_generalizations() const { return generalizations; }
void set_generalizations(std::optional<std::vector<std::string>> value) { this->generalizations = value; }
/**
* Identifies the text shape that renders the generalization set view in the diagram.
*
* Identifies the text shape that renders the note view in the diagram.
*
* Determines the contents of a note using a language string.
*/
std::optional<Text> get_text() const { return text; }
void set_text(std::optional<Text> value) { this->text = value; }
/**
* Identifies the diamond shape that renders the joining of all paths of the n-ary relation
* in the diagram.
*/
std::optional<std::string> get_diamond() const { return diamond; }
void set_diamond(std::optional<std::string> value) { if (value) CheckConstraint("diamond", diamond_constraint, *value); this->diamond = value; }
/**
* Identifies the class views (i.e., the members) that are connected by the n-ary relation
* view in the diagram. This array of member views must be ordered according to the
* properties of the relation the view represents.
*/
std::optional<std::vector<std::string>> get_members() const { return members; }
void set_members(std::optional<std::vector<std::string>> value) { this->members = value; }
/**
* Identifies the path shapes that render each path of the n-ary relation view in the
* diagram. This array of paths must be ordered according to the properties of the relation
* the view represents.
*/
std::optional<std::vector<std::string>> get_paths() const { return paths; }
void set_paths(std::optional<std::vector<std::string>> value) { this->paths = value; }
/**
* Identifies the path shape that renders the binary connector in the diagram.
*/
std::optional<std::string> get_path() const { return path; }
void set_path(std::optional<std::string> value) { if (value) CheckConstraint("path", path_constraint, *value); this->path = value; }
/**
* Identifies the source view the binary connector view connects in the diagram.
*/
std::optional<std::string> get_source_view() const { return source_view; }
void set_source_view(std::optional<std::string> value) { if (value) CheckConstraint("source_view", source_view_constraint, *value); this->source_view = value; }
/**
* Identifies the target view the binary connector view connects in the diagram.
*/
std::optional<std::string> get_target_view() const { return target_view; }
void set_target_view(std::optional<std::string> value) { if (value) CheckConstraint("target_view", target_view_constraint, *value); this->target_view = value; }
/**
* Determines whether the classifier can have direct instances using a boolean. Abstract
* classifiers can only have instances when these are instances of some other classifier
* that is not abstract (i.e., concrete) and is a specialization of the abstract one.
*/
std::optional<bool> get_is_abstract() const { return is_abstract; }
void set_is_abstract(std::optional<bool> value) { this->is_abstract = value; }
/**
* Identifies the properties contained in a classifier. These properties are referred to as
* attributes when contained by classes, and relation ends when contained by relations. In
* the case of relations, the properties array must be ordered.
*/
std::optional<std::vector<std::string>> get_properties() const { return properties; }
void set_properties(std::optional<std::vector<std::string>> value) { this->properties = value; }
/**
* Determines whether the high-order class is a "Cardelli powertype" using a boolean. In
* other words, determines whether the high-order class is defined as the one whose
* instances are its base type plus all possible specializations of it.
*/
std::optional<bool> get_is_powertype() const { return is_powertype; }
void set_is_powertype(std::optional<bool> value) { this->is_powertype = value; }
/**
* Identifies the literals of an enumeration class.
*/
std::optional<std::vector<std::string>> get_literals() const { return literals; }
void set_literals(std::optional<std::vector<std::string>> value) { this->literals = value; }
/**
* Determines the instantiation order of a class using a string. Examples include ordered
* classes such as first-order classes (order "1"), second-order classes (order "2"), and
* third-order classes (order "3"), as well as orderless classes (order "*").
*/
std::optional<std::string> get_order() const { return order; }
void set_order(std::optional<std::string> value) { this->order = value; }
/**
* Determines the possible ontological natures of the instances of a class using an array of
* enumerated strings.
*
* Examples include the class "Vehicle" restricted to having "functional-complex" instances
* and the class "Insured Item" restricted to "functional-complex" and "relator" (e.g.,
* employment insurance).
*/
std::optional<std::vector<RestrictedTo>> get_restricted_to() const { return restricted_to; }
void set_restricted_to(std::optional<std::vector<RestrictedTo>> value) { this->restricted_to = value; }
/**
* Identifies the general classifier in a generalization element. E.g., in the
* generalization of "Student" into "Person", "Person" is the general classifier.
*/
std::optional<std::string> get_general() const { return general; }
void set_general(std::optional<std::string> value) { if (value) CheckConstraint("general", general_constraint, *value); this->general = value; }
/**
* Identifies the general classifier in a generalization element. E.g., in the
* generalization of "Student" into "Person", "Student" is the specific classifier.
*/
std::optional<std::string> get_specific() const { return specific; }
void set_specific(std::optional<std::string> value) { if (value) CheckConstraint("specific", specific_constraint, *value); this->specific = value; }
/**
* Identifies the high-order class that classifies (i.e., is instantiated by) every specific
* class in the generalization set.
*
* For example, "Academic Role" as the categorizer of the generalization set of "Person"
* into "Student" and "Teacher" representing the specific classes as instances of the
* categorizer.
*
* A categorizer can only be present in generalization sets involving exclusively classes.
*/
std::optional<std::string> get_categorizer() const { return categorizer; }
void set_categorizer(std::optional<std::string> value) { this->categorizer = value; }
/**
* Determines whether the specific classifiers in the generalization set completely cover
* the extension of the general classifier.
*
* Examples include the generalization set involving "Child" and "Adult" generalized into
* "Person", where the "is complete" as "true" indicates that every person is either an
* instance of "Child" or "Adult."
*/
std::optional<bool> get_is_complete() const { return is_complete; }
void set_is_complete(std::optional<bool> value) { this->is_complete = value; }
/**
* Determines whether the specific classifiers in the generalization set have disjoint
* extensions.
*
* Examples include the generalization set involving "Child" and "Adult" generalized into
* "Person", where the "is disjoint" as "true" indicates that no person is simultaneously an
* instance of "Child" and "Adult."
*/
std::optional<bool> get_is_disjoint() const { return is_disjoint; }
void set_is_disjoint(std::optional<bool> value) { this->is_disjoint = value; }
/**
* Identifies the model element the link connects.
*/
std::optional<std::string> get_element() const { return element; }
void set_element(std::optional<std::string> value) { if (value) CheckConstraint("element", element_constraint, *value); this->element = value; }
/**
* Identifies the note the link connects.
*/
std::optional<std::string> get_note() const { return note; }
void set_note(std::optional<std::string> value) { if (value) CheckConstraint("note", note_constraint, *value); this->note = value; }
};
/**
* A object that represents a point in a diagram through (x,y) coordinates (horizontal and
* vertical), where the top left corner of the diagram represents the coordinates (0,0)
* which increase downwards and rightwards.
*
* Determines the coordinates of the top left corner of the rectangular shape using a point
* object.
*/
class Point {
public:
Point() :
x_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
y_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt)
{}
virtual ~Point() = default;
private:
int64_t x;
ClassMemberConstraints x_constraint;
int64_t y;
ClassMemberConstraints y_constraint;
public:
/**
* Determines the horizontal coordinate of a point using a positive integer.
*/
const int64_t & get_x() const { return x; }
int64_t & get_mutable_x() { return x; }
void set_x(const int64_t & value) { CheckConstraint("x", x_constraint, value); this->x = value; }
/**
* Determines the vertical coordinate of a point using a positive integer.
*/
const int64_t & get_y() const { return y; }
int64_t & get_mutable_y() { return y; }
void set_y(const int64_t & value) { CheckConstraint("y", y_constraint, value); this->y = value; }
};
enum class OntoUmlElementType : int { BINARY_RELATION, BINARY_RELATION_VIEW, CLASS, CLASS_VIEW, DIAMOND, GENERALIZATION, GENERALIZATION_SET, GENERALIZATION_SET_VIEW, GENERALIZATION_VIEW, LINK, LINK_VIEW, LITERAL, NARY_RELATION, NARY_RELATION_VIEW, NOTE, NOTE_VIEW, PACKAGE, PACKAGE_VIEW, PATH, PROJECT, PROPERTY, RECTANGLE, TEXT };
/**
* An identified element of an OntoUML ontology according to the OntoUML Metamodel, which
* includes projects, model elements, diagrams, views, and shapes.
*
* An OntoUML element that can be assigned a name and other descriptive information.
*
* A named element that serves as the container of an entire OntoUML ontology, including the
* elements of both the abstract syntax (i.e., model elements) and the concrete syntax
* (i.e., diagrams, view, and shapes).
*
* A named element that represents an element of the language's abstract syntax (e.g., a
* class, a relation, or a generalization).
*
* A model element that represents the generalization of a specific classifier into a
* general classifier. When read in the inverse direction, a generalization is referred to
* as a specialization.
*
* Examples include the generalization of a specific class "Student" into a general class
* "Person," and the generalization of a specific relation "close friends with" into a
* general relation "friends with".
*
* A generalization can only connect two classifiers of the same type, i.e., it can either
* connect two class elements or two relation elements.
*
* A model element that represents a group of connected generalization elements. A
* generalization set can define disjoint and/or complete constraints over the
* generalizations it groups.
*
* Examples include the incomplete (i.e., non-complete) and overlapping (i.e., non-disjoint)
* generalization set of "Person" into "Student" and "Teacher", and the disjoint and
* complete generalization set of "Person" into "Child" and "Adult".
*
* All generalizations in the generalization set must share a common general classifier.
*
* A model element that connects a note to a model element it concerns.
*
* A model element that represents a specific value within an enumerated set of values.
* Examples include each letter in an A to F letter grading scale, listed in a class "Letter
* Grade" decorated with the stereotype "enumeration".
*
* A model element that contains an annotation about the ontology or some of its elements. A
* note can also be used to represent a constraint in both natural or structured language
* (i.e., first-order logic, or OCL).
*
* A model element that can group other model elements that are referred to as "packageable
* elements." Package elements are used to perform the modularization of an ontology.
*
* While the OntoUML Metamodel does not require package elements to follow a tree structure
* (i.e., it allows overlapping packages), ontologies that require UML representations
* should adhere to this constraint for compatibility.
*
* A model element that can be decorated with a stereotype to identify its ontological
* properties according to the Unified Foundational Ontology (UFO).
*
* Examples include a class decorated with the stereotype "kind" identifying it as a type of
* object that provides an identity principle to its instances.
*
* A decoratable element that represents an attribute of a class, or one end of a relation.
*
* Examples include the attribute "name" of the class "Person", and the ends of the binary
* relation "studies in" connected to the classes "Student" and "University."
*
* Instances of class and relation elements bear values for the properties these classifiers
* contain, according to the constraints specified within each property. For example, the
* value assigned to a property in an instance must be itself an instance of the classifier
* in property type.
*
* A decoratable element (either a class or a relation) that defines properties exhibited by
* its instances.
*
* A classifier that defines the properties of a set of "individualized" entities (i.e.,
* non-relational) of the subject domain.
*
* Examples include "Person", "Enrollment", and "Grade".
*
* The instances of a class may include entities such as objects (e.g., people,
* organizations, vehicles), reified properties (e.g., leafs' colors, agents' intentions,
* enrollments), and bare values (e.g., a number or a literal).
*
* A relation that defines the properties of a set of binary relations of the subject
* domain.
*
* Examples include "studies in", and derivation relations (e.g., between material relations
* and relators).
*
* A binary relation may either connect two classes, or a relation (as source) and a class
* (as target) in the case of derivation relations connecting descriptive relations to the
* classes that serve as their truthmakers (as in the relation between the material relation
* "studies in" and the "Enrollment" relator).
*
* A relation that defines the properties of a set of relations of the subject domain that
* connect more than two members.
*
* Examples include "studies in", "buys product from" (ternary relation), and derivation
* relations (e.g., between material relations and relators).
*
* An OntoUML element that identifies how to render a view (or a portion of one) in a
* diagram.
*
* A shape defined by a list of points connecting two other shapes.
*
* A shape defined by a top left position, a height, a width.
*
* A rectangular shape that renders the joining diamond of a n-ary relation view.
*
* A rectangular shape that renders the shape of a class view or a package view.
*
* A rectangular shape that renders the shape of a generalization set view or a note view.
*
* An OntoUML element that represents a single model element in a diagram.
*
* A view element connects a model element to the shapes in a diagram necessary to represent
* a single occurrence of it. For example, an n-ary relation view connects a single relation
* element to one diamond and a set of paths that represent a single occurrence of it in a
* diagram. Multiple views can represent multiple occurrences of an element in the same
* diagram.
*
* A view element is responsible for what portions of a model element are present in a
* single diagram representation (e.g., whether the cardinality of a property is shown),
* unlike a shape, which is responsible for aspects of the actual drawing (e.g., how to
* render a portion of a view, in which position, and with which dimensions).
*
* A view element that represents the single occurrence of a class in a diagram.
*
* A view element that represents the single occurrence of a generalization set in a
* diagram.
*
* A view element that represents the single occurrence of a n-ary relation in a diagram.
*
* A view element that represents the single occurrence of a note in a diagram.
*
* A view element that represents the single occurrence of a package in a diagram.
*
* A view element that represents the single occurrence of a binary connector (e.g., a
* binary relation, or a generalization) in a diagram.
*
* A view element that represents the single occurrence of a binary relation in a diagram.
*
* A view element that represents the single occurrence of a link in a diagram.
*
* The OntoUML Schema defines the JSON serializations of OntoUML ontologies and their
* contents according to the OntoUML Metamodel project.
*/
class OntoumlSchema {
public:
OntoumlSchema() :
id_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
general_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
specific_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
element_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
note_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
height_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
width_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
is_view_of_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
rectangle_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
diamond_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
path_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
source_view_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt),
target_view_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 1, std::nullopt, std::nullopt)
{}
virtual ~OntoumlSchema() = default;
private:
std::string created;
std::string id;
ClassMemberConstraints id_constraint;
std::optional<std::string> modified;
std::optional<std::vector<std::map<std::string, std::string>>> alternative_names;
std::optional<std::vector<Resource>> contributors;
std::optional<std::vector<Resource>> creators;
std::optional<std::map<std::string, std::string>> description;
std::optional<std::vector<std::map<std::string, std::string>>> editorial_notes;
std::optional<std::map<std::string, std::string>> name;
std::optional<std::vector<Resource>> access_rights;
std::optional<std::vector<std::string>> acronyms;
std::optional<std::vector<std::map<std::string, std::string>>> bibliographic_citations;
std::optional<std::vector<Resource>> contexts;
std::optional<std::vector<Resource>> designed_for_tasks;
std::optional<std::vector<Element>> elements;
std::optional<std::vector<std::map<std::string, std::string>>> keywords;
std::optional<std::vector<std::string>> landing_pages;
std::optional<std::vector<std::string>> languages;
std::optional<Resource> license;
std::optional<std::string> onto_uml_element_namespace;
std::optional<std::vector<Resource>> ontology_types;
std::optional<Resource> publisher;
std::optional<Resource> representation_style;
std::optional<std::string> root;
std::optional<std::vector<std::string>> sources;
std::optional<std::vector<Resource>> themes;
OntoUmlElementType type;
std::optional<std::map<std::string, nlohmann::json>> custom_properties;
std::optional<std::string> general;
ClassMemberConstraints general_constraint;
std::optional<std::string> specific;
ClassMemberConstraints specific_constraint;
std::optional<std::string> categorizer;
std::optional<std::vector<std::string>> generalizations;
std::optional<bool> is_complete;
std::optional<bool> is_disjoint;
std::optional<std::string> element;
ClassMemberConstraints element_constraint;
std::optional<std::string> note;
ClassMemberConstraints note_constraint;
std::optional<Text> text;
std::optional<std::vector<std::string>> contents;
std::optional<bool> is_derived;
std::optional<std::string> stereotype;
std::optional<AggregationKind> aggregation_kind;
std::optional<std::string> cardinality;
std::optional<bool> is_ordered;
std::optional<bool> is_read_only;
std::optional<std::string> property_type;
std::optional<std::vector<std::string>> redefined_properties;
std::optional<std::vector<std::string>> subsetted_properties;
std::optional<bool> is_abstract;
std::optional<std::vector<std::string>> properties;
std::optional<bool> is_powertype;
std::optional<std::vector<std::string>> literals;
std::optional<std::string> order;
std::optional<std::vector<RestrictedTo>> restricted_to;
std::optional<std::vector<Point>> points;
std::optional<int64_t> height;
ClassMemberConstraints height_constraint;
std::optional<Point> top_left;
std::optional<int64_t> width;
ClassMemberConstraints width_constraint;
std::optional<std::string> is_view_of;
ClassMemberConstraints is_view_of_constraint;
std::optional<std::string> rectangle;
ClassMemberConstraints rectangle_constraint;
std::optional<std::string> diamond;
ClassMemberConstraints diamond_constraint;
std::optional<std::vector<std::string>> members;
std::optional<std::vector<std::string>> paths;
std::optional<std::string> path;
ClassMemberConstraints path_constraint;
std::optional<std::string> source_view;
ClassMemberConstraints source_view_constraint;
std::optional<std::string> target_view;
ClassMemberConstraints target_view_constraint;
public:
/**
* Determines when the element was created using a string in one of the following formats:
* year, year-month, date, or date-time.
*/
const std::string & get_created() const { return created; }
std::string & get_mutable_created() { return created; }
void set_created(const std::string & value) { this->created = value; }
/**
* Determines the unique identifier for an OntoUML element in an ontology using a non-empty
* string.
*/
const std::string & get_id() const { return id; }
std::string & get_mutable_id() { return id; }
void set_id(const std::string & value) { CheckConstraint("id", id_constraint, value); this->id = value; }
/**
* Determines when the element was modified using a string in one of the following formats:
* year, year-month, date, or date-time.
*/
std::optional<std::string> get_modified() const { return modified; }
void set_modified(std::optional<std::string> value) { this->modified = value; }
/**
* Determines alternative names of the named element using an array of language strings.
* Alternative names are not translations of the named element, but indeed alternatives or
* synonyms to the main one.
*/
std::optional<std::vector<std::map<std::string, std::string>>> get_alternative_names() const { return alternative_names; }
void set_alternative_names(std::optional<std::vector<std::map<std::string, std::string>>> value) { this->alternative_names = value; }
/**
* Identifies the agents who contributed to the development of the named element.
*/
std::optional<std::vector<Resource>> get_contributors() const { return contributors; }
void set_contributors(std::optional<std::vector<Resource>> value) { this->contributors = value; }
/**
* Identifies the agents who contributed to the creation of the named element.
*/
std::optional<std::vector<Resource>> get_creators() const { return creators; }
void set_creators(std::optional<std::vector<Resource>> value) { this->creators = value; }
/**
* Determines a free-text account of the named element using language string.
*/
std::optional<std::map<std::string, std::string>> get_description() const { return description; }
void set_description(std::optional<std::map<std::string, std::string>> value) { this->description = value; }
/**
* Determines general notes about the named element using an array of language strings.
* Editorial notes are typically notes on the development process and must not be confused
* with descriptions.
*/
std::optional<std::vector<std::map<std::string, std::string>>> get_editorial_notes() const { return editorial_notes; }
void set_editorial_notes(std::optional<std::vector<std::map<std::string, std::string>>> value) { this->editorial_notes = value; }
/**
* Determines the name of the named element using language string.
*/
std::optional<std::map<std::string, std::string>> get_name() const { return name; }
void set_name(std::optional<std::map<std::string, std::string>> value) { this->name = value; }
/**
* Identifies a document or a text concerning who and how the project can be accessed. E.g.,
* the document <http://publications.europa.eu/resource/authority/access-right/PUBLIC>
* informs that something is "publicly accessible by everyone."
*/
std::optional<std::vector<Resource>> get_access_rights() const { return access_rights; }
void set_access_rights(std::optional<std::vector<Resource>> value) { this->access_rights = value; }
/**
* Determines the acronyms one can use to refer to the project using strings. E.g.,
* "RDBS-O", "COVER", "ROT".
*/
std::optional<std::vector<std::string>> get_acronyms() const { return acronyms; }
void set_acronyms(std::optional<std::vector<std::string>> value) { this->acronyms = value; }
/**
* Determines bibliographic references for the project using language strings. E.g.,
* "Weigand, H., Johannesson, P., & Andersson, B. (2021). An artifact ontology for design
* science research. Data & Knowledge Engineering, 133".
*/
std::optional<std::vector<std::map<std::string, std::string>>> get_bibliographic_citations() const { return bibliographic_citations; }
void set_bibliographic_citations(std::optional<std::vector<std::map<std::string, std::string>>> value) { this->bibliographic_citations = value; }
/**
* Identifies the contexts in which the project was developed. The OntoUML/UFO Catalog
* Metadata Vocabulary (OCMV) provides a set of recurrent modeling contexts:
*
* - ocmv:Research: The project was developed as part of a research project. This usually
* implies that the project was featured in a scientific publication.
*
* - ocmv:Industry: The project was developed for a public or private organization.
*