GCC Code Coverage Report


Directory: src/gate/
File: src/gate/tech/cxx_virtualization.cpp
Date: 2026-10-19 17:06:30
Exec Total Coverage
Lines: 19 77 24.7%
Functions: 4 18 22.2%
Branches: 10 86 11.6%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2026, Stefan Meislinger |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/tech/virtualization.hpp"
30 #include "gate/exceptions.hpp"
31
32 namespace gate
33 {
34 namespace tech
35 {
36
37
38 ✗ VirtualizationSandbox::VirtualizationSandbox(gate_virtualization_sandbox_t* strm)
39 ✗ : Startable((gate_startable_t*)strm)
40 {
41 ✗ }
42
43 ✗ VirtualizationSandbox::VirtualizationSandbox(VirtualizationSandbox const& src) noexcept
44 ✗ : Startable(src)
45 {
46 ✗ }
47
48 ✗ VirtualizationSandbox::StatusEnum VirtualizationSandbox::getStatus()
49 {
50 ✗ enumint_t status = Startable::getStatus();
51 ✗ switch(status)
52 {
53 ✗ case GATE_VIRTUALIZATION_SANDBOX_STATUS_OFFLINE: return VirtualizationSandbox::Status_Offline;
54 ✗ case GATE_VIRTUALIZATION_SANDBOX_STATUS_ONLINE: return VirtualizationSandbox::Status_Online;
55 ✗ case GATE_VIRTUALIZATION_SANDBOX_STATUS_BUSY: return VirtualizationSandbox::Status_Busy;
56 ✗ default: return VirtualizationSandbox::Status_Unknown;
57 }
58 }
59
60 ✗ String VirtualizationSandbox::getId()
61 {
62 gate_string_t id;
63 ✗ result_t result = gate_virtualization_sandbox_get_id(this->c_impl(), &id);
64 ✗ GATEXX_CHECK_EXCEPTION(result);
65 ✗ return String::createFrom(id);
66 }
67
68 ✗ String VirtualizationSandbox::getName()
69 {
70 gate_string_t name;
71 ✗ result_t result = gate_virtualization_sandbox_get_name(this->c_impl(), &name);
72 ✗ GATEXX_CHECK_EXCEPTION(result);
73 ✗ return String::createFrom(name);
74 }
75
76 ✗ Property VirtualizationSandbox::getSettings()
77 {
78 gate_property_t prop;
79 ✗ result_t result = gate_virtualization_sandbox_get_settings(this->c_impl(), &prop);
80 ✗ GATEXX_CHECK_EXCEPTION(result);
81 ✗ return Property::createFrom(prop);
82 }
83
84 ✗ void VirtualizationSandbox::updateSettings(Property const& prop)
85 {
86 ✗ result_t result = gate_virtualization_sandbox_update_settings(this->c_impl(), prop.c_impl());
87 ✗ GATEXX_CHECK_EXCEPTION(result);
88 ✗ }
89
90 ✗ gate_virtualization_sandbox_t* VirtualizationSandbox::c_impl() const noexcept
91 {
92 ✗ return (gate_virtualization_sandbox_t*)Startable::c_impl();
93 }
94
95
96
97
98 ✗ VirtualizationProvider::VirtualizationProvider(gate_virtualization_provider_t* strm)
99 ✗ : object_impl_t(strm)
100 {
101 ✗ if (this->impl_ptr == NULL)
102 {
103 ✗ GATEXX_RAISE_ERROR(results::NullPointer);
104 }
105 ✗ }
106 ✗ VirtualizationProvider::VirtualizationProvider(VirtualizationProvider const& src) noexcept
107 ✗ : object_impl_t(src)
108 {
109 ✗ }
110
111 ✗ String VirtualizationProvider::getName()
112 {
113 gate_string_t name;
114 ✗ result_t result = gate_virtualization_provider_get_name(this->c_impl(), &name);
115 ✗ GATEXX_CHECK_EXCEPTION(result);
116 ✗ return String::createFrom(name);
117 }
118 ✗ Property VirtualizationProvider::getSettings()
119 {
120 gate_property_t settings;
121 ✗ result_t result = gate_virtualization_provider_get_settings(this->c_impl(), &settings);
122 ✗ GATEXX_CHECK_EXCEPTION(result);
123 ✗ return Property::createFrom(settings);
124 }
125
126 ✗ StringArray VirtualizationProvider::listSandboxIds()
127 {
128 gate_array_t arr;
129 ✗ result_t result = gate_virtualization_provider_list_sandbox_ids(this->c_impl(), &arr);
130 ✗ GATEXX_CHECK_EXCEPTION(result);
131 ✗ ArrayList<String> lst = util::createStringArray(arr);
132 ✗ return lst.toArray();
133 }
134 ✗ VirtualizationSandbox VirtualizationProvider::getSandbox(String const& sandboxId)
135 {
136 ✗ gate_virtualization_sandbox_t* ptr_sandbox = NULL;
137 ✗ result_t result = gate_virtualization_provider_get_sandbox(this->c_impl(), sandboxId.c_impl(), &ptr_sandbox);
138 ✗ GATEXX_CHECK_EXCEPTION(result);
139 ✗ return VirtualizationSandbox(ptr_sandbox);
140 }
141
142
143
144 1 VirtualizationProvider::Info::Info(String const& name, String const& descr)
145 1 : Name(name), Description(descr)
146 {
147 1 }
148
149
150 1 static gate_bool_t GATE_CALL VirtualizationProvider_list_callback(gate_string_t const* name, gate_string_t const* description, void* param)
151 {
152 1 ArrayList<VirtualizationProvider::Info>* infoList = static_cast<ArrayList<VirtualizationProvider::Info>*>(param);
153
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 String provName(*name);
154
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 String provDescr(*description);
155 1 VirtualizationProvider::Info info(provName, provDescr);
156
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 infoList->add(info);
157 2 return true;
158 }
159
160 1 Array<VirtualizationProvider::Info> VirtualizationProvider::list()
161 {
162
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ArrayList<Info> infoList;
163
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 result_t result = gate_tech_virtualization_providers_enum(&VirtualizationProvider_list_callback, static_cast<void*>(&infoList));
164
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
165
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 return infoList.toArray();
166 }
167
168 1 VirtualizationProvider VirtualizationProvider::create(String const& providerName)
169 {
170 1 gate_virtualization_provider_t* ptr = NULL;
171
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 result_t result = gate_tech_virtualization_provider_create(providerName.c_impl(), &ptr);
172
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
1 GATEXX_CHECK_EXCEPTION(result);
173 ✗ return VirtualizationProvider(ptr);
174 }
175
176
177 } // end of namespace tech
178 } // end of namespace gate
179