Chameleon Applications

Chameleon Applications Svn Source Tree

Root/trunk/ChameleonPrefPane/Sources/BootPropertyList.h

1/*
2 * BootPropertyList.h
3 * ChameleonPrefPane
4 *
5 * Created by Rekursor on 1/22/10.
6 *
7 */
8#ifndef __CHBOOT_PROPERTYLIST_LIST_H
9#define __CHBOOT_PROPERTYLIST_LIST_H
10
11#include "PropertyList.h"
12#include <map>
13
14// Chameleon Boot options type
15typedef enum
16{
17OptionYesNo=0,// "Yes" or "No"
18OptionString,// String Content
19OptionUnix,// Unix like command option like -x, -v ...
20OptionKernel,// kernel cmd like "mach_kernel" or "blacklist=0"
21OptionKernel1// kernel cmd like "mach_kernel" or "blacklist=0"
22
23} BootOptionType;
24
25// Boot Option descriptor : used by all derived class to permit parameters handling automation ...
26struct BootOptionDesc
27{
28BootOptionDesc(void* i, void * cID, BootOptionType t, const char* n, const char* d) {
29ID=i; contentID=cID, Type=t; Name=n; Default=d;
30}
31void*ID; // the corresponding button or textfield in the interface
32void*contentID; // the corresponding content ID (i.e: the string content for text fields)
33BootOptionTypeType;
34const char *Name;
35const char *Default;
36
37} ;
38
39/**
40 * Specialization of PropertyList with Chameleon Boot Config, fast id key to desc search features
41 */
42class BootPropertyList : public PropertyList
43{
44public:
45BootPropertyList() {}
46virtual ~BootPropertyList() {deleteOptionDesc(); }
47
48// id to map BootOptionDesc handling
49void addOptionDesc(void * ID, void* cID, BootOptionType t, const char * szName, const char* szDefault)
50{
51if (ID) _idToDescDict[ID] = new BootOptionDesc(ID, cID, t, szName? szName : "", szDefault ? szDefault : "");
52}
53
54// find the desc corresponding to id:
55const BootOptionDesc* findOption(void *ID) const
56{
57std::map<void*, BootOptionDesc*>::const_iterator bod;
58if (!ID || (bod=_idToDescDict.find(ID))==_idToDescDict.end()) return NULL;
59return bod->second;
60}
61
62// opaque enumeration for the map
63const BootOptionDesc* firstOption()
64{
65_bod=_idToDescDict.begin();
66if (_bod!= _idToDescDict.end()) return _bod->second; else return NULL;
67}
68
69const BootOptionDesc* nextOption()
70{
71if(_bod++ ==_idToDescDict.end()) return NULL;
72if (_bod != _idToDescDict.end()) return _bod->second; else return NULL;
73}
74
75
76// remove all elements in dict, calls deleteOptionsDesc()
77void clearOptionDesc();
78
79protected:
80void deleteOptionDesc();
81
82private:
83std::map<void *, BootOptionDesc*> _idToDescDict; // dictionary for id -> desc association type
84std::map<void*, BootOptionDesc*>::const_iterator _bod;
85};
86
87#endif

Archive Download this file

Revision: 47