OpenRTM-aist  2.1.0
Typename.h
[詳解]
1 // -*- C++ -*-
20 #ifndef RTC_TYPENAME_H
21 #define RTC_TYPENAME_H
22 
23 #include <rtm/RTC.h>
24 
25 #include <iostream>
26 
27 namespace CORBA_Util
28 {
35  template <class T, typename T::_ptr_type (*)(void)>
37  {
38  using type = void;
39  };
40 
44  template <class T, class U = void>
45  struct has_nil_impl
46  {
47  static const bool value = false;
48  };
49 
56  template <class T>
57  struct has_nil_impl<T, typename has_nil_helper<T, &T::_nil>::type>
58  {
59  static const bool value = true;
60  };
61 
69  template <class T>
70  struct has_nil : has_nil_impl<T>
71  {
72  };
73 
81  template <typename T>
83  {
84  static const bool value = has_nil<T>::value;
85  };
86 
94  template <bool cond, class T>
95  class typecode;
96 
97  template <class T>
98  class typecode<true, T>
99  {
100  public:
101  static const char* id()
102  {
103  CORBA::Any any_var;
104  typename T::_ptr_type tmp_var;
105  tmp_var = T::_nil();
106  any_var <<= tmp_var;
107  return any_var.type()->id();
108  }
109  static const char* name()
110  {
111  CORBA::Any any_var;
112  typename T::_ptr_type tmp_var;
113  tmp_var = T::_nil();
114  any_var <<= tmp_var;
115  return any_var.type()->name();
116  }
117  };
118 
119  template <class T>
120  class typecode<false, T>
121  {
122  public:
123  static const char* id()
124  {
125  CORBA::Any any_var;
126 #ifdef ORB_IS_TAO
127  T tmp_var = T();
128 #else
129  T tmp_var;
130 #endif
131  any_var <<= tmp_var;
132  return any_var.type()->id();
133  }
134  static const char* name()
135  {
136  CORBA::Any any_var;
137 #ifdef ORB_IS_TAO
138  T tmp_var = T();
139 #else
140  T tmp_var;
141 #endif
142  any_var <<= tmp_var;
143  return any_var.type()->name();
144  }
145  };
146 
147 
185  template <class T>
186  const char* toTypename()
187  {
188  return typecode<is_corba_object<T>::value, T>::name();
189  }
190 
191  template <class T>
192  const char* toTypenameOfStruct()
193  {
194  return typecode<false, T>::name();
195  }
196 
197  template <class T>
198  const char* toTypenameOfObject()
199  {
200  return typecode<true, T>::name();
201  }
202 
240  template <class T>
241  const char* toRepositoryId()
242  {
243  return typecode<is_corba_object<T>::value, T>::id();
244  }
245 
246  template <class T>
248  {
249  return typecode<false, T>::id();
250  }
251 
252  template <class T>
254  {
255  return typecode<true, T>::id();
256  }
257 
258 } // namespace CORBA_Util
259 
260 template <class T>
261 const char* toTypename()
262 {
263  std::cerr << "toTypename() is obsolete." << std::endl;
264  std::cerr << "Please use CORBA_Util::toTypename() instead." << std::endl;
266 }
267 
268 #endif // RTC_TYPENAME_H
RTComponent header
const char * toTypename()
Definition: Typename.h:261
static const char * name()
Definition: Typename.h:134
static const char * id()
Definition: Typename.h:123
static const char * name()
Definition: Typename.h:109
static const char * id()
Definition: Typename.h:101
typecode class template
Definition: Typename.h:95
Definition: DataTypeUtil.h:24
const char * toTypename()
CORBA型のタイプ名を文字列で取得する
Definition: Typename.h:186
const char * toRepositoryIdOfObject()
Definition: Typename.h:253
const char * toRepositoryIdOfStruct()
Definition: Typename.h:247
const char * toTypenameOfStruct()
Definition: Typename.h:192
const char * toRepositoryId()
CORBA型のリポジトリIDを文字列で取得する
Definition: Typename.h:241
const char * toTypenameOfObject()
Definition: Typename.h:198
has nil helper
Definition: Typename.h:37
void type
Definition: Typename.h:38
has nil impl: void case
Definition: Typename.h:46
static const bool value
Definition: Typename.h:47
has nil traits class template
Definition: Typename.h:71
is corba object traits class
Definition: Typename.h:83
static const bool value
Definition: Typename.h:84