You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
938 B

7 years ago
​
4 years ago
​
4 years ago
​
4 years ago
7 years ago
4 years ago
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "basicEngine.h"
  2. // Constructor implementation
  3. basicEngine::basicEngine():basicObject(){
  4. m_bOWM = ENG_WM_UNBORN;
  5. m_bWM = ENG_WM_UNBORN;
  6. };
  7. // Destructor implementation
  8. basicEngine::~basicEngine(){
  9. setWM( ENG_WM_DEAD );
  10. };
  11. bool basicEngine::setWM( uint8_t s, bool hard ){
  12. if( hard ){
  13. m_mWMProtector.lock();
  14. m_bOWM = m_bWM;
  15. m_bWM = s;
  16. m_mWMProtector.unlock();
  17. } else {
  18. if( m_mWMProtector.try_lock() ){
  19. m_bOWM = m_bWM;
  20. m_bWM = s;
  21. m_mWMProtector.unlock();
  22. } else return false;
  23. };
  24. return true;
  25. };
  26. uint8_t basicEngine::getWM( void ){
  27. uint8_t s;
  28. m_mWMProtector.lock();
  29. s = m_bWM;
  30. m_mWMProtector.unlock();
  31. return s;
  32. };
  33. uint8_t basicEngine::getOWM( void ){
  34. uint8_t s;
  35. m_mWMProtector.lock();
  36. s = m_bOWM;
  37. m_mWMProtector.unlock();
  38. return s;
  39. };
  40. void basicEngine::setBackOWM( void ){
  41. m_mWMProtector.lock();
  42. m_bWM = m_bOWM;
  43. m_mWMProtector.unlock();
  44. };