rttr  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
register_reflection.h
Go to the documentation of this file.
1 /************************************************************************************
2 * *
3 * Copyright (c) 2014 Axel Menzel <info@axelmenzel.de> *
4 * *
5 * This file is part of RTTR (Run Time Type Reflection) *
6 * License: MIT License *
7 * *
8 * Permission is hereby granted, free of charge, to any person obtaining *
9 * a copy of this software and associated documentation files (the "Software"), *
10 * to deal in the Software without restriction, including without limitation *
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 * and/or sell copies of the Software, and to permit persons to whom the *
13 * Software is furnished to do so, subject to the following conditions: *
14 * *
15 * The above copyright notice and this permission notice shall be included in *
16 * all copies or substantial portions of the Software. *
17 * *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
24 * SOFTWARE. *
25 * *
26 *************************************************************************************/
27 
28 #ifndef __RTTR_REGISTER_REFLECTION_H__
29 #define __RTTR_REGISTER_REFLECTION_H__
30 
32 #include "rttr/metadata.h"
33 #include "rttr/policy.h"
34 
35 #include <string>
36 #include <vector>
37 
38 namespace rttr
39 {
40 
128 template<typename ClassType>
129 class class_
130 {
131  public:
132  class_(std::vector< rttr::metadata > data = std::vector< rttr::metadata >());
133  ~class_();
134 
142  template<typename... Args>
143  class_& constructor(std::vector< rttr::metadata > data = std::vector< rttr::metadata >());
144 
145 
156  template<typename A>
157  class_& property(const std::string& name, A acc);
158 
170  template<typename A>
171  class_& property(const std::string& name, A acc, std::vector< rttr::metadata > data);
172 
184  template<typename A, typename Policy>
185  class_& property(const std::string& name, A acc, const Policy& policy,
186 #ifndef DOXYGEN
187  typename std::enable_if<detail::contains<Policy, detail::policy_list>::value>::type* = nullptr
188 #endif
189  );
190 
191 
204  template<typename A, typename Policy>
205  class_& property(const std::string& name, A acc, std::vector< rttr::metadata > data, const Policy& policy);
206 
220  template<typename A1, typename A2>
221  class_& property(const std::string& name, A1 getter, A2 setter,
222 #ifndef DOXYGEN
223  typename std::enable_if<!detail::contains<A2, detail::policy_list>::value>::type* = nullptr
224 #endif
225 );
226 
227 
242  template<typename A1, typename A2>
243  class_& property(const std::string& name, A1 getter, A2 setter, std::vector< rttr::metadata > data);
244 
259  template<typename A1, typename A2, typename Policy>
260  class_& property(const std::string& name, A1 getter, A2 setter, const Policy& policy);
261 
277  template<typename A1, typename A2, typename Policy>
278  class_& property(const std::string& name, A1 getter, A2 setter, std::vector< rttr::metadata > data, const Policy& policy);
279 
280 
281 
293  template<typename A>
294  class_& property_readonly(const std::string& name, A accessor);
295 
308  template<typename A>
309  class_& property_readonly(const std::string& name, A acc, std::vector< rttr::metadata > data);
310 
323  template<typename A, typename Policy>
324  class_& property_readonly(const std::string& name, A acc, const Policy& policy);
325 
339  template<typename A, typename Policy>
340  class_& property_readonly(const std::string& name, A acc, std::vector< rttr::metadata > data, const Policy& policy);
341 
344 
355  template<typename F>
356  class_& method(const std::string& name, F function);
357 
369  template<typename F>
370  class_& method(const std::string& name, F function, std::vector< rttr::metadata > data);
371 
383  template<typename F, typename Policy>
384  class_& method(const std::string& name, F function, const Policy& policy);
385 
398  template<typename F, typename Policy>
399  class_& method(const std::string& name, F function, std::vector< rttr::metadata > data, const Policy& policy);
400 
411  template<typename EnumType>
412  class_& enumeration(std::vector< std::pair< std::string, EnumType> > enum_data,
413  std::vector< rttr::metadata > data = std::vector< rttr::metadata >());
414 
415  private:
416  class_(const class_& other);
417  class_& operator=(const class_& other);
418 };
419 
421 
431 template<typename T>
432 void constructor_(std::vector< rttr::metadata > data = std::vector< rttr::metadata >());
433 
442 template<typename A>
443 void property_(const std::string& name, A acc);
444 
454 template<typename A>
455 void property_(const std::string& name, A acc, std::vector< rttr::metadata > data);
456 
466 template<typename A, typename Policy>
467 void property_(const std::string& name, A acc, const Policy& policy,
468 #ifndef DOXYGEN
469  typename std::enable_if<detail::contains<Policy, detail::policy_list>::value>::type* = nullptr
470 #endif
471 );
472 
483 template<typename A, typename Policy>
484 void property_(const std::string& name, A acc, std::vector< rttr::metadata > data, const Policy& policy);
485 
495 template<typename A1, typename A2>
496 void property_(const std::string& name, A1 getter, A2 setter,
497 #ifndef DOXYGEN
498  typename std::enable_if<!detail::contains<A2, detail::policy_list>::value>::type* = nullptr
499 #endif
500  );
501 
512 template<typename A1, typename A2>
513 void property_(const std::string& name, A1 getter, A2 setter, std::vector< rttr::metadata > data);
514 
525 template<typename A1, typename A2, typename Policy>
526 void property_(const std::string& name, A1 getter, A2 setter, const Policy& policy);
527 
539 template<typename A1, typename A2, typename Policy>
540 void property_(const std::string& name, A1 getter, A2 setter,
541 #ifndef DOXYGEN
542  std::vector< rttr::metadata > data, const Policy& policy
543 #endif
544 );
545 
558 template<typename A>
559 void property_readonly_(const std::string& name, A acc);
560 
573 template<typename A>
574 void property_readonly_(const std::string& name, A acc, std::vector< rttr::metadata > data);
575 
588 template<typename A, typename Policy>
589 void property_readonly_(const std::string& name, A acc, const Policy& policy);
590 
604 template<typename A, typename Policy>
605 void property_readonly_(const std::string& name, A acc, std::vector< rttr::metadata > data, const Policy& policy);
606 
617 template<typename F>
618 void method_(const std::string& name, F function);
619 
631 template<typename F>
632 void method_(const std::string& name, F function, std::vector< rttr::metadata > data);
633 
645 template<typename F, typename Policy>
646 void method_(const std::string& name, F function, const Policy& policy);
647 
660 template<typename F, typename Policy>
661 void method_(const std::string& name, F function, std::vector< rttr::metadata > data, const Policy& policy);
662 
671 template<typename EnumType>
672 void enumeration_(std::vector< std::pair< std::string, EnumType> > enum_data,
673  std::vector< rttr::metadata > data = std::vector< rttr::metadata >());
674 
675 
676 
677 #ifdef DOXYGEN
678 
694 #define RTTR_REGISTER
695 
718 #define RTTR_REGISTER_FRIEND
719 #endif
720 
721 } // end namespace rttr
722 
723 #include "rttr/impl/register_reflection_impl.h"
724 
725 #endif //__RTTR_REGISTER_REFLECTION_H__
class_ & constructor(std::vector< rttr::metadata > data=std::vector< rttr::metadata >())
Register a constructor for this class type with with or without arguments.
class_ & enumeration(std::vector< std::pair< std::string, EnumType > > enum_data, std::vector< rttr::metadata > data=std::vector< rttr::metadata >())
Register a nested enumeration of type EnumType.
This class holds the type information for any arbitrary object.
Definition: type.h:165
void property_(const std::string &name, A acc)
Register a property with read and write access.
class_ & method(const std::string &name, F function)
Register a method to this class.
class_ & property(const std::string &name, A acc)
Register a property with read and write access to this class.
void method_(const std::string &name, F function)
Register a free function.
void enumeration_(std::vector< std::pair< std::string, EnumType > > enum_data, std::vector< rttr::metadata > data=std::vector< rttr::metadata >())
Register an enumeration of type EnumType.
void constructor_(std::vector< rttr::metadata > data=std::vector< rttr::metadata >())
Register a constructor for a type T.
class_ & property_readonly(const std::string &name, A accessor)
Register a property with read only access to this class.
class_(std::vector< rttr::metadata > data=std::vector< rttr::metadata >())
void property_readonly_(const std::string &name, A acc)
Register a property with read only access.
This class is used to register the constructors, properties, methods and enumeration for a certain cl...
Definition: register_reflection.h:129