BaseApi.hh

00001 /*
00002 ** TowBowlTactics, an adaptation of the tabletop game Blood Bowl.
00003 ** 
00004 ** Copyright (C) 2006, 2007 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   
00059 protected:
00060   T*            rules_; 
00061 };
00062 
00063 template <typename T>
00064 inline BaseApi<T>::BaseApi(T* rules)
00065   : rules_(rules)
00066 {
00067 }
00068 
00069 template <typename T>
00070 inline BaseApi<T>::~BaseApi()
00071 {
00072 }
00073 
00074 template <typename T>
00075 inline void BaseApi<T>::setEventHandler(Event* ev)
00076 {
00077   rules_->setEventHandler(ev);
00078 }
00079 
00080 template <typename T>
00081 inline int BaseApi<T>::getState() const
00082 {
00083   return rules_->getState();
00084 }
00085 
00086 template <typename T>
00087 inline const char* BaseApi<T>::getStateString() const
00088 {
00089   switch (rules_->getState())
00090     {
00091     case GS_WAIT:
00092       return "GS_WAIT";
00093     case GS_END:
00094       return "GS_END";
00095     }
00096   return "Undefined";
00097 }
00098 
00099 template <typename T>
00100 inline int BaseApi<T>::getTeamId() const
00101 {
00102   return rules_->getCoachId();
00103 }
00104 
00105 template <typename T>
00106 inline int BaseApi<T>::getTeamNumber() const
00107 {
00108   return rules_->getTeamNumber();
00109 }
00110 
00111 template <typename T>
00112 inline bool BaseApi<T>::isBusy() const
00113 {
00114   return rules_->isBusy();
00115 }
00116 
00117 #endif /* !BASEAPI_HH_ */

Generated on Sat Jun 23 16:07:22 2007 for Stechec/TBT by  doxygen 1.4.7