GME  13
OCLTypeExGMECM.cpp
Go to the documentation of this file.
00001 //###############################################################################################################################################
00002 //
00003 //      Object Constraint Language Generic Manager
00004 //      OCLTypeExGMECM.cpp
00005 //
00006 //###############################################################################################################################################
00007 #include "Solve4786.h"
00008 #include "OCLTypeExGMECM.h"
00009 
00010 #include "OCLObjectExBasic.h"
00011 #include "OCLObjectExGME.h"
00012 #include "OCLCommonEx.h"
00013 #include "math.h"
00014 #include "mga.h"
00015 #include <regex>
00016 
00017 using std::unique_ptr;
00018 
00019 #define NILNAMESPACE ""
00020 
00021 namespace OclGmeCM
00022 {
00023         typedef OclCommon::FormalParameterVector        FPV;
00024         typedef OclCommon::FormalParameter                      FP;
00025         typedef TypeSeq                                                                 TS;
00026 
00027         class Method
00028                 : public OclImplementation::Method
00029         {
00030                 protected :
00031                         std::string GetKind( int iArgumentPos, const std::string& strMetaKind, bool bCanBeEmpty = false )
00032                         {
00033                                 std::string strKind;
00034                                 if ( iArgumentPos != -1 && GetArgumentCount() > iArgumentPos ) {
00035                                         if ( GetArgument( iArgumentPos ).GetTypeName() == "ocl::String" ) {
00036                                                 DECL_STRING2( strKind, GetArgument( iArgumentPos ) );
00037                                         }
00038                                         else {
00039                                                 DECL_TYPE2( strKind, GetArgument( iArgumentPos ) );
00040                                         }
00041                                         if ( ! bCanBeEmpty && strKind.empty() )
00042                                                 ThrowException( "Kind cannot be empty string." );
00043                                         if ( GetTypeManager()->IsTypeA( strKind, "gme::Object" ) <= 0 )
00044                                                 ThrowException( "Kind does not exists." );
00045                                         if ( ! ( strMetaKind == "gme::Object" ) )
00046                                                 if ( GetTypeManager()->IsTypeA( strKind, strMetaKind ) <= 0 )
00047                                                         ThrowException( "Kind does not conform to " + strMetaKind + "." );
00048                                         return GetTypeManager()->GetType( strKind, NILNAMESPACE )->GetName().substr( 6 );
00049                                 }
00050                                 return strKind;
00051                         }
00052         };
00053 
00054         #define GMEMETHOD( featureName )                        class featureName : public Method
00055 
00056 //##############################################################################################################################################
00057 //
00058 //      T Y P E   O F   ocl::String
00059 //
00060 //##############################################################################################################################################
00061 
00062         METHOD( TStringEx_IntValue_Compatibility  )
00063         {
00064                 void operator()()
00065                 {
00066                         DECL_STRING( strThis, GetThis() );
00067                         Trim( strThis );
00068                         for ( unsigned int i = 0 ; i < strThis.length() ; i ++ )
00069                                 if ( strThis[ i ] < '0' || strThis[ i ] > '9' )
00070                                         ThrowException( "String cannot be converted to ocl::Integer." );
00071                         long lValue = atol( strThis.c_str() );
00072                         SetResult( CREATE_INTEGER( GetTypeManager(), lValue ) );
00073                 }
00074         };
00075 
00076         METHOD( TStringEx_DoubleValue_Compatibility  )
00077         {
00078                 void operator()()
00079                 {
00080                         DECL_STRING( strThis, GetThis() );
00081                         char* pchStop;
00082                         double dValue = strtod( strThis.c_str(), &pchStop );
00083                         if ( fabs( dValue ) == HUGE_VAL )
00084                                 ThrowException( "String cannot be converted to ocl::Real." );
00085                         SetResult( CREATE_REAL( GetTypeManager(), dValue ) );
00086                 }
00087         };
00088 
00089         METHOD( TStringEx_Size_Compatibility )
00090         {
00091                 void operator()()
00092                 {
00093                         DECL_STRING( strThis, GetThis() );
00094                         SetResult( CREATE_INTEGER( GetTypeManager(), strThis.length() ) );
00095                 }
00096         };
00097 
00098         METHOD( TStringEx_Match )
00099         {
00100                 void operator()()
00101                 {
00102                         DECL_STRING( strThis, GetThis() );
00103                         DECL_STRING( strRegExp, GetArgument( 0 ) );
00104                         CString strRegExp2 = OclCommonEx::Convert( strRegExp );
00105                         try {
00106                                 std::wregex tester( strRegExp2 );
00107 
00108                                 SetResult( CREATE_BOOLEAN( GetTypeManager(), std::regex_search(static_cast<const TCHAR*>(OclCommonEx::Convert(strThis)), tester) ) );
00109                         } catch (std::regex_error&) {
00110                                 ThrowException( "Regular Expression is not valid!" );
00111                         }
00112                 }
00113         };
00114 
00115         void TStringEx_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
00116         {
00117                 ((OclBasic::TString_MethodFactory) *this ).GetFeatures( signature, vecFeatures );
00118 
00119                 std::string strName = signature.GetName();
00120                 int iCount = signature.GetParameterCount();
00121                 TS vecType;
00122                 FPV vecParams;
00123 
00124                 if ( ( strName == "intValue" ) && iCount == 0 ) {
00125                         vecType.push_back( "ocl::Integer" );
00126                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TStringEx_IntValue_Compatibility(), false ) );
00127                         return;
00128                 }
00129 
00130                 if ( ( strName == "doubleValue" ) && iCount == 0 ) {
00131                         vecType.push_back( "ocl::Real" );
00132                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TStringEx_DoubleValue_Compatibility(), false ) );
00133                         return;
00134                 }
00135 
00136                 if ( ( strName == "size" ) && iCount == 0 ) {
00137                         vecType.push_back( "ocl::Integer" );
00138                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TStringEx_Size_Compatibility(), false ) );
00139                         return;
00140                 }
00141 
00142                 if ( ( strName == "match" && iCount == 1 ) ) {
00143                         vecParams.push_back( FP( "regExp", "ocl::String", true ) );
00144                         vecType.push_back( "ocl::Boolean" );
00145                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TStringEx_Match(), false ) );
00146                 }
00147         };
00148 
00149 //##############################################################################################################################################
00150 //
00151 //      T Y P E   O F   ocl::Collection
00152 //
00153 //##############################################################################################################################################
00154 
00155         METHOD( TCollectionEx_TheOnly_Compatibility )
00156         {
00157                 void operator()()
00158                 {
00159                         DECL_COLLECTION( collThis, GetThis() );
00160                         if ( collThis.size() == 0 ) {
00161                                 ThrowException( "Collection does not contain any object." );
00162                                 return;
00163                         }
00164                         if ( collThis.size() > 1 )
00165                                 ThrowException( "Collection contains more than one object." );
00166                         SetResult( collThis[ 0 ] );
00167                 }
00168         };
00169 
00170         METHOD( TCollectionEx_Size_Compatibility )
00171         {
00172                 void operator()()
00173                 {
00174                         DECL_COLLECTION( collThis, GetThis() );
00175                         SetResult( CREATE_INTEGER( GetTypeManager(), collThis.size() ) );
00176                 }
00177         };
00178 
00179         void TCollectionEx_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
00180         {
00181                 ((OclBasic::TCollection_MethodFactory) *this ).GetFeatures( signature, vecFeatures );
00182 
00183                 std::string strName = signature.GetName();
00184                 int iCount = signature.GetParameterCount();
00185                 TS vecType;
00186                 FPV vecParams;
00187 
00188                 if ( ( strName == "size" ) && iCount == 0 ) {
00189                         vecType.push_back( "ocl::Integer" );
00190                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TCollectionEx_Size_Compatibility(), false ) );
00191                         return;
00192                 }
00193 
00194                 if ( ( strName == "theOnly" ) && iCount == 0 ) {
00195                         vecType.push_back( TYPE_AGGREGATED_OBJECT );
00196                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TCollectionEx_TheOnly_Compatibility(), false ) );
00197                         return;
00198                 }
00199         };
00200 
00201 //##############################################################################################################################################
00202 //
00203 //      T Y P E   O F   gme::Project
00204 //
00205 //##############################################################################################################################################
00206 
00207         ATTRIBUTE( TProject_Name )
00208         {
00209                 void operator()()
00210                 {
00211                         DECL_GMEPROJECT( spThis, GetThis() );
00212                         if ( ! spThis.p )
00213                                 ThrowException( "Object is null." );
00214                         CString strName;
00215                         COMTHROW( spThis->get_Name( PutOut( strName ) ) );
00216                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::Convert( strName ) ) );
00217                 }
00218         };
00219 
00220         GMEMETHOD( TProject_AllInstancesOf )
00221         {
00222                 void operator()()
00223                 {
00224                         DECL_GMEPROJECT( spThis, GetThis() );
00225                         if ( ! spThis.p )
00226                                 ThrowException( "Object is null." );
00227                         std::string strKind = GetKind( 0, "gme::Object" );
00228 
00229                         OclCommonEx::ObjectVector vecObjects;
00230                         OclCommonEx::GetKindObjects( spThis, strKind, vecObjects );
00231 
00232                         OclMeta::ObjectVector setOut;
00233                         for ( unsigned int i = 0 ; i < vecObjects.size() ; i++ )
00234                                 setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), vecObjects[ i ].p ) );
00235 
00236                         SetResult( CREATE_SET( GetTypeManager(), setOut ) );
00237                 }
00238         };
00239 
00240         GMEMETHOD( TProject_RootFolder )
00241         {
00242                 void operator()()
00243                 {
00244                         DECL_GMEPROJECT( spThis, GetThis() );
00245                         if ( ! spThis.p )
00246                                 ThrowException( "Object is null." );
00247                         CComPtr<IMgaFolder> spFolder;
00248                         COMTHROW( spThis->get_RootFolder( &spFolder ) );
00249                         SetResult( CREATE_GMEOBJECT( GetTypeManager(), spFolder ) );
00250                 }
00251         };
00252 
00253         void TProject_AttributeFactory::GetFeatures( const OclSignature::Attribute& signature, OclMeta::AttributeVector& vecFeatures )
00254         {
00255                 std::string strName = signature.GetName();
00256                 TS vecType;
00257 
00258                 if ( strName == "name" ) {
00259                         vecType.push_back( "ocl::String" );
00260                         vecFeatures.push_back( new OclMeta::Attribute( strName, vecType, new TProject_Name(), false ) );
00261                         return;
00262                 }
00263         }
00264 
00265         void TProject_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
00266         {
00267                 std::string strName = signature.GetName();
00268                 int iCount = signature.GetParameterCount();
00269                 FPV vecParams;
00270                 TS vecType;
00271 
00272                 if ( strName == "allInstancesOf" && iCount == 1 ) {
00273                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
00274                         vecType.push_back( "ocl::Set" );
00275                         vecType.push_back( "gme::Object" );
00276                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TProject_AllInstancesOf(), false ) );
00277                 }
00278 
00279                 if ( strName == "rootFolder" && iCount == 0 ) {
00280                         vecType.push_back( "meta::RootFolder" );
00281                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TProject_RootFolder(), false ) );
00282                 }
00283         }
00284 
00285 //##############################################################################################################################################
00286 //
00287 //      T Y P E   O F   gme::Object
00288 //
00289 //##############################################################################################################################################
00290 
00291         ATTRIBUTE( TObject_Name )
00292         {
00293                 void operator()()
00294                 {
00295                         DECL_GMEOBJECT( spThis, GetThis() );
00296                         if ( ! spThis.p )
00297                                 ThrowException( "Object is null." );
00298                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetObjectName( spThis ) ) );
00299                 }
00300         };
00301 
00302         ATTRIBUTE( TObject_KindName )
00303         {
00304                 void operator()()
00305                 {
00306                         DECL_GMEOBJECT( spThis, GetThis() );
00307                         if ( ! spThis.p )
00308                                 ThrowException( "Object is null." );
00309                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetObjectKind( spThis ) ) );
00310                 }
00311         };
00312 
00313         ATTRIBUTE( TObject_KindDisplayedName )
00314         {
00315                 void operator()()
00316                 {
00317                         DECL_GMEOBJECT( spThis, GetThis() );
00318                         if ( ! spThis.p )
00319                                 ThrowException( "Object is null." );
00320                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetObjectDisplayedName( spThis ) ) );
00321                 }
00322         };
00323 
00324         ATTRIBUTE( TObject_StereotypeName )
00325         {
00326                 void operator()()
00327                 {
00328                         DECL_GMEOBJECT( spThis, GetThis() );
00329                         if ( ! spThis.p )
00330                                 ThrowException( "Object is null." );
00331                         objtype_enum eType = OclCommonEx::GetObjectType ( spThis );
00332                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::ObjectTypeToString( eType ) ) );
00333                 }
00334         };
00335 
00336         GMEMETHOD( TObject_Name_Compatibility )
00337         {
00338                 void operator()()
00339                 {
00340                         DECL_GMEOBJECT( spThis, GetThis() );
00341                         if ( ! spThis.p )
00342                                 ThrowException( "Object is null." );
00343                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetObjectName( spThis ) ) );
00344                 }
00345         };
00346 
00347         GMEMETHOD( TObject_KindName_Compatibility )
00348         {
00349                 void operator()()
00350                 {
00351                         DECL_GMEOBJECT( spThis, GetThis() );
00352                         if ( ! spThis.p )
00353                                 ThrowException( "Object is null." );
00354                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetObjectKind( spThis ) ) );
00355                 }
00356         };
00357 
00358         GMEMETHOD( TObject_Parent )
00359         {
00360                 void operator()()
00361                 {
00362                         DECL_GMEOBJECT( spThis, GetThis() );
00363                         if ( ! spThis.p )
00364                                 ThrowException( "Object is null." );
00365                         CComPtr<IMgaObject> spParent;
00366                         spThis->GetParent( &spParent );
00367                         SetResult( CREATE_GMEOBJECT( GetTypeManager(), spParent ) );
00368                 }
00369         };
00370 
00371         GMEMETHOD( TObject_IsNull )
00372         {
00373                 void operator()()
00374                 {
00375                         DECL_GMEOBJECT( spThis, GetThis() );
00376                         SetResult( CREATE_BOOLEAN( GetTypeManager(), ( spThis.p ) ? false : true ) );
00377                 }
00378         };
00379 
00380         GMEMETHOD( TObject_IsFCO )
00381         {
00382                 void operator()()
00383                 {
00384                         DECL_GMEOBJECT( spThis, GetThis() );
00385                         if ( ! spThis.p )
00386                                 ThrowException( "Object is null." );
00387                         SetResult( CREATE_BOOLEAN( GetTypeManager(), GetTypeManager()->IsTypeA( GetThis().GetTypeName(), "gme::FCO" ) >= 0 ) );
00388                 }
00389         };
00390 
00391         GMEMETHOD( TObject_IsFolder )
00392         {
00393                 void operator()()
00394                 {
00395                         DECL_GMEOBJECT( spThis, GetThis() );
00396                         if ( ! spThis.p )
00397                                 ThrowException( "Object is null." );
00398                         SetResult( CREATE_BOOLEAN( GetTypeManager(), GetTypeManager()->IsTypeA( GetThis().GetTypeName(), "gme::Folder" ) >= 0 ) );
00399                 }
00400         };
00401 
00402         void TObject_AttributeFactory::GetFeatures( const OclSignature::Attribute& signature, OclMeta::AttributeVector& vecFeatures )
00403         {
00404                 std::string strName = signature.GetName();
00405                 TS vecType;
00406 
00407                 if ( strName == "name" ) {
00408                         vecType.push_back( "ocl::String" );
00409                         vecFeatures.push_back( new OclMeta::Attribute( strName, vecType, new TObject_Name(), false ) );
00410                         return;
00411                 }
00412 
00413                 if ( strName == "kindName" ) {
00414                         vecType.push_back( "ocl::String" );
00415                         vecFeatures.push_back( new OclMeta::Attribute( strName, vecType, new TObject_KindName(), false ) );
00416                         return;
00417                 }
00418 
00419                 if ( strName == "kindDisplayedName" ) {
00420                         vecType.push_back( "ocl::String" );
00421                         vecFeatures.push_back( new OclMeta::Attribute( strName, vecType, new TObject_KindDisplayedName(), false ) );
00422                         return;
00423                 }
00424 
00425                 if ( strName == "metaKindName" ) {
00426                         vecType.push_back( "ocl::String" );
00427                         vecFeatures.push_back( new OclMeta::Attribute( strName, vecType, new TObject_StereotypeName(), false ) );
00428                         return;
00429                 }
00430         }
00431 
00432         void TObject_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
00433         {
00434                 std::string strName = signature.GetName();
00435                 int iCount = signature.GetParameterCount();
00436                 FPV vecParams;
00437                 TS vecType;
00438 
00439                 if ( ( strName == "name" ) && iCount == 0 ) {
00440                         vecType.push_back( "ocl::String" );
00441                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TObject_Name_Compatibility(), false ) );
00442                         return;
00443                 }
00444 
00445                 if ( ( strName == "kindName" ) && iCount == 0 ) {
00446                         vecType.push_back( "ocl::String" );
00447                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TObject_KindName_Compatibility(), false ) );
00448                         return;
00449                 }
00450 
00451                 if ( ( strName == "isNull" ) && iCount == 0 ) {
00452                         vecType.push_back( "ocl::Boolean" );
00453                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TObject_IsNull(), false ) );
00454                         return;
00455                 }
00456 
00457                 if ( ( strName == "parent" ) && iCount == 0 ) {
00458                         vecType.push_back( "gme::Object" );
00459                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TObject_Parent(), false ) );
00460                         return;
00461                 }
00462 
00463                 if ( ( strName == "isFCO" ) && iCount == 0 ) {
00464                         vecType.push_back( "ocl::Boolean" );
00465                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TObject_IsFCO(), false ) );
00466                         return;
00467                 }
00468 
00469                 if ( ( strName == "isFolder" ) && iCount == 0 ) {
00470                         vecType.push_back( "ocl::Boolean" );
00471                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TObject_IsFolder(), false ) );
00472                         return;
00473                 }
00474         }
00475 
00476 //##############################################################################################################################################
00477 //
00478 //      T Y P E   O F   gme::Folder
00479 //
00480 //##############################################################################################################################################
00481 
00482         void TFolders__Folders( OclMeta::TypeManager* pManager, CComPtr<IMgaFolder> spFolder, OclMeta::ObjectVector& setFolders, bool bRecursive )
00483         {
00484                 CComPtr<IMgaFolders> spFolders;
00485                 COMTHROW( spFolder->get_ChildFolders( &spFolders ) );
00486                 MGACOLL_ITERATE( IMgaFolder, spFolders ) {
00487                         setFolders.push_back( CREATE_GMEOBJECT( pManager, MGACOLL_ITER ) );
00488                         if ( bRecursive )
00489                                 TFolders__Folders( pManager, MGACOLL_ITER, setFolders, bRecursive );
00490                 } MGACOLL_ITERATE_END;
00491         }
00492 
00493         void TFolders__FCOs( OclMeta::TypeManager* pManager, CComPtr<IMgaFolder> spFolder, OclMeta::ObjectVector& setFCOs, bool bRecursive )
00494         {
00495                 CComPtr<IMgaFCOs> spFCOs;
00496                 COMTHROW( spFolder->get_ChildFCOs( &spFCOs ) );
00497                 MGACOLL_ITERATE( IMgaFCO, spFCOs ) {
00498                         setFCOs.push_back( CREATE_GMEOBJECT( pManager, MGACOLL_ITER ) );
00499                 } MGACOLL_ITERATE_END;
00500                 if ( bRecursive ) {
00501                         CComPtr<IMgaFolders> spFolders;
00502                         COMTHROW( spFolder->get_ChildFolders( &spFolders ) );
00503                         MGACOLL_ITERATE( IMgaFolder, spFolders ) {
00504                                 TFolders__FCOs( pManager, MGACOLL_ITER, setFCOs, bRecursive );
00505                         } MGACOLL_ITERATE_END;
00506                 }
00507         }
00508 
00509         GMEMETHOD( TFolder_Folders )
00510         {
00511                 void operator()()
00512                 {
00513                         DECL_GMEFOLDER( spThis, GetThis() );
00514                         if ( ! spThis.p )
00515                                 ThrowException( "Object is null." );
00516                         OclMeta::ObjectVector setFolders;
00517                         TFolders__Folders( GetTypeManager(), spThis, setFolders, true );
00518                         SetResult( CREATE_SET( GetTypeManager(), setFolders ) );
00519                 }
00520         };
00521 
00522         GMEMETHOD( TFolder_ChildFolders )
00523         {
00524                 void operator()()
00525                 {
00526                         DECL_GMEFOLDER( spThis, GetThis() );
00527                         if ( ! spThis.p )
00528                                 ThrowException( "Object is null." );
00529                         OclMeta::ObjectVector setFolders;
00530                         TFolders__Folders( GetTypeManager(), spThis, setFolders, false );
00531                         SetResult( CREATE_SET( GetTypeManager(), setFolders ) );
00532                 }
00533         };
00534 
00535         GMEMETHOD( TFolder_RootDescendants )
00536         {
00537                 void operator()()
00538                 {
00539                         DECL_GMEFOLDER( spThis, GetThis() );
00540                         if ( ! spThis.p )
00541                                 ThrowException( "Object is null." );
00542                         OclMeta::ObjectVector setFCOs;
00543                         TFolders__FCOs( GetTypeManager(), spThis, setFCOs, true );
00544                         SetResult( CREATE_SET( GetTypeManager(), setFCOs ) );
00545                 }
00546         };
00547 
00548         GMEMETHOD( TFolder_RootChildren )
00549         {
00550                 void operator()()
00551                 {
00552                         DECL_GMEFOLDER( spThis, GetThis() );
00553                         if ( ! spThis.p )
00554                                 ThrowException( "Object is null." );
00555                         OclMeta::ObjectVector setFCOs;
00556                         TFolders__FCOs( GetTypeManager(), spThis, setFCOs, false );
00557                         SetResult( CREATE_SET( GetTypeManager(), setFCOs ) );
00558                 }
00559         };
00560 
00561         GMEMETHOD( TFolder_Models_Atoms )
00562         {
00563                 private :
00564                         std::string m_strObjType;
00565 
00566                 public :
00567                         TFolder_Models_Atoms( const std::string& strObjType )
00568                                 : m_strObjType( strObjType )
00569                         {
00570                         }
00571 
00572                         void operator()()
00573                         {
00574                                 DECL_GMEFOLDER( spThis, GetThis() );
00575                                 if ( ! spThis.p )
00576                                         ThrowException( "Object is null." );
00577                                 std::string strKind = GetKind( 0, ( m_strObjType == "OBJTYPE_MODEL" ) ? "gme::Model" : "gme::Atom" );
00578 
00579                                 CComPtr<IMgaProject> spProject;
00580                                 COMTHROW( spThis->get_Project( &spProject ) );
00581                                 CComPtr<IMgaFilter> spFilter;
00582                                 COMTHROW( spProject->CreateFilter( &spFilter ) );
00583                                 if ( ! strKind.empty() )
00584                                         COMTHROW( spFilter->put_Kind( CComBSTR( OclCommonEx::Convert( strKind ) ) ) );
00585                                 COMTHROW( spFilter->put_ObjType( CComBSTR( OclCommonEx::Convert( m_strObjType ) ) ) );
00586                                 COMTHROW( spFilter->put_Level( CComBSTR( "1-" ) ) );
00587 
00588                                 OclMeta::ObjectVector setOut;
00589                                 CComPtr<IMgaFCOs> spFCOs;
00590                                 COMTHROW( spThis->GetDescendantFCOs( spFilter, &spFCOs ) );
00591                                 MGACOLL_ITERATE( IMgaFCO, spFCOs ) {
00592                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
00593                                 } MGACOLL_ITERATE_END;
00594 
00595                                 SetResult( CREATE_SET( GetTypeManager(), setOut ) );
00596                         }
00597         };
00598 
00599         void TFolder_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
00600         {
00601                 std::string strName = signature.GetName();
00602                 int iCount = signature.GetParameterCount();
00603 
00604                 if ( ( strName == "folders" ) && iCount == 0 ) {
00605                         FPV vecParams; TS vecType;
00606                         vecType.push_back( "ocl::Set" );
00607                         vecType.push_back( "gme::Folder" );
00608                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_Folders(), false ) );
00609                 }
00610 
00611                 if ( ( strName == "childFolders" ) && iCount == 0 ) {
00612                         FPV vecParams; TS vecType;
00613                         vecType.push_back( "ocl::Set" );
00614                         vecType.push_back( "gme::Folder" );
00615                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_ChildFolders(), false ) );
00616                 }
00617 
00618                 if ( ( strName == "rootDescendants" ) && iCount == 0 ) {
00619                         FPV vecParams; TS vecType;
00620                         vecType.push_back( "ocl::Set" );
00621                         vecType.push_back( "gme::FCO" );
00622                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_RootDescendants(), false ) );
00623                 }
00624 
00625                 if ( ( strName == "allDescendants" ) && iCount == 0 ) {
00626                         FPV vecParams; TS vecType;
00627                         vecType.push_back( "ocl::Set" );
00628                         vecType.push_back( "gme::FCO" );
00629                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_RootDescendants(), false ) );
00630                 }
00631 
00632                 if ( ( strName == "rootChildren" ) && iCount == 0 ) {
00633                         FPV vecParams; TS vecType;
00634                         vecType.push_back( "ocl::Set" );
00635                         vecType.push_back( "gme::FCO" );
00636                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_RootChildren(), false ) );
00637                 }
00638 
00639                 if ( ( strName == "models" ) && iCount == 1 ) {
00640                         FPV vecParams; TS vecType;
00641                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
00642                         vecType.push_back( "ocl::Set" );
00643                         vecType.push_back( "gme::Model" );
00644                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_Models_Atoms( "OBJTYPE_MODEL" ), false ) );
00645                 }
00646 
00647                 if ( ( strName == "models" ) && iCount <= 1 ) {
00648                         FPV vecParams; TS vecType;
00649                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
00650                         vecType.push_back( "ocl::Set" );
00651                         vecType.push_back( "gme::Model" );
00652                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_Models_Atoms( "OBJTYPE_MODEL" ), false ) );
00653                 }
00654 
00655                 if ( ( strName == "atoms" ) && iCount == 1 ) {
00656                         FPV vecParams; TS vecType;
00657                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
00658                         vecType.push_back( "ocl::Set" );
00659                         vecType.push_back( "gme::Atom" );
00660                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_Models_Atoms( "OBJTYPE_ATOM" ), false ) );
00661                 }
00662 
00663                 if ( ( strName == "atoms" ) && iCount <= 1 ) {
00664                         FPV vecParams; TS vecType;
00665                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
00666                         vecType.push_back( "ocl::Set" );
00667                         vecType.push_back( "gme::Atom" );
00668                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFolder_Models_Atoms( "OBJTYPE_ATOM" ), false ) );
00669                 }
00670         }
00671 
00672 //##############################################################################################################################################
00673 //
00674 //      T Y P E   O F   gme::FCO
00675 //
00676 //##############################################################################################################################################
00677 
00678         ATTRIBUTE( TFCO_RoleName )
00679         {
00680                 void operator()()
00681                 {
00682                         DECL_GMEFCO( spThis, GetThis() );
00683                         if ( ! spThis.p )
00684                                 ThrowException( "Object is null." );
00685                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetFCORole( spThis ) ) );
00686                 }
00687         };
00688 
00689         GMEMETHOD( TFCO_RoleName_Compatibility )
00690         {
00691                 void operator()()
00692                 {
00693                         DECL_GMEFCO( spThis, GetThis() );
00694                         if ( ! spThis.p )
00695                                 ThrowException( "Object is null." );
00696                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetFCORole( spThis ) ) );
00697                 }
00698         };
00699 
00700         GMEMETHOD( TFCO_ConnectedFCOs )
00701         {
00702                 private :
00703                         int m_iKindPos;
00704 
00705                 public :
00706                         TFCO_ConnectedFCOs( int iKindPos = -1 )
00707                                 : m_iKindPos( iKindPos )
00708                         {
00709                         }
00710 
00711                         void operator()()
00712                         {
00713                                 DECL_GMEFCO( spThis, GetThis() );
00714                                 if ( ! spThis.p )
00715                                         ThrowException( "Object is null." );
00716                                 std::string strRole;
00717                                 if ( m_iKindPos != 0 && GetArgumentCount() > 0 ) {
00718                                         DECL_STRING2( strRole, GetArgument( 0 ) );
00719                                         if ( strRole.empty() )
00720                                                 ThrowException( "Role cannot be empty. Use gme::FCO::connectedFCOs( ocl::Type ) instead." );
00721                                 }
00722                                 std::string strKind = GetKind( m_iKindPos, "gme::Connection" );
00723 
00724                                 OclMeta::ObjectVector setOut;
00725                                 CComPtr<IMgaConnPoints> spStartCPs;
00726                                 COMTHROW( spThis->get_PartOfConns( &spStartCPs ) );
00727                                 MGACOLL_ITERATE( IMgaConnPoint , spStartCPs ) {
00728                                         CComPtr<IMgaConnPoint> spStartCP = MGACOLL_ITER;
00729                                         CComPtr<IMgaConnection> spConnection;
00730                                         COMTHROW( spStartCP->get_Owner( &spConnection ) );
00731                                         if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( spConnection.p ) ) {
00732                                                 CComPtr<IMgaConnPoints> spEndCPs;
00733                                                 COMTHROW( spConnection->get_ConnPoints( &spEndCPs ) );
00734                                                 MGACOLL_ITERATE( IMgaConnPoint, spEndCPs ) {
00735                                                         CComPtr<IMgaConnPoint> spEndCP = MGACOLL_ITER;
00736                                                         if ( spStartCP != spEndCP && ( strRole.empty() || strRole == OclCommonEx::GetConnPointRole( spEndCP ) ) ) {
00737                                                                 CComPtr<IMgaFCO> spDestination;
00738                                                                 COMTHROW( spEndCP->get_Target( &spDestination ) );
00739                                                                 setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), spDestination ) );
00740                                                         }
00741                                                 } MGACOLL_ITERATE_END;
00742                                         }
00743                                 } MGACOLL_ITERATE_END;
00744 
00745                                 SetResult( CREATE_SET( GetTypeManager(), setOut ) );
00746                         }
00747         };
00748 
00749         GMEMETHOD( TFCO_BagConnectedFCOs )
00750         {
00751                 private :
00752                         int m_iKindPos;
00753 
00754                 public :
00755                         TFCO_BagConnectedFCOs( int iKindPos = -1 )
00756                                 : m_iKindPos( iKindPos )
00757                         {
00758                         }
00759 
00760                         void operator()()
00761                         {
00762                                 DECL_GMEFCO( spThis, GetThis() );
00763                                 if ( ! spThis.p )
00764                                         ThrowException( "Object is null." );
00765                                 std::string strRole;
00766                                 if ( m_iKindPos != 0 && GetArgumentCount() > 0 ) {
00767                                         DECL_STRING2( strRole, GetArgument( 0 ) );
00768                                         if ( strRole.empty() )
00769                                                 ThrowException( "Role cannot be empty. Use gme::FCO::bagConnectedFCOs( ocl::Type ) instead." );
00770                                 }
00771                                 std::string strKind = GetKind( m_iKindPos, "gme::Connection" );
00772 
00773                                 OclMeta::ObjectVector setOut;
00774                                 CComPtr<IMgaConnPoints> spStartCPs;
00775                                 COMTHROW( spThis->get_PartOfConns( &spStartCPs ) );
00776                                 MGACOLL_ITERATE( IMgaConnPoint , spStartCPs ) {
00777                                         CComPtr<IMgaConnPoint> spStartCP = MGACOLL_ITER;
00778                                         CComPtr<IMgaConnection> spConnection;
00779                                         COMTHROW( spStartCP->get_Owner( &spConnection ) );
00780                                         if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( spConnection.p ) ) {
00781                                                 CComPtr<IMgaConnPoints> spEndCPs;
00782                                                 COMTHROW( spConnection->get_ConnPoints( &spEndCPs ) );
00783                                                 MGACOLL_ITERATE( IMgaConnPoint, spEndCPs ) {
00784                                                         CComPtr<IMgaConnPoint> spEndCP = MGACOLL_ITER;
00785                                                         if ( spStartCP != spEndCP && ( strRole.empty() || strRole == OclCommonEx::GetConnPointRole( spEndCP ) ) ) {
00786                                                                 CComPtr<IMgaFCO> spDestination;
00787                                                                 COMTHROW( spEndCP->get_Target( &spDestination ) );
00788                                                                 setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), spDestination ) );
00789                                                         }
00790                                                 } MGACOLL_ITERATE_END;
00791                                         }
00792                                 } MGACOLL_ITERATE_END;
00793 
00794                                 SetResult( CREATE_BAG( GetTypeManager(), setOut ) );
00795                         }
00796         };
00797 
00798         // TFCO_Connected is obsolete and equivalent to TFCO_ConnectedFCOs
00799 
00800         GMEMETHOD( TFCO_ReverseConnectedFCOs )
00801         {
00802                 private :
00803                         int m_iKindPos;
00804 
00805                 public :
00806                         TFCO_ReverseConnectedFCOs( int iKindPos = -1 )
00807                                 : m_iKindPos( iKindPos )
00808                         {
00809                         }
00810 
00811                         void operator()()
00812                         {
00813                                 DECL_GMEFCO( spThis, GetThis() );
00814                                 if ( ! spThis.p )
00815                                         ThrowException( "Object is null." );
00816                                 std::string strRole;
00817                                 if ( m_iKindPos != 0 && GetArgumentCount() > 0 ) {
00818                                         DECL_STRING2( strRole, GetArgument( 0 ) );
00819                                         if ( strRole.empty() )
00820                                                 ThrowException( "Role cannot be empty. Use gme::FCO::reverseConnectedFCOs( ocl::Type ) instead." );
00821                                 }
00822                                 std::string strKind = GetKind( m_iKindPos, "gme::Connection" );
00823 
00824                                 OclCommonEx::FCOVector vecFCOs;
00825                                 OclCommonEx::GetAssociationEnds( spThis, strRole, strKind, vecFCOs );
00826                                 OclMeta::ObjectVector setOut;
00827                                 for ( unsigned int i = 0 ; i < vecFCOs.size() ; i++ )
00828                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), CComPtr<IMgaFCO>( vecFCOs[ i ].p ) ) );
00829                                 SetResult( CREATE_SET( GetTypeManager(), setOut ) );
00830                         }
00831         };
00832 
00833         GMEMETHOD( TFCO_BagReverseConnectedFCOs )
00834         {
00835                 private :
00836                         int m_iKindPos;
00837 
00838                 public :
00839                         TFCO_BagReverseConnectedFCOs( int iKindPos = -1 )
00840                                 : m_iKindPos( iKindPos )
00841                         {
00842                         }
00843 
00844                         void operator()()
00845                         {
00846                                 DECL_GMEFCO( spThis, GetThis() );
00847                                 if ( ! spThis.p )
00848                                         ThrowException( "Object is null." );
00849                                 std::string strRole;
00850                                 if ( m_iKindPos != 0 && GetArgumentCount() > 0 ) {
00851                                         DECL_STRING2( strRole, GetArgument( 0 ) );
00852                                         if ( strRole.empty() )
00853                                                 ThrowException( "Role cannot be empty. Use gme::FCO::bagReverseConnectedFCOs( ocl::Type ) instead." );
00854                                 }
00855                                 std::string strKind = GetKind( m_iKindPos, "gme::Connection" );
00856 
00857                                 OclMeta::ObjectVector setOut;
00858                                 CComPtr<IMgaConnPoints> spStartCPs;
00859                                 COMTHROW( spThis->get_PartOfConns( &spStartCPs ) );
00860                                 MGACOLL_ITERATE( IMgaConnPoint , spStartCPs ) {
00861                                         CComPtr<IMgaConnPoint> spStartCP = MGACOLL_ITER;
00862                                         if ( strRole.empty() || strRole == OclCommonEx::GetConnPointRole( spStartCP ) ) {
00863                                                 CComPtr<IMgaConnection> spConnection;
00864                                                 COMTHROW( spStartCP->get_Owner( &spConnection ) );
00865                                                 if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( spConnection.p ) ) {
00866                                                         CComPtr<IMgaConnPoints> spEndCPs;
00867                                                         COMTHROW( spConnection->get_ConnPoints( &spEndCPs ) );
00868                                                         MGACOLL_ITERATE( IMgaConnPoint, spEndCPs ) {
00869                                                                 CComPtr<IMgaConnPoint> spEndCP = MGACOLL_ITER;
00870                                                                 if ( spStartCP != spEndCP ) {
00871                                                                         CComPtr<IMgaFCO> spDestination;
00872                                                                         COMTHROW( spEndCP->get_Target( &spDestination ) );
00873                                                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), spDestination ) );
00874                                                                 }
00875                                                         } MGACOLL_ITERATE_END;
00876                                                 }
00877                                         }
00878                                 } MGACOLL_ITERATE_END;
00879 
00880                                 SetResult( CREATE_BAG( GetTypeManager(), setOut ) );
00881                         }
00882         };
00883 
00884         // TFCO_ConnectedAs is obsolete and equivalent to TFCO_ReverseConnectedFCOs
00885 
00886         GMEMETHOD( TFCO_IsConnectedTo )
00887         {
00888                 private :
00889                         int m_iKindPos;
00890 
00891                 public :
00892                         TFCO_IsConnectedTo( int iKindPos = -1 )
00893                                 : m_iKindPos( iKindPos )
00894                         {
00895                         }
00896 
00897                         void operator()()
00898                         {
00899                                 DECL_GMEFCO( spThis, GetThis() );
00900                                 if ( ! spThis.p )
00901                                         ThrowException( "Object is null." );
00902                                 DECL_GMEFCO( spPeer, GetArgument( 0 ) );
00903                                 if ( ! spPeer.p )
00904                                         ThrowException( "Argument is null." );
00905                                 std::string strRole;
00906                                 if ( m_iKindPos != 1 && GetArgumentCount() > 1 ) {
00907                                         DECL_STRING2( strRole, GetArgument( 1 ) );
00908                                         if ( strRole.empty() )
00909                                                 ThrowException( "Role cannot be empty. Use gme::FCO::isConnectedTo( gme::FCO, ocl::Type ) instead." );
00910                                 }
00911                                 std::string strKind = GetKind( m_iKindPos, "gme::Connection" );
00912 
00913                                 CComPtr<IMgaConnPoints> spStartCPs;
00914                                 COMTHROW( spThis->get_PartOfConns( &spStartCPs ) );
00915                                 MGACOLL_ITERATE( IMgaConnPoint , spStartCPs ) {
00916                                         CComPtr<IMgaConnPoint> spStartCP = MGACOLL_ITER;
00917                                         CComPtr<IMgaConnection> spConnection;
00918                                         COMTHROW( spStartCP->get_Owner( &spConnection ) );
00919                                         if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( spConnection.p ) ) {
00920                                                 CComPtr<IMgaConnPoints> spEndCPs;
00921                                                 COMTHROW( spConnection->get_ConnPoints( &spEndCPs ) );
00922                                                 MGACOLL_ITERATE( IMgaConnPoint, spEndCPs ) {
00923                                                         CComPtr<IMgaConnPoint> spEndCP = MGACOLL_ITER;
00924                                                         if ( spStartCP != spEndCP && ( strRole.empty() || strRole == OclCommonEx::GetConnPointRole( spEndCP ) ) ) {
00925                                                                 CComPtr<IMgaFCO> spDestination;
00926                                                                 COMTHROW( spEndCP->get_Target( &spDestination ) );
00927                                                                 if ( spDestination == spPeer ) {
00928                                                                         SetResult( CREATE_BOOLEAN( GetTypeManager(), true ) );
00929                                                                         return;
00930                                                                 }
00931                                                         }
00932                                                 } MGACOLL_ITERATE_END;
00933                                         }
00934                                 } MGACOLL_ITERATE_END;
00935                                 SetResult( CREATE_BOOLEAN( GetTypeManager(), false ) );
00936                         }
00937         };
00938 
00939         GMEMETHOD( TFCO_AttachingConnPoints )
00940         {
00941                 private :
00942                         int m_iKindPos;
00943 
00944                 public :
00945                         TFCO_AttachingConnPoints( int iKindPos = -1 )
00946                                 : m_iKindPos( iKindPos )
00947                         {
00948                         }
00949 
00950                         void operator()()
00951                         {
00952                                 DECL_GMEFCO( spThis, GetThis() );
00953                                 if ( ! spThis.p )
00954                                         ThrowException( "Object is null." );
00955                                 std::string strRole;
00956                                 if ( m_iKindPos != 0 && GetArgumentCount() > 0 ) {
00957                                         DECL_STRING2( strRole, GetArgument( 0 ) );
00958                                         if ( strRole.empty() )
00959                                                 ThrowException( "Role cannot be empty. Use gme::FCO::attachingConnPoints( ocl::Type ) instead." );
00960                                 }
00961                                 std::string strKind = GetKind( m_iKindPos, "gme::Connection" );
00962 
00963                                 OclMeta::ObjectVector setOut;
00964                                 CComPtr<IMgaConnPoints> spStartCPs;
00965                                 COMTHROW( spThis->get_PartOfConns( &spStartCPs ) );
00966                                 MGACOLL_ITERATE( IMgaConnPoint, spStartCPs ) {
00967                                         CComPtr<IMgaConnPoint> spStartCP = MGACOLL_ITER;
00968                                         if ( strRole.empty() || strRole == OclCommonEx::GetConnPointRole( spStartCP ) ) {
00969                                                 CComPtr<IMgaConnection> spConnection;
00970                                                 COMTHROW( spStartCP->get_Owner( &spConnection ) );
00971                                                 if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( spConnection.p ) ) {
00972                                                         setOut.push_back( CREATE_GMECONNECTIONPOINT( GetTypeManager(), spStartCP ) );
00973                                                 }
00974                                         }
00975                                 } MGACOLL_ITERATE_END;
00976 
00977                                 SetResult( CREATE_SET( GetTypeManager(), setOut ) );
00978                         }
00979         };
00980 
00981         GMEMETHOD( TFCO_AttachingConnections )
00982         {
00983                 private :
00984                         int m_iKindPos;
00985 
00986                 public :
00987                         TFCO_AttachingConnections( int iKindPos = -1 )
00988                                 : m_iKindPos( iKindPos )
00989                         {
00990                         }
00991 
00992                         void operator()()
00993                         {
00994                                 DECL_GMEFCO( spThis, GetThis() );
00995                                 if ( ! spThis.p )
00996                                         ThrowException( "Object is null." );
00997                                 std::string strRole;
00998                                 if ( m_iKindPos != 0 && GetArgumentCount() > 0 ) {
00999                                         DECL_STRING2( strRole, GetArgument( 0 ) );
01000                                         if ( strRole.empty() )
01001                                                 ThrowException( "Role cannot be empty. Use gme::FCO::attachingConnections( ocl::Type ) instead." );
01002                                 }
01003                                 std::string strKind = GetKind( m_iKindPos, "gme::Connection" );
01004 
01005                                 OclMeta::ObjectVector setOut;
01006                                 CComPtr<IMgaConnPoints> spStartCPs;
01007                                 COMTHROW( spThis->get_PartOfConns( &spStartCPs ) );
01008                                 MGACOLL_ITERATE( IMgaConnPoint, spStartCPs ) {
01009                                         CComPtr<IMgaConnPoint> spStartCP = MGACOLL_ITER;
01010                                         if ( strRole.empty() || strRole == OclCommonEx::GetConnPointRole( spStartCP ) ) {
01011                                                 CComPtr<IMgaConnection> spConnection;
01012                                                 COMTHROW( spStartCP->get_Owner( &spConnection ) );
01013                                                 if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( spConnection.p ) ) {
01014                                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), spConnection ) );
01015                                                 }
01016                                         }
01017                                 } MGACOLL_ITERATE_END;
01018 
01019                                 SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01020                         }
01021         };
01022 
01023         GMEMETHOD( TFCO_ReferencedBy )
01024         {
01025                 void operator()()
01026                 {
01027                         DECL_GMEFCO( spThis, GetThis() );
01028                         if ( ! spThis.p )
01029                                 ThrowException( "Object is null." );
01030                         std::string strKind = GetKind( 0, "gme::Reference" );
01031 
01032                         OclMeta::ObjectVector setOut;
01033                         CComPtr<IMgaFCOs> spRefs;
01034                         COMTHROW( spThis->get_ReferencedBy( &spRefs ) );
01035                         MGACOLL_ITERATE( IMgaFCO, spRefs ) {
01036                                 if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( MGACOLL_ITER.p ) ) {
01037                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
01038                                 }
01039                         } MGACOLL_ITERATE_END;
01040 
01041                         SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01042                 }
01043         };
01044 
01045         GMEMETHOD( TFCO_MemberOfSets )
01046         {
01047                 void operator()()
01048                 {
01049                         DECL_GMEFCO( spThis, GetThis() );
01050                         if ( ! spThis.p )
01051                                 ThrowException( "Object is null." );
01052                         std::string strKind = GetKind( 0, "gme::Set" );
01053 
01054                         OclMeta::ObjectVector setOut;
01055                         CComPtr<IMgaFCOs> spSets;
01056                         COMTHROW( spThis->get_MemberOfSets( &spSets ) );
01057                         MGACOLL_ITERATE( IMgaFCO, spSets ) {
01058                                 if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( MGACOLL_ITER.p ) ) {
01059                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
01060                                 }
01061                         } MGACOLL_ITERATE_END;
01062 
01063                         SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01064                 }
01065         };
01066 
01067         GMEMETHOD( TFCO_SubTypes )
01068         {
01069                 void operator()()
01070                 {
01071                         DECL_GMEFCO( spThis, GetThis() );
01072                         if ( ! spThis.p )
01073                                 ThrowException( "Object is null." );
01074 
01075                         OclMeta::ObjectVector setOut;
01076                         CComPtr<IMgaFCOs> spFCOs;
01077                         COMTHROW( spThis->get_DerivedObjects( &spFCOs ) );
01078                         MGACOLL_ITERATE( IMgaFCO, spFCOs ) {
01079                                 VARIANT_BOOL bInstance;
01080                                 COMTHROW( MGACOLL_ITER->get_IsInstance( &bInstance ) );
01081                                 if( ! bInstance ) {
01082                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
01083                                 }
01084                         } MGACOLL_ITERATE_END;
01085 
01086                         SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01087                 }
01088         };
01089 
01090         GMEMETHOD( TFCO_Instances )
01091         {
01092                 void operator()()
01093                 {
01094                         DECL_GMEFCO( spThis, GetThis() );
01095                         if ( ! spThis.p )
01096                                 ThrowException( "Object is null." );
01097 
01098                         OclMeta::ObjectVector setOut;
01099                         CComPtr<IMgaFCOs> spFCOs;
01100                         COMTHROW( spThis->get_DerivedObjects( &spFCOs ) );
01101                         MGACOLL_ITERATE( IMgaFCO, spFCOs ) {
01102                                 VARIANT_BOOL bInstance;
01103                                 COMTHROW( MGACOLL_ITER->get_IsInstance( &bInstance ) );
01104                                 if( bInstance )
01105                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
01106                         } MGACOLL_ITERATE_END;
01107 
01108                         SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01109                 }
01110         };
01111 
01112         GMEMETHOD( TFCO_Type )
01113         {
01114                 void operator()()
01115                 {
01116                         DECL_GMEFCO( spThis, GetThis() );
01117                         if ( ! spThis.p )
01118                                 ThrowException( "Object is null." );
01119 
01120                         CComPtr<IMgaFCO> spType;
01121                         COMTHROW( spThis->get_DerivedFrom( &spType ) );
01122                         SetResult( CREATE_GMEOBJECT( GetTypeManager(), spType ) );
01123                 }
01124         };
01125 
01126         GMEMETHOD( TFCO_BaseType )
01127         {
01128                 void operator()()
01129                 {
01130                         DECL_GMEFCO( spThis, GetThis() );
01131                         if ( ! spThis.p )
01132                                 ThrowException( "Object is null." );
01133 
01134                         CComPtr<IMgaFCO> spType;
01135                         COMTHROW( spThis->get_BaseType( &spType ) );
01136                         SetResult( CREATE_GMEOBJECT( GetTypeManager(), spType ) );
01137                 }
01138         };
01139 
01140         GMEMETHOD( TFCO_IsInstance )
01141         {
01142                 void operator()()
01143                 {
01144                         DECL_GMEFCO( spThis, GetThis() );
01145                         if ( ! spThis.p )
01146                                 ThrowException( "Object is null." );
01147 
01148                         VARIANT_BOOL bInstance;
01149                         COMTHROW( spThis->get_IsInstance( &bInstance ) );
01150                         SetResult( CREATE_BOOLEAN( GetTypeManager(), ( bInstance ) ? true : false ) );
01151                 }
01152         };
01153 
01154         GMEMETHOD( TFCO_IsType )
01155         {
01156                 void operator()()
01157                 {
01158                         DECL_GMEFCO( spThis, GetThis() );
01159                         if ( ! spThis.p )
01160                                 ThrowException( "Object is null." );
01161 
01162                         VARIANT_BOOL bInstance;
01163                         COMTHROW( spThis->get_IsInstance( &bInstance ) );
01164                         SetResult( CREATE_BOOLEAN( GetTypeManager(), ( bInstance ) ? false : true ) );
01165                 }
01166         };
01167 
01168         GMEMETHOD( TFCO_Folder )
01169         {
01170                 void operator()()
01171                 {
01172                         DECL_GMEFCO( spThis, GetThis() );
01173                         if ( ! spThis.p )
01174                                 ThrowException( "Object is null." );
01175 
01176                         CComPtr<IMgaFCO> spRootFCO;
01177                         COMTHROW( spThis->get_RootFCO( &spRootFCO ) );
01178                         CComPtr<IMgaObject> spFolder;
01179                         COMTHROW( spRootFCO->GetParent( &spFolder ) );
01180                         SetResult( CREATE_GMEOBJECT( GetTypeManager(), spFolder ) );
01181                 }
01182         };
01183 
01184         GMEMETHOD( TFCO_Attribute )
01185         {
01186                 void operator()()
01187                 {
01188                         DECL_GMEFCO( spThis, GetThis() );
01189                         if ( ! spThis.p )
01190                                 ThrowException( "Object is null." );
01191                         DECL_STRING( strName, GetArgument( 0 ) );
01192 
01193                         CComVariant objValue;
01194                         if ( ! SUCCEEDED( spThis->get_AttributeByName( CComBSTR( OclCommonEx::Convert( strName ) ), PutOut( objValue ) ) ) )
01195                                 ThrowException( "Attribute [ " + strName + " ] does not exist." );
01196                         switch( objValue.vt ) {
01197                                 case VT_R8 :
01198                                         SetResult( CREATE_REAL( GetTypeManager(), objValue.dblVal ) ); // double
01199                                         break;
01200                                 case VT_I4 :
01201                                         SetResult( CREATE_INTEGER( GetTypeManager(), objValue.lVal ) ); // long
01202                                         break;
01203                                 case VT_BOOL:
01204                                         SetResult( CREATE_BOOLEAN( GetTypeManager(), ( objValue.boolVal ) ? true : false ) ); // boolean
01205                                         break;
01206                                 case VT_BSTR : {
01207                                         CComPtr<IMgaMetaAttribute> spAttribute;
01208                                         CComPtr<IMgaMetaFCO> spMeta;
01209                                         COMTHROW( spThis->get_Meta( &spMeta ) );
01210                                         COMTHROW( spMeta->get_AttributeByName( CComBSTR( OclCommonEx::Convert( strName ) ), &spAttribute ) );
01211                                         attval_enum eType;
01212                                         COMTHROW( spAttribute->get_ValueType( &eType ) );
01213                                         if ( eType == ATTVAL_STRING )
01214                                                 SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::Convert( CString( objValue.bstrVal ) ) ) ); // string
01215                                         else
01216                                                 SetResult( CREATE_ENUMERATION( GetTypeManager(), OclCommonEx::Convert( CString( objValue.bstrVal ) ) ) ); // enum
01217                                         break;
01218                                 }
01219                                 default:
01220                                         SetResult( OclMeta::Object::UNDEFINED );
01221                         }
01222                 }
01223         };
01224 
01225 //---
01226 GMEMETHOD( TFCO_AttrByDefault )
01227         {
01228                 void operator()()
01229                 {
01230                         DECL_GMEFCO( spThis, GetThis() );
01231                         if ( ! spThis.p )
01232                                 ThrowException( "Object is null." );
01233                         DECL_STRING( strName, GetArgument( 0 ) );
01234 
01235                         // Iterating through the FirstFCO's attributes
01236                         CComPtr<IMgaMetaFCO> metafco;
01237                         if ( ! SUCCEEDED( spThis->get_Meta(&metafco)))
01238                                 ThrowException( "There is no IMgaMetaFCO interface." );
01239                         CComPtr<IMgaMetaAttribute> metaattrib;
01240                         if ( ! SUCCEEDED( metafco->get_AttributeByName(CComBSTR( OclCommonEx::Convert( strName ) ), &metaattrib)))
01241                                 ThrowException( "Attribute [ " + strName + " ] does not exist." );
01242                         CComPtr<IMgaAttribute> attrib;
01243                         if ( ! SUCCEEDED( spThis->get_Attribute(metaattrib, &attrib)))
01244                                 ThrowException( "There is no IMgaAttribute interface of attribute [ " + strName + " ]." );
01245                         long status;
01246                         if ( ! SUCCEEDED( attrib->get_Status(&status)))
01247                                 ThrowException( "status cannot be read of attribute [ " + strName + " ]." );
01248 
01249                         // Check whether it is a default value (if it is defined in the meta it's default)
01250                         bool isDefault = (status < 0);
01251                         SetResult( CREATE_BOOLEAN( GetTypeManager(), isDefault) ); // boolean
01252                 }
01253         };
01254 
01255 //---
01256 
01257         void TFCO_AttributeFactory::GetFeatures( const OclSignature::Attribute& signature, OclMeta::AttributeVector& vecFeatures )
01258         {
01259                 std::string strName = signature.GetName();
01260                 TS vecType;
01261 
01262                 if ( strName == "roleName" ) {
01263                         vecType.push_back( "ocl::String" );
01264                         vecFeatures.push_back( new OclMeta::Attribute( strName, vecType, new TFCO_RoleName(), false ) );
01265                         return;
01266                 }
01267         }
01268 
01269         void TFCO_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
01270         {
01271                 std::string strName = signature.GetName();
01272                 int iCount = signature.GetParameterCount();
01273 
01274                 if ( ( strName == "roleName" ) && iCount == 0 ) {
01275                         FPV vecParams; TS vecType;
01276                         vecType.push_back( "ocl::String" );
01277                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_RoleName_Compatibility(), false ) );
01278                 }
01279 
01280                 if ( ( strName == "subTypes" ) && iCount == 0 ) {
01281                         FPV vecParams; TS vecType;
01282                         vecType.push_back( "ocl::Set" );
01283                         vecType.push_back( "gme::FCO" );
01284                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_SubTypes(), false ) );
01285                 }
01286 
01287                 if ( ( strName == "instances" ) && iCount == 0 ) {
01288                         FPV vecParams; TS vecType;
01289                         vecType.push_back( "ocl::Set" );
01290                         vecType.push_back( "gme::FCO" );
01291                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_Instances(), false ) );
01292                 }
01293 
01294                 if ( ( strName == "type" ) && iCount == 0 ) {
01295                         FPV vecParams; TS vecType;
01296                         vecType.push_back( "gme::FCO" );
01297                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_Type(), false ) );
01298                 }
01299 
01300                 if ( ( strName == "baseType" ) && iCount == 0 ) {
01301                         FPV vecParams; TS vecType;
01302                         vecType.push_back( "gme::FCO" );
01303                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_BaseType(), false ) );
01304                 }
01305 
01306                 if ( ( strName == "isInstance" ) && iCount == 0 ) {
01307                         FPV vecParams; TS vecType;
01308                         vecType.push_back( "ocl::Boolean" );
01309                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_IsInstance(), false ) );
01310                 }
01311 
01312                 if ( ( strName == "isType" ) && iCount == 0 ) {
01313                         FPV vecParams; TS vecType;
01314                         vecType.push_back( "ocl::Boolean" );
01315                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_IsType(), false ) );
01316                 }
01317 
01318                 if ( ( strName == "folder" ) && iCount == 0 ) {
01319                         FPV vecParams; TS vecType;
01320                         vecType.push_back( "gme::Folder" );
01321                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_Folder(), false ) );
01322                 }
01323 
01324                 if ( ( strName == "referencedBy" ) && iCount == 1 ) {
01325                         FPV vecParams; TS vecType;
01326                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01327                         vecType.push_back( "ocl::Set" );
01328                         vecType.push_back( "gme::Reference" );
01329                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ReferencedBy(), false ) );
01330                 }
01331 
01332                 if ( ( strName == "referencedBy" ) && iCount <= 1 ) {
01333                         FPV vecParams; TS vecType;
01334                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01335                         vecType.push_back( "ocl::Set" );
01336                         vecType.push_back( "gme::Reference" );
01337                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ReferencedBy(), false ) );
01338                 }
01339 
01340                 if ( ( strName == "memberOfSets" ) && iCount == 1 ) {
01341                         FPV vecParams; TS vecType;
01342                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01343                         vecType.push_back( "ocl::Set" );
01344                         vecType.push_back( "gme::Set" );
01345                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_MemberOfSets(), false ) );
01346                 }
01347 
01348                 if ( ( strName == "memberOfSets" ) && iCount <= 1 ) {
01349                         FPV vecParams; TS vecType;
01350                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01351                         vecType.push_back( "ocl::Set" );
01352                         vecType.push_back( "gme::Set" );
01353                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_MemberOfSets(), false ) );
01354                 }
01355 
01356                 if ( ( strName == "connectedFCOs" ) && iCount == 2 ) {
01357                         FPV vecParams; TS vecType;
01358                         vecParams.push_back( FP( "role", "ocl::String", true ) );
01359                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01360                         vecType.push_back( "ocl::Set" );
01361                         vecType.push_back( "gme::FCO" );
01362                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ConnectedFCOs( 1 ), false ) );
01363                 }
01364 
01365                 if ( ( strName == "connectedFCOs" ) && iCount <= 2 ) {
01366                         FPV vecParams; TS vecType;
01367                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01368                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01369                         vecType.push_back( "ocl::Set" );
01370                         vecType.push_back( "gme::FCO" );
01371                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ConnectedFCOs( 1 ), false ) );
01372                 }
01373 
01374                 if ( ( strName == "connectedFCOs" ) && iCount == 1 ) {
01375                         FPV vecParams; TS vecType;
01376                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01377                         vecType.push_back( "ocl::Set" );
01378                         vecType.push_back( "gme::FCO" );
01379                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ConnectedFCOs( 0 ), false ) );
01380                 }
01381 
01382                 if ( ( strName == "bagConnectedFCOs" ) && iCount <= 2 ) {
01383                         FPV vecParams; TS vecType;
01384                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01385                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01386                         vecType.push_back( "ocl::Bag" );
01387                         vecType.push_back( "gme::FCO" );
01388                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_BagConnectedFCOs( 1 ), false ) );
01389                 }
01390 
01391                 if ( ( strName == "bagConnectedFCOs" ) && iCount == 1 ) {
01392                         FPV vecParams; TS vecType;
01393                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01394                         vecType.push_back( "ocl::Bag" );
01395                         vecType.push_back( "gme::FCO" );
01396                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_BagConnectedFCOs( 0 ), false ) );
01397                 }
01398 
01399                 if ( ( strName == "connected" ) && iCount <= 2 ) {
01400                         FPV vecParams; TS vecType;
01401                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01402                         vecParams.push_back( FP( "kind", "ocl::String", false ) );
01403                         vecType.push_back( "ocl::Set" );
01404                         vecType.push_back( "gme::FCO" );
01405                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ConnectedFCOs( 1 ), false ) );
01406                 }
01407 
01408                 if ( ( strName == "reverseConnectedFCOs" ) && iCount == 2 ) {
01409                         FPV vecParams; TS vecType;
01410                         vecParams.push_back( FP( "role", "ocl::String", true ) );
01411                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01412                         vecType.push_back( "ocl::Set" );
01413                         vecType.push_back( "gme::FCO" );
01414                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ReverseConnectedFCOs( 1 ), false ) );
01415                 }
01416 
01417                 if ( ( strName == "reverseConnectedFCOs" ) && iCount <= 2 ) {
01418                         FPV vecParams; TS vecType;
01419                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01420                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01421                         vecType.push_back( "ocl::Set" );
01422                         vecType.push_back( "gme::FCO" );
01423                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ReverseConnectedFCOs( 1 ), false ) );
01424                 }
01425 
01426                 if ( ( strName == "reverseConnectedFCOs" ) && iCount == 1 ) {
01427                         FPV vecParams; TS vecType;
01428                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01429                         vecType.push_back( "ocl::Set" );
01430                         vecType.push_back( "gme::FCO" );
01431                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ReverseConnectedFCOs( 0 ), false ) );
01432                 }
01433 
01434                 if ( ( strName == "bagReverseConnectedFCOs" ) && iCount <= 2 ) {
01435                         FPV vecParams; TS vecType;
01436                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01437                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01438                         vecType.push_back( "ocl::Bag" );
01439                         vecType.push_back( "gme::FCO" );
01440                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_BagReverseConnectedFCOs( 1 ), false ) );
01441                 }
01442 
01443                 if ( ( strName == "bagReverseConnectedFCOs" ) && iCount == 1 ) {
01444                         FPV vecParams; TS vecType;
01445                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01446                         vecType.push_back( "ocl::Bag" );
01447                         vecType.push_back( "gme::FCO" );
01448                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_BagReverseConnectedFCOs( 0 ), false ) );
01449                 }
01450 
01451                 if ( ( strName == "connectedAs" ) && iCount <= 2 ) {
01452                         FPV vecParams; TS vecType;
01453                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01454                         vecParams.push_back( FP( "kind", "ocl::String", false ) );
01455                         vecType.push_back( "ocl::Set" );
01456                         vecType.push_back( "gme::FCO" );
01457                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_ReverseConnectedFCOs( 1 ), false ) );
01458                 }
01459 
01460                 if ( ( strName == "attachingConnPoints" ) && iCount == 2 ) {
01461                         FPV vecParams; TS vecType;
01462                         vecParams.push_back( FP( "role", "ocl::String", true ) );
01463                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01464                         vecType.push_back( "ocl::Set" );
01465                         vecType.push_back( "gme::ConnectionPoint" );
01466                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_AttachingConnPoints( 1 ), false ) );
01467                 }
01468 
01469                 if ( ( strName == "attachingConnPoints" ) && iCount <= 2 ) {
01470                         FPV vecParams; TS vecType;
01471                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01472                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01473                         vecType.push_back( "ocl::Set" );
01474                         vecType.push_back( "gme::ConnectionPoint" );
01475                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_AttachingConnPoints( 1 ), false ) );
01476                 }
01477 
01478                 if ( ( strName == "attachingConnPoints" ) && iCount == 1 ) {
01479                         FPV vecParams; TS vecType;
01480                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01481                         vecType.push_back( "ocl::Set" );
01482                         vecType.push_back( "gme::ConnectionPoint" );
01483                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_AttachingConnPoints( 0 ), false ) );
01484                 }
01485 
01486                 if ( ( strName == "attachingConnections" ) && iCount == 2 ) {
01487                         FPV vecParams; TS vecType;
01488                         vecParams.push_back( FP( "role", "ocl::String", true ) );
01489                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01490                         vecType.push_back( "ocl::Set" );
01491                         vecType.push_back( "gme::Connection" );
01492                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_AttachingConnections( 1 ), false ) );
01493                 }
01494 
01495                 if ( ( strName == "attachingConnections" ) && iCount <= 2 ) {
01496                         FPV vecParams; TS vecType;
01497                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01498                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01499                         vecType.push_back( "ocl::Set" );
01500                         vecType.push_back( "gme::Connection" );
01501                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_AttachingConnections( 1 ), false ) );
01502                 }
01503 
01504                 if ( ( strName == "attachingConnections" ) && iCount == 1 ) {
01505                         FPV vecParams; TS vecType;
01506                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01507                         vecType.push_back( "ocl::Set" );
01508                         vecType.push_back( "gme::Connection" );
01509                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_AttachingConnections( 0 ), false ) );
01510                 }
01511 
01512                 if ( ( strName == "isConnectedTo" ) && iCount == 3 ) {
01513                         FPV vecParams; TS vecType;
01514                         vecParams.push_back( FP( "fco", "gme::FCO", true ) );
01515                         vecParams.push_back( FP( "role", "ocl::String", true ) );
01516                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01517                         vecType.push_back( "ocl::Boolean" );
01518                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_IsConnectedTo( 2 ), false ) );
01519                 }
01520 
01521                 if ( ( strName == "isConnectedTo" ) && iCount <= 3 && iCount >= 1 ) {
01522                         FPV vecParams; TS vecType;
01523                         vecParams.push_back( FP( "fco", "gme::FCO", true ) );
01524                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01525                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01526                         vecType.push_back( "ocl::Boolean" );
01527                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_IsConnectedTo( 2 ), false ) );
01528                 }
01529 
01530                 if ( ( strName == "isConnectedTo" ) && iCount == 2 ) {
01531                         FPV vecParams; TS vecType;
01532                         vecParams.push_back( FP( "fco", "gme::FCO", true ) );
01533                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01534                         vecType.push_back( "ocl::Boolean" );
01535                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_IsConnectedTo( 1 ), false ) );
01536                 }
01537 
01538                 if ( ( strName == "attribute" ) && iCount == 1 ) {
01539                         FPV vecParams; TS vecType;      
01540                         vecParams.push_back( FP( "name", "ocl::String", true ) );
01541                         vecType.push_back( "ocl::Any" );
01542                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_Attribute(), false ) );
01543                 }
01544 //----
01545                 if ( ( strName == "attrByDefault" ) && iCount == 1 ) {
01546                         FPV vecParams; TS vecType;
01547                         vecParams.push_back( FP( "name", "ocl::String", true ) );
01548                         vecType.push_back( "ocl::Boolean" );
01549                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TFCO_AttrByDefault(), false ) );
01550                 }
01551 //----
01552         }
01553 
01554 //##############################################################################################################################################
01555 //
01556 //      T Y P E   O F   gme::Connection
01557 //
01558 //##############################################################################################################################################
01559 
01560         GMEMETHOD( TConnection_ConnectionPoints )
01561         {
01562                 void operator()()
01563                 {
01564                         DECL_GMECONNECTION( spThis, GetThis() );
01565                         if ( ! spThis.p )
01566                                 ThrowException( "Object is null." );
01567                         std::string strRole;
01568                         if ( GetArgumentCount() > 0 ) {
01569                                 DECL_STRING2( strRole, GetArgument( 0 ) );
01570                                 if ( strRole.empty() )
01571                                         ThrowException( "Role cannot be empty. Use gme::Connection::connectionPoints() without role." );
01572                         }
01573 
01574                         OclMeta::ObjectVector setOut;
01575                         CComPtr<IMgaConnPoints> spCPs;
01576                         COMTHROW( spThis->get_ConnPoints( &spCPs ) );
01577                         MGACOLL_ITERATE( IMgaConnPoint, spCPs ) {
01578                                 if ( strRole.empty() || strRole == OclCommonEx::GetConnPointRole( MGACOLL_ITER ) ) {
01579                                         setOut.push_back( CREATE_GMECONNECTIONPOINT( GetTypeManager(), MGACOLL_ITER ) );
01580                                 }
01581                         } MGACOLL_ITERATE_END;
01582 
01583                         SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01584                 }
01585         };
01586 
01587         GMEMETHOD( TConnection_ConnectionPoint )
01588         {
01589                 void operator()()
01590                 {
01591                         DECL_GMECONNECTION( spThis, GetThis() );
01592                         if ( ! spThis.p )
01593                                 ThrowException( "Object is null." );
01594                         DECL_STRING( strRole, GetArgument( 0 ) );
01595                         if ( strRole.empty() )
01596                                 ThrowException( "Role cannot be empty." );
01597 
01598                         CComPtr<IMgaConnPoints> spCPs;
01599                         COMTHROW( spThis->get_ConnPoints( &spCPs ) );
01600                         MGACOLL_ITERATE( IMgaConnPoint, spCPs ) {
01601                                 if ( strRole == OclCommonEx::GetConnPointRole( MGACOLL_ITER ) ) {
01602                                         SetResult( CREATE_GMECONNECTIONPOINT( GetTypeManager(), MGACOLL_ITER ) );
01603                                         return;
01604                                 }
01605                         } MGACOLL_ITERATE_END;
01606                         ThrowException( "Role '" + strRole + "' is invalid." );
01607                 }
01608         };
01609 
01610         void TConnection_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
01611         {
01612                 std::string strName = signature.GetName();
01613                 int iCount = signature.GetParameterCount();
01614                 FPV vecParams;
01615                 TS vecType;
01616 
01617                 if ( ( strName == "connectionPoints" ) && iCount <= 1 ) {
01618                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01619                         vecType.push_back( "ocl::Set" );
01620                         vecType.push_back( "gme::ConnectionPoint" );
01621                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TConnection_ConnectionPoints(), false ) );
01622                         return;
01623                 }
01624 
01625                 if ( ( strName == "connectionPoint" ) && iCount == 1 ) {
01626                         vecParams.push_back( FP( "role", "ocl::String", true ) );
01627                         vecType.push_back( "gme::ConnectionPoint" );
01628                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TConnection_ConnectionPoint(), false ) );
01629                         return;
01630                 }
01631 
01632         }
01633 
01634 //##############################################################################################################################################
01635 //
01636 //      T Y P E   O F   gme::Reference
01637 //
01638 //##############################################################################################################################################
01639 
01640         GMEMETHOD( TReference_UsedByConnPoints )
01641         {
01642                 void operator()()
01643                 {
01644                         DECL_GMEREFERENCE( spThis, GetThis() );
01645                         if ( ! spThis.p )
01646                                 ThrowException( "Object is null." );
01647                         std::string strKind = GetKind( 0, "gme::Connection" );
01648 
01649                         OclMeta::ObjectVector setOut;
01650                         CComPtr<IMgaConnPoints> spCPs;
01651                         COMTHROW( spThis->get_UsedByConns( &spCPs ) );
01652                         MGACOLL_ITERATE( IMgaConnPoint, spCPs ) {
01653                                 if ( ! strKind.empty() ) {
01654                                         CComPtr<IMgaConnection> spConnection;
01655                                         COMTHROW( MGACOLL_ITER->get_Owner( &spConnection ) );
01656                                         if ( strKind != OclCommonEx::GetObjectKind( spConnection.p ) )
01657                                                 continue;
01658                                 }
01659                                 setOut.push_back( CREATE_GMECONNECTIONPOINT( GetTypeManager(), MGACOLL_ITER ) );
01660                         } MGACOLL_ITERATE_END;
01661 
01662                         SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01663                 }
01664         };
01665 
01666         GMEMETHOD( TReference_RefersTo )
01667         {
01668                 void operator()()
01669                 {
01670                         DECL_GMEREFERENCE( spThis, GetThis() );
01671                         if ( ! spThis.p )
01672                                 ThrowException( "Object is null." );
01673 
01674                         CComPtr<IMgaFCO> spOut;
01675                         COMTHROW( spThis->get_Referred( &spOut ) );
01676                         SetResult( CREATE_GMEOBJECT( GetTypeManager(), spOut ) );
01677                 }
01678         };
01679 
01680         void TReference_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
01681         {
01682                 std::string strName = signature.GetName();
01683                 int iCount = signature.GetParameterCount();
01684 
01685                 if ( ( strName == "usedByConnPoints" ) && iCount == 1 ) {
01686                         FPV vecParams; TS vecType;
01687                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01688                         vecType.push_back( "ocl::Set" );
01689                         vecType.push_back( "gme::ConnectionPoint" );
01690                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TReference_UsedByConnPoints(), false ) );
01691                 }
01692 
01693                 if ( ( strName == "usedByConnPoints" ) && iCount <= 1 ) {
01694                         FPV vecParams; TS vecType;
01695                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01696                         vecType.push_back( "ocl::Set" );
01697                         vecType.push_back( "gme::ConnectionPoint" );
01698                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TReference_UsedByConnPoints(), false ) );
01699                 }
01700 
01701                 if ( ( strName == "refersTo" ) && iCount == 0 ) {
01702                         FPV vecParams; TS vecType;
01703                         vecType.push_back( "gme::FCO" );
01704                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TReference_RefersTo(), false ) );
01705                 }
01706         }
01707 
01708 //##############################################################################################################################################
01709 //
01710 //      T Y P E   O F   gme::Model
01711 //
01712 //##############################################################################################################################################
01713 
01714         GMEMETHOD( TModel_Models_Atoms )
01715         {
01716                 private :
01717                         std::string m_strObjType;
01718 
01719                 public :
01720                         TModel_Models_Atoms( const std::string& strObjType )
01721                                 : m_strObjType( strObjType )
01722                         {
01723                         }
01724 
01725                         void operator()()
01726                         {
01727                                 DECL_GMEMODEL( spThis, GetThis() );
01728                                 if ( ! spThis.p )
01729                                         ThrowException( "Object is null." );
01730                                 std::string strKind = GetKind( 0, ( m_strObjType == "OBJTYPE_MODEL" ) ? "gme::Model" : "gme::Atom" );
01731 
01732                                 CComPtr<IMgaProject> spProject;
01733                                 COMTHROW( spThis->get_Project( &spProject ) );
01734                                 CComPtr<IMgaFilter> spFilter;
01735                                 COMTHROW( spProject->CreateFilter( &spFilter ) );
01736                                 if ( ! strKind.empty() )
01737                                         COMTHROW( spFilter->put_Kind( CComBSTR( OclCommonEx::Convert( strKind ) ) ) );
01738                                 COMTHROW( spFilter->put_ObjType( CComBSTR( OclCommonEx::Convert( m_strObjType ) ) ) );
01739                                 COMTHROW( spFilter->put_Level( CComBSTR( "1-" ) ) );
01740 
01741                                 OclMeta::ObjectVector setOut;
01742                                 CComPtr<IMgaFCOs> spFCOs;
01743                                 COMTHROW( spThis->GetDescendantFCOs( spFilter, &spFCOs ) );
01744                                 MGACOLL_ITERATE( IMgaFCO, spFCOs ) {
01745                                         setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
01746                                 } MGACOLL_ITERATE_END;
01747 
01748                                 SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01749                         }
01750         };
01751 
01752         GMEMETHOD( TModel_Parts )
01753         {
01754                 private :
01755                         objtype_enum    m_eType;
01756                         int                                     m_iKindPos;
01757 
01758                 public :
01759                         TModel_Parts( objtype_enum eType, int iKindPos = -1 )
01760                                 : m_iKindPos( iKindPos ), m_eType( eType )
01761                         {
01762                         }
01763 
01764                         void operator()()
01765                         {
01766                                 DECL_GMEMODEL( spThis, GetThis() );
01767                                 if ( ! spThis.p )
01768                                         ThrowException( "Object is null." );
01769                                 std::string strRole;
01770                                 if ( m_iKindPos != 0 && GetArgumentCount() > 0 ) {
01771                                         DECL_STRING2( strRole, GetArgument( 0 ) );
01772                                         if ( strRole.empty() )
01773                                                 ThrowException( "Role cannot be empty. Use the approriate method without argument." );
01774                                 }
01775                                 std::string strKind = GetKind( m_iKindPos, "gme::" + ( ( m_eType == OBJTYPE_NULL ) ? "Object" : OclCommonEx::ObjectTypeToString( m_eType ) ) );
01776 
01777                                 OclMeta::ObjectVector setOut;
01778                                 CComPtr<IMgaFCOs> spFCOs;
01779                                 COMTHROW( spThis->get_ChildFCOs( &spFCOs ) );
01780                                 MGACOLL_ITERATE( IMgaFCO, spFCOs ) {
01781                                         if ( m_eType == OBJTYPE_NULL || m_eType == OclCommonEx::GetObjectType( MGACOLL_ITER.p ) )
01782                                                 if ( strRole.empty() || strRole == OclCommonEx::GetFCORole( MGACOLL_ITER ) )
01783                                                         if ( strKind.empty() || strKind == OclCommonEx::GetObjectKind( MGACOLL_ITER.p ) )
01784                                                                 setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
01785                                 } MGACOLL_ITERATE_END;
01786 
01787                                 SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01788                         }
01789         };
01790 
01791         void TModel_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
01792         {
01793                 std::string strName = signature.GetName();
01794                 int iCount = signature.GetParameterCount();
01795                 FPV vecParams;
01796                 TS vecType;
01797 
01798                 if ( ( strName == "models" ) && iCount == 1 ) {
01799                         FPV vecParams; TS vecType;
01800                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01801                         vecType.push_back( "ocl::Set" );
01802                         vecType.push_back( "gme::Model" );
01803                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Models_Atoms( "OBJTYPE_MODEL" ), false ) );
01804                 }
01805 
01806                 if ( ( strName == "models" ) && iCount <= 1 ) {
01807                         FPV vecParams; TS vecType;
01808                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01809                         vecType.push_back( "ocl::Set" );
01810                         vecType.push_back( "gme::Model" );
01811                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Models_Atoms( "OBJTYPE_MODEL" ), false ) );
01812                 }
01813 
01814                 if ( ( strName == "atoms" ) && iCount == 1 ) {
01815                         FPV vecParams; TS vecType;
01816                         vecParams.push_back( FP( "kind", "ocl::String", true ) );
01817                         vecType.push_back( "ocl::Set" );
01818                         vecType.push_back( "gme::Atom" );
01819                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Models_Atoms( "OBJTYPE_ATOM" ), false ) );
01820                 }
01821 
01822                 if ( ( strName == "atoms" ) && iCount <= 1 ) {
01823                         FPV vecParams; TS vecType;
01824                         vecParams.push_back( FP( "kind", "ocl::Type", false ) );
01825                         vecType.push_back( "ocl::Set" );
01826                         vecType.push_back( "gme::Atom" );
01827                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Models_Atoms( "OBJTYPE_ATOM" ), false ) );
01828                 }
01829 
01830                 if ( ( strName == "parts" ) && iCount <= 1 ) {
01831                         FPV vecParams; TS vecType;
01832                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01833                         vecType.push_back( "ocl::Set" );
01834                         vecType.push_back( "gme::FCO" );
01835                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_NULL ), false ) );
01836                 }
01837 
01838                 if ( ( strName == "modelParts" ) && iCount <= 1 ) {
01839                         FPV vecParams; TS vecType;
01840                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01841                         vecType.push_back( "ocl::Set" );
01842                         vecType.push_back( "gme::Model" );
01843                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_MODEL ), false ) );
01844                 }
01845 
01846                 if ( ( strName == "atomParts" ) && iCount <= 1 ) {
01847                         FPV vecParams; TS vecType;
01848                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01849                         vecType.push_back( "ocl::Set" );
01850                         vecType.push_back( "gme::Atom" );
01851                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_ATOM ), false ) );
01852                 }
01853 
01854                 if ( ( strName == "connectionParts" ) && iCount <= 1 ) {
01855                         FPV vecParams; TS vecType;
01856                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01857                         vecType.push_back( "ocl::Set" );
01858                         vecType.push_back( "gme::Connection" );
01859                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_CONNECTION ), false ) );
01860                 }
01861 
01862                 if ( ( strName == "referenceParts" ) && iCount <= 1 ) {
01863                         FPV vecParams; TS vecType;
01864                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01865                         vecType.push_back( "ocl::Set" );
01866                         vecType.push_back( "gme::Reference" );
01867                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_REFERENCE ), false ) );
01868                 }
01869 
01870                 if ( ( strName == "setParts" ) && iCount <= 1 ) {
01871                         FPV vecParams; TS vecType;
01872                         vecParams.push_back( FP( "role", "ocl::String", false ) );
01873                         vecType.push_back( "ocl::Set" );
01874                         vecType.push_back( "gme::Set" );
01875                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_SET ), false ) );
01876                 }
01877 
01878                 if ( ( strName == "parts" ) && iCount == 1 ) {
01879                         FPV vecParams; TS vecType;
01880                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01881                         vecType.push_back( "ocl::Set" );
01882                         vecType.push_back( "gme::FCO" );
01883                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_NULL, 0 ), false ) );
01884                 }
01885 
01886                 if ( ( strName == "modelParts" ) && iCount == 1 ) {
01887                         FPV vecParams; TS vecType;
01888                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01889                         vecType.push_back( "ocl::Set" );
01890                         vecType.push_back( "gme::Model" );
01891                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_MODEL, 0 ), false ) );
01892                 }
01893 
01894                 if ( ( strName == "atomParts" ) && iCount == 1 ) {
01895                         FPV vecParams; TS vecType;
01896                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01897                         vecType.push_back( "ocl::Set" );
01898                         vecType.push_back( "gme::Atom" );
01899                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_ATOM, 0 ), false ) );
01900                 }
01901 
01902                 if ( ( strName == "connectionParts" ) && iCount == 1 ) {
01903                         FPV vecParams; TS vecType;
01904                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01905                         vecType.push_back( "ocl::Set" );
01906                         vecType.push_back( "gme::Connection" );
01907                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_CONNECTION, 0 ), false ) );
01908                 }
01909 
01910                 if ( ( strName == "referenceParts" ) && iCount == 1 ) {
01911                         FPV vecParams; TS vecType;
01912                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01913                         vecType.push_back( "ocl::Set" );
01914                         vecType.push_back( "gme::Reference" );
01915                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_REFERENCE, 0 ), false ) );
01916                 }
01917 
01918                 if ( ( strName == "setParts" ) && iCount == 1 ) {
01919                         FPV vecParams; TS vecType;
01920                         vecParams.push_back( FP( "kind", "ocl::Type", true ) );
01921                         vecType.push_back( "ocl::Set" );
01922                         vecType.push_back( "gme::Set" );
01923                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TModel_Parts( OBJTYPE_SET, 0 ), false ) );
01924                 }
01925         }
01926 
01927 //##############################################################################################################################################
01928 //
01929 //      T Y P E    O F   gme::Atom
01930 //
01931 //##############################################################################################################################################
01932 
01933 //##############################################################################################################################################
01934 //
01935 //      T Y P E    O F   gme::Set
01936 //
01937 //##############################################################################################################################################
01938 
01939         GMEMETHOD( TSet_Members )
01940         {
01941                 void operator()()
01942                 {
01943                         DECL_GMESET( spThis, GetThis() );
01944                         if ( ! spThis.p )
01945                                 ThrowException( "Object is null." );
01946 
01947                         OclMeta::ObjectVector setOut;
01948                         CComPtr<IMgaFCOs> spFCOs;
01949                         COMTHROW( spThis->get_Members( &spFCOs ) );
01950                         MGACOLL_ITERATE( IMgaFCO, spFCOs ) {
01951                                 setOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
01952                         } MGACOLL_ITERATE_END;
01953 
01954                         SetResult( CREATE_SET( GetTypeManager(), setOut ) );
01955                 }
01956         };
01957 
01958         void TSet_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
01959         {
01960                 std::string strName = signature.GetName();
01961                 int iCount = signature.GetParameterCount();
01962                 FPV vecParams;
01963                 TS vecType;
01964 
01965                 if ( ( strName == "members" ) && iCount == 0 ) {
01966                         vecType.push_back( "ocl::Set" );
01967                         vecType.push_back( "gme::FCO" );
01968                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TSet_Members(), false ) );
01969                         return;
01970                 }
01971         }
01972 
01973 //##############################################################################################################################################
01974 //
01975 //      T Y P E    O F   gme::ConnectionPoint
01976 //
01977 //##############################################################################################################################################
01978 
01979         ATTRIBUTE( TConnectionPoint_CPRoleName )
01980         {
01981                 void operator()()
01982                 {
01983                         DECL_GMECONNECTIONPOINT( spThis, GetThis() );
01984                         if ( ! spThis.p )
01985                                 ThrowException( "Object is null." );
01986                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetConnPointRole( spThis ) ) );
01987                 }
01988         };
01989 
01990         GMEMETHOD( TConnectionPoint_CPRoleName_Compatibility )
01991         {
01992                 void operator()()
01993                 {
01994                         DECL_GMECONNECTIONPOINT( spThis, GetThis() );
01995                         if ( ! spThis.p )
01996                                 ThrowException( "Object is null." );
01997                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::GetConnPointRole( spThis ) ) );
01998                 }
01999         };
02000 
02001         GMEMETHOD( TConnectionPoint_Owner )
02002         {
02003                 void operator()()
02004                 {
02005                         DECL_GMECONNECTIONPOINT( spThis, GetThis() );
02006                         if ( ! spThis.p )
02007                                 ThrowException( "Object is null." );
02008 
02009                         CComPtr<IMgaConnection> spConnection;
02010                         COMTHROW( spThis->get_Owner( &spConnection ) );
02011                         SetResult( CREATE_GMEOBJECT( GetTypeManager(), spConnection ) );
02012                 }
02013         };
02014 
02015         GMEMETHOD( TConnectionPoint_Target )
02016         {
02017                 void operator()()
02018                 {
02019                         DECL_GMECONNECTIONPOINT( spThis, GetThis() );
02020                         if ( ! spThis.p )
02021                                 ThrowException( "Object is null." );
02022 
02023                         CComPtr<IMgaFCO> spTarget;
02024                         COMTHROW( spThis->get_Target( &spTarget ) );
02025                         SetResult( CREATE_GMEOBJECT( GetTypeManager(), spTarget ) );
02026                 }
02027         };
02028 
02029         GMEMETHOD( TConnectionPoint_Peer )
02030         {
02031                 void operator()()
02032                 {
02033                         DECL_GMECONNECTIONPOINT( spThis, GetThis() );
02034                         if ( ! spThis.p )
02035                                 ThrowException( "Object is null." );
02036 
02037                         CComPtr<IMgaConnection> spConnection;
02038                         CComPtr<IMgaConnPoints> spCPs;
02039                         COMTHROW( spThis->get_Owner( &spConnection ) );
02040                         COMTHROW( spConnection->get_ConnPoints( &spCPs ) );
02041 
02042                         long lCount;
02043                         COMTHROW( spCPs->get_Count( &lCount) );
02044                         if( lCount != 2 )
02045                                 ThrowException( "Peer cannot be used for non-binary associations." );
02046 
02047                         MGACOLL_ITERATE( IMgaConnPoint, spCPs ) {
02048                                 if ( MGACOLL_ITER != spThis ) {
02049                                         SetResult( CREATE_GMECONNECTIONPOINT( GetTypeManager(), MGACOLL_ITER ) );
02050                                         return;
02051                                 }
02052                         } MGACOLL_ITERATE_END;
02053                         SetResult( OclMeta::Object::UNDEFINED );
02054                 }
02055         };
02056 
02057         GMEMETHOD( TConnectionPoint_UsedReferences )
02058         {
02059                 void operator()()
02060                 {
02061                         DECL_GMECONNECTIONPOINT( spThis, GetThis() );
02062                         if ( ! spThis.p )
02063                                 ThrowException( "Object is null." );
02064 
02065                         OclMeta::ObjectVector vecOut;
02066                         CComPtr<IMgaFCOs> spFCOs;
02067                         COMTHROW( spThis->get_References( &spFCOs ) );
02068                         MGACOLL_ITERATE( IMgaFCO, spFCOs ) {
02069                                 vecOut.push_back( CREATE_GMEOBJECT( GetTypeManager(), MGACOLL_ITER ) );
02070                         } MGACOLL_ITERATE_END;
02071                         SetResult( CREATE_SEQUENCE( GetTypeManager(), vecOut ) );
02072                 }
02073         };
02074 
02075         void TConnectionPoint_AttributeFactory::GetFeatures( const OclSignature::Attribute& signature, OclMeta::AttributeVector& vecFeatures )
02076         {
02077                 std::string strName = signature.GetName();
02078                 TS vecType;
02079 
02080                 if ( strName == "cpRoleName" ) {
02081                         vecType.push_back( "ocl::String" );
02082                         vecFeatures.push_back( new OclMeta::Attribute( strName, vecType, new TConnectionPoint_CPRoleName(), false ) );
02083                         return;
02084                 }
02085         }
02086 
02087         void TConnectionPoint_MethodFactory::GetFeatures( const OclSignature::Method& signature, OclMeta::MethodVector& vecFeatures )
02088         {
02089                 std::string strName = signature.GetName();
02090                 int iCount = signature.GetParameterCount();
02091                 FPV vecParams;
02092                 TS vecType;
02093 
02094                 if ( ( strName == "cpRoleName" ) && iCount == 0 ) {
02095                         vecType.push_back( "ocl::String" );
02096                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TConnectionPoint_CPRoleName_Compatibility(), false ) );
02097                         return;
02098                 }
02099 
02100                 if ( ( strName == "owner" ) && iCount == 0 ) {
02101                         vecType.push_back( "gme::Connection" );
02102                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TConnectionPoint_Owner(), false ) );
02103                         return;
02104                 }
02105 
02106                 if ( ( strName == "target" ) && iCount == 0 ) {
02107                         vecType.push_back( "gme::FCO" );
02108                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TConnectionPoint_Target(), false ) );
02109                         return;
02110                 }
02111 
02112                 if ( ( strName == "peer" ) && iCount == 0 ) {
02113                         vecType.push_back( "gme::ConnectionPoint" );
02114                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TConnectionPoint_Peer(), false ) );
02115                         return;
02116                 }
02117 
02118                 if ( ( strName == "usedReferences" ) && iCount == 0 ) {
02119                         vecType.push_back( "ocl::Sequence" );
02120                         vecType.push_back( "gme::FCO" );
02121                         vecFeatures.push_back( new OclMeta::Method( strName, vecParams, vecType, new TConnectionPoint_UsedReferences(), false ) );
02122                         return;
02123                 }
02124         }
02125 
02126 //##############################################################################################################################################
02127 //
02128 //      T Y P E   O F   D E R I V E D   O F   gme::FCO
02129 //
02130 //##############################################################################################################################################
02131 
02132         class FCODerived_Attribute
02133                 : public OclImplementation::Attribute
02134         {
02135                 private :
02136                         std::string     m_strName;
02137 
02138                 public :
02139                         FCODerived_Attribute( const std::string strName )
02140                                 : m_strName( strName )
02141                         {
02142                         }
02143 
02144                         void operator()()
02145                         {
02146                                 DECL_GMEFCO( spThis, GetThis() );
02147                                 if ( ! spThis.p )
02148                                         ThrowException( "Object is null." );
02149 
02150                                 CComVariant objValue;
02151                                 if ( ! SUCCEEDED( spThis->get_AttributeByName( CComBSTR( OclCommonEx::Convert( m_strName ) ), PutOut( objValue ) ) ) )
02152                                         ThrowException( "Attribute [ " + m_strName + " ] does not exist." );
02153                                 switch( objValue.vt ) {
02154                                         case VT_R8 :
02155                                                 SetResult( CREATE_REAL( GetTypeManager(), objValue.dblVal ) ); // double
02156                                                 break;
02157                                         case VT_I4 :
02158                                                 SetResult( CREATE_INTEGER( GetTypeManager(), objValue.lVal ) ); // long
02159                                                 break;
02160                                         case VT_BOOL:
02161                                                 SetResult( CREATE_BOOLEAN( GetTypeManager(), ( objValue.boolVal ) ? true : false ) ); // boolean
02162                                                 break;
02163                                         case VT_BSTR : {
02164                                                 CComPtr<IMgaMetaAttribute> spAttribute;
02165                                                 CComPtr<IMgaMetaFCO> spMeta;
02166                                                 COMTHROW( spThis->get_Meta( &spMeta ) );
02167                                                 COMTHROW( spMeta->get_AttributeByName( CComBSTR( OclCommonEx::Convert( m_strName ) ), &spAttribute ) );
02168                                                 attval_enum eType;
02169                                                 COMTHROW( spAttribute->get_ValueType( &eType ) );
02170                                                 if ( eType == ATTVAL_STRING )
02171                                                         SetResult( CREATE_STRING( GetTypeManager(), OclCommonEx::Convert( CString( objValue.bstrVal ) ) ) ); // string
02172                                                 else
02173                                                         SetResult( CREATE_ENUMERATION( GetTypeManager(), OclCommonEx::Convert( CString( objValue.bstrVal ) ) ) ); // enum
02174                                                 break;
02175                                         }
02176                                         default:
02177                                                 SetResult( OclMeta::Object::UNDEFINED );
02178                                 }
02179                         }
02180         };
02181 
02182         TFCODerived_AttributeFactory::TFCODerived_AttributeFactory( CComPtr<IMgaMetaFCO> spMetaFCO )
02183                 : m_spMetaFCO( spMetaFCO )
02184         {
02185         }
02186 
02187         void TFCODerived_AttributeFactory::GetFeatures( const OclSignature::Attribute& signature, OclMeta::AttributeVector& vecFeatures )
02188         {
02189                 CComPtr<IMgaMetaAttributes> spAttributes;
02190                 COMTHROW( m_spMetaFCO->get_Attributes( &spAttributes ) );
02191                 MGACOLL_ITERATE( IMgaMetaAttribute, spAttributes ) {
02192                         if ( signature.GetName() == OclCommonEx::GetObjectName( MGACOLL_ITER.p ) ) {
02193                                 attval_enum eType;
02194                                 COMTHROW( MGACOLL_ITER->get_ValueType( &eType ) );
02195                                 std::string strReturnType;
02196                                 switch ( eType ) {
02197                                         case ATTVAL_STRING              : strReturnType = "ocl::String"; break;
02198                                         case ATTVAL_INTEGER     : strReturnType = "ocl::Integer"; break;
02199                                         case ATTVAL_DOUBLE              : strReturnType = "ocl::Real"; break;
02200                                         case ATTVAL_BOOLEAN     : strReturnType = "ocl::Boolean"; break;
02201                                         case ATTVAL_ENUM                : strReturnType = "ocl::Enumeration"; break;
02202                                 }
02203                                 if ( ! strReturnType.empty() )
02204                                         vecFeatures.push_back( new OclMeta::Attribute( signature.GetName(), TS( 1, strReturnType ), new FCODerived_Attribute( signature.GetName() ), true ) );
02205                         }
02206                 } MGACOLL_ITERATE_END;
02207         }
02208 
02209 //##############################################################################################################################################
02210 //
02211 //      T Y P E   F A C T O R Y
02212 //
02213 //##############################################################################################################################################
02214 
02215         TypeFactory::TypeFactory( CComPtr<IMgaProject> spProject )
02216                 : m_spProject( spProject )
02217         {
02218         }
02219 
02220         void TypeFactory::GetTypes( const std::string& strName, const std::string& strNSpace, std::vector<unique_ptr<OclMeta::Type>>& vecTypes, std::string& strNameResult )
02221         {
02222                 strNameResult = strName; // will be overwritten by the GetDynamicTypes if it finds something
02223                 bool bHasNamespace = strName.find( "::" ) != std::string::npos;
02224                 std::string str2Name = strName;
02225                 if( vecTypes.empty()
02226                         && !strNSpace.empty()                                                          // if strNSpace specified
02227                         && (!bHasNamespace || strName.substr( 0, strName.find( "::")) == "meta")       // either 'meta::' prefix found or no namespace found
02228                         && strName.find( std::string( "::" + strNSpace + "::"))  == std::string::npos  // "::strNSpace::" is not yet substr of strName
02229                         && strName != "meta::RootFolder" )                                             // special kind needs not modification: meta::RootFolder
02230                 {
02231                         
02232                         if( strName.find( "meta::") != std::string::npos)                              // 'meta::' found
02233                         {
02234                                 str2Name.insert( strName.find( "::" ), std::string( "::" + strNSpace));    // str2Name = meta::strNSpace::strName
02235                         }
02236                         else
02237                         {
02238                                 str2Name = strNSpace + "::" + strName;                                     // str2Name = strNSpace::strName
02239                         }
02240                 }
02241 
02242                 GetDynamicTypes( str2Name, vecTypes, strNameResult );
02243                 if ( ! bHasNamespace && ! vecTypes.empty() )
02244                         return;
02245 
02246                 GetStereotypes( strName, vecTypes );
02247                 if ( ! bHasNamespace && ! vecTypes.empty() )
02248                         return;
02249 
02250                 if ( strName == "ocl::Any" || strName == "Any" ) {
02251                         StringVector vecSupers;
02252                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "ocl::Any", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TAny_MethodFactory(), false ) ));
02253                         return;
02254                 }
02255 
02256                 if ( strName == "ocl::Boolean" || strName == "bool" ) {
02257                         StringVector vecSupers;
02258                         vecSupers.push_back( "ocl::Any" );
02259                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "ocl::Boolean", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclImplementation::MethodFactory(), false ) ));
02260                         return;
02261                 }
02262 
02263                 if ( strName == "ocl::Enumeration" || strName == "enum" ) {
02264                         StringVector vecSupers;
02265                         vecSupers.push_back( "ocl::Any" );
02266                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "ocl::Enumeration", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TEnumeration_MethodFactory(), false ) ));
02267                         return;
02268                 }
02269 
02270                 if ( strName == "ocl::String" || strName == "string" ) {
02271                         StringVector vecSupers;
02272                         vecSupers.push_back( "ocl::Any" );
02273                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "ocl::String", vecSupers, new OclBasic::TString_AttributeFactory(), new OclImplementation::AssociationFactory(), new TStringEx_MethodFactory(), false ) ));
02274                         return;
02275                 }
02276 
02277                 if ( strName == "ocl::Real" || strName == "real" || strName == "double" ) {
02278                         StringVector vecSupers;
02279                         vecSupers.push_back( "ocl::Any" );
02280                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "ocl::Real", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TReal_MethodFactory(), false ) ));
02281                         return;
02282                 }
02283 
02284                 if ( strName == "ocl::Integer" || strName == "int" || strName == "long" ) {
02285                         StringVector vecSupers;
02286                         vecSupers.push_back( "ocl::Real" );
02287                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "ocl::Integer", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TInteger_MethodFactory(), false ) ));
02288                         return;
02289                 }
02290 
02291                 if ( strName == "ocl::Type" || strName == "Type" ) {
02292                         StringVector vecSupers;
02293                         vecSupers.push_back( "ocl::Any" );
02294                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "ocl::Type", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclImplementation::MethodFactory(), false ) ));
02295                         return;
02296                 }
02297 
02298                 if ( strName == "ocl::Collection" || strName == "Collection" ) {
02299                         StringVector vecSupers;
02300                         vecSupers.push_back( "ocl::Any" );
02301                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::CompoundType( "ocl::Collection", vecSupers, new OclBasic::TCollection_AttributeFactory(), new OclImplementation::AssociationFactory(), new TCollectionEx_MethodFactory(),new OclBasic::TCollection_IteratorFactory(),  false ) ));
02302                         return;
02303                 }
02304 
02305                 if ( strName == "ocl::Set" || strName == "Set" ) {
02306                         StringVector vecSupers;
02307                         vecSupers.push_back( "ocl::Collection" );
02308                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::CompoundType( "ocl::Set", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TSet_MethodFactory(),new OclBasic::TSet_IteratorFactory(),  false ) ));
02309                         return;
02310                 }
02311 
02312                 if ( strName == "ocl::Sequence" || strName == "Sequence" ) {
02313                         StringVector vecSupers;
02314                         vecSupers.push_back( "ocl::Collection" );
02315                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::CompoundType( "ocl::Sequence", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TSequence_MethodFactory(),new OclBasic::TSequence_IteratorFactory(),  false ) ));
02316                         return;
02317                 }
02318 
02319                 if ( strName == "ocl::Bag" || strName == "Bag" ) {
02320                         StringVector vecSupers;
02321                         vecSupers.push_back( "ocl::Collection" );
02322                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::CompoundType( "ocl::Bag", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TBag_MethodFactory(),new OclBasic::TBag_IteratorFactory(),  false ) ));
02323                         return;
02324                 }
02325 
02326 // -- ??
02327                 if ( strName == "ocl::OrderedSet" || strName == "OrderedSet" ) {
02328                         StringVector vecSupers;
02329                         vecSupers.push_back( "ocl::Set" );
02330                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::CompoundType( "ocl::OrderedSet", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclBasic::TOrderedSet_MethodFactory(),new OclBasic::TOrderedSet_IteratorFactory(),  false ) ));
02331                         return;
02332                 }
02333 // --
02334         }
02335 
02336         void TypeFactory::GetStereotypes( const std::string& strName, std::vector<unique_ptr<OclMeta::Type>>& vecTypes )
02337         {
02338                 if ( strName == "gme::Object" || strName == "Object" ) {
02339                         StringVector vecSupers;
02340                         vecSupers.push_back( "ocl::Any" );
02341                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::Object", vecSupers, new TObject_AttributeFactory(), new OclImplementation::AssociationFactory(), new TObject_MethodFactory(), false ) ));
02342                         return;
02343                 }
02344 
02345                 if ( strName == "gme::Folder" || strName == "Folder" ) {
02346                         StringVector vecSupers;
02347                         vecSupers.push_back( "gme::Object" );
02348                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::Folder", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new TFolder_MethodFactory(), false ) ));
02349                         return;
02350                 }
02351 
02352                 if ( strName == "gme::FCO" || strName == "FCO" ) {
02353                         StringVector vecSupers;
02354                         vecSupers.push_back( "gme::Object" );
02355                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::FCO", vecSupers, new TFCO_AttributeFactory(), new OclImplementation::AssociationFactory(), new TFCO_MethodFactory(), false ) ));
02356                         return;
02357                 }
02358 
02359                 if ( strName == "gme::Model" || strName == "Model" ) {
02360                         StringVector vecSupers;
02361                         vecSupers.push_back( "gme::FCO" );
02362                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::Model", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new TModel_MethodFactory(), false ) ));
02363                         return;
02364                 }
02365 
02366                 if ( strName == "gme::Atom" || strName == "Atom" ) {
02367                         StringVector vecSupers;
02368                         vecSupers.push_back( "gme::FCO" );
02369                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::Atom", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new OclImplementation::MethodFactory(), false ) ));
02370                         return;
02371                 }
02372 
02373                 if ( strName == "gme::Set" || strName == "Set" ) {
02374                         StringVector vecSupers;
02375                         vecSupers.push_back( "gme::FCO" );
02376                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::Set", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new TSet_MethodFactory(), false ) ));
02377                         return;
02378                 }
02379 
02380                 if ( strName == "gme::Reference" || strName == "Reference" ) {
02381                         StringVector vecSupers;
02382                         vecSupers.push_back( "gme::FCO" );
02383                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::Reference", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new TReference_MethodFactory(), false ) ));
02384                         return;
02385                 }
02386 
02387                 if ( strName == "gme::Connection" || strName == "Connection" ) {
02388                         StringVector vecSupers;
02389                         vecSupers.push_back( "gme::FCO" );
02390                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::Connection", vecSupers, new OclImplementation::AttributeFactory(), new OclImplementation::AssociationFactory(), new TConnection_MethodFactory(), false ) ));
02391                         return;
02392                 }
02393 
02394                 if ( strName == "gme::Project" || strName == "Project" ) {
02395                         StringVector vecSupers;
02396                         vecSupers.push_back( "ocl::Any" );
02397                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::Project", vecSupers, new TProject_AttributeFactory(), new OclImplementation::AssociationFactory(), new TProject_MethodFactory(), false ) ));
02398                         return;
02399                 }
02400 
02401                 if ( strName == "gme::ConnectionPoint" || strName == "ConnPoint" || strName == "ConnectionPoint" ) {
02402                         StringVector vecSupers;
02403                         vecSupers.push_back( "ocl::Any" );
02404                         vecTypes.push_back(unique_ptr<OclMeta::Type>( new OclMeta::Type( "gme::ConnectionPoint", vecSupers, new TConnectionPoint_AttributeFactory(), new OclImplementation::AssociationFactory(), new TConnectionPoint_MethodFactory(), false ) ));
02405                         return;
02406                 }
02407         }
02408 
02409         void TypeFactory::GetDynamicTypes( const std::string& strName, std::vector<unique_ptr<OclMeta::Type>>& vecTypes, std::string& strNameResult )
02410         {
02411                 size_t jPos = strName.find( "gme::" );
02412                 size_t kPos = strName.find( "ocl::" );
02413                 if( jPos == std::string::npos             // neither 'gme::' 
02414                  && kPos == std::string::npos)            // nor     'ocl::' is found
02415                 {
02416                         // lookup in meta:
02417                         size_t iPos = strName.find( "meta::");
02418                         std::string strN = strName;
02419                         std::string strNS;
02420                         if( iPos != std::string::npos)        // if 'meta::' found
02421                         {
02422                                 strNS = "meta";
02423                                 strN = strName.substr( iPos + 6); // let's remove 'meta::' from the name
02424                         }
02425 
02426                         // search for that kind in the Metaproject
02427                         OclCommonEx::MetaBaseVector vecMetas;
02428                         CComPtr<IMgaMetaProject> spMetaProject;
02429                         COMTHROW( m_spProject->get_RootMeta( &spMetaProject ) );
02430                         OclCommonEx::GetMetaObjects( spMetaProject, strN, OBJTYPE_NULL, vecMetas );
02431                         
02432                         // if found, use longer form
02433                         if( vecMetas.size() > 0)
02434                                 strNameResult = "meta::" + strN;
02435 
02436                         for ( unsigned int i = 0 ; i < vecMetas.size() ; i++ ) {
02437                                 objtype_enum eType = OclCommonEx::GetObjectType( vecMetas[ i ].p );
02438                                 std::string strSuperType = "gme::" + OclCommonEx::ObjectTypeToString( eType );
02439                                 std::string strType = "meta::" + OclCommonEx::GetObjectName( vecMetas[ i ].p );
02440                                 CComQIPtr<IMgaMetaFCO> spMetaFCO = vecMetas[ i ].p;
02441                                 vecTypes.push_back(unique_ptr<OclMeta::Type>(new OclMeta::Type( strType, StringVector( 1, strSuperType ), ( ! spMetaFCO.p ) ? new OclImplementation::AttributeFactory() : new TFCODerived_AttributeFactory( spMetaFCO.p ), new OclImplementation::AssociationFactory(), new OclImplementation::MethodFactory(), false ) ));
02442                         }
02443                 }
02444         }
02445 
02446 }; // namespace OclGmeCM