Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Shadow.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.1.1.1 $
00022 // $Date: 2000/09/15 08:23:16 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/actor/shadow/Shadow.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/actor/Shadow.C
00027 //
00028 // Written: fmk
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Purpose: This file contains the implementation of Shadow.
00033 //
00034 // What: "@(#) Shadow.C, revA"
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     // start the remote actor process running
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   // now call setUpShadow on the channel
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 
Copyright Contact Us