Conscience Core
CommandParamsSpec.h
Go to the documentation of this file.
1 #ifndef ConscienceEnvironmentInteractionCommandParams_h
2 #define ConscienceEnvironmentInteractionCommandParams_h
3 
4 #include "CscCommon.h"
5 #include "Util/json.h"
6 #include <any>
7 #include <functional>
8 #include <type_traits>
9 #include <typeinfo>
10 #include <shared_mutex>
13 
14 using std::type_info, std::any, std::shared_mutex, std::shared_lock, std::unique_lock, std::any_cast, std::function;
15 using namespace conscience_utils::mutexutils;
16 using namespace conscience_core::bridging;
17 
18 #define FOR_EACH_PAIR(macro, ...) \
19  __VA_OPT__(MACRO_EXPAND(FOR_EACH_PAIR_HELPER(macro, __VA_ARGS__)))
20 
21 #define FOR_EACH_PAIR_HELPER(macro, a1, a2, ...) \
22  macro(a1, a2) \
23  __VA_OPT__(FOR_EACH_PAIR_AGAIN MACRO_PARENS(macro, __VA_ARGS__))
24 #define FOR_EACH_PAIR_AGAIN() FOR_EACH_PAIR_HELPER
25 
26 template <typename TClass>
27 const TClass *anyToPointer(const any &objectAny) {
28  if (!objectAny.has_value()) {
29  return nullptr;
30  }
31  try {
32  ptr<const TClass> objectPtr = any_cast<ptr<const TClass>>(objectAny);
33  return objectPtr == nullptr ? nullptr : objectPtr.get();
34  } catch (exception &e) {
35  }
36  try {
37  ptr<TClass> objectPtr = any_cast<ptr<TClass>>(objectAny);
38  return objectPtr == nullptr ? nullptr : objectPtr.get();
39  } catch (exception &e) {
40  }
41  try {
42  return any_cast<TClass *>(objectAny);
43  } catch (exception &e) {
44  }
45  try {
46  return any_cast<const TClass *>(objectAny);
47  } catch (exception &e) {
48  }
49  throw runtime_error("cannot get " + getClassName(typeid(TClass), true) + "* from " + getClassName(objectAny.type(), true));
50 }
51 
52 template <class TValue>
53 using map_by_string = std::map<string, TValue>;
54 
55 template <class TValue>
56 using map_by_int = std::map<int, TValue>;
57 
58 using namespace conscience_utils::JSON;
59 
61 
62 ENUM(CommandParamMetaType,
63  CommandParamMetaType_double,
64  CommandParamMetaType_float,
65  CommandParamMetaType_int,
66  CommandParamMetaType_long,
67  CommandParamMetaType_unsigned_long_long,
68  CommandParamMetaType_bool,
69  CommandParamMetaType_string,
70  CommandParamMetaType_list,
71  CommandParamMetaType_map,
72  CommandParamMetaType_object,
73  CommandParamMetaType_optional,
74  CommandParamMetaType_enum,
75  CommandParamMetaType_entityReflexion,
76  CommandParamMetaType_entityModel,
77  CommandParamMetaType_placeModel,
78  CommandParamMetaType_objectModel);
79 
84 public:
85  MissingCommandDataTypeException(const string &missingParamType, const string &message);
86  const string missingParamTypeName;
87 };
88 
93 public:
94  MissingCommandMetadataException(const string &missingCommandId, const string &message);
95  const string missingCommandId;
96 };
97 
102 public:
103  WrongCommandDataTypeDuringParseException(const string &name, CommandParamMetaType expectedType, int actualUnderlyingType);
104  const string name;
105  const CommandParamMetaType expectedType;
107 };
108 
113 public:
114  WrongCommandParamsSizeDuringParseException(const string &name, int expectedSize, int actualSize);
115  const string name;
116  const int expectedSize;
117  const int actualSize;
118 };
119 
121 public:
122  virtual map<string, JsonSerializableData> toJsonMap() = 0;
123 };
124 
126 
130  map<string, unsigned long long> values;
131  map<string, string> valuesDoc;
132  string doc;
133  string headerFileRelativePath = "";
134 
135  string toString() const {
136  return enumQualifiedName + " - values=" + mapToString(values) + " - headerFileRelativePath=" + headerFileRelativePath;
137  }
138 };
139 
148 };
149 
151  return refType == CommandPtrType_STAR || refType == CommandPtrType_SHARED;
152 }
153 
158 private:
159  string name = "";
160  string doc = "";
161  CommandParamMetaType type;
162  const CscEnumInfos *enumInfos = nullptr;
163 
164  vector<const CscCommandDataTypeNodeMetadata *> nestedParams;
165  const CscCommandDataTypeMetadata *objectTypeMetadata = nullptr;
166 
167  optional<CscCommandPtrType> ptrType = {};
168 
169  CscCommandDataTypeNodeMetadata(const string &name, const string &doc, CommandParamMetaType type);
170  CscCommandDataTypeNodeMetadata(const string &name, const string &doc, const CscCommandDataTypeNodeMetadata *elementsType, CommandParamMetaType type);
171  CscCommandDataTypeNodeMetadata(const string &name, const string &doc, const CscCommandDataTypeNodeMetadata *elementsType);
172  CscCommandDataTypeNodeMetadata(const string &name, const string &doc, const CscCommandDataTypeNodeMetadata *keysType, const CscCommandDataTypeNodeMetadata *valuesType);
173  CscCommandDataTypeNodeMetadata(const string &name, const string &doc, const CscCommandDataTypeMetadata *objectTypeMetadata, CscCommandPtrType ptrType);
174  CscCommandDataTypeNodeMetadata(const string &name, const string &doc, const CscEnumInfos *enumInfos);
175 
176 public:
177  static const CscCommandDataTypeNodeMetadata *forPrimitive(const string &name, const string &doc, CommandParamMetaType type);
178  static const CscCommandDataTypeNodeMetadata *forList(const string &name, const string &doc, const CscCommandDataTypeNodeMetadata *elementsType);
179  static const CscCommandDataTypeNodeMetadata *forMap(const string &name, const string &doc, const CscCommandDataTypeNodeMetadata *keysType, const CscCommandDataTypeNodeMetadata *valuesType);
180  static const CscCommandDataTypeNodeMetadata *forObject(const string &name, const string &doc, const CscCommandDataTypeMetadata *objectTypeMetadata, CscCommandPtrType ptrType);
181  static const CscCommandDataTypeNodeMetadata *forOptional(const string &name, const string &doc, const CscCommandDataTypeNodeMetadata *optionalType);
182  static const CscCommandDataTypeNodeMetadata *forEnum(const string &name, const string &doc, const CscEnumInfos *enumInfos);
184 
188  const string &getName() const;
189 
193  const string &getDoc() const;
194 
195  CommandParamMetaType getType() const;
196 
197  bool isValueRequired() const;
198 
202  string typeToString() const;
203 
207  const vector<const CscCommandDataTypeNodeMetadata *> &getNestedParams() const;
208 
212  const CscCommandDataTypeMetadata *getObjectTypeMetadata() const;
213 
217  optional<CscCommandPtrType> getPtrType() const;
218 
222  const CscEnumInfos *getEnumMetadata() const;
223 
224  bool isTypeOrOptionalOfType(CommandParamMetaType commandParamMeta) const;
225 
226  static vector<const CscCommandDataTypeNodeMetadata *> parseFromFieldsList(const string &fieldsList);
227 
231  void appendDoc(const string &doc);
232 
236  CscCommandDataTypeNodeMetadata(const string &name, const string &doc, CommandParamMetaType type, vector<const CscCommandDataTypeNodeMetadata *> &nestedTypes, optional<CscCommandPtrType> ptrType, const CscCommandDataTypeMetadata *objectTypeMetadata, const CscEnumInfos *enumInfos);
237 
238  const CscCommandDataTypeNodeMetadata *resolveTypePath(const string &path) const;
239  void collectReferencedObjectTypesMetadataRecursively(vector<const CscCommandDataTypeMetadata *> &targetList) const;
240  void collectEnumsMetadataRecursively(vector<const CscEnumInfos *> &targetList) const;
241 };
242 
247 }
248 
252 inline map<string, CscCommandDataTypeMetadata *> &commandTypesMetadataByTypeName() {
253  static map<string, CscCommandDataTypeMetadata *> theMap;
254  return theMap;
255 }
256 
261 }
262 
263 inline map<string, const CscCommandDataTypeMetadata *> &commandsMetadataById() {
264  static map<string, const CscCommandDataTypeMetadata *> theMap;
265  return theMap;
266 }
267 
272 CSC_DLL_IMPORTEXPORT bool hasCommandTypeMetadataForName(const string &qualifiedTypeName);
273 CSC_DLL_IMPORTEXPORT const CscCommandDataTypeMetadata *getCommandTypeMetadataByName(const string &qualifiedTypeName);
274 CSC_DLL_IMPORTEXPORT const CscCommandDataTypeMetadata *updateCommandTypeMetadataByName(const string &headerFileRelativePath, const string &classQualifiedName, const string &classSimpleName, const string &doc, const vector<const CscCommandDataTypeNodeMetadata *> &paramsMetadata, optional<string> commandId);
275 
280 CSC_DLL_IMPORTEXPORT void registerCommandTypeMetadata(CscCommandDataTypeMetadata *typeMetadata);
281 
286 CSC_DLL_IMPORTEXPORT void registerCommandMetadataTypeById(const CscCommandDataTypeMetadata *typeMetadata);
287 
288 CSC_DLL_IMPORTEXPORT const CscCommandDataTypeNodeMetadata *parseMetadataTypeNode(const string &name, const string &typeString);
289 
294 private:
295  string headerFileRelativePath;
296  string paramsClassNameWithNamespace;
297  string paramsClassName;
298  int version;
299  string commandId;
300  string description;
301  vector<const CscCommandDataTypeNodeMetadata *> params;
302  function<any()> createNullInstanceFunction;
303 
304 public:
305  CscCommandDataTypeMetadata(const string &headerFileFullPath,
306  const type_info &paramsClass,
307  int version, const string &commandId,
308  const string &fieldsList,
309  const string &description);
310  CscCommandDataTypeMetadata(const string &headerFileFullPath,
311  const string &paramsClassNameWithNamespace,
312  const string &paramsClassName,
313  int version, const string &commandId,
314  const vector<const CscCommandDataTypeNodeMetadata *> &params,
315  const string &description);
317 
321  const string getClassName(bool withNamespace = true) const;
322 
326  const string &getCommandId() const;
327 
331  const string &getHeaderFileRelativePath() const;
332 
336  vector<const CscCommandDataTypeMetadata *> getAllObjectTypesMetadata() const;
337 
341  vector<const CscEnumInfos *> getAllEnumsMetadata() const;
342 
343  void collectReferencedObjectTypesMetadataRecursively(vector<const CscCommandDataTypeMetadata *> &targetList) const;
344  void collectEnumsMetadataRecursively(vector<const CscEnumInfos *> &targetList) const;
345 
349  int getVersion() const;
350  const string &getDescription() const;
351  const vector<const CscCommandDataTypeNodeMetadata *> &getParams() const;
352 
357  vector<string> getParamNames() const;
358 
359  void update(const string &headerFileRelativePath, const string &classQualifiedName, const string &classSimpleName, const string &doc, const vector<const CscCommandDataTypeNodeMetadata *> &paramsMetadata, const string &commandId);
360 
361  const CscCommandDataTypeNodeMetadata *resolveTypePath(const string &path) const;
362 
366  static map<string, const CscCommandDataTypeMetadata *> getAllCommandsMetadata();
370  static vector<string> getKnownCommandIds();
371 
372  static const CscCommandDataTypeMetadata *getCommandMetadata(const string &commandId);
373 };
374 
379 }
380 
381 inline map<const type_info *, function<optional<JsonSerializableData>(const any &object)>> &getCommandDataJsonSerializers() {
382  static map<const type_info *, function<optional<JsonSerializableData>(const any &object)>> serializers;
383  return serializers;
384 }
385 
386 inline bool registerCommandDataJsonSerializer(const type_info &typeInfo, function<optional<JsonSerializableData>(const any &object)> serializer) {
387  map<const type_info *, function<optional<JsonSerializableData>(const any &object)>> &serializers = getCommandDataJsonSerializers();
388  unique_lock lock(commandDataJsonSerializersMutex());
389  bool existing = serializers.find(&typeInfo) != serializers.end();
390  LOG_DEBUG("register deserializer for " + string(typeInfo.name()) + " -- existing=" + boolToString(existing));
391  serializers[&typeInfo] = serializer;
392 
393  return true;
394 }
395 
396 namespace {
397 function<optional<JsonSerializableData>(const any &object)> SERIALIZER_STRING = [](const any &object) -> optional<JsonSerializableData> {
398  const string *stringPtr = anyToPointer<string>(object);
399  if (stringPtr == nullptr) {
400  return nullopt;
401  }
402  return *stringPtr;
403 };
404 }
405 
406 template <typename TData>
407 inline function<optional<JsonSerializableData>(const any &object)> getCommandDataJsonSerializer() {
408  map<const type_info *, function<optional<JsonSerializableData>(const any &object)>> &serializers = getCommandDataJsonSerializers();
409  shared_lock lock(commandDataJsonSerializersMutex());
410  const type_info &resultType = typeid(TData);
411  auto jsonSerializerMatch = serializers.find(&resultType);
412  if (jsonSerializerMatch == serializers.end()) {
413  using TDataCleaned = std::remove_cvref_t<TData>;
414  if constexpr (std::is_same_v<TDataCleaned, string>) {
415  return SERIALIZER_STRING;
416  }
417  if constexpr (std::is_arithmetic_v<TDataCleaned> || std::is_enum_v<TDataCleaned>) {
418  return [](const any &object) -> optional<JsonSerializableData> {
419  const TDataCleaned *objectPtr = anyToPointer<TDataCleaned>(object);
420  if (objectPtr == nullptr) {
421  return nullopt;
422  }
423  if constexpr (std::is_enum_v<TDataCleaned>) {
424  using Under = std::underlying_type_t<TDataCleaned>;
425  return JsonSerializableData(static_cast<Under>(*objectPtr));
426  } else {
427  return JsonSerializableData(*objectPtr);
428  }
429  };
430  }
431  throw runtime_error("no serializer for type: " + conscience_utils::getClassName(resultType, true));
432  }
433  return jsonSerializerMatch->second;
434 }
435 
437 };
438 
439 #define FIELDS_PAIR_PRINT(type, name) type name;
440 
441 template <typename T>
442 T field_value_any_cast(any anyValue);
443 
444 template <IsMap TMap>
445 TMap field_value_any_cast(any anyValue);
446 
447 template <IsOptional TOptional>
448 TOptional field_value_any_cast(any anyValue);
449 
450 template <IsVector TVector>
451 TVector field_value_any_cast(any anyValue);
452 
453 template <typename T>
454 T field_value_any_cast(any anyValue) {
455  try {
456  return any_cast<T>(anyValue);
457  } catch (const std::bad_any_cast &e) {
458  LOG_WARN(string("cannot cast ") + getClassName(anyValue.type(), false) + " to " + getClassName(typeid(T), false) + ": " + e.what());
459  throw;
460  }
461 }
462 
463 template <IsMap TMap>
464 TMap field_value_any_cast(any anyValue) {
465  using K = typename TMap::key_type;
466  using V = typename TMap::mapped_type;
467  if (anyValue.type() == typeid(TMap)) {
468  return any_cast<TMap>(anyValue);
469  }
470 
471  try {
472  map<K, any> mapAny = any_cast<map<K, any>>(anyValue);
473  TMap result;
474  for (auto it : mapAny) {
475  result[it.first] = field_value_any_cast<V>(it.second);
476  }
477  return result;
478 
479  } catch (const std::bad_any_cast &e) {
480  LOG_WARN(string("cannot cast ") + getClassName(anyValue.type(), false) + " to " + getClassName(typeid(map<K, any>), false) + ": " + e.what());
481  throw;
482  }
483 }
484 
485 template <IsOptional TOptional>
486 TOptional field_value_any_cast(any anyValue) {
487  using TElement = typename TOptional::value_type;
488  if (anyValue.type() == typeid(TOptional)) {
489  return any_cast<TOptional>(anyValue);
490  }
491  TOptional result;
492  if (anyValue.type() == typeid(optional<any>)) {
493  auto theOptional = any_cast<optional<any>>(anyValue);
494  if (theOptional.has_value()) {
495  result = field_value_any_cast<TElement>(theOptional.value());
496  }
497  } else if (anyValue.has_value()) {
498  result = field_value_any_cast<TElement>(anyValue);
499  }
500 
501  return result;
502 }
503 
504 template <IsVector TVector>
505 TVector field_value_any_cast(any anyValue) {
506  using TElement = typename TVector::value_type;
507  if (anyValue.type() == typeid(TVector)) {
508  return any_cast<TVector>(anyValue);
509  }
510  try {
511  vector<any> vectorAny = any_cast<vector<any>>(anyValue);
512  TVector result;
513  for (auto it : vectorAny) {
514  result.push_back(field_value_any_cast<TElement>(it));
515  }
516  return result;
517  } catch (const std::bad_any_cast &e) {
518  LOG_WARN(string("cannot cast ") + getClassName(anyValue.type(), false) + " to " + getClassName(typeid(vector<any>), false) + ": " + e.what());
519  throw;
520  }
521 }
522 
523 #define FIELDS_ASSIGN_FROM_MAP_PRINT(FIELD_type, FIELD_name) \
524  try { \
525  if (fieldsValues.find(#FIELD_name) != fieldsValues.end()) { \
526  any actualValue = fieldsValues.at(#FIELD_name); \
527  if (string(#FIELD_type) == "string" && typeid(const char *) == actualValue.type()) { \
528  actualValue = string(any_cast<const char *>(actualValue)); \
529  } \
530  LOGGER_TRACE("set " + string(#FIELD_name)); \
531  actualValue = field_value_any_cast<FIELD_type>(actualValue); \
532  targetObject->FIELD_name = any_cast<FIELD_type>(actualValue); \
533  } else { \
534  LOGGER_WARN(string("cannot find ") + #FIELD_name) \
535  } \
536  } catch (const std::bad_any_cast &e) { \
537  LOGGER_INFO(string("cannot set ") + #FIELD_type + " " + #FIELD_name + ": " + e.what()); \
538  throw e; \
539  }
540 
541 template <typename T>
542 concept HasBuiltinCommandJsonSerialization = IsVector<T> || IsStarPointer<std::remove_cvref_t<T>> || IsMap<T> || IsSharedPointer<std::remove_cvref_t<T>>;
543 
544 template <typename T>
545  requires(IsSharedPointer<std::remove_cvref_t<T>>)
547 
548 template <typename T>
549  requires(IsStarPointer<std::remove_cvref_t<T>>)
551 
552 template <typename T>
554 
555 template <IsVector TVector>
557 
558 template <IsMap TMap>
560 
561 template <typename T>
564 
565 template <typename T>
568 
569 template <typename T>
570  requires(IsStarPointer<std::remove_cvref_t<T>>)
572  using TPointee = std::remove_cvref_t<typename PointeeType<std::remove_cvref_t<T>>::pointee_type>;
573 
574  if (value == nullptr) {
575  return nullptr;
576  }
577  if constexpr (std::is_base_of_v<CscCommandDataTypeBase, TPointee>) {
578  if (auto jsonObject = dynamic_cast<CscCommandDataTypeBase *>(value)) {
579  return jsonObject->toJsonMap();
580  }
581  throw runtime_error("cannot retrieve data type as CscCommandDataTypeBase: " + getClassName(typeid(TPointee), true));
582  } else {
583  function<optional<JsonSerializableData>(const any &object)> serializer = getCommandDataJsonSerializer<TPointee>();
584  optional<JsonSerializableData> jsonMap = serializer(value);
585  if (jsonMap.has_value()) {
586  return jsonMap.value();
587  }
588  return nullptr;
589  }
590 
591  throw runtime_error("unsupported object type for serialization: " + getClassName(typeid(TPointee), true));
592 }
593 
594 template <typename T>
595  requires(IsSharedPointer<std::remove_cvref_t<T>>)
597  if (value == nullptr) {
598  return nullptr;
599  }
600  return field_value_to_json_serializable(value.get());
601 }
602 
603 template <typename T>
605  if (!value.has_value()) {
606  return nullptr;
607  }
608  return field_value_to_json_serializable(value.value());
609 }
610 
611 template <IsMap TMap>
613  using K = typename TMap::key_type;
614  map<K, JsonSerializableData> jsonMap;
615  for (auto it : value) {
616  jsonMap[it.first] = field_value_to_json_serializable(it.second);
617  }
618  return jsonMap;
619 }
620 
621 template <IsVector TVector>
623  vector<JsonSerializableData> jsonList;
624  for (auto it : value) {
625  jsonList.push_back(field_value_to_json_serializable(it));
626  }
627  return jsonList;
628 }
629 
630 
631 
632 template <typename T>
633 requires (std::is_convertible_v<T, JsonSerializableData> && !HasBuiltinCommandJsonSerialization<T>)
635  return value;
636 }
637 
638 template <typename T>
639 requires (!std::is_convertible_v<T, JsonSerializableData> && !HasBuiltinCommandJsonSerialization<T>)
641  function<optional<JsonSerializableData>(const any &object)> serializer = getCommandDataJsonSerializer<T>();
642  optional<JsonSerializableData> jsonMap = serializer(&value);
643  if (jsonMap.has_value()) {
644  return jsonMap.value();
645  }
646  return nullptr;
647 }
648 
649 #define FIELDS_ASSIGN_INTO_JSONMAP_PRINT(FIELD_type, FIELD_name) \
650  try { \
651  JsonSerializableData jsonSerializableValue = field_value_to_json_serializable(object->FIELD_name); \
652  jsonMap[#FIELD_name] = jsonSerializableValue; \
653  } catch (const exception &e) { \
654  LOGGER_INFO(string("cannot set ") + #FIELD_type + " " + #FIELD_name + " into map: " + e.what()); \
655  throw e; \
656  }
657 
658 #define FIELDS_ASSIGN_INTO_JSONMAP_PRINT_NOTYPE(FIELD_name) \
659  FIELDS_ASSIGN_INTO_JSONMAP_PRINT(UnspecifiedType, FIELD_name)
660 
661 template <typename T>
662 concept IsCommandParams = std::is_base_of<BaseCommandParams, T>::value;
663 
672 CSC_DLL_IMPORTEXPORT map<string, any> parseCommandParametersAsMap(const string &commandId, const vector<string> &commandStringArguments, optional<int> knowledgeId, bool objectsAsMap, bool resolveObjects = true, bool permissive = false);
673 
675 
679 inline bool isUserCommand(const string &commandId) {
680  return fs::is_directory(CscKeyDirectories::getInstance()->getUserCustomCommandCodeDir(commandId));
681 }
682 
688 CSC_DLL_IMPORTEXPORT fs::path resolveCommandFileAbsolutePathFromRelative(const fs::path &headerFileRelativePath, const string &forCommandId);
689 
690 }
691 
692 #endif
conscience_core::bridging
Definition: CscCoreObjectsJsonEncoder.cpp:13
conscience_utils::JSON::JsonSerializableData
Definition: json.h:71
conscience_core::bridging::commands::MissingCommandMetadataException::missingCommandId
const string missingCommandId
Definition: CommandParamsSpec.h:95
map_by_string
std::map< string, TValue > map_by_string
Definition: CommandParamsSpec.h:53
CSC_DLL_IMPORTEXPORT
#define CSC_DLL_IMPORTEXPORT
Definition: os.h:34
conscience_core::bridging::commands::CommandDataJsonSerializersMutexUniqueType
Definition: CommandParamsSpec.h:375
conscience_core::bridging::commands::CscCommandDataTypeNodeMetadata
Definition: CommandParamsSpec.h:157
conscience_core::bridging::commands::WrongCommandParamsSizeDuringParseException
Definition: CommandParamsSpec.h:112
conscience_core::bridging::commands::CscCommandDataTypeMetadata
Definition: CommandParamsSpec.h:293
conscience_core::bridging::commands::registerCommandMetadataTypeById
void registerCommandMetadataTypeById(const CscCommandDataTypeMetadata *typeMetadata)
Definition: CommandParamsSpec.cpp:919
LOG_DEBUG
#define LOG_DEBUG(message)
Definition: conscience_log.h:182
conscience_core::bridging::commands::WrongCommandDataTypeDuringParseException::name
const string name
Definition: CommandParamsSpec.h:104
conscience_core::bridging::commands::commandTypesMetadataByTypeName
map< string, CscCommandDataTypeMetadata * > & commandTypesMetadataByTypeName()
Definition: CommandParamsSpec.h:252
conscience_core::bridging::commands::CscEnumInfos::toString
string toString() const
Definition: CommandParamsSpec.h:135
conscience_core::bridging::commands::CommandPtrType_PLAIN
@ CommandPtrType_PLAIN
Definition: CommandParamsSpec.h:147
conscience_core::bridging::commands::listCommandsWithDocumentedParams
void listCommandsWithDocumentedParams()
Definition: CommandParamsSpec.cpp:854
conscience_core::bridging::commands::MissingCommandDataTypeException::missingParamTypeName
const string missingParamTypeName
Definition: CommandParamsSpec.h:86
conscience_core::bridging::commands::CscCommandDataTypeBase
Definition: CommandParamsSpec.h:120
conscience_core::bridging::commands::CscEnumInfos::doc
string doc
Definition: CommandParamsSpec.h:132
conscience_core::bridging::commands::CommandPtrType_STAR
@ CommandPtrType_STAR
Definition: CommandParamsSpec.h:141
conscience_core::bridging::commands::field_value_to_json_serializable
JsonSerializableData field_value_to_json_serializable(TMap value)
Definition: CommandParamsSpec.h:612
conscience_core::bridging::commands::isUserCommand
bool isUserCommand(const string &commandId)
Definition: CommandParamsSpec.h:679
conscience_core::bridging::commands::WrongCommandDataTypeDuringParseException::expectedType
const CommandParamMetaType expectedType
Definition: CommandParamsSpec.h:105
conscience_core::bridging::commands::parseCommandParametersAsMap
map< string, any > parseCommandParametersAsMap(const string &commandId, const vector< string > &commandStringArguments, optional< int > knowledgeId, bool objectsAsMap, bool resolveObjects, bool permissive)
Definition: CommandParamsSpec.cpp:821
conscience_core::bridging::commands::IsCommandParams
concept IsCommandParams
Definition: CommandParamsSpec.h:662
conscience_utils::boolToString
string boolToString(bool value)
Definition: conscience_util.cpp:99
conscience_core::bridging::commands::CscEnumInfos::valuesDoc
map< string, string > valuesDoc
Definition: CommandParamsSpec.h:131
conscience_core::bridging::commands::CscEnumInfos::values
map< string, unsigned long long > values
Definition: CommandParamsSpec.h:130
conscience_core::bridging::commands::ENUM
ENUM(CommandParamMetaType, CommandParamMetaType_double, CommandParamMetaType_float, CommandParamMetaType_int, CommandParamMetaType_long, CommandParamMetaType_unsigned_long_long, CommandParamMetaType_bool, CommandParamMetaType_string, CommandParamMetaType_list, CommandParamMetaType_map, CommandParamMetaType_object, CommandParamMetaType_optional, CommandParamMetaType_enum, CommandParamMetaType_entityReflexion, CommandParamMetaType_entityModel, CommandParamMetaType_placeModel, CommandParamMetaType_objectModel)
CscKeyDirectories.h
conscience_core::bridging::commands::WrongCommandParamsSizeDuringParseException::expectedSize
const int expectedSize
Definition: CommandParamsSpec.h:116
conscience_core::bridging::commands::WrongCommandDataTypeDuringParseException
Definition: CommandParamsSpec.h:101
conscience_core::bridging::commands::hasCommandTypeMetadataForName
bool hasCommandTypeMetadataForName(const string &qualifiedTypeName)
Definition: CommandParamsSpec.cpp:863
conscience_utils::getClassName
string getClassName(const type_info &paramsClass, bool withNamespace)
Definition: conscience_util.cpp:593
conscience_core::bridging::commands::MissingCommandMetadataException
Definition: CommandParamsSpec.h:92
conscience_core::bridging::commands
Definition: cartographyCommands.cpp:4
conscience_core::bridging::commands::getCommandDataJsonSerializer
function< optional< JsonSerializableData >const any &object)> getCommandDataJsonSerializer()
Definition: CommandParamsSpec.h:407
conscience_utils::IsStarPointer
concept IsStarPointer
Definition: conscience_util.h:202
LOG_WARN
#define LOG_WARN(message)
Definition: conscience_log.h:193
conscience_core::bridging::commands::commandDataJsonSerializersMutex
CommandDataJsonSerializersMutex & commandDataJsonSerializersMutex()
Definition: CommandParamsSpec.h:377
conscience_core::bridging::commands::WrongCommandDataTypeDuringParseException::actualUnderlyingType
const int actualUnderlyingType
Definition: CommandParamsSpec.h:106
conscience_utils::IsMap
concept IsMap
Definition: conscience_util.h:160
conscience_utils::mutexutils
Definition: shared_recursive_mutex.h:9
conscience_core::bridging::commands::CommandPtrType_SHARED
@ CommandPtrType_SHARED
Definition: CommandParamsSpec.h:142
conscience_core::bridging::commands::WrongCommandParamsSizeDuringParseException::name
const string name
Definition: CommandParamsSpec.h:115
conscience_utils::JSON
Definition: CscCommandMetadataBuilder.h:20
conscience_core::bridging::commands::CommandsMetadataByIdMutexUniqueType
Definition: CommandParamsSpec.h:257
CscCommon.h
jwt::json::type
type
Generic JSON types used in JWTs.
Definition: jwt.h:1794
conscience_core::bridging::commands::registerCommandTypeMetadata
void registerCommandTypeMetadata(CscCommandDataTypeMetadata *typeMetadata)
Definition: CommandParamsSpec.cpp:906
shared_recursive_mutex.h
requires
requires(!IsStringLike< T1 >) void assertEquals(T1 left
conscience_core::bridging::commands::HasBuiltinCommandJsonSerialization
concept HasBuiltinCommandJsonSerialization
Definition: CommandParamsSpec.h:542
anyToPointer
const TClass * anyToPointer(const any &objectAny)
Definition: CommandParamsSpec.h:27
conscience_core::bridging::commands::getCommandTypeMetadataByName
const CscCommandDataTypeMetadata * getCommandTypeMetadataByName(const string &qualifiedTypeName)
Definition: CommandParamsSpec.cpp:869
conscience_utils::mutexutils::shared_recursive_mutex_t
Implementation of a fast shared_recursive_mutex Thanks to https://github.com/KonanM/shared_recursive_...
Definition: shared_recursive_mutex.h:18
conscience_server::entities::instance
ServerEntities * instance
Definition: ServerEntities.cpp:39
conscience_core::bridging::commands::commandTypesMetadataByTypeNameMutex
CommandTypesMetadataByTypeNameMutex & commandTypesMetadataByTypeNameMutex()
Definition: CommandParamsSpec.h:245
conscience_core::bridging::commands::updateCommandTypeMetadataByName
const CscCommandDataTypeMetadata * updateCommandTypeMetadataByName(const string &headerFileRelativePath, const string &classQualifiedName, const string &classSimpleName, const string &doc, const vector< const CscCommandDataTypeNodeMetadata * > &paramsMetadata, optional< string > commandId)
Definition: CommandParamsSpec.cpp:879
conscience_core::bridging::commands::CscEnumInfos::enumQualifiedName
string enumQualifiedName
Definition: CommandParamsSpec.h:129
conscience_core::bridging::commands::WrongCommandParamsSizeDuringParseException::actualSize
const int actualSize
Definition: CommandParamsSpec.h:117
conscience_core::bridging::commands::CscEnumInfos
Definition: CommandParamsSpec.h:127
conscience_utils::IsSharedPointer
concept IsSharedPointer
Definition: conscience_util.h:218
std
Definition: json.hpp:4598
map_by_int
std::map< int, TValue > map_by_int
Definition: CommandParamsSpec.h:56
conscience_core::bridging::commands::metadata::enumInfos
static map< string, const CscEnumInfos * > enumInfos
Definition: CscCommandMetadataBuilder.cpp:204
conscience_core::bridging::commands::resolveCommandFileAbsolutePathFromRelative
fs::path resolveCommandFileAbsolutePathFromRelative(const fs::path &headerFileRelativePath, const string &forCommandId)
Definition: CommandParamsSpec.cpp:932
json.h
conscience_core::bridging::commands::CscEnumInfos::enumSimpleName
string enumSimpleName
Definition: CommandParamsSpec.h:128
conscience_core::bridging::commands::CscCommandPtrType
CscCommandPtrType
Definition: CommandParamsSpec.h:140
conscience_utils::IsVector
concept IsVector
Definition: conscience_util.h:147
conscience_core::bridging::commands::BaseCommandParams
Definition: CommandParamsSpec.h:436
conscience_core::bridging::commands::parseMetadataTypeNode
const CscCommandDataTypeNodeMetadata * parseMetadataTypeNode(const string &name, const string &typeString)
Definition: CommandParamsSpec.cpp:25
conscience_utils::mapToString
string mapToString(const map< K, V > &theMap, const string &entriesSeparator=",", const string &keyValueSeparator="=")
Definition: conscience_util.h:502
conscience_core::bridging::commands::isNullableObjectType
bool isNullableObjectType(CscCommandPtrType refType)
Definition: CommandParamsSpec.h:150
conscience_core::bridging::commands::environment_objects::optional< string >
const ptr< CscObjectModel > const string const CscPoint3d const CscPoint3d optional< string >
Definition: environmentObjectsCommands.h:373
conscience_core::bridging::commands::CommandTypesMetadataByTypeNameMutexUniqueType
Definition: CommandParamsSpec.h:243
conscience_core::bridging::commands::CommandPtrType_REF
@ CommandPtrType_REF
Definition: CommandParamsSpec.h:143
ptr
std::shared_ptr< T > ptr
Definition: CscCommon.h:29
conscience_core::bridging::commands::commandsMetadataByIdMutex
CommandsMetadataByIdMutex & commandsMetadataByIdMutex()
Definition: CommandParamsSpec.h:259
conscience_core::bridging::commands::field_value_any_cast
TVector field_value_any_cast(any anyValue)
Definition: CommandParamsSpec.h:505
conscience_core::bridging::commands::registerCommandDataJsonSerializer
bool registerCommandDataJsonSerializer(const type_info &typeInfo, function< optional< JsonSerializableData >(const any &object)> serializer)
Definition: CommandParamsSpec.h:386
conscience_core::bridging::commands::getCommandDataJsonSerializers
map< const type_info *, function< optional< JsonSerializableData >const any &object)> > & getCommandDataJsonSerializers()
Definition: CommandParamsSpec.h:381
conscience_core::bridging::commands::commandsMetadataById
map< string, const CscCommandDataTypeMetadata * > & commandsMetadataById()
Definition: CommandParamsSpec.h:263
conscience_core::bridging::commands::MissingCommandDataTypeException
Definition: CommandParamsSpec.h:83