Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PythonAI< SuperClass > Class Template Reference

#include <pythonai.h>

Inheritance diagram for PythonAI< SuperClass >:
PythonClass< SuperClass >

Public Member Functions

 PythonAI (PyObject *self, float reaction_time, float agressivity)
 
virtual void Execute ()
 
virtual ~PythonAI ()
 
 PythonAI (PyObject *self_)
 
virtual void Execute ()
 
virtual void ChooseTarget ()
 
virtual void SetParent (Unit *parent)
 
- Public Member Functions inherited from PythonClass< SuperClass >
 PythonClass (PyObject *self_)
 
virtual void callFunction (std::string str)
 
virtual ~PythonClass ()
 

Static Public Member Functions

static void default_Execute (FireAt &pay)
 
static void InitModuleAI ()
 
static PythonAILastAI ()
 
static PythonAIFactory (const std::string &file)
 
static void default_Execute (SuperClass &self_)
 
static void default_ChooseTarget (SuperClass &self_)
 
static void default_SetParent (SuperClass &self_, Unit *parent)
 
static PythonClass< SuperClass > * LastPythonClass ()
 
static PythonClass< SuperClass > * Factory (const std::string &file)
 
static PythonClass< SuperClass > * FactoryString (char *code)
 
- Static Public Member Functions inherited from PythonClass< SuperClass >
static PythonClassLastPythonClass ()
 
static PythonClassFactory (const std::string &file)
 
static PythonClassFactoryString (char *code)
 

Protected Member Functions

virtual void Destruct ()
 
- Protected Member Functions inherited from PythonClass< SuperClass >
virtual void Destructor ()
 

Additional Inherited Members

- Static Public Attributes inherited from PythonClass< SuperClass >
static PythonClass< SuperClass > * last_instance
 
- Protected Attributes inherited from PythonClass< SuperClass >
PyObject * self
 

Detailed Description

template<class SuperClass>
class PythonAI< SuperClass >

Definition at line 6 of file pythonai.h.

Constructor & Destructor Documentation

template<class SuperClass >
PythonAI< SuperClass >::PythonAI ( PyObject *  self,
float  reaction_time,
float  agressivity 
)

Definition at line 20 of file pythonai.cpp.

20  : FireAt( reaction_time, aggressivity )
21 {
22  self = self_;
23  //boost::python:
24  Py_XINCREF( self ); //by passing this to whoami, we are counting on them to Destruct us
25  last_ai = this;
26 }
template<class SuperClass >
PythonAI< SuperClass >::~PythonAI ( )
virtual

Definition at line 58 of file pythonai.cpp.

References VSFileSystem::vs_fprintf().

59 {
60  VSFileSystem::vs_fprintf( stderr, "Destruct called. If called from C++ this is death %ld (%lx)", (unsigned long) this,
61  (unsigned long) this );
62 }
template<class SuperClass >
PythonAI< SuperClass >::PythonAI ( PyObject *  self_)
inline

Definition at line 227 of file python_class.h.

227  :PythonClass<SuperClass>(self_)
228  {
229  }

Member Function Documentation

template<class SuperClass >
virtual void PythonAI< SuperClass >::ChooseTarget ( )
inlinevirtual

Definition at line 234 of file python_class.h.

References PYTHONCALLBACK.

235  {
236  PYTHONCALLBACK(void, this->self, "ChooseTarget");
237  }
template<class SuperClass >
static void PythonAI< SuperClass >::default_ChooseTarget ( SuperClass &  self_)
inlinestatic

Definition at line 247 of file python_class.h.

248  {
249  (self_).SuperClass::ChooseTarget();
250  }
template<class SuperClass >
void PythonAI< SuperClass >::default_Execute ( FireAt pay)
static

Definition at line 31 of file pythonai.cpp.

Referenced by PythonAI< SuperClass >::InitModuleAI().

32 {
33  (self_).FireAt::Execute();
34 }
template<class SuperClass >
static void PythonAI< SuperClass >::default_Execute ( SuperClass &  self_)
inlinestatic

Definition at line 243 of file python_class.h.

244  {
245  (self_).SuperClass::Execute();
246  }
template<class SuperClass >
static void PythonAI< SuperClass >::default_SetParent ( SuperClass &  self_,
Unit parent 
)
inlinestatic

Definition at line 251 of file python_class.h.

252  {
253  }
template<class SuperClass >
void PythonAI< SuperClass >::Destruct ( )
protectedvirtual

Definition at line 27 of file pythonai.cpp.

28 {
29  Py_XDECREF( self ); //this should destroy SELF
30 }
template<class SuperClass >
void PythonAI< SuperClass >::Execute ( )
virtual

Definition at line 46 of file pythonai.cpp.

47 {
48  boost::python::callback< void >::call_method( self, "Execute" );
49 }
template<class SuperClass >
virtual void PythonAI< SuperClass >::Execute ( )
inlinevirtual

Definition at line 230 of file python_class.h.

References PYTHONCALLBACK.

231  {
232  PYTHONCALLBACK(void, this->self, "Execute");
233  }
template<class SuperClass >
PythonAI * PythonAI< SuperClass >::Factory ( const std::string &  file)
static

Definition at line 41 of file pythonai.cpp.

References CompileRunPython(), and PythonAI< SuperClass >::LastAI().

42 {
43  CompileRunPython( filename );
44  return LastAI();
45 }
template<class SuperClass >
static PythonClass<SuperClass>* PythonAI< SuperClass >::Factory ( const std::string &  file)
inlinestatic

Definition at line 258 of file python_class.h.

References PythonClass< SuperClass >::Factory().

259  {
261  }
template<class SuperClass >
static PythonClass<SuperClass>* PythonAI< SuperClass >::FactoryString ( char *  code)
inlinestatic

Definition at line 262 of file python_class.h.

References PythonClass< SuperClass >::FactoryString().

263  {
265  }
template<class SuperClass >
void PythonAI< SuperClass >::InitModuleAI ( )
static

Definition at line 50 of file pythonai.cpp.

References PythonAI< SuperClass >::default_Execute().

51 {
52  boost::python::module_builder ai_builder( "AI" );
53  boost::python::class_builder< FireAt, PythonAI >BaseClass( ai_builder, "FireAt" );
54 
55  BaseClass.def( boost::python::constructor< float, float > () );
56  BaseClass.def( &FireAt::Execute, "PythonAI", PythonAI::default_Execute );
57 }
template<class SuperClass >
PythonAI * PythonAI< SuperClass >::LastAI ( )
static

Definition at line 35 of file pythonai.cpp.

Referenced by PythonAI< SuperClass >::Factory().

36 {
37  PythonAI *myai = last_ai;
38  last_ai = NULL;
39  return myai;
40 }
template<class SuperClass >
static PythonClass<SuperClass>* PythonAI< SuperClass >::LastPythonClass ( )
inlinestatic

Definition at line 254 of file python_class.h.

References PythonClass< SuperClass >::LastPythonClass().

Referenced by Orders::FireAt::LastPythonScript().

255  {
257  }
template<class SuperClass >
virtual void PythonAI< SuperClass >::SetParent ( Unit parent)
inlinevirtual

Definition at line 238 of file python_class.h.

References PYTHONCALLBACK2.

239  {
240  SuperClass::SetParent (parent);
241  PYTHONCALLBACK2(void, this->self, "init", parent);
242  }

The documentation for this class was generated from the following files: