[GME-commit] GMESRC/GME/MgaUtil ClosureSimple.cpp,NONE,1.1
ClosureSimple.h,NONE,1.1 GUIDCreate.cpp,NONE,1.1
GUIDCreate.h,NONE,1.1 MakeKindClosure.cpp,NONE,1.1
MakeKindClosure.h,NONE,1.1 MakeSimpleClosure.cpp,NONE,1.1
MakeSimpleClosure.h,NONE,1.1 MakeClosure.cpp,1.14,1.15
MakeClosure.h,1.8,1.9 MgaClosure.cpp,1.7,1.8 MgaUtil.rc,1.48,1.49
MgaUtil.vcproj,1.2,1.3 resource.h,1.29,1.30
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Tue Jul 19 18:35:19 CDT 2005
- Previous message: [GME-commit] GMESRC/GME/Parser Helper.cpp,1.2,1.3 Helper.h,1.2,1.3
MgaDumper.cpp,1.25,1.26 MgaParser.h,1.12,1.13
MgaParserBC.cpp,1.6,1.7 MgaParserClosureHelper.cpp,1.3,1.4
MgaParserSC.cpp,1.5,1.6 StdAfx.h,1.3,1.4 mgaclosure.dtd,1.2,1.3
- Next message: [GME-commit] GMESRC/GME/Interfaces InterfaceVersion.h,1.61,1.62
Parser.idl,1.12,1.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /project/gme-repository/GMESRC/GME/MgaUtil
In directory escher:/tmp/cvs-serv28570
Modified Files:
MakeClosure.cpp MakeClosure.h MgaClosure.cpp MgaUtil.rc
MgaUtil.vcproj resource.h
Added Files:
ClosureSimple.cpp ClosureSimple.h GUIDCreate.cpp GUIDCreate.h
MakeKindClosure.cpp MakeKindClosure.h MakeSimpleClosure.cpp
MakeSimpleClosure.h
Log Message:
Old SmartCopy calculation saved into MakeKindClosure.cpp (CKindSelectClosure and CContainerSelectSomeKindClosure classes).
New SmartCopy calculation found in MakeSimpleClosure.cpp (CSimpleSelectClosure class).
New Dialog for SimpleClosure found in ClosureSimple.cpp
CVS User: Zoltan Molnar, ISIS (zolmol)
--- NEW FILE: ClosureSimple.h ---
#pragma once
#include "afxwin.h"
#include "resource.h"
// CClosureSimple dialog
class CClosureSimple : public CDialog
{
DECLARE_DYNAMIC(CClosureSimple)
public:
CClosureSimple(CWnd* pParent = NULL); // standard constructor
virtual ~CClosureSimple();
// Dialog Data
enum { IDD = IDD_CLOSURESIMPLECP };
bool m_enableContainChkBox;
bool m_enableFolderChkBox;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
CButton m_cont;
CButton m_foldCont;
BOOL m_bCont;
BOOL m_bFoldCont;
};
--- NEW FILE: MakeKindClosure.cpp ---
#include "stdafx.h"
#if(0) // this class is not used for smart copy anymore
#include "MakeKindClosure.h"
#include <algorithm>
//---------------------------------------------------------------------------
// C L A S S CKindSelectClosure
// previous enabler of SmartCopy
//---------------------------------------------------------------------------
bool CKindSelectClosure::isValidSelection()
{
m_peculiarFcos.clear(); // reset to prevent some data left in it
m_iniSelPath = ""; // not used currently in this class, only for the container
m_accKind = "";
checkMeta( m_selFolds, m_selFcos);// works based on the initially selected objects
getAccKindsInString( m_accKind);
return true;
}
void CKindSelectClosure::procObj( IMgaObject* obj)
{
ASSERT( obj != NULL );
//!m_bIntoLibraries <=> m_iIntoLibraries != 2
if ( m_iIntoLibraries != LIB_CONT && isInLibrary( obj)) // if no intention to step into libraries and the object is in a library then return
return;
objtype_enum objtype;
COMTHROW( obj->get_ObjType( &objtype) );
switch( objtype)
{
case OBJTYPE_FOLDER:
{
if ( m_bFolderContainment)
{
CComObjPtr<IMgaFolder> f;
COMTHROW( ::QueryInterface( obj, f) );
procFolder( f);
}
break;
}
case OBJTYPE_MODEL:
{
if ( m_bContainment)
{
CComObjPtr<IMgaModel> m;
COMTHROW( ::QueryInterface( obj, m) );
procModel( m);
}
break;
}
case OBJTYPE_REFERENCE:
{
if ( m_bRefs)
{
CComObjPtr<IMgaFCO> fco;
COMTHROW( ::QueryInterface( obj, fco) );
m_peculiarFcos.push_back( fco);
}
break;
}
case OBJTYPE_CONNECTION:
{
if ( m_bConns)
{
CComObjPtr<IMgaFCO> fco;
COMTHROW( ::QueryInterface( obj, fco) );
m_peculiarFcos.push_back( fco);
}
break;
}
case OBJTYPE_SET:
{
if ( m_bSets)
{
CComObjPtr<IMgaFCO> fco;
COMTHROW( ::QueryInterface( obj, fco) );
m_peculiarFcos.push_back( fco);
}
break;
}
default: { }
};
}
bool CKindSelectClosure::postValidateSelection()
{
return true;
}
void CKindSelectClosure::preProcess()
{
send2Console("[Smart Copy] Working...");
}
void CKindSelectClosure::postProcess()
{
// acc kinds already calculated in isValidSelection()
if( m_peculiarFcos.size() > 0)
send2Console( "[Smart Copy] The following kinds may accept the copied data: " + m_accKind + ".");
else //
send2Console( "[Smart Copy] No data copied.");
std::sort( m_peculiarFcos.begin(), m_peculiarFcos.end(), ConnsLast());
m_selFcos = m_topFcos = m_peculiarFcos;
ASSERT( m_peculiarFolds.size() == 0);
}
//---------------------------------------------------------------------------
// C L A S S CContainerSelectSomeKindClosure
//---------------------------------------------------------------------------
bool CContainerSelectSomeKindClosure::isValidSelection()
{
m_peculiarFcos.clear(); // reset to prevent some data left in it
m_iniSelPath = "";
CComBstrObj kind_name;
ASSERT( m_selFcos.size() + m_selFolds.size() == 1);
if( m_selFcos.size() + m_selFolds.size() != 1) return false;
for( unsigned int i = 0; i < m_selFcos.size(); ++i)
{
CComBSTR path;
COMTHROW( m_selFcos[i]->get_AbsPath( &path));
CopyTo( path, m_iniSelPath);
CComObjPtr<IMgaMetaFCO> k_meta;
COMTHROW( m_selFcos[i]->get_Meta( PutOut( k_meta)));
COMTHROW( k_meta->get_Name( PutOut(kind_name)) );
ASSERT( i == 0);
}
if( i == 0)
for( unsigned int j = 0; j < m_selFolds.size(); ++j)
{
CComBSTR path;
COMTHROW( m_selFolds[j]->get_AbsPath( &path));
CopyTo( path, m_iniSelPath);
CComObjPtr<IMgaMetaFolder> f_meta;
COMTHROW( m_selFolds[j]->get_MetaFolder( PutOut( f_meta)));
COMTHROW( f_meta->get_Name( PutOut(kind_name)) );
ASSERT( j == 0);
}
CopyTo( kind_name, m_accKind);// the acc kind is intended to be similar to the one and only container's kind
return true;
}
void CContainerSelectSomeKindClosure::postProcess()
{
// m_accKind already calculated in isValidSelection()
if( m_peculiarFcos.size() > 0)
send2Console( "[Smart Copy] The following container may accept the copied data: " + m_accKind + ".");
else
send2Console( "[Smart Copy] The container does not contain the kinds specified. No data copied.");
std::sort( m_peculiarFcos.begin(), m_peculiarFcos.end(), ConnsLast());
m_selFcos = m_topFcos = m_peculiarFcos;
ASSERT( m_peculiarFolds.size() == 0);
}
bool ConnsLast::operator()( const CComObjPtr<IMgaFCO>& p1, const CComObjPtr<IMgaFCO>& p2) const
{
// used for sort. 1st rule: Connections will be put in the back of the vector
// 2nd rule: if the two elements are both connections or none of them is connection then sort on ID
// returns true if p1 precedes p2
objtype_enum objtype1, objtype2;
COMTHROW( p1->get_ObjType( &objtype1));
COMTHROW( p2->get_ObjType( &objtype2));
bool c1 = objtype1 == OBJTYPE_CONNECTION;
bool c2 = objtype2 == OBJTYPE_CONNECTION;
if( c1 && c2 || !c1 && !c2)
{
//return true;// the predicate must be a strict weak ordering, so let's compare the IDs
CComBstrObj bstr1, bstr2;
COMTHROW( p1->get_ID( PutOut( bstr1)));
COMTHROW( p2->get_ID( PutOut( bstr2)));
return bstr1.Compare( bstr2) < 0;
}
else if( c2) // && !c1
return true;
else // c1
return false;
}
#endif
Index: resource.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/resource.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** resource.h 6 Jul 2005 22:11:29 -0000 1.29
--- resource.h 19 Jul 2005 17:35:17 -0000 1.30
***************
*** 58,61 ****
--- 58,62 ----
#define IDC_CHECK1 2004
#define IDD_METADLG 2005
+ #define IDC_CHECK6 2005
#define IDR_MGAREGISTRAR 2006
#define IDD_GMEDLG 2007
***************
*** 92,95 ****
--- 93,97 ----
#define IDD_CLOSURESMARTCP 2067
#define IDD_CLOSUREKINDSEL 2069
+ #define IDD_CLOSURESIMPLECP 2070
#define IDR_COMPONENTPROXY 2090
#define IDC_PROGRESS1 2150
***************
*** 204,208 ****
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
! #define _APS_NEXT_RESOURCE_VALUE 2070
#define _APS_NEXT_COMMAND_VALUE 32778
#define _APS_NEXT_CONTROL_VALUE 2262
--- 206,210 ----
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
! #define _APS_NEXT_RESOURCE_VALUE 2071
#define _APS_NEXT_COMMAND_VALUE 32778
#define _APS_NEXT_CONTROL_VALUE 2262
Index: MakeClosure.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MakeClosure.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** MakeClosure.cpp 8 Jun 2005 00:02:49 -0000 1.14
--- MakeClosure.cpp 19 Jul 2005 17:35:17 -0000 1.15
***************
*** 1495,1499 ****
COMTHROW( m_project->CreateTerritory(NULL, PutOut(m_territory), NULL) );
! COMTHROW( m_project->BeginTransaction(m_territory, TRANSACTION_READ_ONLY) );
m_GME = get_GME(m_project);
--- 1495,1500 ----
COMTHROW( m_project->CreateTerritory(NULL, PutOut(m_territory), NULL) );
! // needs write access, when guids are created for all objects in the closure
! COMTHROW( m_project->BeginTransaction(m_territory, TRANSACTION_GENERAL) );
m_GME = get_GME(m_project);
***************
*** 1627,1825 ****
if( m_GME) m_GME->ConsoleMessage( bstr, MSG_INFO);
else ASSERT(0);// m_GME is not valid
- }
-
- //---------------------------------------------------------------------------
- // C L A S S CKindSelectClosure
- //---------------------------------------------------------------------------
- bool CKindSelectClosure::isValidSelection()
- {
- m_peculiarFcos.clear(); // reset to prevent some data left in it
- m_iniSelPath = ""; // not used currently in this class, only for the container
- m_accKind = "";
-
- checkMeta( m_selFolds, m_selFcos);// works based on the initially selected objects
-
- getAccKindsInString( m_accKind);
-
- return true;
- }
-
- void CKindSelectClosure::procObj( IMgaObject* obj)
- {
- ASSERT( obj != NULL );
- //!m_bIntoLibraries <=> m_iIntoLibraries != 2
- if ( m_iIntoLibraries != LIB_CONT && isInLibrary( obj)) // if no intention to step into libraries and the object is in a library then return
- return;
-
- objtype_enum objtype;
- COMTHROW( obj->get_ObjType( &objtype) );
-
- switch( objtype)
- {
- case OBJTYPE_FOLDER:
- {
- if ( m_bFolderContainment)
- {
- CComObjPtr<IMgaFolder> f;
- COMTHROW( ::QueryInterface( obj, f) );
- procFolder( f);
- }
- break;
- }
-
- case OBJTYPE_MODEL:
- {
- if ( m_bContainment)
- {
- CComObjPtr<IMgaModel> m;
- COMTHROW( ::QueryInterface( obj, m) );
-
- procModel( m);
- }
- break;
- }
-
- case OBJTYPE_REFERENCE:
- {
- if ( m_bRefs)
- {
- CComObjPtr<IMgaFCO> fco;
- COMTHROW( ::QueryInterface( obj, fco) );
- m_peculiarFcos.push_back( fco);
- }
- break;
- }
-
- case OBJTYPE_CONNECTION:
- {
- if ( m_bConns)
- {
- CComObjPtr<IMgaFCO> fco;
- COMTHROW( ::QueryInterface( obj, fco) );
- m_peculiarFcos.push_back( fco);
- }
- break;
- }
-
- case OBJTYPE_SET:
- {
- if ( m_bSets)
- {
- CComObjPtr<IMgaFCO> fco;
- COMTHROW( ::QueryInterface( obj, fco) );
- m_peculiarFcos.push_back( fco);
- }
- break;
- }
-
- default: { }
- };
- }
-
- bool CKindSelectClosure::postValidateSelection()
- {
- return true;
- }
-
- void CKindSelectClosure::preProcess()
- {
- send2Console("[Smart Copy] Working...");
- }
-
- void CKindSelectClosure::postProcess()
- {
- // acc kinds already calculated in isValidSelection()
- if( m_peculiarFcos.size() > 0)
- send2Console( "[Smart Copy] The following kinds may accept the copied data: " + m_accKind + ".");
- else //
- send2Console( "[Smart Copy] No data copied.");
-
-
- std::sort( m_peculiarFcos.begin(), m_peculiarFcos.end(), ConnsLast());
-
- m_selFcos = m_topFcos = m_peculiarFcos;
- ASSERT( m_peculiarFolds.size() == 0);
- }
-
- //---------------------------------------------------------------------------
- // C L A S S CContainerSelectSomeKindClosure
- //---------------------------------------------------------------------------
- bool CContainerSelectSomeKindClosure::isValidSelection()
- {
- m_peculiarFcos.clear(); // reset to prevent some data left in it
- m_iniSelPath = "";
-
- CComBstrObj kind_name;
- ASSERT( m_selFcos.size() + m_selFolds.size() == 1);
- if( m_selFcos.size() + m_selFolds.size() != 1) return false;
-
- for( unsigned int i = 0; i < m_selFcos.size(); ++i)
- {
- CComBSTR path;
- COMTHROW( m_selFcos[i]->get_AbsPath( &path));
- CopyTo( path, m_iniSelPath);
-
- CComObjPtr<IMgaMetaFCO> k_meta;
- COMTHROW( m_selFcos[i]->get_Meta( PutOut( k_meta)));
- COMTHROW( k_meta->get_Name( PutOut(kind_name)) );
-
- ASSERT( i == 0);
- }
-
- if( i == 0)
- for( unsigned int j = 0; j < m_selFolds.size(); ++j)
- {
- CComBSTR path;
- COMTHROW( m_selFolds[j]->get_AbsPath( &path));
- CopyTo( path, m_iniSelPath);
-
- CComObjPtr<IMgaMetaFolder> f_meta;
- COMTHROW( m_selFolds[j]->get_MetaFolder( PutOut( f_meta)));
- COMTHROW( f_meta->get_Name( PutOut(kind_name)) );
-
- ASSERT( j == 0);
- }
-
- CopyTo( kind_name, m_accKind);// the acc kind is intended to be similar to the one and only container's kind
-
- return true;
- }
-
- void CContainerSelectSomeKindClosure::postProcess()
- {
- // m_accKind already calculated in isValidSelection()
- if( m_peculiarFcos.size() > 0)
- send2Console( "[Smart Copy] The following container may accept the copied data: " + m_accKind + ".");
- else
- send2Console( "[Smart Copy] The container does not contain the kinds specified. No data copied.");
-
- std::sort( m_peculiarFcos.begin(), m_peculiarFcos.end(), ConnsLast());
-
- m_selFcos = m_topFcos = m_peculiarFcos;
- ASSERT( m_peculiarFolds.size() == 0);
- }
-
- bool ConnsLast::operator()( const CComObjPtr<IMgaFCO>& p1, const CComObjPtr<IMgaFCO>& p2) const
- {
- // used for sort. 1st rule: Connections will be put in the back of the vector
- // 2nd rule: if the two elements are both connections or none of them is connection then sort on ID
- // returns true if p1 precedes p2
-
- objtype_enum objtype1, objtype2;
- COMTHROW( p1->get_ObjType( &objtype1));
- COMTHROW( p2->get_ObjType( &objtype2));
- bool c1 = objtype1 == OBJTYPE_CONNECTION;
- bool c2 = objtype2 == OBJTYPE_CONNECTION;
- if( c1 && c2 || !c1 && !c2)
- {
- //return true;// the predicate must be a strict weak ordering, so let's compare the IDs
- CComBstrObj bstr1, bstr2;
- COMTHROW( p1->get_ID( PutOut( bstr1)));
- COMTHROW( p2->get_ID( PutOut( bstr2)));
- return bstr1.Compare( bstr2) < 0;
- }
- else if( c2) // && !c1
- return true;
- else // c1
- return false;
}
--- 1628,1630 ----
Index: MgaClosure.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MgaClosure.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MgaClosure.cpp 12 Apr 2005 23:37:31 -0000 1.7
--- MgaClosure.cpp 19 Jul 2005 17:35:17 -0000 1.8
***************
*** 6,9 ****
--- 6,11 ----
#include "ClosureSmart.h"
#include "MakeClosure.h"
+ #include "ClosureSimple.h"
+ #include "MakeSimpleClosure.h"
STDMETHODIMP CMgaClosure::SelectiveClosureDlg
***************
*** 167,249 ****
STDMETHODIMP CMgaClosure::SmartCopy(
! IMgaFCOs *in_fcos, IMgaFolders *in_folders,
! IMgaFCOs **sel_fcos, IMgaFolders **sel_folders,
! IMgaFCOs **top_fcos, IMgaFolders **top_folders,
! int options_in,
! long *pOptions,
! BSTR *accept,
! BSTR *path
)
{
AFX_MANAGE_STATE( AfxGetStaticModuleState());
! ASSERT( pOptions);
! bool res;
CWaitCursor w;
! CClosureSmart dlg;
! CKindSelectClosure *mc;
!
! bool any_container = (options_in & 1024) == 1024; // container (model, folder)
! if( any_container)
! {
! dlg.m_disable = false;
!
! res = dlg.DoModal() == IDOK;
! mc = new CContainerSelectSomeKindClosure
! ( in_fcos
! , in_folders
! , dlg.m_bRefs
! , dlg.m_bConns
! , dlg.m_bSets
! );
! }
! else
! {
! dlg.m_disable = true;
! dlg.m_bRefs = (options_in & 2048) == 2048; // is any ref
! dlg.m_bSets = (options_in & 4096) == 4096; // is any set
! dlg.m_bConns = (options_in & 8192) == 8192; // is any conn
! res = dlg.DoModal() == IDOK;
! mc = new CKindSelectClosure
! ( in_fcos
! , in_folders
! , dlg.m_bRefs
! , dlg.m_bConns
! , dlg.m_bSets
! );
! }
if( res)
{
! mc->process(); // do the hard job
// load the results
! mc->getFCOs( sel_fcos);
! mc->getFolders( sel_folders);
! bool normal_tops = !mc->noTopObjs();
if( normal_tops) // the top fcos/folds is calculated and The RootFolder is not among them
{
! mc->getTopFCOs( top_fcos);
! mc->getTopFolders( top_folders);
}
! *pOptions = 0;
//*pOptions = (dlg.m_libraryHandling == 0)?0x1:0; // in case of "stubs" set the options to 1
! *pOptions = (LIB_STUBS == 0)?0x1:0; // in case of "stubs" set the options to 1
! *pOptions = *pOptions | 0x2; // dump the closure2 like attributes
! *pOptions = *pOptions | 0x4; // smart copy signal
! CComBSTR acckind = mc->m_accKind.c_str();
! *accept = acckind.Detach();
! CComBSTR name = mc->m_iniSelPath.c_str();
! *path = name.Detach();
! }
! delete mc;
return S_OK;
--- 169,234 ----
STDMETHODIMP CMgaClosure::SmartCopy(
! IMgaFCOs *p_fcosIn, IMgaFolders *p_foldersIn,
! IMgaFCOs **p_fcosSelOut, IMgaFolders **p_foldersSelOut,
! IMgaFCOs **p_topFcosOut, IMgaFolders **p_topFoldersOut,
! int p_optionsIn,
! long *p_optionsOut,
! BSTR *p_accept,
! BSTR *p_path
)
{
AFX_MANAGE_STATE( AfxGetStaticModuleState());
! ASSERT( p_optionsOut);
! bool res = true;
CWaitCursor w;
! CClosureSimple dlg;
! bool any_cont = (p_optionsIn & 1024) == 1024; // is any container
! bool any_fold = (p_optionsIn & 16384) == 16384; // is any folder
! dlg.m_enableContainChkBox = any_cont;
! dlg.m_enableFolderChkBox = any_fold;
! // remain silent if no user interaction needed really
! if( any_cont) res = dlg.DoModal() == IDOK;
if( res)
{
! CSimpleSelectClosure mc
! ( p_fcosIn
! , p_foldersIn
! , dlg.m_bCont // need containment?
! , dlg.m_bFoldCont // need folder containment?
! );
!
! mc.process(); // do the hard job
// load the results
! mc.getFCOs( p_fcosSelOut);
! mc.getFolders( p_foldersSelOut);
! bool normal_tops = !mc.noTopObjs();
if( normal_tops) // the top fcos/folds is calculated and The RootFolder is not among them
{
! mc.getTopFCOs( p_topFcosOut);
! mc.getTopFolders( p_topFoldersOut);
}
! *p_optionsOut = 0;
//*pOptions = (dlg.m_libraryHandling == 0)?0x1:0; // in case of "stubs" set the options to 1
! *p_optionsOut = (LIB_STUBS == 0)?0x1:0; // in case of "stubs" set the options to 1
! *p_optionsOut = *p_optionsOut | 0x2; // dump the closure2 like attributes
! *p_optionsOut = *p_optionsOut | 0x4; // smart copy signal
! std::string res_str;
! mc.getAccKindsInString( res_str);
! CComBSTR acckind = res_str.c_str();
! *p_accept = acckind.Detach();
! CComBSTR name;
! *p_path = name.Detach();
! }
return S_OK;
--- NEW FILE: MakeSimpleClosure.h ---
#ifndef SIMPLE_CLOSURE_H
#define SIMPLE_CLOSURE_H
#include "MakeClosure.h"
class CSimpleSelectClosure : public CMakeClosure
{
public:
CSimpleSelectClosure
( IMgaFCOs *fcos
, IMgaFolders *fols
, int containment
, int folder_containment
)
: CMakeClosure
( fcos
, fols
, 0 //ref
, 0 //refd
, 0 //conn
, 0 //refportconn
, 0 //set_mem
, 0 //mem_of_set
, containment //cont
, 0 //part_of_mod
, folder_containment //fold_cont
, 0 //part_of_fold
, 0 //base_type
, 0 //derived_type
, LIB_CONT //into_libr
, 3 //container_opt( 3)
, 1 //direction_opt
, -1 //all kinds
)
{ }
~CSimpleSelectClosure()
{
}
/*virtual*/ bool isValidSelection();
/*virtual*/ void procObj( IMgaObject* obj);
/*virtual*/ void preProcess();
/*virtual*/ void postProcess();
void manageGuid( CComObjPtr<IMgaObject> obj);
protected:
};
struct ConnsAndDerivsLast
{
bool operator()( const CComObjPtr<IMgaFCO>& p1, const CComObjPtr<IMgaFCO>& p2) const;
};
#endif // SIMPLE_CLOSURE_H
--- NEW FILE: MakeSimpleClosure.cpp ---
#include "stdafx.h"
#include "MakeSimpleClosure.h"
#include "GUIDCreate.h"
#include <algorithm>
//---------------------------------------------------------------------------
// C L A S S CSimpleSelectClosure
// enabler of SmartCopy
//---------------------------------------------------------------------------
#define GLOBAL_ID_STR "guid"
bool CSimpleSelectClosure::isValidSelection()
{
// be more permissive than the base class
// allows connections thru refport also
return true;
}
void CSimpleSelectClosure::manageGuid( CComObjPtr<IMgaObject> object)
{
if( object)
{
CComObjPtr<IMgaRegNode> regnode;
CComObjPtr<IMgaFCO> fco;
object.QueryInterface( fco);
if( fco) COMTHROW( fco->get_RegistryNode( CComBSTR( GLOBAL_ID_STR), PutOut( regnode)));
else
{
CComObjPtr<IMgaFolder> folder;
object.QueryInterface( folder);
if( folder) COMTHROW( folder->get_RegistryNode( CComBSTR( GLOBAL_ID_STR), PutOut( regnode)));
else ASSERT(0);
}
// in case object is in Library, do not write anything into registry
VARIANT_BOOL vbLibrary;
COMTHROW( object->get_IsLibObject( &vbLibrary ) );
if( regnode && !vbLibrary)
{
long status;
COMTHROW( regnode->get_Status(&status) );
if( status != ATTSTATUS_HERE) //UNDEFINED, METADEF, INVALID, ARCHETYPE1,2,...
COMTHROW( regnode->put_Value( GuidCreate::newGuid()));
}
}
}
// there is not much magic: process down the hierarchy (folders and models)
void CSimpleSelectClosure::procObj( IMgaObject* obj)
{
ASSERT( obj != NULL );
//!m_bIntoLibraries <=> m_iIntoLibraries != 2
//if ( m_iIntoLibraries != LIB_CONT && isInLibrary( obj)) // if no intention to step into libraries and the object is in a library then return
// return;
// library elements are handled the same way as the usual objects,
// except no guids are stored in their registry
objtype_enum objtype;
COMTHROW( obj->get_ObjType( &objtype) );
switch( objtype)
{
case OBJTYPE_FOLDER:
{
if ( m_bFolderContainment)
{
CComObjPtr<IMgaFolder> f;
COMTHROW( ::QueryInterface( obj, f) );
procFolder( f);
manageGuid( obj);
}
break;
}
case OBJTYPE_MODEL:
{
if ( m_bContainment)
{
CComObjPtr<IMgaModel> m;
COMTHROW( ::QueryInterface( obj, m) );
procModel( m);
manageGuid( obj);
}
break;
}
case OBJTYPE_ATOM:
case OBJTYPE_REFERENCE:
case OBJTYPE_CONNECTION:
case OBJTYPE_SET:
default: {
manageGuid( obj);
}
};
}
void CSimpleSelectClosure::preProcess()
{
send2Console("[Smart Copy] Working...");
}
void CSimpleSelectClosure::postProcess()
{
// sort the elements based on: basetypes first, connections last rule
std::sort( m_selFcos.begin(), m_selFcos.end(), ConnsAndDerivsLast());
selectTop(); // calculate the parentless objects
autoWrap(); // wrapping (resets the Top values)
// normally if objects selected from the View
// would not wrap much
// if initial objects selected from the activebrowser
// it might have to do something
checkMeta( m_topFolds, m_topFcos); // calculate the accepting kind
std::string res_str;
getAccKindsInString( res_str);
if( !res_str.empty()) send2Console( "[Smart Copy] The following kinds may accept the copied data: " + res_str + ".");
else send2Console( "[Smart Copy] Possible accepting kind not found based on the meta.");
}
bool ConnsAndDerivsLast::operator()( const CComObjPtr<IMgaFCO>& p1, const CComObjPtr<IMgaFCO>& p2) const
{
// used for sort.
// 0th rule: derived types will be put after the archetypes
// 1st rule: Connections will be put in the back of the vector
// 2nd rule: if the two elements are both connections or none of them is connection then sort on ID
// returns true if p1 precedes p2
objtype_enum objtype1, objtype2;
CComObjPtr<IMgaFCO> bas1, bas2;
COMTHROW( p1->get_ArcheType( PutOut(bas1))); // returns 0 for archetypes
COMTHROW( p2->get_ArcheType( PutOut(bas2)));
bool p1_is_der = bas1 != 0;
bool p2_is_der = bas2 != 0;
COMTHROW( p1->get_ObjType( &objtype1));
COMTHROW( p2->get_ObjType( &objtype2));
// compare on deriv or not?
bool sim = objtype1 == objtype2;
if( sim && p1_is_der != p2_is_der)
return p2_is_der;//IF p1 is F, p2 is T ->ret true, IF p1 is T, p2 is F ->ret false
// sim is F or p1_is_der == p2_is_der
// compare on conn or not?
bool c1 = objtype1 == OBJTYPE_CONNECTION;
bool c2 = objtype2 == OBJTYPE_CONNECTION;
if( c1 == c2)
{
//return true;// the predicate must be a strict weak ordering, so let's compare the IDs
CComBstrObj bstr1, bstr2;
COMTHROW( p1->get_ID( PutOut( bstr1)));
COMTHROW( p2->get_ID( PutOut( bstr2)));
return bstr1.Compare( bstr2) < 0;
}
else
return c2; // IF c2 is T, c1 is F -> ret true, IF c2 is F, c1 is T ->ret false
}
--- NEW FILE: GUIDCreate.cpp ---
#include "stdafx.h"
#include "GUIDCreate.h"
/*static*/ const char * GuidCreate::format_str = "{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}";
CComBSTR GuidCreate::newGuid()
{
CString res;
GUID t_guid = GUID_NULL;
::CoCreateGuid(&t_guid);
if (t_guid != GUID_NULL)
{
res.Format(format_str,
t_guid.Data1, t_guid.Data2, t_guid.Data3,
t_guid.Data4[0], t_guid.Data4[1], t_guid.Data4[2], t_guid.Data4[3],
t_guid.Data4[4], t_guid.Data4[5], t_guid.Data4[6], t_guid.Data4[7]);
} // else send blank
return CComBSTR(res);
}
--- NEW FILE: ClosureSimple.cpp ---
// ClosureSimple.cpp : implementation file
//
#include "stdafx.h"
#include "MgaUtil.h"
#include "ClosureSimple.h"
// CClosureSimple dialog
IMPLEMENT_DYNAMIC(CClosureSimple, CDialog)
CClosureSimple::CClosureSimple(CWnd* pParent /*=NULL*/)
: CDialog(CClosureSimple::IDD, pParent)
, m_enableContainChkBox( true)
, m_enableFolderChkBox( true)
, m_bCont(FALSE)
, m_bFoldCont(FALSE)
{
}
CClosureSimple::~CClosureSimple()
{
}
void CClosureSimple::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CHECK1, m_cont);
DDX_Control(pDX, IDC_CHECK6, m_foldCont);
DDX_Check(pDX, IDC_CHECK1, m_bCont);
DDX_Check(pDX, IDC_CHECK6, m_bFoldCont);
}
BEGIN_MESSAGE_MAP(CClosureSimple, CDialog)
END_MESSAGE_MAP()
// CClosureSimple message handlers
BOOL CClosureSimple::OnInitDialog()
{
m_bCont = m_enableContainChkBox?TRUE:FALSE;
m_bFoldCont = m_enableContainChkBox && m_enableFolderChkBox?TRUE:FALSE;
UpdateData( FALSE);
CDialog::OnInitDialog();
m_cont.EnableWindow( m_enableContainChkBox);
m_foldCont.EnableWindow( m_enableContainChkBox && m_enableFolderChkBox);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Index: MgaUtil.rc
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MgaUtil.rc,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** MgaUtil.rc 6 Jul 2005 22:11:57 -0000 1.48
--- MgaUtil.rc 19 Jul 2005 17:35:17 -0000 1.49
***************
*** 563,566 ****
--- 563,581 ----
END
+ IDD_CLOSURESIMPLECP DIALOGEX 0, 0, 186, 55
+ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+ CAPTION "Smart Copy"
+ FONT 8, "MS Shell Dlg", 400, 0, 0x1
+ BEGIN
+ DEFPUSHBUTTON "OK",IDOK,129,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
+ CONTROL "Containment",IDC_CHECK1,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,16,16,79,10
+ CONTROL "Folder Containment",IDC_CHECK6,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,16,33,79,10
+ GROUPBOX "Process down through",IDC_STATIC,7,3,109,46
+ END
+
#ifdef APSTUDIO_INVOKED
***************
*** 799,802 ****
--- 814,825 ----
TOPMARGIN, 7
BOTTOMMARGIN, 88
+ END
+
+ IDD_CLOSURESIMPLECP, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 48
END
END
Index: MgaUtil.vcproj
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MgaUtil.vcproj,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MgaUtil.vcproj 6 Jul 2005 22:11:29 -0000 1.2
--- MgaUtil.vcproj 19 Jul 2005 17:35:17 -0000 1.3
***************
*** 343,346 ****
--- 343,349 ----
</File>
<File
+ RelativePath=".\ClosureSimple.cpp">
+ </File>
+ <File
RelativePath="ClosureSmart.cpp">
<FileConfiguration
***************
*** 619,622 ****
--- 622,628 ----
</File>
<File
+ RelativePath=".\GUIDCreate.cpp">
+ </File>
+ <File
RelativePath="MakeClosure.cpp">
<FileConfiguration
***************
*** 640,643 ****
--- 646,655 ----
</File>
<File
+ RelativePath=".\MakeKindClosure.cpp">
+ </File>
+ <File
+ RelativePath=".\MakeSimpleClosure.cpp">
+ </File>
+ <File
RelativePath="MetaDlg.cpp">
<FileConfiguration
***************
*** 1095,1098 ****
--- 1107,1113 ----
</File>
<File
+ RelativePath=".\ClosureSimple.h">
+ </File>
+ <File
RelativePath="ClosureSmart.h">
</File>
***************
*** 1131,1135 ****
--- 1146,1159 ----
</File>
<File
+ RelativePath=".\GUIDCreate.h">
+ </File>
+ <File
RelativePath="MakeClosure.h">
+ </File>
+ <File
+ RelativePath=".\MakeKindClosure.h">
+ </File>
+ <File
+ RelativePath=".\MakeSimpleClosure.h">
</File>
<File
--- NEW FILE: GUIDCreate.h ---
#ifndef GUIDCREATE_H
#define GUIDCREATE_H
class GuidCreate
{
public:
static const char * format_str;
static CComBSTR newGuid();
};
#endif //GUIDCREATE_H
Index: MakeClosure.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaUtil/MakeClosure.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** MakeClosure.h 26 Jan 2005 17:30:52 -0000 1.8
--- MakeClosure.h 19 Jul 2005 17:35:17 -0000 1.9
***************
*** 244,339 ****
};
! class CKindSelectClosure : public CMakeClosure
! {
! public:
! CKindSelectClosure
! ( IMgaFCOs *fcos
! , IMgaFolders *fols
! , int refs = 1
! , int conns = 1
! , int sets = 1
! )
! : CMakeClosure
! ( fcos
! , fols
! , 0 //ref
! , 0 //refd
! , 0 //conn
! , 0 //refportconn
! , 0 //set_mem
! , 0 //mem_of_set
! , 1 //cont
! , 0 //part_of_mod
! , 1 //fold_cont
! , 0 //part_of_fold
! , 0 //base_type
! , 0 //derived_type
! , LIB_STUBS //into_libr
! , 3 //container_opt( 3)
! , 1 //direction_opt
! , -1 //all kinds
! )
! , m_bRefs( refs == 1)
! , m_bConns( conns == 1)
! , m_bSets( sets == 1)
! , m_peculiarFolds()
! , m_peculiarFcos()
! { }
!
! ~CKindSelectClosure()
! {
! m_peculiarFolds.clear();
! m_peculiarFcos.clear();
! }
!
! /*void getSpecFCOs( IMgaFCOs **spec_fcos);
! void getSpecFolders( IMgaFolders **spec_folds);*/
!
! /*virtual*/ void procObj( IMgaObject* obj);
! /*virtual*/ bool isValidSelection();
! /*virtual*/ bool postValidateSelection();
! /*virtual*/ void preProcess();
! /*virtual*/ void postProcess();
! std::string m_iniSelPath;
! std::string m_accKind; // to store the special container kind the closure has been initiated from
! protected:
! bool m_bRefs;
! bool m_bConns;
! bool m_bSets;
!
! CComObjPtrVector<IMgaFolder> m_peculiarFolds;
! CComObjPtrVector<IMgaFCO> m_peculiarFcos;
! };
!
!
! class CContainerSelectSomeKindClosure : public CKindSelectClosure
! {
! public:
! CContainerSelectSomeKindClosure
! ( IMgaFCOs *fcos
! , IMgaFolders *fols
! , int refs = 1
! , int conns = 1
! , int sets = 1
! )
! : CKindSelectClosure
! ( fcos
! , fols
! , refs
! , conns
! , sets
! )
! { }
!
! /*virtual*/ bool isValidSelection();
! /*virtual*/ void postProcess();
! protected:
!
! };
!
! struct ConnsLast
! {
! bool operator()( const CComObjPtr<IMgaFCO>& p1, const CComObjPtr<IMgaFCO>& p2) const;
! };
!
! #endif // MAKE_CLOSURE_H
\ No newline at end of file
--- 244,246 ----
};
! #endif // MAKE_CLOSURE_H
--- NEW FILE: MakeKindClosure.h ---
#if(0) // this class is not used for smart copy anymore
#ifndef KIND_CLOSURE_H
#define KIND_CLOSURE_H
#include "MakeClosure.h"
class CKindSelectClosure : public CMakeClosure
{
public:
CKindSelectClosure
( IMgaFCOs *fcos
, IMgaFolders *fols
, int refs = 1
, int conns = 1
, int sets = 1
)
: CMakeClosure
( fcos
, fols
, 0 //ref
, 0 //refd
, 0 //conn
, 0 //refportconn
, 0 //set_mem
, 0 //mem_of_set
, 1 //cont
, 0 //part_of_mod
, 1 //fold_cont
, 0 //part_of_fold
, 0 //base_type
, 0 //derived_type
, LIB_STUBS //into_libr
, 3 //container_opt( 3)
, 1 //direction_opt
, -1 //all kinds
)
, m_bRefs( refs == 1)
, m_bConns( conns == 1)
, m_bSets( sets == 1)
, m_peculiarFolds()
, m_peculiarFcos()
{ }
~CKindSelectClosure()
{
m_peculiarFolds.clear();
m_peculiarFcos.clear();
}
/*void getSpecFCOs( IMgaFCOs **spec_fcos);
void getSpecFolders( IMgaFolders **spec_folds);*/
/*virtual*/ void procObj( IMgaObject* obj);
/*virtual*/ bool isValidSelection();
/*virtual*/ bool postValidateSelection();
/*virtual*/ void preProcess();
/*virtual*/ void postProcess();
std::string m_iniSelPath;
std::string m_accKind; // to store the special container kind the closure has been initiated from
protected:
bool m_bRefs;
bool m_bConns;
bool m_bSets;
CComObjPtrVector<IMgaFolder> m_peculiarFolds;
CComObjPtrVector<IMgaFCO> m_peculiarFcos;
};
class CContainerSelectSomeKindClosure : public CKindSelectClosure
{
public:
CContainerSelectSomeKindClosure
( IMgaFCOs *fcos
, IMgaFolders *fols
, int refs = 1
, int conns = 1
, int sets = 1
)
: CKindSelectClosure
( fcos
, fols
, refs
, conns
, sets
)
{ }
/*virtual*/ bool isValidSelection();
/*virtual*/ void postProcess();
protected:
};
struct ConnsLast
{
bool operator()( const CComObjPtr<IMgaFCO>& p1, const CComObjPtr<IMgaFCO>& p2) const;
};
#endif // KIND_CLOSURE_H
#endif
- Previous message: [GME-commit] GMESRC/GME/Parser Helper.cpp,1.2,1.3 Helper.h,1.2,1.3
MgaDumper.cpp,1.25,1.26 MgaParser.h,1.12,1.13
MgaParserBC.cpp,1.6,1.7 MgaParserClosureHelper.cpp,1.3,1.4
MgaParserSC.cpp,1.5,1.6 StdAfx.h,1.3,1.4 mgaclosure.dtd,1.2,1.3
- Next message: [GME-commit] GMESRC/GME/Interfaces InterfaceVersion.h,1.61,1.62
Parser.idl,1.12,1.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the GME-commit
mailing list