1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
27 /////////////////////////////////////////////////////////////////////////////
28 //===========================================================================
29 //#####DESCRIPTIONBEGIN####
36 // Description: interface of the CConfigToolDoc class
43 //####DESCRIPTIONEND####
45 //===========================================================================
47 #if !defined(AFX_ConfigToolDOC_H__A4845246_05EE_11D2_80BE_00A0C949ADAC__INCLUDED_)
48 #define AFX_ConfigToolDOC_H__A4845246_05EE_11D2_80BE_00A0C949ADAC__INCLUDED_
52 #endif // _MSC_VER >= 1000
54 #define INCLUDEFILE <string>
55 #include "IncludeSTL.h"
56 #define INCLUDEFILE "cdl.hxx"
57 #include "IncludeSTL.h"
59 #include "memmap.h" // for mem_map
61 #include "ConfigTool.h"
68 class CProjectManager;
70 class CConfigToolDoc {
72 static LPCTSTR CALLBACK GetFn (void *pObj) { return (LPCTSTR)*(CString *)pObj; }
73 static void CALLBACK PutFn (void *pObj,LPCTSTR psz) { *(CString *)pObj=psz; }
75 class CConfigToolDoc : public CDocument {
77 DECLARE_DYNCREATE(CConfigToolDoc)
82 static void CdlParseErrorHandler (std::string message);
83 static void CdlParseWarningHandler (std::string message);
85 // ctors and dtors: public for benefit of plugin case
87 virtual ~CConfigToolDoc();
89 void RegenerateData();
92 // These are mostly relevant to the properties view, which will generally ignore them unless
93 // the pHint matches what it is currently displaying (i.e. the last SelChanged message)
94 enum {SelChanged=1,IntFormatChanged=2,ValueChanged=3, Clear=4, AllSaved=6, NameFormatChanged=7, ExternallyChanged=8, MemLayoutChanged=9};
96 enum {Never=0, Immediate=1, Deferred=2, SuggestFixes=4};
97 int m_nRuleChecking; // OR of above values
99 // Configuration items
100 CConfigItem * FirstItem(){return ItemCount()==0?NULL:Item(0);}
101 CConfigItem *Item(int nIndex){ return (CConfigItem *)m_arItem[nIndex];}
102 int ItemCount(){ return m_arItem.GetSize();}
104 void SelectTemplate (std::string NewTemplate, std::string NewTemplateVersion);
105 void SelectHardware (std::string NewTemplate);
107 void SelectPackages ();
108 CString GetPackageName (const CString & strAlias);
112 CString strSelectedSection;
113 CString strSelectedRegion;
114 bool SwitchMemoryLayout (BOOL bNewTargetPlatform);
115 bool SaveMemoryMap();
117 const CFileName BuildTree() const { return m_strBuildTree; }
118 const CFileName InstallTree() const { return m_strInstallTree; }
119 const CFileName HeadersDir() const { return InstallTree()+_T("include"); }
120 const CFileName ObjectDir() const { return BuildTree()+_T("obj"); }
121 const CFileName MLTDir ();
122 const CFileName DocBase() const { return Repository()+_T("doc"); }
124 void SetBuildTree (LPCTSTR pszBuild) { m_strBuildTree=pszBuild; }
125 void SetInstallTree (LPCTSTR pszInstall) { m_strInstallTree=pszInstall; }
127 void UpdateFailingRuleCount();
128 bool GetRunPlatform (CString &strTarget);
130 bool SetEnabled (CConfigItem &ti, bool bEnabled, CdlTransaction transaction=NULL);
131 bool SetValue(CConfigItem &ti,ItemIntegerType nValue, CdlTransaction transaction=NULL);
132 bool SetValue(CConfigItem &ti,const CString &strValue, CdlTransaction transaction=NULL);
133 bool SetValue (CConfigItem &ti, double dValue, CdlTransaction transaction=NULL);
134 CString GetDefaultHardware ();
138 WhereType m_nFindWhere;
144 bool ShowURL (LPCTSTR pszURL);
145 static const CFileName &DefaultExternalBrowser ();
147 // Absolute path name to root of respository - parent of PackagesDir below
148 const CFileName Repository() const { return m_strRepository; }
149 void SetRepository(LPCTSTR pszRepository) { m_strRepository=CFileName(pszRepository); }
151 // Absolute path name to "packages" directory - i.e. the one under the repository
152 // named "packages" in a delivery or "ecc" in CVS:
153 const CFileName PackagesDir() const { return m_strPackagesDir; }
155 CConfigItem * Find (const CString &strWhat,WhereType where=InMacro);
156 CConfigItem * Find (CdlValuable v);
158 const CFileName CurrentLinkerScript();
159 const CString CurrentStartup();
160 const CString CurrentTestingIdentifier();
161 const CString CurrentPlatform();
162 const CString CurrentMemoryLayout ();
163 CFileName m_strMemoryLayoutFolder;
164 CFileName m_strLinkerScriptFolder;
165 const CFileName CurrentPlatformPackageFolder();
166 bool OpenRepository(LPCTSTR pszRepository=NULL,bool bPromptInitially=false);
167 void CloseRepository();
168 CdlPackagesDatabase GetCdlPkgData () { return m_CdlPkgData; }
169 CdlConfiguration GetCdlConfig () { return m_CdlConfig; }
170 CdlInterpreter GetCdlInterpreter() { return m_CdlInterp; }
171 std::string GetTemplateVersion() { return m_template_version; }
173 bool UpdateBuildInfo(bool bFirstTime=false);
174 CdlBuildInfo &BuildInfo() { return m_BuildInfo; }
176 enum GlobalConflictOutcome {OK,Cancel,NotDone};
177 GlobalConflictOutcome ResolveGlobalConflicts(CPtrArray *parConflictsOfInterest=NULL);
179 bool CheckConflictsBeforeSave();
180 int GetTestExeNames (CFileNameArray &ar,CFileNameArray &arTestsMissing);
182 void SetPathName( LPCTSTR pszPath, BOOL bAddToMRU = TRUE );
183 static bool ShowHtmlHelp(LPCTSTR pszURL);
184 static const CString HTMLHelpLinkFileName(); // the full path to "link2.htm"
188 void RemoveAllItems();
189 void LogConflicts (const std::list<CdlConflict> & conflicts);
190 void ShowSectionProperties();
191 void ShowRegionProperties();
192 void ErrorBox (UINT, UINT);
194 void EnableCallbacks (bool bEnable=true);
196 CdlPackagesDatabase m_CdlPkgData;
197 CdlInterpreter m_CdlInterp;
198 CdlConfiguration m_CdlConfig;
199 std::string m_template_version;
200 static void CdlTransactionHandler (const CdlTransactionCallback & data);
201 static CdlInferenceCallbackResult CdlInferenceHandler (CdlTransaction data);
202 static CdlInferenceCallbackResult CdlGlobalInferenceHandler(CdlTransaction data);
203 static void CdlLoadErrorHandler(std::string message);
204 static void CdlLoadWarningHandler(std::string message);
205 static CFileName m_strDefaultExternalBrowser;
206 CdlBuildInfo m_BuildInfo;
207 CFileName m_strBuildTree;
208 CFileName m_strInstallTree;
210 CFileName m_strRepository;
211 bool m_bRepositoryOpen;
215 bool NewMemoryLayout (const CString &strPrefix);
216 CFileName m_strPackagesDir;
220 void AddContents (const CdlContainer container, CConfigItem * pParent);
221 CConfigItem * AddItem (const CdlUserVisible visible, CConfigItem * pParent);
222 CString m_strCdlErrorMessage;
223 bool OpenRepository (const CFileName strNewRepository,CdlPackagesDatabase &NewCdlPkgData,CdlInterpreter &NewCdlInterp,CdlConfiguration &NewCdlConfig,CFileName &strNewPackagesDir);
224 bool GenerateHeaders();
226 // This data supports communication information to the failing rules dialog invoked by CdlGlobalInferenceHandler():
227 GlobalConflictOutcome m_ConflictsOutcome;
228 CPtrArray m_arConflictsOfInterest; // used by CRulesView::OnResolve
230 bool QualifyDocURL(CString &strURL);
234 CProject * m_peCosProject;
237 bool CreateTestProjects();
238 CProjectManager *m_pm; // A pointer so as to reduce dependencies on this header file
239 void SeteCosProject(CProject *peCosProject){m_peCosProject=peCosProject; }
240 CProject *eCosProject(){return m_peCosProject; }
241 // Here are the declarations that make us look like a CDocument-derived class:
243 bool UnloadPackage (CConfigItem *pItem);
244 void OnMLTNewRegion();
245 void OnMLTNewSection();
247 void OnMLTProperties();
251 // Making the class look as if it is derived from CDocument:
252 BOOL OnNewDocument();
253 BOOL OnOpenDocument(LPCTSTR lpszPathName);
254 void OnCloseDocument();
255 BOOL OnSaveDocument(LPCTSTR lpszPathName);
256 void DeleteContents();
257 void SetModifiedFlag( BOOL bModified = TRUE ) { m_bModified=bModified; }
258 void UpdateAllViews( CView* pSender, LPARAM lHint = 0L, CObject* pHint = NULL );
259 const CString& GetPathName( ) const { return m_strPathName; }
261 bool PostOpenDocument();
263 CString m_strPathName;
266 //{{AFX_VIRTUAL(CConfigToolDoc)
268 virtual BOOL OnNewDocument();
269 virtual void Serialize(CArchive& ar);
270 virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
271 virtual void OnCloseDocument();
272 virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
273 virtual void DeleteContents();
275 // virtual BOOL SaveModified();
278 // Standlone-specific:
280 enum BrowserType { Internal, AssociatedExternal, CustomExternal };
282 CStringArray m_arstrUserToolPaths;
283 bool m_bUseCustomViewer;
284 bool m_bUseExternalBrowser;
285 CString m_strBrowser;
286 CFileName m_strViewer;
287 BrowserType m_eUseCustomBrowser;
288 const CString CurrentTargetPrefix();
289 int GetCompilationCount(LPCTSTR psz);
293 CString m_strBufferedLogMessages;
294 // Access to header files:
296 virtual void AssertValid() const;
297 virtual void Dump(CDumpContext& dc) const;
300 void SetModifiedFlag (BOOL bModified = TRUE) { CDocument::SetModifiedFlag (bModified); UpdateFrameCounts (); }
301 // void SetTitle(LPCTSTR lpszTitle);
303 void SaveProfileSettings();
304 void LoadProfileSettings();
305 //{{AFX_MSG(CConfigToolDoc)
306 afx_msg void OnBuildConfigure();
307 afx_msg void OnConfigurationRepository();
308 afx_msg void OnBuildTemplates();
309 afx_msg void OnBuildPackages();
310 afx_msg void OnMLTNewRegion();
311 afx_msg void OnMLTNewSection();
312 afx_msg void OnMLTDelete();
313 afx_msg void OnMLTProperties();
314 afx_msg void OnUpdateEditDelete(CCmdUI* pCmdUI);
315 afx_msg void OnUpdateEditNewSection(CCmdUI* pCmdUI);
316 afx_msg void OnUpdateEditProperties(CCmdUI* pCmdUI);
317 afx_msg void OnToolsAdministration();
318 afx_msg void OnFileExport();
319 afx_msg void OnFileImport();
321 DECLARE_MESSAGE_MAP()
325 /////////////////////////////////////////////////////////////////////////////
327 //{{AFX_INSERT_LOCATION}}
328 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
330 #endif // !defined(AFX_ConfigToolDOC_H__A4845246_05EE_11D2_80BE_00A0C949ADAC__INCLUDED_)