]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - tools/src/tools/ecostest/common/eCosTestPlatform.h
Initial revision
[karo-tx-redboot.git] / tools / src / tools / ecostest / common / eCosTestPlatform.h
1 //####COPYRIGHTBEGIN####
2 //                                                                          
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5 //
6 // This program is part of the eCos host tools.
7 //
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) 
11 // any later version.
12 // 
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 
16 // more details.
17 // 
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.
21 //
22 // ----------------------------------------------------------------------------
23 //                                                                          
24 //####COPYRIGHTEND####
25 //=================================================================
26 //
27 //        eCosTestPlatform.h
28 //
29 //        platform information header
30 //
31 //=================================================================
32 //=================================================================
33 //#####DESCRIPTIONBEGIN####
34 //
35 // Author(s):     sdf
36 // Contributors:  sdf
37 // Date:          2000-04-01
38 // Description:   eCosTestPlatform
39 // Usage:
40 //
41 //####DESCRIPTIONEND####
42
43 #ifndef _CeCosTestPlatform_H
44 #define _CeCosTestPlatform_H
45
46 #include "eCosStd.h"
47 #include "Collections.h"
48 #include "Properties.h"
49 #include <vector>
50
51 //=================================================================
52 // This class holds properties associated with a platform type (i.e. common to all instances of that platform)
53 // The information is read from a .eCosrc file or from the registry.
54 // An instance of a platform corresponds to the class CTestResource.
55 //=================================================================
56
57 class CeCosTestPlatform {
58   class CeCosTestPlatformProperties : public CProperties {
59   public:
60     CeCosTestPlatformProperties(CeCosTestPlatform *pti);
61     virtual ~CeCosTestPlatformProperties(){}
62   protected:
63   };
64   friend class CeCosTestPlatformProperties;
65 public:
66
67   static bool Load();
68         static bool Save();
69
70   bool IsValid()    const { return NULL!=Get(m_strName); }
71   LPCTSTR Name()    const { return m_strName.c_str(); }
72   LPCTSTR Prefix()  const { return m_strPrefix.c_str(); }
73   LPCTSTR GdbCmds() const { return m_strCommands.c_str(); }
74   LPCTSTR Prompt()  const { return m_strPrompt.c_str(); }
75   LPCTSTR Inferior()const { return m_strInferior.c_str(); }
76   bool ServerSideGdb() const { return 0!=m_nServerSideGdb; }
77   CeCosTestPlatform():m_nServerSideGdb(0){}
78         bool LoadFromCommandString(LPCTSTR psz);
79   CeCosTestPlatform(LPCTSTR pszIm,LPCTSTR pszPre,LPCTSTR pszPrompt,LPCTSTR pszGdb,bool bServerSideGdb,LPCTSTR pszInferior):
80     m_strName(pszIm),
81     m_strPrefix(pszPre),
82     m_strCommands(pszGdb),
83     m_strPrompt(pszPrompt),
84     m_nServerSideGdb(bServerSideGdb),
85     m_strInferior(pszInferior)
86   {}
87   static int Add (const CeCosTestPlatform &t);
88
89   static unsigned int Count() { return (unsigned)arPlatforms.size(); }
90   
91   // Get a platform by name:
92   static const CeCosTestPlatform *Get(LPCTSTR t);
93
94   // This is only used to enumerate the available platforms:
95   static const CeCosTestPlatform *Get(unsigned int i) { return (i<Count())?&arPlatforms[i]:0; }
96
97   static void RemoveAllPlatforms();
98
99   static bool IsValid (LPCTSTR pszTarget) { return NULL!=Get(pszTarget); }
100
101 protected:
102         static bool LoadFromDir (LPCTSTR pszDir);
103         static bool SaveToDir (LPCTSTR pszDir);
104 #ifdef _WIN32
105         bool   LoadFromRegistry(HKEY hKey,LPCTSTR pszKey);
106   static const String GetGreatestSubkey (LPCTSTR pszKey);
107   static bool SaveToRegistry(HKEY hKey,LPCTSTR pszKey);
108 #endif
109   String m_strName;
110   String m_strPrefix;
111   String m_strCommands;
112   String m_strPrompt;
113   int    m_nServerSideGdb;
114   String m_strInferior;
115   static std::vector<CeCosTestPlatform> arPlatforms;
116 };
117
118 #endif