GME
13
|
00001 #ifndef MAKE_CLOSURE_H 00002 #define MAKE_CLOSURE_H 00003 00004 #include "Gme.h" 00005 00006 class GmeEqual 00007 { 00008 public: 00009 GmeEqual( CComObjPtr<IMgaObject>); 00010 GmeEqual( CComObjPtr<IMgaFCO>); 00011 GmeEqual( CComObjPtr<IMgaFolder>); 00012 GmeEqual( CComObjPtr<IMgaModel>); 00013 00014 bool operator() ( CComObjPtr<IMgaObject>& ); 00015 bool operator() ( CComObjPtr<IMgaFCO>& ); 00016 bool operator() ( CComObjPtr<IMgaFolder>& ); 00017 bool operator() ( CComObjPtr<IMgaModel>& ); 00018 private: 00019 CComObjPtr<IMgaObject> m_objToFind; 00020 CComObjPtr<IMgaFCO> m_fcoToFind; 00021 CComObjPtr<IMgaFolder> m_folderToFind; 00022 CComObjPtr<IMgaModel> m_modelToFind; 00023 int m_which; // which variable is set 00024 }; 00025 00026 #define LIB_STUBS 0 00027 #define LIB_STOP 1 00028 #define LIB_CONT 2 00029 00030 class CMakeClosure 00031 { 00032 public : // operations 00033 CMakeClosure( 00034 IMgaFCOs *fcos, IMgaFolders *fols, 00035 int ref = 1, int refd = 1, 00036 int conn = 1, int refport_conn = 1, 00037 int set_mem = 1, int mem_of_set = 1, 00038 int cont = 1, int part_of_mod = 1, 00039 int fold_cont = 1, int part_of_fold = 1, 00040 int base_type = 1, int derived_type = 1, 00041 int into_libr = LIB_STUBS, 00042 int container_opt = 0, 00043 int direction_opt = 1, 00044 int all_kinds = -1, 00045 int mark_with = -1 00046 ) 00047 : m_bRefersTo( ref == 1) 00048 , m_bReferredBy( refd == 1) 00049 , m_bConnection( conn == 1) 00050 , m_bRefPortConnection( refport_conn == 1) 00051 , m_bSetMember( set_mem == 1) 00052 , m_bMemberOfSets( mem_of_set == 1) 00053 , m_bContainment( cont == 1) 00054 , m_bPartOfModels( part_of_mod == 1) 00055 , m_bFolderContainment( fold_cont == 1) 00056 , m_bPartOfFolders( part_of_fold == 1) 00057 , m_bBaseTypes( base_type == 1) 00058 , m_bDerivedTypes( derived_type == 1) 00059 , m_iIntoLibraries( into_libr) 00060 , m_iContainerOption( container_opt) 00061 , m_bDirection( direction_opt == 1) 00062 , m_kindFilter( all_kinds) 00063 , m_markWith( mark_with) 00064 { 00065 if ( fcos) CopyTo( fcos, m_selFcos); 00066 if ( fols) CopyTo( fols, m_selFolds); 00067 00068 if ( !m_selFcos.empty()) COMTHROW( m_selFcos.front()->get_Project( PutOut( m_project)) ); 00069 else if ( !m_selFolds.empty()) COMTHROW( m_selFolds.front()->get_Project( PutOut( m_project)) ); 00070 else ASSERT( 0); 00071 00072 } 00073 00074 virtual ~CMakeClosure() 00075 { 00076 m_selFolds.clear(); 00077 m_selFcos.clear(); 00078 m_newlySelFolds.clear(); 00079 m_newlySelFcos.clear(); 00080 m_topFolds.clear(); 00081 m_topFcos.clear(); 00082 m_acceptingKindsAndFolders.clear(); 00083 } 00084 00085 long process(); 00086 void getFCOs( IMgaFCOs **res_fcos); 00087 void getFolders( IMgaFolders **res_folds); 00088 00089 bool noTopObjs(); // signals if The RootFolder is the common top (root) of all selected objects 00090 void clearTopObjs(); 00091 void getTopFCOs( IMgaFCOs **res_fcos); 00092 void getTopFolders( IMgaFolders **res_folds); 00093 00094 bool isAnyAccepting() const; 00095 void getAccKindsInString( std::string& p_resStr) const; 00096 const std::vector< std::string >& getAccKindsVector() const; 00097 00098 void send2Console( const std::string& msg); 00099 00100 protected: 00101 00102 void initTrans(); // transaction 00103 void doneTrans( bool abort); 00104 static CComPtr<IGMEOLEApp> get_GME(CComObjPtr<IMgaProject> project); 00105 00106 00107 void doClosure(); 00108 void processFolders(); 00109 void processFCOs(); 00110 00111 virtual void preProcess(); 00112 virtual void postProcess(); 00113 void selectTop(); 00114 void totalWrap(); 00115 void autoWrap(); 00116 std::string processUpward(IMgaObject *obj, CComObjPtrVector<IMgaFolder>& f_parents, CComObjPtrVector<IMgaModel>& m_parents); 00117 00118 void checkMeta( const CComObjPtrVector<IMgaFolder>& p_folds, const CComObjPtrVector<IMgaFCO>& p_fcos); 00119 std::vector< std::string > m_acceptingKindsAndFolders; // the meta names of those kinds which the closure may be inserted into 00120 00121 template<class T> void markObj( CComObjPtr<T> obj); 00122 virtual void procObj( IMgaObject* obj); 00123 00124 void procFolder( IMgaFolder *folder); 00125 00126 void procModel ( IMgaModel *model); 00127 void procAtom ( IMgaAtom *atom); 00128 void procReference ( IMgaReference *reference); 00129 void procSet ( IMgaSet *set); 00130 void procConnection ( IMgaConnection *connection); 00131 void procConnPoint ( IMgaConnPoint *connpoint); 00132 00133 void procMyConnections ( IMgaFCO * fco); 00134 void procMyContainerSets ( IMgaFCO * fco); 00135 void procMyReferences ( IMgaFCO * fco); 00136 void procMyParent ( IMgaFCO * fco); 00137 void procMyParent ( IMgaFolder * fco); 00138 00139 void procMyBaseTypes ( IMgaFCO * fco); 00140 void procMyDerivedTypes ( IMgaFCO * fco); 00141 00142 bool isSimpleConnection( IMgaConnection * connection); 00143 virtual bool isValidSelection(); 00144 virtual bool isValidFCO( IMgaFCO *fco); 00145 virtual bool isValidConnection( IMgaConnection * connection); 00146 bool isInLibrary( IMgaObject * obj); 00147 00148 virtual bool postValidateSelection(); 00149 virtual bool postValidateFCO( IMgaFCO *fco); 00150 virtual bool postValidateConnection( IMgaConnection * connection); 00151 00152 bool findAmongSelected( const CComObjPtr<IMgaFCO>& in); 00153 bool findAmongSelected( const CComObjPtr<IMgaFolder>& in); 00154 bool findAmongNews( const CComObjPtr<IMgaFCO>& in); 00155 bool findAmongNews( const CComObjPtr<IMgaFolder>& in); 00156 00157 void insertNew( const std::string& id, bool is_the_top = false); 00158 void insertNew( const CComObjPtr<IMgaFCO>& in); 00159 void insertNew( const CComObjPtrVector<IMgaFCO>& in_v); 00160 void insertNew( const CComObjPtr<IMgaFolder>& in); 00161 void insertNew( const CComObjPtrVector<IMgaFolder>& in_v); 00162 void insertNew( const CComObjPtr<IMgaModel>& in); 00163 00164 template<class INTERFACE, class FUNC_INTERFACE, class COLLECTION> 00165 void insertNew(INTERFACE p, HRESULT (__stdcall FUNC_INTERFACE::*func)(COLLECTION **q)) 00166 { 00167 FUNC_INTERFACE *q = p; 00168 ASSERT( q != NULL ); 00169 00170 typedef TYPENAME_COLL2ELEM(COLLECTION) element_type; 00171 00172 CComObjPtrVector<element_type> v; 00173 COMTHROW( (q->*func)(PutOut(v)) ); 00174 00175 CComObjPtrVector<element_type>::iterator i = v.begin(); 00176 CComObjPtrVector<element_type>::iterator e = v.end(); 00177 while( i != e ) 00178 { 00179 if( m_kindFilter == -1) 00180 insertNew( *i); 00181 else 00182 { 00183 CComObjPtr<element_type> elem( *i); 00184 CComObjPtr<IMgaFolder> f; 00185 CComObjPtr<IMgaModel> m; 00186 CComObjPtr<IMgaAtom> a; 00187 CComObjPtr<IMgaSet> s; 00188 CComObjPtr<IMgaReference> r; 00189 ::QueryInterface( elem, f); 00190 ::QueryInterface( elem, m); 00191 ::QueryInterface( elem, a); 00192 ::QueryInterface( elem, s); 00193 ::QueryInterface( elem, r); 00194 00195 if( f && ( m_kindFilter & 0x1) 00196 || m && ( m_kindFilter & 0x2) 00197 || a && ( m_kindFilter & 0x4) 00198 || s && ( m_kindFilter & 0x8) 00199 || r && ( m_kindFilter & 0x10)) 00200 insertNew( *i); 00201 } 00202 00203 ++i; 00204 } 00205 } 00206 00207 protected: // variables 00208 CComPtr<IGMEOLEApp> m_GME; // to access the console 00209 00210 CComObjPtr<IMgaProject> m_project; 00211 CComObjPtr<IMgaTerritory> m_territory; 00212 00213 CComObjPtrVector<IMgaFolder> m_selFolds; // folders already in closure 00214 CComObjPtrVector<IMgaFCO> m_selFcos; // fcos already in closure 00215 00216 CComObjPtrVector<IMgaFCO> m_newlySelFcos; // will be copied into selfcos 00217 CComObjPtrVector<IMgaFolder> m_newlySelFolds; // will be copied into selfolders 00218 00219 // members used for the non-miniproject cases 00220 CComObjPtrVector<IMgaFolder> m_topFolds; // parentless (top) folders 00221 CComObjPtrVector<IMgaFCO> m_topFcos; // parentless (top) fcos 00222 00223 00224 bool m_bRefersTo; // objects references refer to 00225 bool m_bReferredBy; // references to an fco 00226 00227 bool m_bConnection; // fcos on the other end of a connection and the connections themselves 00228 bool m_bRefPortConnection; // special connections: thru reference ports 00229 00230 bool m_bSetMember; // members of a set 00231 bool m_bMemberOfSets; // all sets containing the fco 00232 00233 bool m_bContainment; // model containment, downward 00234 bool m_bPartOfModels; // model containment, upward 00235 00236 bool m_bFolderContainment; // folder containment, downward 00237 bool m_bPartOfFolders; // folder containment, upward 00238 00239 bool m_bBaseTypes; // base types of selected objects 00240 bool m_bDerivedTypes; // derived types of selected objects 00241 00242 int m_iIntoLibraries; // 0 stubs, 1 stop, 2 continue process through links that point into a library? 00243 00244 int m_iContainerOption; // wrap? 0: miniproj, 1: auto, 2: asis, 00245 00246 bool m_bDirection; // up or down? 00247 00248 int m_kindFilter; // if -1 then all kinds, otherwise bitmasking needed to calc which kinds are considered from the children 00249 int m_markWith; // if -1 then don't mark, otherwise mark all objects in closure (into registry) 00250 static const wchar_t* m_markerNode; 00251 }; 00252 00253 #endif // MAKE_CLOSURE_H