00001
00002 #include "SCA_IObject.h"
00003 #include "SCA_ISensor.h"
00004 #include "SCA_IController.h"
00005 #include "SCA_IActuator.h"
00006
00007 #include "ListValue.h"
00008
00009
00010
00011
00012
00013
00014 PyTypeObject SCA_IObject::Type = {
00015 PyObject_HEAD_INIT(&PyType_Type)
00016 0,
00017 "SCA_IObject",
00018 sizeof(SCA_IObject),
00019 0,
00020 PyDestructor,
00021 0,
00022 __getattr,
00023 __setattr,
00024 0,
00025 __repr,
00026 0,
00027 0,
00028 0,
00029 0,
00030 0
00031 };
00032
00033 PyParentObject SCA_IObject::Parents[] = {
00034 &SCA_IObject::Type,
00035 &CValue::Type,
00036 NULL
00037 };
00038
00039 PyMethodDef SCA_IObject::Methods[] = {
00040
00041
00042 {NULL,NULL}
00043 };
00044
00045 SCA_IObject::~SCA_IObject() {
00046 SCA_SensorList::iterator its;
00047 for (its = m_sensors.begin(); !(its == m_sensors.end()); ++its) {
00048 ((CValue*)(*its))->Release();
00049 }
00050 SCA_ControllerList::iterator itc;
00051 for (itc = m_controllers.begin(); !(itc == m_controllers.end()); ++itc)
00052 {
00053 ((CValue*)(*itc))->Release();
00054 }
00055 SCA_ActuatorList::iterator ita;
00056 for (ita = m_actuators.begin(); !(ita==m_actuators.end()); ++ita) {
00057 ((CValue*)(*ita))->Release();
00058 }
00059
00060
00061
00062
00063
00064 }
00065
00066 PyObject* SCA_IObject::_getattr(char* attr) {
00067 _getattr_up(CValue);
00068 }
00069
00070
00071 void SCA_IObject::ReParentLogic()
00072 {
00073 SCA_SensorList& oldsensors = GetSensors();
00074
00075 int sen = 0;
00076 SCA_SensorList::iterator its;
00077 for (its = oldsensors.begin(); !(its==oldsensors.end()); ++its)
00078 {
00079 SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica();
00080 newsensor->ReParent(this);
00081 oldsensors[sen++] = newsensor;
00082 }
00083
00084 SCA_ControllerList& oldcontrollers = GetControllers();
00085 int con = 0;
00086 SCA_ControllerList::iterator itc;
00087 for (itc = oldcontrollers.begin(); !(itc==oldcontrollers.end()); ++itc)
00088 {
00089 SCA_IController* newcontroller = (SCA_IController*)(*itc)->GetReplica();
00090 newcontroller->ReParent(this);
00091 oldcontrollers[con++]=newcontroller;
00092
00093 }
00094 SCA_ActuatorList& oldactuators = GetActuators();
00095
00096 int act = 0;
00097 SCA_ActuatorList::iterator ita;
00098 for (ita = oldactuators.begin(); !(ita==oldactuators.end()); ++ita)
00099 {
00100 SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica();
00101 newactuator->ReParent(this);
00102 newactuator->SetActive(false);
00103 oldactuators[act++] = newactuator;
00104 }
00105
00106 }
00107
00108 SCA_ISensor* SCA_IObject::FindSensor(const CCString& sensorname)
00109 {
00110 SCA_ISensor* foundsensor = NULL;
00111
00112 for (SCA_SensorList::iterator its = m_sensors.begin();!(its==m_sensors.end());its++)
00113 {
00114 if ((*its)->GetName() == sensorname)
00115 {
00116 foundsensor = (*its);
00117 break;
00118 }
00119 }
00120 return foundsensor;
00121 }
00122
00123
00124 SCA_IController* SCA_IObject::FindController(const CCString& controllername)
00125 {
00126 SCA_IController* foundcontroller = NULL;
00127
00128 for (SCA_ControllerList::iterator itc = m_controllers.begin();!(itc==m_controllers.end());itc++)
00129 {
00130 if ((*itc)->GetName() == controllername)
00131 {
00132 foundcontroller = (*itc);
00133 break;
00134 }
00135 }
00136 return foundcontroller;
00137 }
00138
00139 SCA_IActuator* SCA_IObject::FindActuator(const CCString& actuatorname)
00140 {
00141 SCA_IActuator* foundactuator = NULL;
00142
00143 for (SCA_ActuatorList::iterator ita = m_actuators.begin();!(ita==m_actuators.end());ita++)
00144 {
00145 if ((*ita)->GetName() == actuatorname)
00146 {
00147 foundactuator = (*ita);
00148 break;
00149 }
00150 }
00151
00152 return foundactuator;
00153 }
00154
00155
00156 void SCA_IObject::SetCurrentTime(float currentTime) {
00157
00158
00159
00160
00161 }
00162