1 // 2 // Copyright 2005 The Android Open Source Project 3 // 4 // Our collection of devices. 5 // 6 #ifndef _SIM_PHONE_COLLECTION_H 7 #define _SIM_PHONE_COLLECTION_H 8 9 #include <stdlib.h> 10 #include "PhoneData.h" 11 12 /* 13 * Only one instance of this class exists. It contains a list of all 14 * known devices, and methods for scanning for devices. 15 */ 16 class PhoneCollection { 17 public: 18 /* get the global instance */ GetInstance(void)19 static PhoneCollection* GetInstance(void) { 20 if (mpInstance == NULL) 21 mpInstance = new PhoneCollection; 22 return mpInstance; 23 } 24 /* destroy the global instance when shutting down */ DestroyInstance(void)25 static void DestroyInstance(void) { 26 delete mpInstance; 27 mpInstance = NULL; 28 } 29 30 /* scan for phones in subdirectories of "directory" */ 31 void ScanForPhones(const char* directory); 32 33 /* get phone data */ GetPhoneCount(void)34 int GetPhoneCount(void) const { return mPhoneList.size(); } // slow 35 PhoneData* GetPhoneData(int idx); 36 PhoneData* GetPhoneData(const char* name); 37 38 /* layout.xml filename -- a string constant used in various places */ 39 static const char* kLayoutFile; 40 41 private: PhoneCollection(void)42 PhoneCollection(void) {} ~PhoneCollection(void)43 ~PhoneCollection(void) {} 44 45 /* the phone data; make this a Vector someday */ 46 android::List<PhoneData> mPhoneList; 47 48 /* storage for global instance pointer */ 49 static PhoneCollection* mpInstance; 50 }; 51 52 #endif // _SIM_PHONE_COLLECTION_H 53