1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the MIT License. 4 //--------------------------------------------------------------------- 5 6 #include "AddOnImage.h" 7 8 9 // constructor 10 AddOnImage::AddOnImage() 11 : fID(-1) 12 { 13 } 14 15 16 // destructor 17 AddOnImage::~AddOnImage() 18 { 19 Unload(); 20 } 21 22 23 // Load 24 status_t 25 AddOnImage::Load(const char* path) 26 { 27 Unload(); 28 status_t error = (path ? B_OK : B_BAD_VALUE); 29 if (error == B_OK) { 30 image_id id = load_add_on(path); 31 if (id >= 0) 32 fID = id; 33 else 34 error = id; 35 } 36 return error; 37 } 38 39 40 // Unload 41 void 42 AddOnImage::Unload() 43 { 44 if (fID >= 0) { 45 unload_add_on(fID); 46 fID = -1; 47 } 48 } 49 50 51 // SetID 52 void 53 AddOnImage::SetID(image_id id) 54 { 55 Unload(); 56 if (id >= 0) 57 fID = id; 58 } 59