MediumFormatImpl.h revision e475db425142b37cb088dc96daae0d4e8d13166e
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync/* $Id$ */
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync/** @file
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync *
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * VirtualBox COM class implementation
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync */
c58f1213e628a545081c70e26c6b67a841cff880vboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync/*
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * Copyright (C) 2008-2009 Oracle Corporation
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync *
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * available from http://www.virtualbox.org. This file is free software;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * you can redistribute it and/or modify it under the terms of the GNU
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * General Public License (GPL) as published by the Free Software
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync */
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync#ifndef ____H_MEDIUMFORMAT
4651430e55b9df9726347e3e3968618e540fe729vboxsync#define ____H_MEDIUMFORMAT
4651430e55b9df9726347e3e3968618e540fe729vboxsync
d5bf937d132098565e18a0d1fc408fb777c5e5b6vboxsync#include "VirtualBoxBase.h"
d5bf937d132098565e18a0d1fc408fb777c5e5b6vboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync#include <VBox/com/array.h>
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync#include <list>
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsyncstruct VDBACKENDINFO;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync/**
382dd16193dd5770e53a99d3e3f3bc4e96f1ddd8vboxsync * The MediumFormat class represents the backend used to store medium data
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * (IMediumFormat interface).
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync *
76f5d3db08b007661ae4af93200838d24683af52vboxsync * @note Instances of this class are permanently caller-referenced by Medium
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * objects (through addCaller()) so that an attempt to uninitialize or delete
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * them before all Medium objects are uninitialized will produce an endless
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync * wait!
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync */
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsyncclass ATL_NO_VTABLE MediumFormat :
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync public VirtualBoxBase,
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync VBOX_SCRIPTABLE_IMPL(IMediumFormat)
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync{
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsyncpublic:
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync struct Property
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync {
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync Utf8Str strName;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync Utf8Str strDescription;
a536b4958564d95ba9fb795645a7b876e6b409edvboxsync DataType_T type;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync ULONG flags;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync Utf8Str strDefaultValue;
231051c77670a4142b7545d51bd2251ae603189dvboxsync };
231051c77670a4142b7545d51bd2251ae603189dvboxsync
454ac5c6ef4960887035ceea6b5247789d3272davboxsync typedef std::list<Utf8Str> StrList;
231051c77670a4142b7545d51bd2251ae603189dvboxsync typedef std::list<Property> PropertyList;
76f5d3db08b007661ae4af93200838d24683af52vboxsync
76f5d3db08b007661ae4af93200838d24683af52vboxsync struct Data
76f5d3db08b007661ae4af93200838d24683af52vboxsync {
76f5d3db08b007661ae4af93200838d24683af52vboxsync Data() : capabilities (0) {}
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync const Utf8Str strId;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync const Utf8Str strName;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync const StrList llFileExtensions;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync const uint64_t capabilities;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync const PropertyList llProperties;
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync };
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumFormat, IMediumFormat)
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync DECLARE_NOT_AGGREGATABLE (MediumFormat)
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync BEGIN_COM_MAP(MediumFormat)
231051c77670a4142b7545d51bd2251ae603189dvboxsync COM_INTERFACE_ENTRY (ISupportErrorInfo)
454ac5c6ef4960887035ceea6b5247789d3272davboxsync COM_INTERFACE_ENTRY (IMediumFormat)
a536b4958564d95ba9fb795645a7b876e6b409edvboxsync COM_INTERFACE_ENTRY (IDispatch)
a536b4958564d95ba9fb795645a7b876e6b409edvboxsync END_COM_MAP()
8ae161fca703d669e1306fafee128914f831f72bvboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync DECLARE_EMPTY_CTOR_DTOR (MediumFormat)
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync HRESULT FinalConstruct();
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync void FinalRelease();
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync // public initializer/uninitializer for internal purposes only
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync HRESULT init (const VDBACKENDINFO *aVDInfo);
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync void uninit();
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync // IMediumFormat properties
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync STDMETHOD(COMGETTER(Id)) (BSTR *aId);
b2a9ade0eaa3c7b26c02cc05f83c352cafb9e03avboxsync STDMETHOD(COMGETTER(Name)) (BSTR *aName);
22ea904a6fe5c95f54c4374502747cc844ce8204vboxsync STDMETHOD(COMGETTER(FileExtensions)) (ComSafeArrayOut (BSTR, aFileExtensions));
22ea904a6fe5c95f54c4374502747cc844ce8204vboxsync STDMETHOD(COMGETTER(Capabilities)) (ULONG *aCaps);
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync // IMediumFormat methods
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync STDMETHOD(DescribeProperties) (ComSafeArrayOut (BSTR, aNames),
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync ComSafeArrayOut (BSTR, aDescriptions),
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync ComSafeArrayOut (DataType_T, aTypes),
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync ComSafeArrayOut (ULONG, aFlags),
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync ComSafeArrayOut (BSTR, aDefaults));
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync // public methods only for internal purposes
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync // public methods for internal purposes only
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync // (ensure there is a caller and a read lock before calling them!)
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync /** Const, no need to lock */
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync const Utf8Str& getId() const { return m.strId; }
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync /** Const, no need to lock */
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync const StrList& getFileExtensions() const { return m.llFileExtensions; }
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync /** Const, no need to lock */
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync uint64_t getCapabilities() const { return m.capabilities; }
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync /** Const, no need to lock */
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync const PropertyList& getProperties() const { return m.llProperties; }
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsyncprivate:
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync Data m;
62c8fef246519d59ee7ad41dd71de75b96b3552bvboxsync};
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync#endif // ____H_MEDIUMFORMAT
0c9573129c50b7f9f4ea54e61417c2ed06bb8ebavboxsync
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync/* vi: set tabstop=4 shiftwidth=4 expandtab: */
6b9316bfe743cc7d2ee00d925f4ab455bc224e86vboxsync