Changeset 45518 in vbox for trunk/src/VBox/Main/src-server/MediumFormatImpl.cpp
- Timestamp:
- Apr 12, 2013 12:01:02 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84995
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MediumFormatImpl.cpp
r45497 r45518 2 2 /** @file 3 3 * 4 * VirtualBoxCOM class implementation4 * MediumFormat COM class implementation 5 5 */ 6 6 … … 76 76 DeviceType_T devType; 77 77 78 unconst(m. llFileExtensions).push_back(papExtension->pszExtension);78 unconst(m.maFileExtensions).push_back(papExtension->pszExtension); 79 79 80 80 switch(papExtension->enmType) … … 94 94 } 95 95 96 unconst(m. llDeviceTypes).push_back(devType);96 unconst(m.maDeviceTypes).push_back(devType); 97 97 ++papExtension; 98 98 } … … 157 157 flags, 158 158 defaultValue }; 159 unconst(m. llProperties).push_back(prop);159 unconst(m.maProperties).push_back(prop); 160 160 ++pa; 161 161 } … … 181 181 return; 182 182 183 unconst(m. llProperties).clear();184 unconst(m. llFileExtensions).clear();185 unconst(m. llDeviceTypes).clear();183 unconst(m.maProperties).clear(); 184 unconst(m.maFileExtensions).clear(); 185 unconst(m.maDeviceTypes).clear(); 186 186 unconst(m.capabilities) = (MediumFormatCapabilities_T)0; 187 187 unconst(m.strName).setNull(); … … 192 192 ///////////////////////////////////////////////////////////////////////////// 193 193 194 STDMETHODIMP MediumFormat::COMGETTER(Id)(BSTR *aId) 195 { 196 CheckComArgOutPointerValid(aId); 197 198 AutoCaller autoCaller(this); 199 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 200 201 /* this is const, no need to lock */ 202 m.strId.cloneTo(aId); 203 204 return S_OK; 205 } 206 207 STDMETHODIMP MediumFormat::COMGETTER(Name)(BSTR *aName) 208 { 209 CheckComArgOutPointerValid(aName); 210 211 AutoCaller autoCaller(this); 212 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 213 214 /* this is const, no need to lock */ 215 m.strName.cloneTo(aName); 216 217 return S_OK; 218 } 219 220 STDMETHODIMP MediumFormat::COMGETTER(Capabilities)(ComSafeArrayOut(MediumFormatCapabilities_T, aCaps)) 221 { 222 CheckComArgOutSafeArrayPointerValid(aCaps); 223 224 AutoCaller autoCaller(this); 225 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 226 227 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 228 229 SafeArray<MediumFormatCapabilities_T> capabilities(sizeof(MediumFormatCapabilities_T)*8); 230 231 for (ULONG i = 0; i < capabilities.size(); ++i) 232 { 233 ULONG temp = m.capabilities; 234 temp &= 1<<i; 235 capabilities [i] = (MediumFormatCapabilities_T)temp; 236 } 237 238 capabilities.detachTo(ComSafeArrayOutArg(aCaps)); 239 240 return S_OK; 241 } 242 243 STDMETHODIMP MediumFormat::DescribeFileExtensions(ComSafeArrayOut(BSTR, aFileExtensions), 244 ComSafeArrayOut(DeviceType_T, aDeviceTypes)) 245 { 246 CheckComArgOutSafeArrayPointerValid(aFileExtensions); 247 248 AutoCaller autoCaller(this); 249 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 250 251 /* this is const, no need to lock */ 252 com::SafeArray<BSTR> fileExtentions(m.llFileExtensions.size()); 253 int i = 0; 254 for (StrList::const_iterator it = m.llFileExtensions.begin(); 255 it != m.llFileExtensions.end(); 256 ++it, ++i) 257 (*it).cloneTo(&fileExtentions[i]); 258 fileExtentions.detachTo(ComSafeArrayOutArg(aFileExtensions)); 259 260 com::SafeArray<DeviceType_T> deviceTypes(m.llDeviceTypes.size()); 261 i = 0; 262 for (DeviceTypeList::const_iterator it = m.llDeviceTypes.begin(); 263 it != m.llDeviceTypes.end(); 264 ++it, ++i) 265 deviceTypes[i] = (*it); 266 deviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes)); 267 268 return S_OK; 269 } 270 271 STDMETHODIMP MediumFormat::DescribeProperties(ComSafeArrayOut(BSTR, aNames), 272 ComSafeArrayOut(BSTR, aDescriptions), 273 ComSafeArrayOut(DataType_T, aTypes), 274 ComSafeArrayOut(ULONG, aFlags), 275 ComSafeArrayOut(BSTR, aDefaults)) 276 { 277 CheckComArgOutSafeArrayPointerValid(aNames); 278 CheckComArgOutSafeArrayPointerValid(aDescriptions); 279 CheckComArgOutSafeArrayPointerValid(aTypes); 280 CheckComArgOutSafeArrayPointerValid(aFlags); 281 CheckComArgOutSafeArrayPointerValid(aDefaults); 282 283 AutoCaller autoCaller(this); 284 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 285 286 /* this is const, no need to lock */ 287 size_t c = m.llProperties.size(); 288 com::SafeArray<BSTR> propertyNames(c); 289 com::SafeArray<BSTR> propertyDescriptions(c); 290 com::SafeArray<DataType_T> propertyTypes(c); 291 com::SafeArray<ULONG> propertyFlags(c); 292 com::SafeArray<BSTR> propertyDefaults(c); 293 294 int i = 0; 295 for (PropertyList::const_iterator it = m.llProperties.begin(); 296 it != m.llProperties.end(); 297 ++it, ++i) 298 { 299 const Property &prop = (*it); 300 prop.strName.cloneTo(&propertyNames[i]); 301 prop.strDescription.cloneTo(&propertyDescriptions[i]); 302 propertyTypes[i] = prop.type; 303 propertyFlags[i] = prop.flags; 304 prop.strDefaultValue.cloneTo(&propertyDefaults[i]); 305 } 306 307 propertyNames.detachTo(ComSafeArrayOutArg(aNames)); 308 propertyDescriptions.detachTo(ComSafeArrayOutArg(aDescriptions)); 309 propertyTypes.detachTo(ComSafeArrayOutArg(aTypes)); 310 propertyFlags.detachTo(ComSafeArrayOutArg(aFlags)); 311 propertyDefaults.detachTo(ComSafeArrayOutArg(aDefaults)); 194 HRESULT MediumFormat::getId(com::Utf8Str &aId) 195 { 196 /* this is const, no need to lock */ 197 aId = m.strId; 198 199 return S_OK; 200 } 201 202 HRESULT MediumFormat::getName(com::Utf8Str &aName) 203 { 204 /* this is const, no need to lock */ 205 aName = m.strName; 206 207 return S_OK; 208 } 209 210 HRESULT MediumFormat::getCapabilities(std::vector<MediumFormatCapabilities_T> &aCapabilities) 211 { 212 /* m.capabilities is const, no need to lock */ 213 214 aCapabilities.resize(sizeof(MediumFormatCapabilities_T) * 8); 215 size_t cCapabilities = 0; 216 for (size_t i = 0; i < aCapabilities.size(); i++) 217 { 218 uint64_t tmp = m.capabilities; 219 tmp &= 1ULL << i; 220 if (tmp) 221 aCapabilities[cCapabilities] = (MediumFormatCapabilities_T)tmp; 222 } 223 aCapabilities.resize(RT_MIN(cCapabilities, 1)); 312 224 313 225 return S_OK; … … 317 229 ///////////////////////////////////////////////////////////////////////////// 318 230 231 HRESULT MediumFormat::describeFileExtensions(std::vector<com::Utf8Str> &aExtensions, 232 std::vector<DeviceType_T> &aTypes) 233 { 234 /* this is const, no need to lock */ 235 aExtensions = m.maFileExtensions; 236 aTypes = m.maDeviceTypes; 237 238 return S_OK; 239 } 240 241 HRESULT MediumFormat::describeProperties(std::vector<com::Utf8Str> &aNames, 242 std::vector<com::Utf8Str> &aDescriptions, 243 std::vector<DataType_T> &aTypes, 244 std::vector<ULONG> &aFlags, 245 std::vector<com::Utf8Str> &aDefaults) 246 { 247 /* this is const, no need to lock */ 248 size_t c = m.maProperties.size(); 249 aNames.resize(c); 250 aDescriptions.resize(c); 251 aTypes.resize(c); 252 aFlags.resize(c); 253 aDefaults.resize(c); 254 for (size_t i = 0; i < c; i++) 255 { 256 const Property &prop = m.maProperties[i]; 257 aNames[i] = prop.strName; 258 aDescriptions[i] = prop.strDescription; 259 aTypes[i] = prop.type; 260 aFlags[i] = prop.flags; 261 aDefaults[i] = prop.strDefaultValue; 262 } 263 264 return S_OK; 265 } 266 319 267 // public methods only for internal purposes 320 268 /////////////////////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.