1 | /** @file
|
---|
2 | * VirtualBox COM class implementation
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2014 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef ____H_ADDITIONSFACILITYIMPL
|
---|
18 | #define ____H_ADDITIONSFACILITYIMPL
|
---|
19 |
|
---|
20 | #include <vector>
|
---|
21 | #include <iprt/time.h>
|
---|
22 |
|
---|
23 | #include "AdditionsFacilityWrap.h"
|
---|
24 |
|
---|
25 | class Guest;
|
---|
26 |
|
---|
27 | class ATL_NO_VTABLE AdditionsFacility :
|
---|
28 | public AdditionsFacilityWrap
|
---|
29 | {
|
---|
30 | public:
|
---|
31 |
|
---|
32 | DECLARE_EMPTY_CTOR_DTOR(AdditionsFacility)
|
---|
33 |
|
---|
34 | // public initializer/uninitializer for internal purposes only
|
---|
35 | HRESULT init(Guest *a_pParent, AdditionsFacilityType_T a_enmFacility, AdditionsFacilityStatus_T a_enmStatus,
|
---|
36 | uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
|
---|
37 | void uninit();
|
---|
38 |
|
---|
39 | HRESULT FinalConstruct();
|
---|
40 | void FinalRelease();
|
---|
41 |
|
---|
42 |
|
---|
43 | public:
|
---|
44 | /** Facility <-> string mappings. */
|
---|
45 | struct FacilityInfo
|
---|
46 | {
|
---|
47 | /** The facilitie's name. */
|
---|
48 | const char *mName; /* utf-8 */
|
---|
49 | /** The facilitie's type. */
|
---|
50 | AdditionsFacilityType_T mType;
|
---|
51 | /** The facilitie's class. */
|
---|
52 | AdditionsFacilityClass_T mClass;
|
---|
53 | };
|
---|
54 | static const FacilityInfo s_aFacilityInfo[8];
|
---|
55 |
|
---|
56 | // public internal methods
|
---|
57 | static const AdditionsFacility::FacilityInfo &i_typeToInfo(AdditionsFacilityType_T aType);
|
---|
58 | AdditionsFacilityClass_T i_getClass() const;
|
---|
59 | LONG64 i_getLastUpdated() const;
|
---|
60 | com::Utf8Str i_getName() const;
|
---|
61 | AdditionsFacilityStatus_T i_getStatus() const;
|
---|
62 | AdditionsFacilityType_T i_getType() const;
|
---|
63 | void i_update(AdditionsFacilityStatus_T a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
|
---|
64 |
|
---|
65 | private:
|
---|
66 |
|
---|
67 | // Wrapped IAdditionsFacility properties
|
---|
68 | HRESULT getClassType(AdditionsFacilityClass_T *aClassType);
|
---|
69 | HRESULT getLastUpdated(LONG64 *aLastUpdated);
|
---|
70 | HRESULT getName(com::Utf8Str &aName);
|
---|
71 | HRESULT getStatus(AdditionsFacilityStatus_T *aStatus);
|
---|
72 | HRESULT getType(AdditionsFacilityType_T *aType);
|
---|
73 |
|
---|
74 | /** A structure for keeping a facility status
|
---|
75 | * set at a certain time. Good for book-keeping. */
|
---|
76 | struct FacilityState
|
---|
77 | {
|
---|
78 | RTTIMESPEC mTimestamp;
|
---|
79 | /** The facilitie's current status. */
|
---|
80 | AdditionsFacilityStatus_T mStatus;
|
---|
81 | };
|
---|
82 |
|
---|
83 | struct Data
|
---|
84 | {
|
---|
85 | /** Record of current and previous facility
|
---|
86 | * states, limited to the 10 last states set.
|
---|
87 | * Note: This intentionally only is kept in
|
---|
88 | * Main so far! */
|
---|
89 | std::vector<FacilityState> mStates;
|
---|
90 | /** The facilitie's ID/type. */
|
---|
91 | AdditionsFacilityType_T mType;
|
---|
92 | } mData;
|
---|
93 | };
|
---|
94 |
|
---|
95 | #endif // ____H_ADDITIONSFACILITYIMPL
|
---|
96 |
|
---|