QDMI Devices v0.1
Quantum Device Management Interface Devices
Loading...
Searching...
No Matches
session.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2Copyright 2024 Munich Quantum Software Stack Project
3
4Licensed under the Apache License, Version 2.0 with LLVM Exceptions (the
5"License"); you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8https://github.com/Munich-Quantum-Software-Stack/QDMI-Devices/blob/develop/LICENSE
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13License for the specific language governing permissions and limitations under
14the License.
15
16SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
17------------------------------------------------------------------------------*/
18
19#include "dcdb_qdmi/device.h"
20#include "qdmi/constants.h"
21
22#include <cassandra.h>
23#include <dcdb/connection.h>
24#include <iostream>
25#include <string>
26
30
44
54private:
56 std::string hostname = "stor";
57
59 uint16_t port = 9042;
60
62 std::string username = "";
63
65 std::string password = "";
66
68 DCDB::Connection *connection = nullptr;
69
84 int connect(std::string hostname, uint16_t port, std::string username,
85 std::string password);
86
89
94 void setHostname(const std::string &new_hostname) {
95 hostname = new_hostname;
96 };
97
102 void setPort(const uint16_t new_port) { port = new_port; }
103
104public:
114 void setHostnameAndPort(const std::string &baseUrl);
115
120 void setUsername(const std::string &new_username) { username = new_username; }
121
126 void setPassword(const std::string &new_password) { password = new_password; }
127
133
134 DCDB::Connection *getConnection() { return connection; }
135
154
156 void disconnect() { connection->disconnect(); }
162
169
172};
@ ALLOCATED
The session is allocated but not yet initialized.
Definition qaptiva.c:67
@ INITIALIZED
The session is successfully initialized.
Definition qaptiva.c:69
DCDB_QDMI_DEVICE_SESSION_STATUS
Enum of the session status that can be set internally.
Definition session.h:37
The implementation of the encapsulated type QDMI_Device_Session on the device-side.
Definition session.h:53
std::string username
Username used for authentication.
Definition session.h:62
DCDB_QDMI_DEVICE_SESSION_STATUS status
Current status of the session.
Definition session.h:88
void setHostname(const std::string &new_hostname)
Set a hostname for the session.
Definition session.h:94
std::string password
Password used for authentication.
Definition session.h:65
void setStatus(DCDB_QDMI_DEVICE_SESSION_STATUS _status)
Set the session's status.
Definition session.h:161
void setPort(const uint16_t new_port)
Set a port for the session.
Definition session.h:102
DCDB_QDMI_DEVICE_SESSION_STATUS getStatus()
Get function for the current session status.
Definition session.h:168
DCDB::Connection * connection
Pointer to the underlying DCDB connection object.
Definition session.h:68
DCDB::Connection * getConnection()
Get function for the underlying connection object.
Definition session.h:134
void setPassword(const std::string &new_password)
Set the password for authentication.
Definition session.h:126
~DCDB_QDMI_Device_Session_impl_d()
Destructor.
Definition session.h:171
uint16_t port
Port number of the DCDB server.
Definition session.h:59
std::string hostname
Hostname of the DCDB server.
Definition session.h:56
int connect()
Public function to connect to the DCDB server.
Definition session.h:153
void setUsername(const std::string &new_username)
Set the username for authentication.
Definition session.h:120
void setHostnameAndPort(const std::string &baseUrl)
Public function to set hostname and port number for the DCDB server.
Definition session.cpp:31
void disconnect()
Disconnect and clean up the session.
Definition session.h:156