XC Open source finite element analysis program
Channel.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 /* ****************************************************************** **
28 ** OpenSees - Open System for Earthquake Engineering Simulation **
29 ** Pacific Earthquake Engineering Research Center **
30 ** **
31 ** **
32 ** (C) Copyright 1999, The Regents of the University of California **
33 ** All Rights Reserved. **
34 ** **
35 ** Commercial use of this program without express permission of the **
36 ** University of California, Berkeley, is strictly prohibited. See **
37 ** file 'COPYRIGHT' in main directory for information on usage and **
38 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
39 ** **
40 ** Developed by: **
41 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
42 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
43 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
44 ** **
45 ** ****************************************************************** */
46 
47 // $Revision: 1.5 $
48 // $Date: 2005/11/23 18:27:24 $
49 // $Source: /usr/local/cvs/OpenSees/SRC/actor/channel/Channel.h,v $
50 
51 
52 #ifndef Channel_h
53 #define Channel_h
54 
55 // Written: fmk
56 // Created: 11/96
57 // Revision: A
58 //
59 // Purpose: This file contains the class definition for Channel.
60 // Channel is an abstract base class which defines the channel interface.
61 // A channel is a point of communication in a program, a mailbox to/from
62 // which data enters/leaves a program.
63 //
64 // What: "@(#) Channel.h, revA"
65 
66 
67 #include "xc_utils/src/nucleo/EntCmd.h"
68 #include <set>
69 
70 namespace XC {
71 class ChannelAddress;
72 class Message;
73 class MovableObject;
74 class Matrix;
75 class Vector;
76 class ID;
77 class FEM_ObjectBroker;
78 
80 //
85 class Channel: public EntCmd
86  {
87  private:
88  static int numChannel;
89  int tag;
90  std::set<int> usedDbTags;
91  protected:
92  int sendMovable(int commitTag, MovableObject &);
93  int receiveMovable(int commitTag, MovableObject &, FEM_ObjectBroker &);
94  public:
95  Channel(void);
96  inline virtual ~Channel(void) {}
97 
98  // methods to set up the channel in an actor space
99  virtual char *addToProgram(void) =0;
100  virtual int setUpConnection(void) =0;
101  virtual int setNextAddress(const ChannelAddress &theAddress) =0;
102  virtual ChannelAddress *getLastSendersAddress(void) =0;
103 
104  virtual bool isDatastore(void) const;
105  virtual int getDbTag(void) const;
106  bool checkDbTag(const int &dbTag);
107  const ID &getUsedTags(void) const;
108  void clearDbTags(void);
109  int getTag(void) const;
110 
111  // methods to send/receive messages and objects on channels.
112  virtual int sendObj(int commitTag, MovableObject &, ChannelAddress *theAddress= nullptr) =0;
113  virtual int recvObj(int commitTag, MovableObject &, FEM_ObjectBroker &, ChannelAddress *theAddress= nullptr) =0;
114  template <class inputIterator>
115  int sendObjs(int commitTag,const inputIterator &first,const inputIterator &last,ChannelAddress *theAddress= nullptr);
116  template <class inputIterator>
117  int recvObjs(int commitTag,const inputIterator &first,const inputIterator &last, FEM_ObjectBroker &, ChannelAddress *theAddress= nullptr);
118 
119  virtual int sendMsg(int dbTag, int commitTag, const Message &, ChannelAddress *theAddress= nullptr) =0;
120  virtual int recvMsg(int dbTag, int commitTag, Message &,ChannelAddress *theAddress= nullptr) =0;
121 
122  virtual int sendMatrix(int dbTag, int commitTag, const Matrix &,ChannelAddress *theAddress= nullptr) =0;
123  virtual int recvMatrix(int dbTag, int commitTag, Matrix &, ChannelAddress *theAddress= nullptr) =0;
124 
125  virtual int sendVector(int dbTag, int commitTag, const Vector &, ChannelAddress *theAddress= nullptr) =0;
126  virtual int recvVector(int dbTag, int commitTag, Vector &, ChannelAddress *theAddress= nullptr) =0;
127 
128  virtual int sendID(int dbTag, int commitTag,const ID &, ChannelAddress *theAddress= nullptr) =0;
129  virtual int recvID(int dbTag, int commitTag,ID &, ChannelAddress *theAddress= nullptr) =0;
130  };
131 
133 template <class inputIterator>
134 int Channel::sendObjs(int commitTag,const inputIterator &first,const inputIterator &last,ChannelAddress *theAddress)
135  {
136  int retval= 0;
137  for(inputIterator i= first;i!=last;i++)
138  {
139  retval= sendObj(commitTag,*i,theAddress);
140  if(retval!=0)
141  break;
142  }
143  return retval;
144  }
145 
147 template <class inputIterator>
148 int Channel::recvObjs(int commitTag,const inputIterator &first,const inputIterator &last, FEM_ObjectBroker &ob, ChannelAddress *theAddress)
149  {
150  int retval= 0;
151  for(inputIterator i= first;i!=last;i++)
152  {
153  retval= recvObj(commitTag,*i,ob,theAddress);
154  if(retval!=0)
155  break;
156  }
157  return retval;
158  }
159 
160 } // end of XC namespace
161 
162 #endif
int sendObjs(int commitTag, const inputIterator &first, const inputIterator &last, ChannelAddress *theAddress=nullptr)
Send the objects on interval [first,last).
Definition: Channel.h:134
Definition: Vector.h:82
const ID & getUsedTags(void) const
Return the lista de dbTags usados.
Definition: Channel.cpp:86
FEM_ObjectBroker is is an object broker class for the finite element method. All methods are virtual ...
Definition: FEM_ObjectBroker.h:138
int receiveMovable(int commitTag, MovableObject &, FEM_ObjectBroker &)
Recibe el objeto a través de éste canal.
Definition: Channel.cpp:126
Definition: ChannelAddress.h:69
Object that can move between processes.
Definition: MovableObject.h:91
Definition: ID.h:77
int sendMovable(int commitTag, MovableObject &)
Envía el objeto a través de éste canal.
Definition: Channel.cpp:119
Channel(void)
Constructor.
Definition: Channel.cpp:73
Definition: Matrix.h:82
Channel is an abstract base class which defines the channel interface. A channel is a point of commun...
Definition: Channel.h:85
Message between processes.
Definition: Message.h:67
================================================================================
Definition: ContinuaReprComponent.h:34
int recvObjs(int commitTag, const inputIterator &first, const inputIterator &last, FEM_ObjectBroker &, ChannelAddress *theAddress=nullptr)
Recibe una serie de objetos.
Definition: Channel.h:148
bool checkDbTag(const int &dbTag)
Comprueba si ya se ha usado este dbTag.
Definition: Channel.cpp:98