Ares
Public Member Functions | Public Attributes | Private Attributes

Promotable< T > Class Template Reference

#include <src/Utilities/Template.h>

List of all members.

Public Member Functions

 Promotable (TechnoClass *Object=NULL)
Promotable< T > * BindTo (TechnoClass *Object)
void SetAll (T val)
void LoadFromINI (CCINIClass *pINI, const char *Section, const char *BaseFlag)
T * GetEx ()
Get ()

Public Attributes

Rookie
Veteran
Elite

Private Attributes

TechnoClass * _BindTo

template<typename T>
class Promotable< T >


Constructor & Destructor Documentation

template<typename T>
Promotable< T >::Promotable ( TechnoClass *  Object = NULL) [inline]
: _BindTo(Object) {};

Member Function Documentation

template<typename T>
Promotable<T>* Promotable< T >::BindTo ( TechnoClass *  Object) [inline]
                                                    {
                this->_BindTo = Object;
                return this;
        }
template<typename T>
T Promotable< T >::Get ( ) [inline]
                {
                return *this->GetEx();
        }
template<typename T>
T* Promotable< T >::GetEx ( ) [inline]
                   {
                if(!this->_BindTo) {
                        Debug::Log("Promotable<T> invoked without an owner!\n");
                        throw std::logic_error("Promotable<T> invoked without an owner!\n");
                }
                VeterancyStruct *XP = &this->_BindTo->Veterancy;
                if(XP->IsElite()) {
                        return &this->Elite;
                }
                if(XP->IsVeteran()) {
                        return &this->Veteran;
                }
                return &this->Rookie;
        }
template<typename T>
void Promotable< T >::LoadFromINI ( CCINIClass *  pINI,
const char *  Section,
const char *  BaseFlag 
) [inline]
                                                                                      {
                unsigned int buflen = strlen(BaseFlag) + 8;
                char *FlagName = new char[buflen];

                Customizable<T> Placeholder;
                INI_EX exINI(pINI);
                Placeholder.Set(this->Rookie);

                _snprintf(FlagName, buflen, BaseFlag, "Rookie");
                Placeholder.Read(&exINI, Section, FlagName);
                this->Rookie = Placeholder.Get();

                Placeholder.Set(this->Veteran);
                _snprintf(FlagName, buflen, BaseFlag, "Veteran");
                Placeholder.Read(&exINI, Section, FlagName);
                this->Veteran = Placeholder.Get();

                Placeholder.Set(this->Elite);
                _snprintf(FlagName, buflen, BaseFlag, "Elite");
                Placeholder.Read(&exINI, Section, FlagName);
                this->Elite = Placeholder.Get();

                delete[] FlagName;
        }
template<typename T>
void Promotable< T >::SetAll ( val) [inline]
                           {
                this->Elite = this->Veteran = this->Rookie = val;
        }

Member Data Documentation

template<typename T>
TechnoClass* Promotable< T >::_BindTo [private]
template<typename T>
T Promotable< T >::Elite
template<typename T>
T Promotable< T >::Rookie
template<typename T>
T Promotable< T >::Veteran

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines