Author: veithm
Date: Fri May 15 15:02:27 2015
New Revision: 1679582

URL: http://svn.apache.org/r1679582
Log:
Add macro for validators static get function

The static Get function in the validator classes was a code
duplicate. It has been extracted into a macro which can then
by used by the different validator classes.

Change-Id: I13d5f33a930f58f5b7a73371d79a184603e2e03c

Modified:
    etch/trunk/binding-cpp/runtime/include/serialization/EtchValidator.h

Modified: etch/trunk/binding-cpp/runtime/include/serialization/EtchValidator.h
URL: 
http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/include/serialization/EtchValidator.h?rev=1679582&r1=1679581&r2=1679582&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/include/serialization/EtchValidator.h 
(original)
+++ etch/trunk/binding-cpp/runtime/include/serialization/EtchValidator.h Fri 
May 15 15:02:27 2015
@@ -44,6 +44,30 @@ class EtchValidatorStringRuntimeListener
     return SValidatorCache##validatorClassName.get(runtime);                   
                 \
 }
 
+#define VALIDATOR_GET_DEF()                                                    
                                                     \
+    static status_t Get(EtchRuntime* runtime, capu::uint32_t ndim, 
capu::SmartPointer<EtchValidator> &val);
+
+
+#define VALIDATOR_GET_IMPL(validatorClassName)                                 
                                                     \
+    status_t validatorClassName::Get(EtchRuntime* runtime, capu::uint32_t 
ndim, capu::SmartPointer<EtchValidator> &val) {           \
+                                                                               
                                                     \
+                                                                               
                                                     \
+    if (ndim > MAX_NDIMS) {                                                    
                                                     \
+        return ETCH_EINVAL;                                                    
                                                     \
+    }                                                                          
                                                     \
+    if (ndim >= MAX_CACHED) {                                                  
                                                     \
+        val = new validatorClassName(runtime, ndim);                           
                                                     \
+        return ETCH_OK;                                                        
                                                     \
+    }                                                                          
                                                     \
+    if (Validators(runtime)[ndim].get() == NULL) {                             
                                                     \
+        Validators(runtime)[ndim] = new validatorClassName(runtime, ndim);     
                                                     \
+        runtime->registerListener(&SRuntimeChangedListener);                   
                                                     \
+        ETCH_LOG_TRACE(runtime->getLogger(), 
runtime->getLogger().getValidatorContext(), "##validatorClassName has been 
created");  \
+    }                                                                          
                                                     \
+    val = Validators(runtime)[ndim];                                           
                                                     \
+    return ETCH_OK;                                                            
                                                     \
+}
+
 #include "common/EtchObject.h"
 #include "support/EtchRuntime.h"
 


Reply via email to