AnimatLab  2
Test
ThreadProcessor.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
10 #include "AnimatBase.h"
11 
12 #include "Node.h"
13 #include "Link.h"
14 #include "IPhysicsMovableItem.h"
15 #include "IPhysicsBody.h"
16 #include "BoundingBox.h"
17 #include "MovableItem.h"
18 #include "BodyPart.h"
19 #include "Adapter.h"
20 #include "Joint.h"
21 #include "ReceptiveField.h"
22 #include "ContactSensor.h"
23 #include "RigidBody.h"
24 #include "Structure.h"
25 #include "NeuralModule.h"
26 #include "NervousSystem.h"
27 #include "Organism.h"
28 #include "ActivatedItem.h"
29 #include "ActivatedItemMgr.h"
30 #include "DataChartMgr.h"
31 #include "ExternalStimuliMgr.h"
32 #include "KeyFrame.h"
33 #include "SimulationRecorder.h"
34 #include "OdorType.h"
35 #include "Odor.h"
36 #include "Light.h"
37 #include "LightManager.h"
38 #include "Simulator.h"
39 
40 namespace AnimatSim
41 {
51 {
52 }
53 
63 {
64 
65 try
66 {
67  m_aryModules.Clear();
68 }
69 catch(...)
70 {Std_TraceMsg(0, "Caught Error in desctructor of ThreadProcessor\r\n", "", -1, false, true);}
71 }
72 
73 int ThreadProcessor::FindModuleProcessorIndex(std::string strModuleName)
74 {
75  int iSize = m_aryModules.GetSize();
76  for(int iIndex=0; iIndex<iSize; iIndex++)
77  if(m_aryModules[iIndex]->Name() == strModuleName)
78  return iIndex;
79 
80  return -1;
81 }
82 
83 void ThreadProcessor::CreateModuleProcessor(std::string strModuleName)
84 {
85  if(FindModuleProcessorIndex(strModuleName) == -1)
86  {
87  ModuleThreadProcessor *lpModule = new ModuleThreadProcessor(strModuleName);
88  m_aryModules.Add(lpModule);
89  }
90 }
91 
92 void ThreadProcessor::RemoveModuleProcessor(std::string strModuleName)
93 {
94  int iIndex = FindModuleProcessorIndex(strModuleName);
95  if(iIndex >= 0)
96  m_aryModules.RemoveAt(iIndex);
97 }
98 
99 void ThreadProcessor::StartThread()
100 {
101 }
102 
103 void ThreadProcessor::EndThread()
104 {
105 }
106 
108 {
109  int iSize = m_aryModules.GetSize();
110  for(int iIndex=0; iIndex<iSize; iIndex++)
111  m_aryModules[iIndex]->StepSimulation();
112 
113  for(int iIndex=0; iIndex<iSize; iIndex++)
114  m_aryModules[iIndex]->StepAdapters();
115 }
116 
117 } //AnimatSim
ThreadProcessor()
Default constructor.
Base class file for all Animat simulation objects.
Declares the nervous system class.
Declares the simulation recorder class.
Root namespace for the base simulation library for AnimatLab.
Declares the body part class.
Declares the key frame class.
Declares the joint class.
Declares the organism class.
virtual void StepSimulation()
Step the simulation for this object.
Declares a light object.
Declares the activated item class.
Declares a light manager object.
Declares the bounding box class.
virtual std::string Name()
Gets the name of this object.
Definition: AnimatBase.cpp:195
Handles processing of a single module within a thread of the simulation.
Declares the node class.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
virtual ~ThreadProcessor()
Destructor.
Declares the data chart manager class.
Declares the rigid body class.
Declares the structure class.
Declares the odor type class.
Declares the odor class.
Declares the simulator class.
Declares the neural module class.
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
CStdArray< ModuleThreadProcessor * > m_aryModules
An Array of module thread processors that will be run within this thread.
Declares the receptive field class.