Patch to change license to GPL only, from GSR.
[blender.git] / source / gameengine / GameLogic / SCA_PythonController.h
1 /**
2  * Execute Python scripts
3  *
4  * $Id$
5  *
6  * ***** BEGIN GPL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  *
22  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23  * All rights reserved.
24  *
25  * The Original Code is: all of this file.
26  *
27  * Contributor(s): none yet.
28  *
29  * ***** END GPL LICENSE BLOCK *****
30  */
31
32 #ifndef KX_PYTHONCONTROLLER_H
33 #define KX_PYTHONCONTROLLER_H
34               
35 #include "SCA_IController.h"
36 #include "SCA_LogicManager.h"
37 #include "BoolValue.h"
38
39 class SCA_IObject;
40 class SCA_PythonController : public SCA_IController
41 {
42         Py_Header;
43         struct _object *                m_bytecode;
44         bool                                    m_bModified;
45
46  protected:
47         STR_String                              m_scriptText;
48         STR_String                              m_scriptName;
49         PyObject*                               m_pythondictionary;
50
51  public: 
52         static SCA_PythonController* m_sCurrentController; // protected !!!
53
54         //for debugging
55         //virtual       CValue*         AddRef();
56         //virtual int                   Release();                                                                                              // Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
57
58         SCA_PythonController(SCA_IObject* gameobj,PyTypeObject* T = &Type);
59         virtual ~SCA_PythonController();
60
61         virtual CValue* GetReplica();
62         virtual void  Trigger(class SCA_LogicManager* logicmgr);
63   
64         void    SetScriptText(const STR_String& text);
65         void    SetScriptName(const STR_String& name);
66         void    SetDictionary(PyObject* pythondictionary);
67
68         static char* sPyGetCurrentController__doc__;
69         static PyObject* sPyGetCurrentController(PyObject* self, 
70                                                                                          PyObject* args, 
71                                                                                          PyObject* kwds);
72         static char* sPyAddActiveActuator__doc__;
73         static PyObject* sPyAddActiveActuator(PyObject* self, 
74                                                                                   PyObject* args, 
75                                                                                   PyObject* kwds);
76         virtual PyObject* _getattr(const STR_String& attr);
77
78         KX_PYMETHOD_DOC(SCA_PythonController,GetSensors);
79         KX_PYMETHOD_DOC(SCA_PythonController,GetSensor);
80         KX_PYMETHOD_DOC(SCA_PythonController,GetActuator);
81         KX_PYMETHOD_DOC(SCA_PythonController,GetActuators);
82         KX_PYMETHOD(SCA_PythonController,SetScript);
83         KX_PYMETHOD(SCA_PythonController,GetScript);
84         
85
86 };
87
88 #endif //KX_PYTHONCONTROLLER_H
89