Cumulia Illustrator Rendering Engine v1.1.0
A Rendering engine for industrial CAD/CAE model and optimized for greatest performance
 
Loading...
Searching...
No Matches
tuple.h
1//##################################################################################################
2//
3// Copyright (c) 2024 Beijing Qiongqi Tech Co.,Ltd. All rights reserved.
4
5// This source code is confidential and proprietary to Beijing Qiongqi Tech Co.,Ltd(The Holder).
6// Any unauthorized use, copying, modification, or distribution of the code is strictly prohibited.
7// Any user shall obtain authorizaition from the Holder before modifying the source code. And the user shall not
8// sublicense, sell, distribute, or transfer the source code, whether in original or modified form, to any third party
9// without the prior written consent of the Holder.
10
11// This copyright notice and permission grant shall be included in all copies or substantial portions of the source code.
12
13// Author Cumulia Illustrator
14// Date 2024-10-31
15// Version V1.1.0
16//##################################################################################################
17
18#pragma once
19
20#include "variant.h"
21
22namespace cil
23{
25 template <typename T>
26 class Tuple : public Variant
27 {
28 private:
29 Tuple()
30 : Variant()
31 {
32 }
33
34 protected:
35 T* m_data;
36 int m_size;
37
38 public:
39
42 : Variant()
43 {
44 this->m_size = size;
45 this->m_data = new T[this->m_size]{};
46 }
47
48 virtual ~Tuple()
49 {
50 delete[] this->m_data;
51 }
52
54 int size() const
55 {
56 return this->m_size;
57 }
58
60 T* data()
61 {
62 return this->m_data;
63 }
64
66 const T* data() const
67 {
68 return this->m_data;
69 }
70
72 void setData(const T* data)
73 {
74 int size = this->m_size;
75 for (int i = 0; i < size; i++)
76 this->m_data[i] = data[i];
77 }
78
80 Tuple<T>& operator=(const Tuple& other)
81 {
82 if (this == &other) return *this;
83
84 this->setData(other.data());
85
86 return *this;
87 }
88
90 bool operator==(const Tuple& other) const
91 {
92 if (this->m_type != other.type())
93 return false;
94
95 int size = this->m_size;
96 for (int i = 0; i < size; i++)
97 if (this->m_data[i] != other.data()[i])
98 return false;
99
100 return true;
101 }
102
104 bool operator!=(const Tuple& other) const
105 {
106 return !this->operator==(other);
107 }
108 };
109}
The Tuple is a templated class inheriting from the most basic class Variant.
Definition tuple.h:27
T * data()
Gets the data array of the Tuple.
Definition tuple.h:60
virtual ~Tuple()
Definition tuple.h:48
void setData(const T *data)
Sets the data array of the Variant.
Definition tuple.h:72
int m_size
The number of elements that the data array of the Tuple holds.
Definition tuple.h:36
T * m_data
The data array of the Tuple.
Definition tuple.h:35
Tuple(int size)
Constructs a Tuple object with a specified number of elements, and initialize all elements to 0.
Definition tuple.h:41
bool operator!=(const Tuple &other) const
Compares the Tuple with another one, and returns false if they are equal, otherwise returns true.
Definition tuple.h:104
int size() const
Gets the number of elements of the Tuple.
Definition tuple.h:54
const T * data() const
Gets the data array of the Tuple, and the data could not be modified upon which this function is call...
Definition tuple.h:66
bool operator==(const Tuple &other) const
Compares the Tuple with another one, and returns true if they are equal, otherwise returns false.
Definition tuple.h:90
Tuple< T > & operator=(const Tuple &other)
Copys the data of another Tuple to the one on which the operator is invoked.
Definition tuple.h:80
The Variant class is the most basic class of other mathamatic classes.
Definition variant.h:26
std::string m_type
Definition variant.h:28
const std::string & type() const
Definition decal.h:23