00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "StdAfx.h"
00022 #include "BON2Component.h"
00023
00024 namespace BON
00025 {
00026
00027
00028
00029
00030
00031
00032
00033 Component::Component()
00034 : m_bIsInteractive( false )
00035 {
00036 }
00037
00038 Component::~Component()
00039 {
00040 finalize( m_project );
00041 m_project = NULL;
00042 }
00043
00044
00045
00046
00047
00048 void Component::initialize( Project& project )
00049 {
00050
00051
00052 }
00053
00054
00055
00056
00057
00058 void Component::finalize( Project& project )
00059 {
00060
00061
00062 }
00063
00064
00065
00066
00067
00068 void Component::invoke( Project& project, const std::set<FCO>& setModels, long lParam )
00069 {
00070 #ifdef SUPPORT_OLD_INVOKE
00071 Object focus;
00072 invokeEx( project, focus, setModels, lParam );
00073 #else
00074 if ( m_bIsInteractive )
00075 AfxMessageBox("This BON2 Component does not support the obsolete invoke mechanism!");
00076 #endif
00077 }
00078
00079
00080
00081
00082
00083 void Component::invokeEx( Project& project, FCO& currentFCO, const std::set<FCO>& setSelectedFCOs, long lParam )
00084 {
00085
00086
00087
00088
00089
00090 CPrintDlg dlg;
00091 MyVisitor visitor( &dlg );
00092 project->getRootFolder()->accept( &visitor );
00093 dlg.DoModal();
00094
00095 }
00096
00097
00098
00099
00100
00101 void Component::objectInvokeEx( Project& project, Object& currentObject, const std::set<Object>& setSelectedObjects, long lParam )
00102 {
00103 if ( m_bIsInteractive )
00104 AfxMessageBox("This BON2 Component does not support objectInvokeEx method!");
00105 }
00106
00107
00108
00109
00110 Util::Variant Component::getParameter( const std::string& strName )
00111 {
00112
00113
00114
00115 return Util::Variant();
00116 }
00117
00118 void Component::setParameter( const std::string& strName, const Util::Variant& varValue )
00119 {
00120
00121
00122 }
00123
00124 #ifdef GME_ADDON
00125
00126
00127
00128
00129 void Component::globalEventPerformed( globalevent_enum event )
00130 {
00131
00132
00133 }
00134
00135
00136
00137
00138 void Component::objectEventPerformed( Object& object, unsigned long event, VARIANT v )
00139 {
00140
00141
00142 }
00143
00144 #endif GME_ADDON
00145
00146
00147
00148
00149
00150
00151
00152 void ProcessingBaseImpl::initialize()
00153 {
00154 m_bParamsAccessed = false;
00155 childParameters();
00156 }
00157
00158
00159
00160 std::vector<Parameter>& ProcessingBaseImpl::childParameters()
00161 {
00162 if ( ! m_bParamsAccessed ) {
00163 std::set<FCO> children = getChildFCOs();
00164 for ( std::set<FCO>::iterator it = children.begin() ; it != children.end() ; it++ )
00165 if ( (*it)->getFCOMeta().name().find( "Param" ) != std::string::npos )
00166 m_vecParams.push_back( *it );
00167 m_bParamsAccessed = true;
00168 }
00169 return m_vecParams;
00170 }
00171
00172
00173
00174 ProcessingBaseImpl::~ProcessingBaseImpl()
00175 {
00176
00177 m_vecParams.clear();
00178 }
00179
00180
00181
00182
00183
00184
00185
00186 IMPLEMENT_BONEXTENSION( Compound, "Compound" );
00187
00188
00189
00190 int CompoundImpl::getHighPrimitivesCount()
00191 {
00192 int iCnt = 0;
00193 std::set<FCO> children = getChildFCOsAs( "PrimitiveParts" );
00194 for ( std::set<FCO>::iterator it = children.begin() ; it != children.end() ; it++ )
00195 if ( Primitive( *it )->priority() > 5 )
00196 iCnt++;
00197 return iCnt;
00198 }
00199
00200
00201
00202
00203
00204
00205
00206 IMPLEMENT_BONEXTENSION( Primitive, "PrimitiveParts" );
00207
00208
00209
00210
00211 void PrimitiveImpl::initialize()
00212 {
00213 ProcessingBaseImpl::initialize();
00214 m_iPriority = getAttribute( "Priority" )->getIntegerValue();
00215 }
00216
00217 long PrimitiveImpl::priority() const
00218 {
00219 return m_iPriority;
00220 }
00221
00222
00223
00224
00225
00226
00227
00228 IMPLEMENT_BONEXTENSION( Parameter, "Param InputParam OutputParam" );
00229
00230 void ParameterImpl::initialize()
00231 {
00232 m_iSize = getAttribute( "Size" )->getIntegerValue();
00233 std::string str = getAttribute( "DataType" )->getStringValue();
00234 if ( str == "Integer" )
00235 m_eType = DT_Integer;
00236 else if ( str == "Real" )
00237 m_eType = DT_Real;
00238 else if ( str == "Character" )
00239 m_eType = DT_Character;
00240 else
00241 m_eType = DT_Pointer;
00242 }
00243
00244
00245
00246
00247 std::set<IOParameter> ParameterImpl::inputParameters()
00248 {
00249 std::multiset<ConnectionEnd> params = getConnEndsAs( "ParameterConn", "dst" );
00250 std::set<IOParameter> params2;
00251 for ( std::multiset<ConnectionEnd>::iterator it = params.begin() ; it != params.end() ; it++ )
00252 if ( (*it)->isReferencePort() )
00253 params2.insert( IOParameter( ReferencePort( *it )->getFCO() ) );
00254 else
00255 params2.insert( IOParameter( FCO( *it ) ) );
00256 return params2;
00257 }
00258
00259
00260
00261
00262 std::set<IOParameter> ParameterImpl::outputParameters()
00263 {
00264 std::multiset<ConnectionEnd> params = getConnEnds( "", "dst" );
00265 std::set<IOParameter> params2;
00266 for ( std::multiset<ConnectionEnd>::iterator it = params.begin() ; it != params.end() ; it++ )
00267 params2.insert( ( (*it)->isReferencePort() ) ? ReferencePort( *it )->getFCO() : FCO( *it ) );
00268 return params2;
00269 }
00270
00271 std::string ParameterImpl::className() const
00272 {
00273 return "Parameter";
00274 }
00275
00276
00277
00278
00279
00280
00281
00282 IMPLEMENT_BONEXTENSION( IOParameter, "InputParameters OutputParameters" );
00283
00284 std::string IOParameterImpl::className() const
00285 {
00286 return "IOParameter";
00287 }
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 IMPLEMENT_BONEXTENSION( Signal, "BON::Atom" );
00298
00299 bool SignalImpl::isMyParentPrimitive()
00300 {
00301 if ( getParentModel( "Primitive" ) )
00302 return true;
00303 return false;
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 MyVisitor::MyVisitor( CPrintDlg* pDlg )
00326 : m_pDlg( pDlg )
00327 {
00328 pDlg->m_strValue = "";
00329 }
00330
00331 void MyVisitor::visitObjectImpl( const Object& object )
00332 {
00333 PrintLine( "-----------------------------------------------------------------------" );
00334 PrintLine( "ObjectName : " + object->getName() );
00335 PrintLine( "ObjectKind : " + object->getObjectMeta().name() );
00336 PrintLine( "ObjectPath : " + object->getPath() );
00337 }
00338
00339 void MyVisitor::visitFCOImpl( const FCO& object )
00340 {
00341 MON::Containment role = object->getRole();
00342 if ( role )
00343 PrintLine( "ContainmentRole : " + role.name() );
00344 }
00345
00346 void MyVisitor::visitAtomImpl( const Atom& object )
00347 {
00348 PrintLine( "ObjectMetaKind : Atom" );
00349 if ( ! visitIOParameter( IOParameter( object ) ) )
00350 if ( ! visitParameter( Parameter( object ) ) )
00351 if ( ! visitSignal( Signal( object ) ) )
00352 PrintLine( "Something wrong" );
00353 }
00354
00355 void MyVisitor::visitModelImpl( const Model& object )
00356 {
00357 PrintLine( "ObjectMetaKind : Model" );
00358 if ( ! visitCompound( Compound( object ) ) )
00359 if ( ! visitPrimitive( Primitive( object ) ) )
00360 PrintLine( "Something wrong" );
00361 }
00362
00363 void MyVisitor::PrintLine( const std::string& str )
00364 {
00365 m_pDlg->m_strValue += CString( str.c_str() ) + "\r\n";
00366 }
00367
00368 bool MyVisitor::visitPrimitive( const Primitive& object )
00369 {
00370 if ( object ) {
00371 PrintLine( "ClassExtension : Primitive" );
00372 PrintLine( "Size value : " + (std::string) Util::Variant( object->priority() ) );
00373 return true;
00374 }
00375 return false;
00376 }
00377
00378 bool MyVisitor::visitCompound( const Compound& object )
00379 {
00380 if ( object ) {
00381 PrintLine( "ClassExtension : Compound" );
00382 PrintLine( "HighPrimitiveCnt value : " + (std::string) Util::Variant( (long) object->getHighPrimitivesCount() ) );
00383 return true;
00384 }
00385 return false;
00386 }
00387
00388 bool MyVisitor::visitParameter( const Parameter& object )
00389 {
00390 if ( object ) {
00391 PrintLine( "ClassExtension : Parameter" );
00392 PrintLine( "Size value : " + (std::string) Util::Variant( object->m_iSize ) );
00393 PrintLine( "ClassName by Class: " + (std::string) Util::Variant( object->className() ) );
00394 return true;
00395 }
00396 return false;
00397 }
00398
00399 bool MyVisitor::visitIOParameter( const IOParameter& object )
00400 {
00401 if ( object ) {
00402 PrintLine( "ClassExtension : IOParameter" );
00403 PrintLine( "Size value : " + (std::string) Util::Variant( object->m_iSize ) );
00404 PrintLine( "ClassName by Class: " + (std::string) Util::Variant( object->className() ) );
00405 return true;
00406 }
00407 return false;
00408 }
00409
00410 bool MyVisitor::visitSignal( const Signal& object )
00411 {
00412 if ( object ) {
00413 PrintLine( "ClassExtension : Signal" );
00414 PrintLine( "Is parent Primitive value : " + (std::string) Util::Variant( object->isMyParentPrimitive() ) );
00415 return true;
00416 }
00417 return false;
00418 }
00419
00420 };
00421