- Timestamp:
- Nov 25, 2008 8:23:51 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDisk2Impl.cpp
r14579 r14596 923 923 STDMETHODIMP HardDisk2::GetProperty (INPTR BSTR aName, BSTR *aValue) 924 924 { 925 // CheckComArgStrNotEmptyOrNull (aName); 926 // CheckComArgOutPointerValid (aValue); 927 // 928 // AutoCaller autoCaller (this); 929 // CheckComRCReturnRC (autoCaller.rc()); 930 // 931 // AutoReadLock alock (this); 932 933 return E_NOTIMPL; 925 CheckComArgStrNotEmptyOrNull (aName); 926 CheckComArgOutPointerValid (aValue); 927 928 AutoCaller autoCaller (this); 929 CheckComRCReturnRC (autoCaller.rc()); 930 931 AutoReadLock alock (this); 932 933 Data::PropertyMap::const_iterator it = mm.properties.find (Bstr (aName)); 934 if (it == mm.properties.end()) 935 return setError (VBOX_E_OBJECT_NOT_FOUND, 936 tr ("Property '%ls' does not exist"), aName); 937 938 it->second.cloneTo (aValue); 939 940 return S_OK; 934 941 } 935 942 936 943 STDMETHODIMP HardDisk2::SetProperty (INPTR BSTR aName, INPTR BSTR aValue) 937 944 { 938 // CheckComArgStrNotEmptyOrNull (aName); 939 // 940 // AutoWriteLock alock (this); 941 942 return E_NOTIMPL; 945 CheckComArgStrNotEmptyOrNull (aName); 946 947 AutoWriteLock alock (this); 948 949 Data::PropertyMap::iterator it = mm.properties.find (Bstr (aName)); 950 if (it == mm.properties.end()) 951 return setError (VBOX_E_OBJECT_NOT_FOUND, 952 tr ("Property '%ls' does not exist"), aName); 953 954 it->second = aValue; 955 956 return S_OK; 943 957 } 944 958 … … 947 961 ComSafeArrayOut (BSTR, aReturnValues)) 948 962 { 949 // ComSafeArrayOutIsNull 950 951 return E_NOTIMPL; 963 CheckComArgOutSafeArrayPointerValid (aReturnNames); 964 CheckComArgOutSafeArrayPointerValid (aReturnValues); 965 966 AutoCaller autoCaller (this); 967 CheckComRCReturnRC (autoCaller.rc()); 968 969 AutoReadLock alock (this); 970 971 com::SafeArray <BSTR> names (mm.properties.size()); 972 com::SafeArray <BSTR> values (mm.properties.size()); 973 size_t i = 0; 974 975 for (Data::PropertyMap::const_iterator it = mm.properties.begin(); 976 it != mm.properties.end(); ++ it) 977 { 978 it->first.cloneTo (&names [i]); 979 it->second.cloneTo (&values [i]); 980 ++ i; 981 } 982 983 names.detachTo (ComSafeArrayOutArg (aReturnNames)); 984 values.detachTo (ComSafeArrayOutArg (aReturnValues)); 985 986 return S_OK; 952 987 } 953 988 … … 2437 2472 HRESULT rc = mm.formatObj->addCaller(); 2438 2473 AssertComRCReturnRC (rc); 2474 2475 /* get properties (preinsert them as keys in the map). Note that the 2476 * map doesn't grow over the object life time since the set of 2477 * properties is meant to be constant. */ 2478 2479 mm.properties.clear(); 2480 2481 for (HardDiskFormat::PropertyList::const_iterator it = 2482 mm.formatObj->properties().begin(); 2483 it != mm.formatObj->properties().end(); 2484 ++ it) 2485 { 2486 mm.properties.insert (std::make_pair (it->name, Bstr::Null)); 2487 } 2439 2488 } 2440 2489 -
trunk/src/VBox/Main/include/HardDisk2Impl.h
r14573 r14596 35 35 #include <VBox/VBoxHDD-new.h> 36 36 37 #include <map> 38 37 39 class Progress; 38 40 … … 267 269 uint64_t logicalSize; /*< In MBytes. */ 268 270 271 typedef std::map <Bstr, Bstr> PropertyMap; 272 PropertyMap properties; 273 269 274 bool implicit : 1; 270 275 -
trunk/src/VBox/Main/include/HardDiskFormatImpl.h
r14272 r14596 114 114 115 115 /** Const, no need to lock */ 116 const Bstr &id() { return m.id; }116 const Bstr &id() const { return m.id; } 117 117 /** Const, no need to lock */ 118 const BstrList &fileExtensions() { return m.fileExtensions; }118 const BstrList &fileExtensions() const { return m.fileExtensions; } 119 119 /** Const, no need to lock */ 120 uint64_t capabilities() { return m.capabilities; } 120 uint64_t capabilities() const { return m.capabilities; } 121 /** Const, no need to lock */ 122 const PropertyList &properties() const { return m.properties; } 121 123 122 124 // for VirtualBoxSupportErrorInfoImpl -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r14184 r14596 593 593 594 594 #if 0 595 // find a registered hard disk by location 595 // find a registered hard disk by location and get properties 596 596 /////////////////////////////////////////////////////////////////////////// 597 597 do 598 598 { 599 ComPtr <IHardDisk > hd;599 ComPtr <IHardDisk2> hd; 600 600 static const wchar_t *Names[] = 601 601 { 602 602 #ifndef RT_OS_LINUX 603 L"E:/Develop/innotek/images/thinker/freedos.vdi", 604 L"E:/Develop/innotek/images/thinker/fReeDoS.vDI", 605 L"E:/Develop/innotek/images/vmdk/haiku.vmdk", 603 L"freedos.vdi", 604 L"MS-DOS.vmdk", 605 L"iscsi", 606 L"some/path/and/disk.vdi", 606 607 #else 607 L" /mnt/host/common/Develop/innotek/images/maggot/freedos.vdi",608 L" /mnt/host/common/Develop/innotek/images/maggot/fReeDoS.vDI",608 L"xp.vdi", 609 L"Xp.vDI", 609 610 #endif 610 611 }; 612 613 printf ("\n"); 614 611 615 for (size_t i = 0; i < RT_ELEMENTS (Names); ++ i) 612 616 { 613 617 Bstr src = Names [i]; 614 618 printf ("Searching for hard disk '%ls'...\n", src.raw()); 615 rc = virtualBox->FindHardDisk (src, hd.asOutParam());619 rc = virtualBox->FindHardDisk2 (src, hd.asOutParam()); 616 620 if (SUCCEEDED (rc)) 617 621 { … … 622 626 printf ("Found, UUID={%Vuuid}, location='%ls'.\n", 623 627 id.raw(), location.raw()); 628 629 com::SafeArray <BSTR> names; 630 com::SafeArray <BSTR> values; 631 632 CHECK_ERROR_BREAK (hd, GetProperties (NULL, 633 ComSafeArrayAsOutParam (names), 634 ComSafeArrayAsOutParam (values))); 635 636 printf ("Properties:\n"); 637 for (size_t i = 0; i < names.size(); ++ i) 638 printf (" %ls = %ls\n", names [i], values [i]); 639 640 if (names.size() == 0) 641 printf (" <none>\n"); 642 624 643 } 625 644 else 626 645 { 627 PRINT_ERROR_INFO (com::ErrorInfo (virtualBox)); 646 com::ErrorInfo info (virtualBox); 647 PRINT_ERROR_INFO (info); 628 648 } 649 printf ("\n"); 629 650 } 630 651 } … … 1097 1118 #endif 1098 1119 1099 #if def VBOX_WITH_RESOURCE_USAGE_API1120 #if 0 && defined (VBOX_WITH_RESOURCE_USAGE_API) 1100 1121 do { 1101 1122 // Get collector
Note:
See TracChangeset
for help on using the changeset viewer.