BaseApi.hh

00001 /*
00002 ** TowBowlTactics, a turn-based strategy football game.
00003 ** 
00004 ** Copyright (C) 2006-2010 The TBT Team.
00005 ** 
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 ** 
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 ** 
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 #ifndef BASEAPI_HH_
00018 # define BASEAPI_HH_
00019 
00020 # include "BaseCRules.hh"
00021 
00022 class Event;
00023 
00028 template <typename T>
00029 class BaseApi
00030 {
00031 public:
00032   BaseApi(T* rules);
00033   virtual ~BaseApi();
00034 
00037   void          setEventHandler(Event* evp);
00038 
00041   int           getState() const;
00042 
00044   const char*   getStateString() const;
00045   
00047   int           getTeamId() const;
00048 
00051   int           getTeamNumber() const;
00052 
00057   bool      isBusy() const;
00058   
00061   const PacketHistory& getEventsHistory() const;
00062 
00063 protected:
00064   T*            rules_; 
00065 };
00066 
00067 template <typename T>
00068 inline BaseApi<T>::BaseApi(T* rules)
00069   : rules_(rules)
00070 {
00071 }
00072 
00073 template <typename T>
00074 inline BaseApi<T>::~BaseApi()
00075 {
00076 }
00077 
00078 template <typename T>
00079 inline void BaseApi<T>::setEventHandler(Event* ev)
00080 {
00081   rules_->setEventHandler(ev);
00082 }
00083 
00084 template <typename T>
00085 inline int BaseApi<T>::getState() const
00086 {
00087   return rules_->getState();
00088 }
00089 
00090 template <typename T>
00091 inline const char* BaseApi<T>::getStateString() const
00092 {
00093   return BaseRules::stringifyGameState(rules_->getState());
00094 }
00095 
00096 template <typename T>
00097 inline int BaseApi<T>::getTeamId() const
00098 {
00099   return rules_->getCoachId();
00100 }
00101 
00102 template <typename T>
00103 inline int BaseApi<T>::getTeamNumber() const
00104 {
00105   return rules_->getTeamNumber();
00106 }
00107 
00108 template <typename T>
00109 inline bool BaseApi<T>::isBusy() const
00110 {
00111   return rules_->isBusy();
00112 }
00113 
00114 template <typename T>
00115 inline const PacketHistory& BaseApi<T>::getEventsHistory() const
00116 {
00117   return rules_->getHistory();
00118 }
00119 
00120 #endif /* !BASEAPI_HH_ */
Generated on Mon Apr 5 21:17:11 2010 for Stechec/TBT by  doxygen 1.6.3