Procházet zdrojové kódy

* Name Changes
* DataRepository added

jos.itemis@gmail.com před 14 roky
rodič
revize
d3ca7f3548

+ 4 - 4
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/templates/CustomEventH.xpt

@@ -16,9 +16,9 @@ Templates for the main statechart cpp file.
 
 «DEFINE file FOR ExecutionFlow»
 
-«FILE name.toFirstUpper()+'Event.h'»
-#ifndef «name.toUpperCase()»EVENTS_H_
-#define «name.toUpperCase()»EVENTS_H_
+«FILE name.toFirstUpper()+'.h'»
+#ifndef «name.toUpperCase()»_H_
+#define «name.toUpperCase()»_H_
 
 #include "Event.h"
 
@@ -35,7 +35,7 @@ enum EventID {
 «ENDFOREACH»
  
 
-#endif /* «name.toUpperCase()»EVENTS_H_ */
+#endif /* «name.toUpperCase()»_H_ */
 
 «ENDFILE»
 

+ 53 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/templates/DataRepositoryH.xpt

@@ -0,0 +1,53 @@
+«REM»
+
+Templates for the main statechart cpp file.
+
+@auther joern seger
+
+«ENDREM»
+
+«IMPORT sexec»
+«IMPORT stext»
+«IMPORT sgraph»
+
+
+«DEFINE file FOR ExecutionFlow»
+
+«FILE 'DataRepository.h'»
+#ifndef DATAREPOSITORY_H_
+#define DATAREPOSITORY_H_
+
+#ifndef WITH_BOOST
+
+class DataRepository {
+protected:
+	virtual void lock(){}
+	virtual void unlock(){}
+
+public:
+	DataRepository(){};
+	virtual ~DataRepository(){};
+};
+
+#else
+
+#include <boost/thread/mutex.hpp>
+
+class  DataRepository {
+protected:
+	boost::mutex mutex;
+
+	virtual void lock(){ mutex.lock(); }
+	virtual void unlock(){ mutex.unlock(); }
+
+public:
+	DataRepositoryBoost(){};
+	virtual ~DataRepositoryBoost(){};
+};
+
+#endif
+
+#endif /* DATAREPOSITORY_H_ */
+«ENDFILE»
+
+«ENDDEFINE»

+ 2 - 1
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/templates/Expression.ext

@@ -63,8 +63,9 @@ String toCppCode(NumericalAddSubtractExpression expression) :
 String toCppCode(NumericalMultiplyDivideExpression expression) :
   	expression.leftOperand.toCppCode() + getOperator(expression.operator) + expression.rightOperand.toCppCode();
 
+// is this just relevant for events?
 String toCppCode(ElementReferenceExpression ev) :
-    " ( " + ev.value.name + " == ev.getID() ) ";
+    " ( _" + ev.value.name.toLowerCase() + " == ev.getID() ) ";
 
 String getOperator(AdditiveOperator operator) : 
     switch(operator) {

+ 2 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/templates/Main.xpt

@@ -4,6 +4,7 @@ Contais the root templates that call the different file templates.
 
 @author andreas muelder
 @auther axel terfloth
+@author joern seger
 
 «ENDREM»
 
@@ -17,6 +18,7 @@ Contais the root templates that call the different file templates.
 
 	«REM» basis files «ENDREM»
 	«EXPAND EventH::file FOR this»
+	«EXPAND DataRepositoryH::file FOR this»
 	«EXPAND StatemachineH::file FOR this»
 	«EXPAND StatemachineExceptionH::file FOR this»
 	«EXPAND definitionH::file FOR this»