Преглед на файлове

Added forced cast enum to int

gbeurier преди 6 години
родител
ревизия
441f3fd073
променени са 1 файла, в които са добавени 25 реда и са изтрити 14 реда
  1. 25 14
      src/artis/kernel/Any.hpp

+ 25 - 14
src/artis/kernel/Any.hpp

@@ -130,7 +130,7 @@ public:
     void put(T* o, const V& value )
     {
         V T::* p = dynamic_cast <
-            data < T, V >* >(ptr_)->value_;
+                data < T, V >* >(ptr_)->value_;
         o->*(p) = value;
     }
 
@@ -177,44 +177,44 @@ public:
     {
         if (ptr_) {
             data < T, double >* q_double =
-                dynamic_cast < data < T, double >* >(ptr_);
+                    dynamic_cast < data < T, double >* >(ptr_);
 
             if (q_double) {
                 return context::Value(o->*(q_double->value_));
             } else {
                 data < T, int >* q_int =
-                    dynamic_cast < data < T, int >* >(ptr_);
+                        dynamic_cast < data < T, int >* >(ptr_);
 
                 if (q_int) {
                     return context::Value(o->*(q_int->value_));
                 } else {
                     data < T, bool >* q_bool =
-                        dynamic_cast < data < T, bool >* >(ptr_);
+                            dynamic_cast < data < T, bool >* >(ptr_);
 
                     if (q_bool) {
                         return context::Value(o->*(q_bool->value_));
                     } else {
                         data < T, std::vector < double > >* q_double_v =
-                            dynamic_cast < data < T, std::vector <
+                                dynamic_cast < data < T, std::vector <
                                 double > >* >(ptr_);
 
                         if (q_double_v) {
                             return context::Value(o->*(q_double_v->value_));
                         } else {
                             data < T, std::vector < int > >* q_int_v =
-                                dynamic_cast < data < T, std::vector <
+                                    dynamic_cast < data < T, std::vector <
                                     int > >* >(ptr_);
 
                             if (q_int_v) {
                                 return context::Value(o->*(q_int_v->value_));
                             } else {
                                 data < T, std::vector < bool > >* q_bool_v =
-                                    dynamic_cast < data < T, std::vector <
+                                        dynamic_cast < data < T, std::vector <
                                         bool > >* >(ptr_);
 
                                 if (q_bool_v) {
                                     return context::Value(
-                                        o->*(q_bool_v->value_));
+                                                o->*(q_bool_v->value_));
                                 }
                             }
                         }
@@ -231,45 +231,56 @@ public:
     {
         if (ptr_) {
             data < T, double >* q_double =
-                dynamic_cast < data < T, double >* >(ptr_);
+                    dynamic_cast < data < T, double >* >(ptr_);
 
             if (q_double) {
                 return std::to_string(o->*(q_double->value_));
             } else {
                 data < T, int >* q_int =
-                    dynamic_cast < data < T, int >* >(ptr_);
+                        dynamic_cast < data < T, int >* >(ptr_);
 
                 if (q_int) {
                     return std::to_string(o->*(q_int->value_));
                 } else {
                     data < T, bool >* q_bool =
-                        dynamic_cast < data < T, bool >* >(ptr_);
+                            dynamic_cast < data < T, bool >* >(ptr_);
 
                     if (q_bool) {
                         return o->*(q_bool->value_) ? "true": "false";
                     } else {
                         data < T, std::vector < double > >* q_double_v =
-                            dynamic_cast < data < T, std::vector <
+                                dynamic_cast < data < T, std::vector <
                                 double > >* >(ptr_);
 
                         if (q_double_v) {
                             return "";
                         } else {
                             data < T, std::vector < int > >* q_int_v =
-                                dynamic_cast < data < T, std::vector <
+                                    dynamic_cast < data < T, std::vector <
                                     int > >* >(ptr_);
 
                             if (q_int_v) {
                                 return "";
                             } else {
                                 data < T, std::vector < bool > >* q_bool_v =
-                                    dynamic_cast < data < T, std::vector <
+                                        dynamic_cast < data < T, std::vector <
                                         bool > >* >(ptr_);
 
                                 if (q_bool_v) {
                                     return "";
                                 } else {
+#ifdef FORCE_TRACE_ENUM
+                                    data < T, int >* q_enum =
+                                            static_cast < data < T, int >* >(ptr_);
+
+                                    if (q_enum) {
+                                        return std::to_string(o->*(q_enum->value_));
+                                    } else {
+                                        return "NA";
+                                    }
+#else
                                     return "NA";
+#endif
                                 }
                             }
                         }