OpenRTM-aist  1.2.1
Typename.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef RTC_TYPENAME_H
21 #define RTC_TYPENAME_H
22 
23 #include <iostream>
24 #include <rtm/RTC.h>
25 
26 namespace CORBA_Util
27 {
34  template <class T, typename T::_ptr_type (*)(void)>
36  {
37  typedef void type;
38  };
39 
43  template <class T, class U = void>
44  struct has_nil_impl
45  {
46  static const bool value = false;
47  };
48 
55  template <class T>
56  struct has_nil_impl<T, typename has_nil_helper<T, &T::_nil>::type>
57  {
58  static const bool value = true;
59  };
60 
68  template <class T>
69  struct has_nil : has_nil_impl<T>
70  {
71  };
72 
80  template <typename T>
82  {
83  static const bool value = has_nil<T>::value;
84  };
85 
93  template <bool cond, class T>
94  class typecode;
95 
96  template <class T>
97  class typecode<true, T>
98  {
99  public:
100  static const char* id()
101  {
102  CORBA::Any any_var;
103  typename T::_ptr_type tmp_var;
104  tmp_var = T::_nil();
105  any_var <<= tmp_var;
106  return any_var.type()->id();
107  }
108  static const char* name()
109  {
110  CORBA::Any any_var;
111  typename T::_ptr_type tmp_var;
112  tmp_var = T::_nil();
113  any_var <<= tmp_var;
114  return any_var.type()->name();
115  }
116  };
117 
118  template <class T>
119  class typecode<false, T>
120  {
121  public:
122  static const char* id()
123  {
124  CORBA::Any any_var;
125  T tmp_var;
126  any_var <<= tmp_var;
127  return any_var.type()->id();
128  }
129  static const char* name()
130  {
131  CORBA::Any any_var;
132  T tmp_var;
133  any_var <<= tmp_var;
134  return any_var.type()->name();
135  }
136  };
137 
138 
176  template <class T>
177  const char* toTypename()
178  {
179  return typecode<is_corba_object<T>::value, T>::name();
180  }
181 
182  template <class T>
183  const char* toTypenameOfStruct()
184  {
185  return typecode<false, T>::name();
186  }
187 
188  template <class T>
189  const char* toTypenameOfObject()
190  {
191  return typecode<true, T>::name();
192  }
193 
231  template <class T>
232  const char* toRepositoryId()
233  {
234  return typecode<is_corba_object<T>::value, T>::id();
235  }
236 
237  template <class T>
239  {
240  return typecode<false, T>::id();
241  }
242 
243  template <class T>
245  {
246  return typecode<true, T>::id();
247  }
248 
249 }; // namespace CORBA_Util
250 
251 template <class T>
252 const char* toTypename()
253 {
254  std::cerr << "toTypename() is obsolete." << std::endl;
255  std::cerr << "Please use CORBA_Util::toTypename() instead." << std::endl;
257 }
258 
259 #endif // RTC_TYPENAME_H
static const char * id()
Definition: Typename.h:122
const char * toTypename()
Getting CORBA defined type as characters.
Definition: Typename.h:177
typecode class template
Definition: Typename.h:94
has nil traits class template
Definition: Typename.h:69
is corba object traits class
Definition: Typename.h:81
const char * toRepositoryIdOfStruct()
Definition: Typename.h:238
const char * toTypenameOfObject()
Definition: Typename.h:189
const char * toTypenameOfStruct()
Definition: Typename.h:183
static const char * name()
Definition: Typename.h:108
Definition: Typename.h:26
static const char * id()
Definition: Typename.h:100
const char * toRepositoryIdOfObject()
Definition: Typename.h:244
const char * toRepositoryId()
Getting CORBA defined type as characters.
Definition: Typename.h:232
RTComponent header.
has nil impl: void case
Definition: Typename.h:44
has nil helper
Definition: Typename.h:35
void type
Definition: Typename.h:37
static const char * name()
Definition: Typename.h:129