2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync/* $Id$ */
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync/** @file
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync *
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync * MediumFormat COM class implementation
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync */
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2008-2013 Oracle Corporation
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync *
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * available from http://www.virtualbox.org. This file is free software;
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * you can redistribute it and/or modify it under the terms of the GNU
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * General Public License (GPL) as published by the Free Software
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync */
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync#ifndef MEDIUMFORMAT_IMPL_H_
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync#define MEDIUMFORMAT_IMPL_H_
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync#include "MediumFormatWrap.h"
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
4651430e55b9df9726347e3e3968618e540fe729vboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsyncstruct VDBACKENDINFO;
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync/**
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * The MediumFormat class represents the backend used to store medium data
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * (IMediumFormat interface).
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync *
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * @note Instances of this class are permanently caller-referenced by Medium
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * objects (through addCaller()) so that an attempt to uninitialize or delete
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * them before all Medium objects are uninitialized will produce an endless
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync * wait!
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync */
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsyncclass ATL_NO_VTABLE MediumFormat :
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync public MediumFormatWrap
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync{
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsyncpublic:
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync struct Property
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync {
e475db425142b37cb088dc96daae0d4e8d13166evboxsync Utf8Str strName;
e475db425142b37cb088dc96daae0d4e8d13166evboxsync Utf8Str strDescription;
e475db425142b37cb088dc96daae0d4e8d13166evboxsync DataType_T type;
e475db425142b37cb088dc96daae0d4e8d13166evboxsync ULONG flags;
e475db425142b37cb088dc96daae0d4e8d13166evboxsync Utf8Str strDefaultValue;
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync };
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync typedef std::vector<Property> PropertyArray;
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync typedef std::vector<com::Utf8Str> StrArray;
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
3e729152bacbdd8ae206df8fafe3187bb9fb7614vboxsync DECLARE_EMPTY_CTOR_DTOR(MediumFormat)
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync HRESULT FinalConstruct();
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync void FinalRelease();
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync // public initializer/uninitializer for internal purposes only
3e729152bacbdd8ae206df8fafe3187bb9fb7614vboxsync HRESULT init(const VDBACKENDINFO *aVDInfo);
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync void uninit();
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync // public methods for internal purposes only
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync // (ensure there is a caller and a read lock before calling them!)
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync /** Const, no need to lock */
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const Utf8Str &i_getId() const { return m.strId; }
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync /** Const, no need to lock */
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const StrArray &i_getFileExtensions() const { return m.maFileExtensions; }
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync /** Const, no need to lock */
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync MediumFormatCapabilities_T i_getCapabilities() const { return m.capabilities; }
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync /** Const, no need to lock */
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const PropertyArray &i_getProperties() const { return m.maProperties; }
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsyncprivate:
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync // wrapped IMediumFormat properties
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync HRESULT getId(com::Utf8Str &aId);
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync HRESULT getName(com::Utf8Str &aName);
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync HRESULT getCapabilities(std::vector<MediumFormatCapabilities_T> &aCapabilities);
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync // wrapped IMediumFormat methods
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync HRESULT describeFileExtensions(std::vector<com::Utf8Str> &aExtensions,
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync std::vector<DeviceType_T> &aTypes);
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync HRESULT describeProperties(std::vector<com::Utf8Str> &aNames,
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync std::vector<com::Utf8Str> &aDescriptions,
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync std::vector<DataType_T> &aTypes,
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync std::vector<ULONG> &aFlags,
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync std::vector<com::Utf8Str> &aDefaults);
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync // types
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync typedef std::vector<DeviceType_T> DeviceTypeArray;
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync // data
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync struct Data
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync {
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync Data() : capabilities((MediumFormatCapabilities_T)0) {}
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const Utf8Str strId;
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const Utf8Str strName;
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const StrArray maFileExtensions;
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const DeviceTypeArray maDeviceTypes;
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const MediumFormatCapabilities_T capabilities;
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync const PropertyArray maProperties;
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync };
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync Data m;
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync};
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
c0d22c23d3289cef0332f4d61ab15df48ed34979vboxsync#endif // MEDIUMFORMAT_IMPL_H_
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync
2c4460e3cb462e743aa08229a17e49aa4f061effvboxsync/* vi: set tabstop=4 shiftwidth=4 expandtab: */