00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <Shadow.h>
00037 #include <stdlib.h>
00038
00039 #include <Channel.h>
00040 #include <MachineBroker.h>
00041 #include <Message.h>
00042 #include <MovableObject.h>
00043 #include <Matrix.h>
00044 #include <Vector.h>
00045 #include <ID.h>
00046 #include <FEM_ObjectBroker.h>
00047
00048
00049 Shadow::Shadow(Channel &theChan,
00050 FEM_ObjectBroker &myBroker,
00051 ChannelAddress &theAddress)
00052 :theChannel(&theChan),theBroker(&myBroker),theRemoteActorsAddress(&theAddress)
00053 {
00054
00055 }
00056
00057 Shadow::Shadow(char *program,
00058 Channel &theChan,
00059 FEM_ObjectBroker &myBroker,
00060 MachineBroker &theMachineBroker,
00061 int compDemand,
00062 bool startShadow)
00063 :theChannel(&theChan),theBroker(&myBroker),theRemoteActorsAddress(0)
00064 {
00065
00066 if (startShadow == true) {
00067 int res = theMachineBroker.startActor(program,theChan,compDemand);
00068 if (res < 0) {
00069 cerr << "Shadow::Shadow - could not start remote actor\n";
00070 cerr << " using program " << *program << endl;
00071 exit(-1);
00072 }
00073 }
00074
00075
00076 theChan.setUpShadow();
00077 theRemoteActorsAddress = theChan.getLastSendersAddress();
00078 }
00079
00080 Shadow::~Shadow()
00081 {
00082
00083 }
00084
00085 int
00086 Shadow::sendObject(MovableObject &theObject)
00087 {
00088 return theChannel->sendObj(0, theObject,theRemoteActorsAddress);
00089 }
00090
00091 int
00092 Shadow::recvObject(MovableObject &theObject)
00093 {
00094 return theChannel->recvObj(0, theObject,*theBroker,theRemoteActorsAddress);
00095 }
00096
00097
00098 int
00099 Shadow::recvMessage(Message &theMessage)
00100 {
00101 return theChannel->recvMsg(0, 0, theMessage,theRemoteActorsAddress);
00102 }
00103
00104 int
00105 Shadow::sendMessage(const Message &theMessage)
00106 {
00107 return theChannel->sendMsg(0, 0, theMessage,theRemoteActorsAddress);
00108 }
00109
00110
00111
00112 int
00113 Shadow::sendMatrix(const Matrix &theMatrix)
00114 {
00115 return theChannel->sendMatrix(0, 0, theMatrix,theRemoteActorsAddress);
00116 }
00117
00118 int
00119 Shadow::recvMatrix(Matrix &theMatrix)
00120 {
00121 return theChannel->recvMatrix(0, 0, theMatrix,theRemoteActorsAddress);
00122 }
00123
00124 int
00125 Shadow::sendVector(const Vector &theVector)
00126 {
00127 return theChannel->sendVector(0, 0, theVector,theRemoteActorsAddress);
00128 }
00129
00130 int
00131 Shadow::recvVector(Vector &theVector)
00132 {
00133 return theChannel->recvVector(0, 0, theVector,theRemoteActorsAddress);
00134 }
00135
00136 int
00137 Shadow::sendID(const ID &theID)
00138 {
00139 return theChannel->sendID(0, 0, theID,theRemoteActorsAddress);
00140 }
00141
00142 int
00143 Shadow::recvID(ID &theID)
00144 {
00145 return theChannel->recvID(0, 0, theID,theRemoteActorsAddress);
00146 }
00147
00148
00149 Channel *
00150 Shadow::getChannelPtr(void) const
00151 {
00152 return theChannel;
00153 }
00154
00155 FEM_ObjectBroker *
00156 Shadow::getObjectBrokerPtr(void) const
00157 {
00158 return theBroker;
00159 }
00160
00161 ChannelAddress *
00162 Shadow::getActorAddressPtr(void) const
00163 {
00164 return theRemoteActorsAddress;
00165 }
00166
00167