FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
moose-core/basecode/SharedFinfo.cpp at master · BhallaLab/moose-core · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
BhallaLab
/
moose-core
Public
Notifications
You must be signed in to change notification settings
Fork
38
Star
19
Code
Issues
47
Pull requests
2
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
moose-core
/
basecode
/
SharedFinfo.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
179 lines (158 loc) · 4.86 KB
Breadcrumbs
moose-core
/
basecode
/
SharedFinfo.cpp
Copy path
File metadata and controls
179 lines (158 loc) · 4.86 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
*********************************************************************
** This program is part of 'MOOSE', the
** Messaging Object Oriented Simulation Environment.
** Copyright (C) 2003-2010 Upinder S. Bhalla. and NCBS
** It is made available under the terms of the
** GNU Lesser General Public License version 2.1
** See the file COPYING.LIB for the full notice.
*********************************************************************
*/
#
include
"
header.h
"
/*
*
* This set of classes define Message Sources. Their main job is to supply
* a type-safe send operation, and to provide typechecking for it.
*/
SharedFinfo::SharedFinfo
(
const
string& name,
const
string& doc,
Finfo** entries,
unsigned
int
numEntries )
: Finfo( name, doc )
{
for
(
unsigned
int
i =
0
; i < numEntries; ++i )
{
Finfo* foo = entries[i];
SrcFinfo* s =
dynamic_cast
< SrcFinfo* >( foo );
//
SrcFinfo* s = dynamic_cast< SrcFinfo* >( entries[i] );
if
( s !=
0
)
src_.
push_back
( s );
else
dest_.
push_back
( entries[i] );
}
}
void
SharedFinfo::registerFinfo
( Cinfo* c )
{
for
( vector< SrcFinfo* >::iterator i =
src_.
begin
(); i != src_.
end
(); ++i)
c->
registerFinfo
( *i );
for
( vector< Finfo* >::iterator i =
dest_.
begin
(); i != dest_.
end
(); ++i)
c->
registerFinfo
( *i );
}
bool
SharedFinfo::strSet
(
const
Eref& tgt,
const
string& field,
const
string& arg )
const
{
return
0
;
}
bool
SharedFinfo::strGet
(
const
Eref& tgt,
const
string& field, string& returnValue )
const
{
return
0
;
}
/*
*
* It is possible that we have DestFinfos in this SharedFinfo, that have
* not been registered. So we need to scan through.
* Note that the register operation overwrites values if they already
* exist. Best not to have conflicts!.
*/
/*
void SharedFinfo::registerOpFuncs(
map< string, FuncId >& fnames, vector< OpFunc* >& funcs )
{
for ( unsigned int i = 0; i < dest_.size(); ++i )
dest_[i]->registerOpFuncs( fnames, funcs );
}
BindIndex SharedFinfo::registerBindIndex( BindIndex current )
{
return current;
}
*/
bool
SharedFinfo::checkTarget
(
const
Finfo* target )
const
{
const
SharedFinfo* tgt =
dynamic_cast
<
const
SharedFinfo* >( target );
if
( tgt ) {
if
( src_.
size
() != tgt->
dest_
.
size
() &&
dest_.
size
() != tgt->
src_
.
size
() )
return
0
;
for
(
unsigned
int
i =
0
; i < src_.
size
(); ++i ) {
if
( !src_[i]->
checkTarget
( tgt->
dest_
[i] ) )
return
0
;
}
for
(
unsigned
int
i =
0
; i < tgt->
src_
.
size
(); ++i ) {
if
( !tgt->
src_
[i]->
checkTarget
( dest_[i] ) )
return
0
;
}
return
1
;
}
return
0
;
}
bool
SharedFinfo::addMsg
(
const
Finfo* target, ObjId mid,
Element* srcElm )
const
{
if
( !
checkTarget
( target ) )
return
0
;
const
SharedFinfo* tgt =
dynamic_cast
<
const
SharedFinfo* >( target );
//
We have a problem if the src and dest elms (e1 and e2) are the
//
same, because this messes up the logic to assign the isForward flag.
//
This is an issue only if the target Finfo wants to send data back.
//
In other words, there are dest_ finfos on this SharedFinfo.
//
Report this problem.
const
Msg* m =
Msg::getMsg
( mid );
assert
( m->
e1
() == srcElm );
Element* destElm = m->
e2
();
if
( srcElm == destElm && srcElm->
id
() !=
Id
() ) {
if
( dest_.
size
() >
0
) {
cout <<
"
Error: SharedFinfo::addMsg: MessageId
"
<< mid <<
endl <<
"
Source Element == DestElement ==
"
<< srcElm->
getName
() <<
endl <<
"
Recommend that you individually set up messages for
"
<<
"
the components of the SharedFinfo, to ensure that the
"
<<
"
direction of messaging is consistent.
\n
"
;
return
0
;
}
}
for
(
unsigned
int
i =
0
; i < src_.
size
(); ++i ) {
if
( !src_[i]->
addMsg
( tgt->
dest_
[i], mid, srcElm ) ) {
//
Should never happen. The checkTarget should preclude this.
cerr <<
"
Error:SharedFinfo::addMsg: Failed on MessageId
"
<<
mid <<
"
, unrecoverable
\n
"
;
exit
(
0
);
}
}
for
(
unsigned
int
i =
0
; i < tgt->
src_
.
size
(); ++i ) {
if
( !tgt->
src_
[i]->
addMsg
( dest_[i], mid, destElm ) ) {
//
Should never happen. The checkTarget should preclude this.
cerr <<
"
Error:SharedFinfo::addMsg: Failed on MessageId
"
<<
mid <<
"
, unrecoverable
\n
"
;
exit
(
0
);
}
}
return
1
;
}
const
vector< SrcFinfo* >&
SharedFinfo::src
()
const
{
return
src_;
}
const
vector< Finfo* >&
SharedFinfo::dest
()
const
{
return
dest_;
}
//
///////////////////////////////////////////////////////////////////
//
overridden default virtual funcs for internal set/get names
//
///////////////////////////////////////////////////////////////////
vector< string >
SharedFinfo::innerSrc
()
const
{
vector< string > ret;
for
( vector< SrcFinfo* >::const_iterator i = src_.
begin
();
i != src_.
end
(); ++i )
ret.
push_back
( (*i)->
name
() );
return
ret;
}
vector< string >
SharedFinfo::innerDest
()
const
{
vector< string > ret;
for
( vector< Finfo* >::const_iterator i = dest_.
begin
();
i != dest_.
end
(); ++i )
ret.
push_back
( (*i)->
name
() );
return
ret;
}
string
SharedFinfo::rttiType
()
const
{
return
"
void
"
;
}
Back
|
FazBrowse Home
|
New Git URL