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.5 $
00022 // $Date: 2005/11/23 18:25:17 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/actor/shadow/Shadow.cpp,v $
00024                                                                         
00025 
00026 // Written: fmk
00027 // Revision: A
00028 //
00029 // Purpose: This file contains the implementation of Shadow.
00030 //
00031 // What: "@(#) Shadow.C, revA"
00032 
00033 #include <Shadow.h>
00034 #include <stdlib.h>
00035 
00036 #include <Channel.h>
00037 #include <MachineBroker.h>
00038 #include <Message.h>
00039 #include <MovableObject.h>
00040 #include <Matrix.h>
00041 #include <Vector.h>
00042 #include <ID.h>
00043 #include <FEM_ObjectBroker.h>
00044 
00045 Shadow::Shadow(Channel &theChan, 
00046                FEM_ObjectBroker &myBroker)
00047   :theChannel(&theChan), theBroker(&myBroker), theRemoteActorsAddress(0), commitTag(0)
00048 {
00049   theChannel->setUpConnection();
00050 }
00051 
00052 
00053 Shadow::Shadow(Channel &theChan, 
00054                FEM_ObjectBroker &myBroker,
00055                ChannelAddress &theAddress)
00056   :theChannel(&theChan), theBroker(&myBroker), theRemoteActorsAddress(&theAddress),
00057    commitTag(0)
00058 {
00059   theChannel->setUpConnection();
00060 }
00061 
00062 Shadow::Shadow(int actorType,
00063                FEM_ObjectBroker &myBroker,             
00064                MachineBroker &theMachineBroker,
00065                int compDemand)
00066   :theBroker(&myBroker), theRemoteActorsAddress(0), commitTag(0)
00067 {
00068   // start the remote actor process running
00069   theChannel = theMachineBroker.startActor(actorType, compDemand);
00070   if (theChannel < 0) {
00071     opserr << "Shadow::Shadow - could not start remote actor\n";
00072     opserr << " using program " << actorType << endln;
00073     exit(-1);
00074   }
00075 
00076   // now call setUpShadow on the channel
00077   theChannel->setUpConnection();
00078   theRemoteActorsAddress = theChannel->getLastSendersAddress();
00079 }
00080 
00081 Shadow::~Shadow()
00082 {
00083     
00084 }    
00085 
00086 int
00087 Shadow::sendObject(MovableObject &theObject)
00088 {
00089     return theChannel->sendObj(commitTag, theObject, theRemoteActorsAddress);
00090 }
00091 
00092 int
00093 Shadow::recvObject(MovableObject &theObject)
00094 {
00095     return theChannel->recvObj(commitTag, theObject,*theBroker, theRemoteActorsAddress);
00096 }
00097 
00098 
00099 int
00100 Shadow::recvMessage(Message &theMessage)
00101 {
00102     return theChannel->recvMsg(0, commitTag, theMessage, theRemoteActorsAddress);
00103 }
00104 
00105 int
00106 Shadow::sendMessage(const Message &theMessage)
00107 {
00108     return theChannel->sendMsg(0, commitTag, theMessage, theRemoteActorsAddress);
00109 }
00110 
00111 int
00112 Shadow::sendMatrix(const Matrix &theMatrix)
00113 {
00114     return theChannel->sendMatrix(0, commitTag, theMatrix, theRemoteActorsAddress);
00115 }
00116 
00117 int
00118 Shadow::recvMatrix(Matrix &theMatrix)
00119 {
00120     return theChannel->recvMatrix(0, commitTag, theMatrix, theRemoteActorsAddress);
00121 }
00122 
00123 int
00124 Shadow::sendVector(const Vector &theVector)
00125 {
00126     return theChannel->sendVector(0, commitTag, theVector, theRemoteActorsAddress);
00127 }
00128 
00129 int
00130 Shadow::recvVector(Vector &theVector)
00131 {
00132     return theChannel->recvVector(0, commitTag, theVector, theRemoteActorsAddress);
00133 }
00134 
00135 int
00136 Shadow::sendID(const ID &theID)
00137 {
00138     return theChannel->sendID(0, commitTag, theID, theRemoteActorsAddress);
00139 }
00140 
00141 int
00142 Shadow::recvID(ID &theID)
00143 {
00144     return theChannel->recvID(0, commitTag, theID, theRemoteActorsAddress);
00145 }
00146 
00147 
00148 void
00149 Shadow::setCommitTag(int tag)
00150 {
00151   commitTag = tag;
00152 }
00153 
00154 
00155 Channel *
00156 Shadow::getChannelPtr(void) const
00157 {
00158     return theChannel;
00159 }
00160 
00161 FEM_ObjectBroker *
00162 Shadow::getObjectBrokerPtr(void) const
00163 {
00164     return theBroker;
00165 }
00166 
00167 ChannelAddress *
00168 Shadow::getActorAddressPtr(void) const
00169 {
00170     return theRemoteActorsAddress;
00171 }
00172 
00173 

Generated on Mon Oct 23 15:04:56 2006 for OpenSees by doxygen 1.5.0