MIRA
MetaSerializer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
48 #ifndef _MIRA_METASERIALIZER_H_
49 #define _MIRA_METASERIALIZER_H_
50 
51 #include <iostream>
52 
53 #include <type_traits>
54 
55 #include <platform/Platform.h>
56 #include <utils/MakeString.h>
58 
61 #include <serialization/adapters/boost/optional.hpp>
62 #include <serialization/adapters/std/list>
63 #include <serialization/adapters/std/vector>
64 
65 namespace mira {
66 
68 
70 namespace serialization {
71 
73 
74 // with c++20 this will be part of the language in std
75 template <typename T>
76 struct remove_cvref
77 {
79 };
80 
82 
83 } // namespace
84 
86 
97 class MIRA_BASE_EXPORT TypeMeta : public std::vector<uint8>
98 {
99  typedef std::vector<uint8> Base;
100 public:
101 
106  enum Type {
107  TYPE_INVALID = 0,
109 
110  // class type, (typename is stored in mIdentifier)
112 
113  // user-defined atomic type (typename is stored in mIdentifier)
115 
116  // built-in atomic types (mIdentifier stays empty)
117  TYPE_UINT8 , TYPE_INT8,
118  TYPE_UINT16, TYPE_INT16,
119  TYPE_UINT32, TYPE_INT32,
120  TYPE_UINT64, TYPE_INT64,
121  TYPE_FLOAT , TYPE_DOUBLE,
126 
127  LAST_TYPE_FIELD
128  };
129 
135  NO_QUALIFIER=0,
136  // first value must be larger than last value in TypeField
137  FIRST_TYPE_QUALIFIER = 0x20,
138  TYPE_COLLECTION = FIRST_TYPE_QUALIFIER,
140  TYPE_PROPERTY
141  };
142 
143  // this version is the format version of the TypeMeta
144  // only deviate from default if you really know what you are doing!
145  TypeMeta(uint8 version = 2) : mVersion(version) {}
146 
147  template<typename Reflector>
148  void reflect(Reflector& r) {
149  MIRA_REFLECT_BASE(r,Base);
150  if(getType()==TYPE_ATOMIC || getType()==TYPE_CLASS)
151  r.member("Identifier", mIdentifier, "The identifier of the class "
152  "or 'complex' atomic type");
153  r.member("Version", mVersion, "The metatype format version", 2);
154  }
155 
156  template<typename BinaryStream>
158  MIRA_REFLECT_BASE(r,Base);
159  if(getType()==TYPE_ATOMIC || getType()==TYPE_CLASS)
160  r.member("Identifier", mPlainIdentifier, "The identifier of the class "
161  "or 'complex' atomic type", REFLECT_CTRLFLAG_TEMP_TRACKING);
162  mVersion = 0;
163  if (getType()==TYPE_CLASS)
164  mIdentifier += mPlainIdentifier + " @v0";
165  else
166  mIdentifier = mPlainIdentifier;
167  }
168 
169  // just in case someone tries to use it...
170  template<typename BinaryStream>
172  MIRA_REFLECT_BASE(r,Base);
173  if(getType()==TYPE_ATOMIC || getType()==TYPE_CLASS)
174  r.member("Identifier", mPlainIdentifier, "The identifier of the class "
175  "or 'complex' atomic type", REFLECT_CTRLFLAG_TEMP_TRACKING);
176  }
177 
182  void addQualifier(TypeQualifier qualifier) {
183  assert(Base::size()>=1);
184  push_back(qualifier);
185  }
186 
191  assert(type!=TYPE_CLASS && type!=TYPE_ATOMIC && type!=TYPE_INVALID);
192  assert(Base::size()==0);
193  push_back(type);
194  }
195 
201  void setAtomicType(const std::string& typenam);
202 
206  template <typename T>
207  void setAtomicType() { setAtomicType(typeName<T>()); }
208 
212  void setClassType(const std::string& identifier) {
213  assert(Base::size()==0);
214  push_back(TYPE_CLASS);
215  mIdentifier = identifier;
216  mPlainIdentifier = mIdentifier;
217  }
218 
223  template <typename T>
224  void setType() {
226  setAtomicType<T>();
227  else
228  setClassType(typeName<T>());
229  }
230 
234  Type getType() const {
235  if(empty() || front() >= LAST_TYPE_FIELD)
236  return TYPE_INVALID;
237  return (Type)front();
238  }
239 
243  bool hasQualifier() const {
244  return Base::size()>1;
245  }
246 
250  int qualifierCount() const {
251  return std::max(size()-1,0);
252  }
253 
258  TypeQualifier getQualifier(int i=0) const {
259  assert(i>=0);
260  if(i>=qualifierCount())
261  return NO_QUALIFIER;
262  return (TypeQualifier)Base::at(size()-i-1);
263  }
264 
269  void removeQualifiers(int n)
270  {
271  assert(n>=0);
272  if(n>qualifierCount())
273  n=qualifierCount();
274  return Base::resize(size()-n);
275  }
276 
281  const std::string& getIdentifier() const {
282  return mIdentifier;
283  }
284 
289  std::string getTypename() const;
290 
295  std::string toString() const;
296 
298  int size() const { return (int)Base::size(); }
299 
301  uint8 version() const { return mVersion; }
302 
303 private:
304  std::string mIdentifier;
305  std::string mPlainIdentifier;
306  uint8 mVersion;
307 };
308 
309 typedef boost::shared_ptr<TypeMeta> TypeMetaPtr;
310 
312 
317 {
318  struct Parameter
319  {
322  type(iType) {}
324  const std::string& iName,
325  const std::string& iDescription) :
326  type(iType),
327  name(iName),
328  description(iDescription) {}
329 
330  template<typename Reflector>
331  void reflect(Reflector& r)
332  {
333  r.member("Type",type,"The meta type info of the parameter");
334  r.member("Name",name,"The name of the parameter");
335  r.member("Description",description,"The description for the parameter");
336  }
337 
341  std::string name;
343  std::string description;
344  };
345 
347  MethodMeta(const std::string& iName,
348  const std::string& iComment) :
349  name(iName),
350  comment(iComment) {}
351 
352  template<typename Reflector>
353  void reflect(Reflector& r)
354  {
355  r.member("Name",name,"The name of the method");
356  r.member("Comment",comment,"The user defined comment");
357  r.member("ReturnType",returnType,"The meta type info of the return type");
358  r.member("Parameters",parameters,"A list with type infos for each parameter");
359  }
360 
362  std::string name;
364  std::string comment;
368  std::list<Parameter> parameters;
369 };
370 
371 typedef boost::shared_ptr<MethodMeta> MethodMetaPtr;
372 
374 
380 {
381 public:
383  struct Member
384  {
385  Member() {}
386  Member(TypeMetaPtr iType, const std::string& iName, const std::string& iComment) :
387  type(iType), name(iName), comment(iComment) {}
388 
389  template<typename Reflector>
390  void reflect(Reflector& r)
391  {
392  r.member("Type", type, "The type of the member");
393  r.member("Name", name, "The name of the member");
394  r.member("Comment", comment, "The user defined comment");
395  }
396 
400  std::string name;
402  std::string comment;
403  };
404 
406 
407  template<typename Reflector>
408  void reflect(Reflector& r)
409  {
410  VersionType v = r.requireVersion(2, 1, this);
411 
412  if (v < 2) {
413  boost::optional<int> optVersion; // version was int32 back then
414  r.member("Version",optVersion,"The version of the serialization format");
415 
416  if (optVersion)
417  version[""] = *optVersion;
418  } else
419  r.member("Version",version,"The version of the serialization format");
420 
421  r.member("Members",members,"The members of the compound");
422  r.member("Interfaces",interfaces,"The supported interfaces");
423  r.member("Methods",methods,"The reflected methods");
424  }
425 
426  template<typename BinaryStream>
428  r.version(1, this); // version 2 of CompoundMeta was unknown back then
429 
430  boost::optional<int> optVersion; // serialization version type was int32 back then
431  if (!version.empty())
432  optVersion = version.cbegin()->second; // we assume the version of the serialized class did not change
433  // from v0, otherwise it will be unreadable for the recipient anyway
434  // --> it can have only one or no version at all now
435  r.member("Version",optVersion,"The version of the serialization format");
436 
437  r.member("Members",members,"The members of the compound");
438  r.member("Interfaces",interfaces,"The supported interfaces");
439  r.member("Methods",methods,"The reflected methods");
440  }
441 
442  void addMember(const ReflectMemberMeta& memberMeta, TypeMetaPtr type)
443  {
444  addMember(memberMeta.id, memberMeta.comment, type);
445  }
446 
447  void addMember(const std::string& name, TypeMetaPtr type)
448  {
449  addMember(name, "", type);
450  }
451 
452  void addMember(const std::string& name, const std::string& comment, TypeMetaPtr type)
453  {
454  members.push_back(Member(type, name, comment));
455  }
456 
457  void insertMember(const std::string& name, TypeMetaPtr type, int index)
458  {
459  std::list<Member>::iterator pos = members.begin();
460  while ((pos != members.end()) && (index-- > 0))
461  ++pos;
462  members.insert(pos, Member(type, name, ""));
463  }
464 
465  void insertMember(const std::string& name, TypeMetaPtr type, const std::string& before)
466  {
467  std::list<Member>::iterator pos = members.begin();
468  while ((pos != members.end()) && (pos->name != before))
469  ++pos;
470  members.insert(pos, Member(type, name, ""));
471  }
472 
473  void addInterface(const std::string& iface)
474  {
475  interfaces.push_back(iface);
476  }
477 
478  void addMethod(const MethodMetaPtr& method)
479  {
480  methods.push_back(method);
481  }
482 
483  void setVersion(VersionType version) {
484  this->version[""] = version;
485  }
486 
487  void setVersion(const std::string& type, VersionType version) {
488  this->version[type] = version;
489  }
490 
491  std::string toString() const;
492 
494  std::map<std::string, VersionType> version;
496  std::list<Member> members;
498  std::list<std::string> interfaces;
500  std::list<MethodMetaPtr> methods;
501 };
502 
503 typedef boost::shared_ptr<CompoundMeta> CompoundMetaPtr;
504 
509 class MIRA_BASE_EXPORT MetaTypeDatabase : public std::map<std::string, CompoundMetaPtr>
510 {
511  typedef std::map<std::string, CompoundMetaPtr> Base;
512 public:
513 
516  Base(other) {}
518  {
519  Base::operator=(other);
520  return *this;
521  }
522 
523  template<typename Reflector>
524  void reflect(Reflector& r)
525  {
526  MIRA_REFLECT_BASE(r,Base);
527  }
528 
529  template<typename BinaryStream>
531  {
532  MIRA_REFLECT_BASE(r,Base);
533 
534  // mark all loaded type keys as '@v0' (TypeMetas in entries are also marked by TypeMeta::reflect())
535  MetaTypeDatabase db;
536  foreach (auto p, *this)
537  db[p.first+" @v0"] = p.second;
538 
539  swap(db);
540  }
541 
542  // just in case...
543  template<typename BinaryStream>
545  {
546  MetaTypeDatabase db;
547  foreach (auto p, *this) {
548  // if tagged ' @v0', remove tag, else ignore
549  size_t s = p.first.size();
550  if (p.first.substr(s-4, std::string::npos) == " @v0")
551  db[p.first.substr(0, s-4)] = p.second;
552  }
553 
554  r.template reflectBase<Base>(db);
555  }
556 
560  void merge(const MetaTypeDatabase& other)
561  {
562  this->insert(other.begin(), other.end());
563  }
564 
570  {
571  MetaTypeDatabase db;
572  generateDependentTypesDB(type, db);
573  return db;
574  }
575 
576 private:
577 
578  void generateDependentTypesDB(TypeMetaPtr type, MetaTypeDatabase& db);
579 };
580 
581 template <>
582 class IsCollection<MetaTypeDatabase> : public std::true_type {};
583 
585 
586 class MIRA_BASE_EXPORT MetaSerializer : public BinarySerializer<MetaSerializer>
587 {
589 
590 public:
591  typedef boost::mpl::bool_<false> isObjectTrackingSupported;
592 
593  typedef boost::mpl::bool_<true> requireReflectBarriers;
595 
596 public:
597 
602  mMetaDatabase(database) {}
603 
604  template<typename T>
605  TypeMetaPtr addMeta(const T& v)
606  {
607 #ifdef CHECK_FORCE_SERIALIZE_BINARY_VERSION
609  if ((vf >= 0) && (vf < BinaryBufferSerializer::getSerializerFormatVersion()))
610  return TypeMetaPtr(); //disable meta serialization if an older binary format is forced
611 #endif
612  try
613  {
614  mCurrentMeta.reset();
615  mParentMeta.reset();
616  serialize(MIRA_REFLECTOR_TOPLEVEL_NAME, v);
617  return mCurrentMeta;
618  }
619  catch(XNotImplemented&)
620  {
621  return TypeMetaPtr(); //return a null ptr as we are not able to extract meta information
622  }
623  }
624 
626 
627 private:
628 
629  void setVersion(VersionType version, const std::string& type,
630  const std::string& versionString) {
631  if(mParentMeta)
632  mParentMeta->setVersion(type, version);
633 
634  mCurrentVersion->name = versionString;
635  mCurrentVersion->comment = "";
636  }
637 
638 protected:
639 
640  // required for subclasses that can only tell the type by name (e.g. Python toolbox)
641  VersionType version(VersionType version, const std::string& type,
642  bool acceptDesiredVersion = false) {
643  version = this->queryDesiredClassVersion(version, type, acceptDesiredVersion);
644  setVersion(version, type, "@version[" + type + "]");
645  return version;
646  }
647 
648 public:
649 
650  template <typename T>
651  VersionType version(VersionType version, const T* caller = NULL) {
652  return this->version(version, typeName<T>(), false);
653  }
654 
655  MIRA_DEPRECATED("Please call as version<MyType>(v) or version(v, this)",
656  VersionType version(VersionType version)) {
657  if(mParentMeta)
658  mParentMeta->setVersion(version);
659 
660  mCurrentVersion->name = std::string("@version");
661 
662  return version;
663  }
664 
665  template <typename T>
666  VersionType version(VersionType version, AcceptDesiredVersion, const T* caller = NULL) {
667  return this->version(version, typeName<T>(), true);
668  }
669 
670 public:
671 
672  ReflectState preReflect(const char* context = "")
673  {
674  ReflectState state = mCurrentVersion;
675 
676  mCurrentMeta.reset(new TypeMeta);
677  mCurrentMeta->setBaseAtomicType(TypeMeta::TYPE_VERSION);
678  if(mParentMeta) {
679  mParentMeta->addMember("@version_default", std::string("implicit: ") + context, mCurrentMeta);
680  mCurrentVersion = &(mParentMeta->members.back());
681  }
682 
683  return state;
684  }
685 
686  void postReflect(const ReflectState& prev)
687  {
688  mCurrentVersion = prev;
689  }
690 
691  template <typename T>
692  void write(const T* data, std::size_t count) {
693 
694  }
695 
701  template <typename T>
702  bool hasCodec() const {
703  return false;
704  }
705 
713  template <typename T>
714  bool codec(const T& obj)
715  {
716  return false;
717  }
718 
719  void interface(const char* name)
720  {
721  assert(name != NULL); // check if user has specified NULL as interface name
722  if(mParentMeta)
723  mParentMeta->addInterface(name);
724  }
725 
727  {
728  assert(method);
729  if (mParentMeta)
730  mParentMeta->addMethod(method);
731  }
732 
733  template<typename R, typename... Args, typename F, typename... Description>
734  InvalidRPCDescription<R(Args...), Description...>
735  method(const char*, F&&, Description&&...)
736  {
737  Private::rpc::invalidAssertion<R(Args...), Description...>();
738  }
739 
740  template<typename F, typename... Description>
741  InvalidRPCDescription<F, Description...>
742  method(const char*, F&&, Description&&...)
743  {
744  Private::rpc::invalidAssertion<F, Description...>();
745  }
746 
747  template<typename R, typename Class, typename... Args, typename... Description>
748  InvalidRPCDescription<R (Class::*)(Args...), Description...>
749  method(const char*, R (Class::*)(Args...), Class*, Description&&...)
750  {
751  Private::rpc::invalidAssertion<R (Class::*)(Args...), Description...>();
752  }
753 
754  template<typename R, typename Class, typename... Args, typename... Description>
755  InvalidRPCDescription<R (Class::*)(Args...) const, Description...>
756  method(const char*, R (Class::*)(Args...) const, Class*, Description&&...)
757  {
758  Private::rpc::invalidAssertion<R (Class::*)(Args...) const, Description...>();
759  }
760 
761  template<typename R, typename... Args, typename F, typename... Description>
762  ValidRPCDescription<R(Args...), Description...>
763  method(const char* name, F&& fn, Description&&... descriptions)
764 
765  {
766  createMethodMeta<R, Args...>(name, std::forward<Description>(descriptions)...);
767  }
768 
769  template<typename F, typename... Description>
770  ValidRPCDescription<F, Description...>
771  method(const char* name, F&& fn, Description&&... descriptions)
772  {
773  concreteMethodMetaHelper<typename Private::FunctionTraits<F>::ReturnValue>(
774  name, typename Private::FunctionTraits<F>::Arguments{},
775  std::forward<Description>(descriptions)...);
776  }
777 
778  template<typename R, typename Class, typename... Args, typename... Description>
779  ValidRPCDescription<R (Class::*)(Args...), Description...>
780  method(const char* name, R (Class::*fn)(Args...), Class* This, Description&&... descriptions)
781  {
782  createMethodMeta<R, Args...>(name, std::forward<Description>(descriptions)...);
783  }
784 
785  template<typename R, typename Class, typename... Args, typename... Description>
786  ValidRPCDescription<R (Class::*)(Args...) const, Description...>
787  method(const char* name, R (Class::*fn)(Args...) const, Class* This, Description&&... descriptions)
788 
789  {
790  createMethodMeta<R, Args...>(name, std::forward<Description>(descriptions)...);
791  }
792 
793  template<typename T>
794  void atomic(T& )
795  {
797  MIRA_THROW(XNotImplemented, "Type " << typeName<T>() << " is not meta-serializable");
798 
799  mCurrentMeta.reset(new TypeMeta);
800  mCurrentMeta->setAtomicType<T>();
801  addCurrentAsMemberToParent();
802  }
803 
804  template<typename T>
805  void enumeration(T& )
806  {
808  MIRA_THROW(XNotImplemented, "Type " << typeName<T>() << " is not meta-serializable");
809 
810  mCurrentMeta.reset(new TypeMeta);
811  mCurrentMeta->setBaseAtomicType(TypeMeta::TYPE_ENUMERATION);
812  addCurrentAsMemberToParent();
813  }
814 
815  template<typename T>
816  void pointer(T* &pointer)
817  {
819  MIRA_THROW(XNotImplemented, "Type " << typeName<T>() << " is not meta-serializable");
820 
821  if(pointer!=NULL)
822  Base::pointer(pointer);
823  else
825 
826  assert(mCurrentMeta);
827  mCurrentMeta->addQualifier(TypeMeta::TYPE_POINTER);
828  }
829 
830  template<typename T>
831  void object(T& member)
832  {
834  MIRA_THROW(XNotImplemented, "Type " << typeName<T>() << " is not meta-serializable");
835 
836  mCurrentMeta.reset(new TypeMeta);
837  mCurrentMeta->setClassType(typeName<T>());
838  addCurrentAsMemberToParent();
839 
840  // add us to the global type map
841  CompoundMetaPtr compound = createMapEntry(mCurrentMeta);
842  if(compound)
843  {
844  // push on "stack" and create new meta object for first member
845  TypeMetaPtr prevCurrentMeta = mCurrentMeta;
846  CompoundMetaPtr prevParentMeta = mParentMeta;
847  mParentMeta = compound;
848 
849  Base::object(member);
850 
851  // go "stack" back upwards
852  mCurrentMeta = prevCurrentMeta;
853  mParentMeta = prevParentMeta;
854  }
855  // else we were already reflected, so skip this object
856  }
857 
858  template<typename T>
859  void invokeOverwrite(T& object)
860  {
861 
862  static const std::string context = "invokeOverwrite " + typeName<T>();
863  ReflectState state = preReflect(context.c_str());
864 
865  Base::invokeOverwrite(object);
866 
867  postReflect(state);
868  }
869 
873  template<typename T>
874  void invokeOverwrite(serialization::PlainArray<T>& array)
875  {
876  static const std::string context = "invokeOverwrite PlainArray<" + typeName<T>() +">";
877  ReflectState prevState = preReflect(context.c_str());
878 
879  if(this->template isTrackingEnabled<T>() || !IsBitwiseSerializable<T>::value) {
880  Base::invokeOverwrite(array);
881  } else {
882  collectionItems<T>("@itemcount", true);
883  }
884 
885  postReflect(prevState);
886  }
887 
888 
889 protected:
890 
892  {
893  assert(type->getType() == TypeMeta::TYPE_CLASS);
894  const std::string& n = type->getIdentifier();
895 
896  if(mMetaDatabase.count(n)>0)
897  return CompoundMetaPtr();
898 
899  CompoundMetaPtr compound(new CompoundMeta);
900  mMetaDatabase[n] = compound;
901  return compound;
902  }
903 
905  {
906  if(mParentMeta)
907  mParentMeta->addMember(getCurrentMemberMeta(), mCurrentMeta);
908  }
909 
910  template <typename T, bool> friend struct TypeWithoutObjectHelper;
911  template<typename T, bool>
913  static void invoke(MetaSerializer* metaserializer) {
914  metaserializer->mCurrentMeta.reset(new TypeMeta);
915  metaserializer->mCurrentMeta->setType<T>();
916  metaserializer->addCurrentAsMemberToParent();
917  }
918  };
919 
920  template<typename T>
921  struct TypeWithoutObjectHelper<T,true> {
922  static void invoke(MetaSerializer* metaserializer) {
923  T element;
924  metaserializer->delegate(element);
925  }
926  };
927 
928  template<typename T>
929  struct TypeWithoutObjectHelper<T*,true> {
930  static void invoke(MetaSerializer* metaserializer) {
931  T* element = NULL;
932  metaserializer->delegate(element);
933  }
934  };
935 
936  template <typename T, bool> friend struct TypeWithoutObjectAbstractHelper;
937  template<typename T, bool>
939  static void invoke(MetaSerializer* metaserializer) {
941  }
942  };
943 
944  template<typename T>
946  static void invoke(MetaSerializer* metaserializer) {
947  metaserializer->mCurrentMeta.reset(new TypeMeta);
948  metaserializer->mCurrentMeta->setType<T>();
949  metaserializer->addCurrentAsMemberToParent();
950  }
951  };
952 
953  template<typename T>
955  static void invoke(MetaSerializer* metaserializer) {
956  metaserializer->mCurrentMeta.reset(new TypeMeta);
957  metaserializer->mCurrentMeta->setType<T>();
958  metaserializer->addCurrentAsMemberToParent();
959  }
960  };
961 
962  template <typename T>
964  {
965  // push on "stack" and create new meta object for first member
966  TypeMetaPtr prevCurrentMeta = mCurrentMeta;
967  CompoundMetaPtr prevParentMeta = mParentMeta;
968  mParentMeta.reset();
970  {
971  T* dummy = NULL;
972  delegate(*dummy); // is safe, even if element==NULL since atomic never accesses it here
973  }
974  else
976 
977  TypeMetaPtr meta = mCurrentMeta;
978  // go "stack" back upwards
979  mCurrentMeta = prevCurrentMeta;
980  mParentMeta = prevParentMeta;
981  return meta;
982  }
983 
984  // call this when T could be void, will call the respective overload
985  template<typename T>
987  {
988  typedef typename serialization::remove_cvref<T>::type Type;
989  Type* dummy; // just to select the required createMetaHelper() overload
990  return createMetaHelper(dummy);
991  }
992 
993  // can directly call this when not necessary to check for void
994  template<typename T>
996  {
997  typedef typename serialization::remove_cvref<T>::type Type;
998  return createMeta<Type>();
999  }
1000 
1001  // different overloads for void/non-void type (can't use void as type here -> use T*/void*)
1002 
1003  template<typename T>
1005  {
1006  return createMeta<T>();
1007  }
1008 
1010  {
1011  TypeMetaPtr meta(new TypeMeta);
1012  meta->setBaseAtomicType(TypeMeta::TYPE_VOID);
1013  return meta;
1014  }
1015 
1016  template<typename R, typename... Args, typename... Description>
1018  Description&&... descriptions)
1019  {
1020  createMethodMeta<R, Args...>(name, std::forward<Description>(descriptions)...);
1021  }
1022 
1023  template<typename R, typename ... Args, typename Comment, typename ...Descriptions>
1024  void createMethodMeta(const std::string& name, Comment&& comment, Descriptions&&... args)
1025  {
1026  MethodMetaPtr m(new MethodMeta(name, std::forward<Comment>(comment)));
1027  m->returnType = createMetaOrVoidHelper<R>();
1028  addParameterDescription<Args...>(*m, std::forward<Descriptions>(args)...);
1029  addMethod(std::move(m));
1030  }
1031 
1032 private:
1033  template<typename... RECURSIONSTOP>
1034  typename std::enable_if<(sizeof...(RECURSIONSTOP)) == 0>::type addParameterDescription(MethodMeta& m)
1035  {
1036  }
1037 
1038  template<typename ParameterType, typename... Args>
1039  void addParameterDescription(MethodMeta& m)
1040  {
1041  m.parameters.push_back(MethodMeta::Parameter(createMetaHelper<ParameterType>()));
1042  addParameterDescription<Args...>(m);
1043  }
1044 
1045  template<typename ParameterType, typename... Args, class Name, class Description, typename... Tail,
1046  typename = typename std::enable_if<(sizeof...(Args)) * 2 == sizeof...(Tail)>::type>
1047  void addParameterDescription(MethodMeta& m, Name&& name, Description&& description, Tail&&... tail)
1048  {
1049  m.parameters.push_back(MethodMeta::Parameter(createMetaHelper<ParameterType>(),
1050  std::forward<Name>(name),
1051  std::forward<Description>(description)));
1052  addParameterDescription<Args...>(m, std::forward<Tail>(tail)...);
1053  }
1054 
1055  template<typename ParameterType, typename... Args, class Name, class Description, class Example,
1056  typename... Tail,
1057  typename = typename std::enable_if<(sizeof...(Args)) * 3 == sizeof...(Tail)>::type>
1058  void addParameterDescription(MethodMeta& m, Name&& name, Description&& description, Example&& example,
1059  Tail&&... tail)
1060  {
1061  m.parameters.push_back(MethodMeta::Parameter(createMetaHelper<ParameterType>(),
1062  std::forward<Name>(name),
1063  std::forward<Description>(description)));
1064  addParameterDescription<Args...>(m, std::forward<Tail>(tail)...);
1065  }
1066 
1067 public:
1068 
1069  // TODO: add the property qualifier just once at the end
1070 
1071  template<typename T>
1072  void property(const char* name, T& member, const char* comment,
1073  PropertyHint&& hint = PropertyHint(),
1075  Base::property(name,member,comment,std::move(hint), flags);
1076  //mCurrentMeta->addQualifier(TypeMeta::TYPE_PROPERTY);
1077  }
1078 
1079  template<typename T>
1080  void property(const char* name, const std::string& id, T& member,
1081  const char* comment, PropertyHint&& hint = PropertyHint(),
1083  Base::property(name,id,member,comment,std::move(hint), flags);
1084  //mCurrentMeta->addQualifier(TypeMeta::TYPE_PROPERTY);
1085  }
1086 
1087  template<typename T>
1088  void property(const char* name, const T& member, Setter<T> setter,
1089  const char* comment, PropertyHint&& hint = PropertyHint(),
1091  Base::property<T>(name,member,setter,comment,std::move(hint), flags);
1092  //mCurrentMeta->addQualifier(TypeMeta::TYPE_PROPERTY);
1093  }
1094 
1095  template<typename T>
1096  void property(const char* name, Getter<T> getter, Setter<T> setter,
1097  const char* comment, PropertyHint&& hint = PropertyHint(),
1099  Base::property(name,getter,setter,comment,std::move(hint), flags);
1100  //mCurrentMeta->addQualifier(TypeMeta::TYPE_PROPERTY);
1101  }
1102 
1103  template<typename T, typename U>
1104  void property(const char* name, T& member, const char* comment,
1105  const U& defaultValue, PropertyHint&& hint = PropertyHint(),
1107  Base::property(name,member,comment,defaultValue,std::move(hint), flags);
1108  //mCurrentMeta->addQualifier(TypeMeta::TYPE_PROPERTY);
1109  }
1110 
1111  template<typename T, typename U>
1112  void property(const char* name, const T& member, Setter<T> setter,
1113  const char* comment, const U& defaultValue,
1114  PropertyHint&& hint = PropertyHint(),
1116  Base::property(name,member,setter,comment,defaultValue, std::move(hint), flags);
1117  //mCurrentMeta->addQualifier(TypeMeta::TYPE_PROPERTY);
1118  }
1119 
1120  template<typename T, typename U>
1121  void property(const char* name, Getter<T> getter, Setter<T> setter,
1122  const char* comment, const U& defaultValue,
1123  PropertyHint&& hint = PropertyHint(),
1125  Base::property(name,getter,setter,comment,defaultValue,std::move(hint), flags);
1126  //mCurrentMeta->addQualifier(TypeMeta::TYPE_PROPERTY);
1127  }
1128 
1129  template<typename T>
1131  if (flags & REFLECT_CTRLFLAG_TEMP_TRACKING) {
1132  this->This()->pushObjectTrackingStore();
1133  this->invokeMember(member, ReflectMemberMeta("@transparent", "@transparent", "delegated") );
1134  this->This()->popObjectTrackingStore();
1135  } else
1136  this->invokeMember(member, ReflectMemberMeta("@transparent", "@transparent", "delegated") );
1137  }
1138 
1139  template<typename T>
1140  void delegate(const T& member, Setter<T> setter,
1142  auto a = makeAccessor(member, setter);
1143  this->This()->pushObjectTrackingStore();
1144  this->invokeMember(a, ReflectMemberMeta("@transparent", "@transparent", "delegated") );
1145  this->This()->popObjectTrackingStore();
1146  }
1147 
1148  template<typename T>
1151  auto a = makeAccessor(getter, setter);
1152  this->This()->pushObjectTrackingStore();
1153  this->invokeMember(a, ReflectMemberMeta("@transparent", "@transparent", "delegated") );
1154  this->This()->popObjectTrackingStore();
1155  }
1156 
1157  template<typename T>
1158  void collectionItems(const std::string& countName, bool blockdump = false)
1159  {
1161 
1162  assert(mCurrentMeta);
1163  mCurrentMeta->addQualifier(TypeMeta::TYPE_COLLECTION);
1164 
1165  assert(mParentMeta);
1166  if (blockdump) {
1167  mParentMeta->members.back().name = "@items_blockdump";
1168  mParentMeta->members.back().comment = countName;
1169  } else {
1170  mParentMeta->members.back().name = "@items";
1171  mParentMeta->members.back().comment = countName;
1172  }
1173  }
1174 
1175 protected:
1176 
1180 
1182 };
1183 
1184 
1186 
1193 template<typename T>
1194 class IsTransparentSerializableHelper<T, MetaSerializer> : public std::false_type {};
1195 
1196 template<typename T>
1197 class IsTransparentSerializableHelper<serialization::PlainArray<T>, MetaSerializer> : public std::true_type {};
1198 
1199 namespace serialization {
1200 
1202 
1211 template<typename Container>
1212 struct ReflectCollectionItems<MetaSerializer, Container>
1213 {
1214  static void reflect(MetaSerializer& r, Container& c)
1215  {
1216  typedef typename Container::value_type rawtype;
1217  typedef typename remove_cvref<rawtype>::type type;
1218 
1219  r.template collectionItems<type>("@itemcount");
1220  }
1221 };
1222 
1223 template<typename Allocator>
1224 struct ReflectReadBoolVectorItems<MetaSerializer, Allocator>
1225 {
1226  static void reflect(MetaSerializer& r, std::vector<bool, Allocator>& c)
1227  {
1228  r.template collectionItems<bool>("@itemcount");
1229  }
1230 };
1231 
1232 template<typename Container>
1233 struct ReflectReadSetItems<MetaSerializer, Container>
1234 {
1235  typedef typename Container::value_type rawtype;
1236  typedef typename remove_cvref<rawtype>::type type;
1237 
1238  static void reflect(MetaSerializer& r, Container& c)
1239  {
1240  r.template collectionItems<type>("@itemcount");
1241  }
1242 };
1243 
1244 template<typename Container>
1245 struct ReflectReadMapItems<MetaSerializer, Container>
1246 {
1247  typedef typename Container::key_type rawkeytype;
1248  typedef typename Container::mapped_type rawmappedtype;
1251 
1252  static void reflect(MetaSerializer& r, Container& c)
1253  {
1254  r.template collectionItems<type>("@itemcount");
1255  }
1256 };
1257 
1259 
1260 } // namespace
1261 
1263 
1265 
1266 } // namespace
1267 
1268 #endif
Member(TypeMetaPtr iType, const std::string &iName, const std::string &iComment)
Definition: MetaSerializer.h:386
This object can use object tracking internally, but the object tracking system&#39;s state remains unchan...
Definition: ReflectControlFlags.h:82
void reflect(Reflector &r)
Definition: MetaSerializer.h:524
void property(const char *name, const T &member, Setter< T > setter, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1088
TypeMetaPtr createMetaHelper(T *)
Definition: MetaSerializer.h:1004
void merge(const MetaTypeDatabase &other)
Merge meta information from other database into THIS.
Definition: MetaSerializer.h:560
MethodMeta()
Definition: MetaSerializer.h:346
Database that stores all meta type information and provides additional functions for accessing the da...
Definition: MetaSerializer.h:509
int qualifierCount() const
Returns the number of qualifiers.
Definition: MetaSerializer.h:250
std::list< Parameter > parameters
A list with info for each parameter.
Definition: MetaSerializer.h:368
std::list< Member > members
The members of the compound.
Definition: MetaSerializer.h:496
boost::shared_ptr< CompoundMeta > CompoundMetaPtr
Definition: MetaSerializer.h:503
Definition: BinarySerializer.h:324
void reflect(ConcreteBinarySerializer< BinaryStream, 0 > &r)
Definition: MetaSerializer.h:427
bool hasQualifier() const
Returns true, if the type meta contains qualifiers.
Definition: MetaSerializer.h:243
static void invoke(MetaSerializer *metaserializer)
Definition: MetaSerializer.h:955
Definition: MetaSerializer.h:114
Type
The different types (ranging from fundamental types to user-defined class).
Definition: MetaSerializer.h:106
Definition: RPCPatternCheck.h:82
Class for in place stream formatting.
bool hasCodec() const
Returns true, of there is a codec for the specified type T.
Definition: MetaSerializer.h:702
std::string name
The name of the method.
Definition: MetaSerializer.h:362
static void reflect(Reflector &r, Container &c)
Definition: StlCollections.h:142
Parameter()
Definition: MetaSerializer.h:320
TypeMetaPtr type
The meta type info of the return parameter.
Definition: MetaSerializer.h:339
void object(T &member)
Definition: MetaSerializer.h:831
void addMember(const std::string &name, const std::string &comment, TypeMetaPtr type)
Definition: MetaSerializer.h:452
void addQualifier(TypeQualifier qualifier)
Adds a type qualifier.
Definition: MetaSerializer.h:182
ValidRPCDescription< R(Args...), Description... > method(const char *name, F &&fn, Description &&... descriptions)
Definition: MetaSerializer.h:763
Definition: MetaSerializer.h:117
typename ReflectorInterface< MetaSerializer >::AcceptDesiredVersion AcceptDesiredVersion
Definition: AbstractReflector.h:195
void reflect(ConcreteBinarySerializer< BinaryStream, 0 > &r)
Definition: MetaSerializer.h:171
Parameter(TypeMetaPtr iType)
Definition: MetaSerializer.h:321
Type trait that indicates whether a type can be serialized bitwise by just copying the data buffer...
Definition: IsBitwiseSerializable.h:70
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void reflect(Reflector &r)
Definition: MetaSerializer.h:408
MetaTypeDatabase(const MetaTypeDatabase &other)
Definition: MetaSerializer.h:515
InvalidRPCDescription< R(Class::*)(Args...) const, Description... > method(const char *, R(Class::*)(Args...) const, Class *, Description &&...)
Definition: MetaSerializer.h:756
void delegate(Getter< T > getter, Setter< T > setter, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1149
void member(const char *name, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: RecursiveMemberReflector.h:862
Definition: MetaSerializer.h:108
Definition: MetaSerializer.h:119
Definition: MetaSerializer.h:120
ReflectState preReflect(const char *context="")
Definition: MetaSerializer.h:672
ValidRPCDescription< F, Description... > method(const char *name, F &&fn, Description &&... descriptions)
Definition: MetaSerializer.h:771
Definition: MetaSerializer.h:138
#define MIRA_REFLECT_BASE(reflector, BaseClass)
Macro that can be used to reflect the base class easily.
Definition: ReflectorInterface.h:912
Class object which supports some kind of class reflection.
Definition: Class.h:97
void collectionItems(const std::string &countName, bool blockdump=false)
Definition: MetaSerializer.h:1158
void addMember(const ReflectMemberMeta &memberMeta, TypeMetaPtr type)
Definition: MetaSerializer.h:442
void addMethod(MethodMetaPtr method)
Definition: MetaSerializer.h:726
Setter< T > setter(void(*f)(const T &))
Creates a Setter for global or static class methods taking the argument by const reference.
Definition: GetterSetter.h:443
Definition: BinarySerializer.h:991
void property(const char *name, const std::string &id, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1080
Holds a boost::function object to a special setter function that must meet the signature "void method...
Definition: GetterSetter.h:395
Stores meta information for each member.
Definition: ReflectMemberMeta.h:64
Type trait that indicates whether a type can be serialized as an atomic value.
Definition: IsAtomicSerializable.h:83
void addMethod(const MethodMetaPtr &method)
Definition: MetaSerializer.h:478
static void invoke(MetaSerializer *metaserializer)
Definition: MetaSerializer.h:913
void reflect(Reflector &r)
Definition: MetaSerializer.h:353
void concreteMethodMetaHelper(const char *name, Private::ArgumentTuple< Args... >, Description &&... descriptions)
Definition: MetaSerializer.h:1017
VersionType version(VersionType version, AcceptDesiredVersion, const T *caller=NULL)
Definition: MetaSerializer.h:666
ValidRPCDescription< R(Class::*)(Args...), Description... > method(const char *name, R(Class::*fn)(Args...), Class *This, Description &&... descriptions)
Definition: MetaSerializer.h:780
void reflect(Reflector &r)
Definition: MetaSerializer.h:148
uint8 VersionType
Definition: ReflectorInterface.h:72
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
Type trait to check if a class is default constructible.
MetaTypeDatabase()
Definition: MetaSerializer.h:514
A property hint gives optional instructions to the property editor, i.e.
Definition: PropertyHint.h:82
std::string toString(const T &value, int precision=-1)
Converts any data type to string (the data type must support the stream << operator).
Definition: ToString.h:256
TypeQualifier getQualifier(int i=0) const
Returns the i-th type qualifier, or NO_QUALIFIER if there is no such qualifier.
Definition: MetaSerializer.h:258
void insertMember(const std::string &name, TypeMetaPtr type, int index)
Definition: MetaSerializer.h:457
void pointer(T *&pointer)
Definition: MetaSerializer.h:816
serialization::VersionType VersionType
Definition: MetaSerializer.h:625
serialization::VersionType VersionType
Definition: MetaSerializer.h:405
std::string name
The name of the parameter.
Definition: MetaSerializer.h:341
void setBaseAtomicType(Type type)
Sets the datatype to one of the built-in atomic types (TYPE_INT,FLOAT, etc).
Definition: MetaSerializer.h:190
static void invoke(MetaSerializer *metaserializer)
Definition: MetaSerializer.h:939
Type trait that indicates whether a type does not support to gather meta information about it...
Definition: IsNotMetaSerializable.h:65
TypeMetaPtr type
The meta type info of the member.
Definition: MetaSerializer.h:398
Type trait that indicates whether a type does not support to gather meta information about it...
void removeQualifiers(int n)
Removes the n last qualifiers.
Definition: MetaSerializer.h:269
Binary serializer and deserializer.
Parameter(TypeMetaPtr iType, const std::string &iName, const std::string &iDescription)
Definition: MetaSerializer.h:323
Definition: MetaSerializer.h:586
void atomic(T &)
Definition: MetaSerializer.h:794
static void reflect(Reflector &r, Container &c)
Definition: StlCollections.h:343
No flags.
Definition: ReflectControlFlags.h:65
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
uint8 version() const
Returns the metatype format version.
Definition: MetaSerializer.h:301
void delegate(const T &member, Setter< T > setter, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1140
void reflect(Reflector &r)
Definition: MetaSerializer.h:331
void delegate(T &member, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1130
void reflect(Reflector &r)
Definition: MetaSerializer.h:390
TypeMetaPtr createMeta()
Definition: MetaSerializer.h:963
Definition: MetaSerializer.h:125
VersionType version(VersionType version, const T *caller=NULL)
Definition: MetaSerializer.h:651
Container::value_type type
Definition: ReflectCollection.h:87
Getter< T > getter(T(*f)())
Creates a Getter for global or static class methods returning the result by value.
Definition: GetterSetter.h:136
void property(const char *name, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1072
void reflect(Reflector &r, LogRecord &record)
Non-intrusive reflector for LogRecord.
Definition: LoggingCore.h:137
InvalidRPCDescription< R(Class::*)(Args...), Description... > method(const char *, R(Class::*)(Args...), Class *, Description &&...)
Definition: MetaSerializer.h:749
static void reflect(Reflector &r, Container &c)
Definition: ReflectCollection.h:89
TypeMetaPtr returnType
The meta type info of the return type.
Definition: MetaSerializer.h:366
boost::shared_ptr< TypeMeta > TypeMetaPtr
Definition: MetaSerializer.h:309
void property(const char *name, Getter< T > getter, Setter< T > setter, const char *comment, const U &defaultValue, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1121
CompoundMetaPtr mParentMeta
Definition: MetaSerializer.h:1179
TypeQualifier
Additional qualifiers.
Definition: MetaSerializer.h:134
Definition: MetaSerializer.h:122
const char * comment
Additional user comments.
Definition: ReflectMemberMeta.h:76
std::list< std::string > interfaces
The reflected interfaces.
Definition: MetaSerializer.h:498
typename std::enable_if< Private::rpc::isValid< F, Description... >()>::type ValidRPCDescription
Definition: RPCPatternCheck.h:307
void addMember(const std::string &name, TypeMetaPtr type)
Definition: MetaSerializer.h:447
void reflect(ConcreteBinaryDeserializer< BinaryStream, 0 > &r)
Definition: MetaSerializer.h:157
void property(const char *name, const T &member, Setter< T > setter, const char *comment, const U &defaultValue, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1112
Definition: MetaSerializer.h:123
Type getType() const
Returns the type flag which is the first item in the vector.
Definition: MetaSerializer.h:234
CompoundMeta::Member * mCurrentVersion
Definition: MetaSerializer.h:1181
typename std::enable_if<!Private::rpc::isValid< F, Description... >()>::type InvalidRPCDescription
Definition: RPCPatternCheck.h:310
MIRA_DEPRECATED("Please call as version<MyType>(v) or version(v, this)", VersionType version(VersionType version))
Definition: MetaSerializer.h:655
InvalidRPCDescription< R(Args...), Description... > method(const char *, F &&, Description &&...)
Definition: MetaSerializer.h:735
ValidRPCDescription< R(Class::*)(Args...) const, Description... > method(const char *name, R(Class::*fn)(Args...) const, Class *This, Description &&... descriptions)
Definition: MetaSerializer.h:787
TypeMetaPtr createMetaOrVoidHelper()
Definition: MetaSerializer.h:986
VersionType version(VersionType version, const T *caller=NULL)
Definition: BinarySerializer.h:617
static int forcedSerializeVersion()
Returns either the version number from value of environment variable &#39;MIRA_FORCE_SERIALIZE_VERSION&#39;, or -1 (= do not force a version).
Definition: Serializer.h:145
void write(const T *data, std::size_t count)
Definition: MetaSerializer.h:692
boost::mpl::bool_< false > isObjectTrackingSupported
Definition: MetaSerializer.h:591
void postReflect(const ReflectState &prev)
Definition: MetaSerializer.h:686
MetaTypeDatabase & operator=(const MetaTypeDatabase &other)
Definition: MetaSerializer.h:517
CompoundMeta::Member * ReflectState
Definition: MetaSerializer.h:594
std::string comment
The user defined comment as specified in the r.method() call.
Definition: MetaSerializer.h:364
Holds a boost::function object to a special getter function that must meet the signature "T method()"...
Definition: GetterSetter.h:87
Definition: MetaSerializer.h:111
Definition: RPCPatternCheck.h:88
Meta Type information.
Definition: MetaSerializer.h:97
std::map< std::string, VersionType > version
The version(s) of the described type&#39;s serialization format.
Definition: MetaSerializer.h:494
void addCurrentAsMemberToParent()
Definition: MetaSerializer.h:904
TypeMetaPtr createMetaHelper(void *)
Definition: MetaSerializer.h:1009
Definition: MetaSerializer.h:912
const std::string & getIdentifier() const
Returns the identifier of the user-defined atomic type or class type.
Definition: MetaSerializer.h:281
Meta information for RPC methods.
Definition: MetaSerializer.h:316
void setAtomicType()
Same as above, but typename is extracted from T.
Definition: MetaSerializer.h:207
TypeMetaPtr addMeta(const T &v)
Definition: MetaSerializer.h:605
Definition: BinarySerializer.h:257
static void invoke(MetaSerializer *metaserializer)
Definition: MetaSerializer.h:946
MetaTypeDatabase getDependentTypesDB(TypeMetaPtr type)
Generates a database which is a subset of THIS database and contains all types that are necessary to ...
Definition: MetaSerializer.h:569
int size() const
Returns the number of items (the type item + qualifier items)
Definition: MetaSerializer.h:298
void insertMember(const std::string &name, TypeMetaPtr type, const std::string &before)
Definition: MetaSerializer.h:465
void setVersion(const std::string &type, VersionType version)
Definition: MetaSerializer.h:487
VersionType version(VersionType version, const std::string &type, bool acceptDesiredVersion=false)
Definition: MetaSerializer.h:641
std::string name
The name of the member.
Definition: MetaSerializer.h:400
ReflectCtrlFlags
Control Flags that can modify the behavior of certain reflectors.
Definition: ReflectControlFlags.h:63
void setType()
Sets the datatype.
Definition: MetaSerializer.h:224
std::string comment
The user defined comment as specified in the r.member() call.
Definition: MetaSerializer.h:402
Definition: MetaSerializer.h:139
void setClassType(const std::string &identifier)
Sets the data type to TYPE_CLASS and sets the class identifier.
Definition: MetaSerializer.h:212
TypeMeta(uint8 version=2)
Definition: MetaSerializer.h:145
#define MIRA_BASE_EXPORT
This is required because on windows there is a macro defined called ERROR.
Definition: Platform.h:153
Type trait that indicates whether a type is a collection.
Definition: IsCollection.h:63
void property(const char *name, Getter< T > getter, Setter< T > setter, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1096
TypeMetaPtr createMetaHelper()
Definition: MetaSerializer.h:995
void property(const char *name, T &member, const char *comment, const U &defaultValue, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: MetaSerializer.h:1104
void createMethodMeta(const std::string &name, Comment &&comment, Descriptions &&... args)
Definition: MetaSerializer.h:1024
std::string description
The description for the parameter.
Definition: MetaSerializer.h:343
void reflect(ConcreteBinaryDeserializer< BinaryStream, 0 > &r)
Definition: MetaSerializer.h:530
void reflect(ConcreteBinarySerializer< BinaryStream, 0 > &r)
Definition: MetaSerializer.h:544
Definition: MetaSerializer.h:124
void invokeOverwrite(T &object)
Definition: MetaSerializer.h:859
Definition: IsTransparentSerializable.h:84
Accessor< Getter, Setter > makeAccessor(const Getter &getter, const Setter &setter)
Helper method that creates an accessor from a different combination of either direct access to a vari...
Definition: Accessor.h:300
InvalidRPCDescription< F, Description... > method(const char *, F &&, Description &&...)
Definition: MetaSerializer.h:742
MethodMeta(const std::string &iName, const std::string &iComment)
Definition: MetaSerializer.h:347
TypeMetaPtr mCurrentMeta
Definition: MetaSerializer.h:1178
void invokeOverwrite(serialization::PlainArray< T > &array)
Specialized for PlainArray, because the BinarySerializer does it...
Definition: MetaSerializer.h:874
boost::mpl::bool_< true > requireReflectBarriers
Definition: MetaSerializer.h:593
void addInterface(const std::string &iface)
Definition: MetaSerializer.h:473
const char * id
The id (used for containers where the name is identical, in all other cases the id usually is equal t...
Definition: ReflectMemberMeta.h:73
A single member of the compound.
Definition: MetaSerializer.h:383
void interface(const char *name)
Definition: MetaSerializer.h:719
void setVersion(VersionType version)
Definition: MetaSerializer.h:483
Definition: MetaSerializer.h:118
Meta information for complex compounds, like classes and structs.
Definition: MetaSerializer.h:379
Definition: MetaSerializer.h:318
static void invoke(MetaSerializer *metaserializer)
Definition: MetaSerializer.h:922
CompoundMetaPtr createMapEntry(TypeMetaPtr &type)
Definition: MetaSerializer.h:891
constexpr std::enable_if<!FunctionTraits< F >::isFunction >::type invalidAssertion()
Definition: RPCPatternCheck.h:282
MetaTypeDatabase & mMetaDatabase
Definition: MetaSerializer.h:1177
void enumeration(T &)
Definition: MetaSerializer.h:805
Definition: MetaSerializer.h:121
std::list< MethodMetaPtr > methods
The reflected methods (RPC methods)
Definition: MetaSerializer.h:500
static void invoke(MetaSerializer *metaserializer)
Definition: MetaSerializer.h:930
Platform dependent defines and macros.
boost::shared_ptr< MethodMeta > MethodMetaPtr
Definition: MetaSerializer.h:371
MetaSerializer(MetaTypeDatabase &database)
The meta serializer will work on the database and adds new types there.
Definition: MetaSerializer.h:601
bool codec(const T &obj)
Encodes the specified object containing the data using a matching codec.
Definition: MetaSerializer.h:714
Container::value_type type
Definition: StlCollections.h:140
Member()
Definition: MetaSerializer.h:385