ICG 2
Electric Boogaloo
ArrayDataType.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Type/DataType.hpp"
4 #include "DataTypeInator.hpp"
5 
6 #include <stddef.h>
7 #include <string>
8 #include <stdexcept>
9 
10 
13 class ArrayDataType : public DataType {
14 
15  public:
16 
23  ArrayDataType( std::string typeSpecifierName,
24  unsigned int n_elems ) ;
25 
30  ArrayDataType ( const ArrayDataType & original, unsigned int newSize );
31 
32  // no default constructor allowed
33  ArrayDataType() = delete;
34 
35  /* ================================================================================= */
36  /* RULE OF THREE (and a half) INTERFACE */
37  /* ================================================================================= */
38 
42  ArrayDataType ( const ArrayDataType & original ) = delete;
43 
47  ~ArrayDataType ();
48 
54 
55  // friend void swap (ArrayDataType& a, ArrayDataType& b);
56 
57  /* ==================================================================== */
58  /* VIRTUAL INTERFACE */
59  /* ==================================================================== */
60 
63  // DataType * clone () const;
64 
67  bool validate(DataTypeInator* dataTypeInator) override;
68 
69  bool isValid() const override;
70 
71 
75  size_t getSize() const override ;
76 
79  void* createInstance(unsigned int num) const override;
80 
83  void deleteInstance(void* address) const override;
84 
87  std::string getTypeSpecName() const override;
88 
91  std::string makeDeclaration(std::string declarator) const override;
92 
93  bool accept(DataTypeVisitor * visitor) const override;
94 
95 
96  /* ==================================================================== */
97  /* CLASS SPECIFIC INTERFACE */
98  /* ==================================================================== */
99 
100  std::shared_ptr<const DataType> getSubType() const;
104  unsigned int getTotalElementCount() const;
105 
109  unsigned int getElementCount() const;
110 
111  private:
112  bool initArrayDataType( const DataTypeInator* dataTypeInator, std::string typeSpecName, unsigned int n_elems );
113 
114  std::shared_ptr<const DataType> subType;
115 
116  size_t typeSize;
117  unsigned int elementCount;
118  bool is_valid;
119  std::string typeSpecName;
120 };
121 
Definition: ArrayDataType.hpp:13
bool accept(DataTypeVisitor *visitor) const override
Definition: ArrayDataType.cpp:121
ArrayDataType()=delete
ArrayDataType & operator=(ArrayDataType rhs)=delete
ArrayDataType(const ArrayDataType &original, unsigned int newSize)
bool validate(DataTypeInator *dataTypeInator) override
Verify that all of the types that are named by this DataType or subordinate DataTypes are resolvable ...
Definition: ArrayDataType.cpp:39
unsigned int getTotalElementCount() const
Definition: ArrayDataType.cpp:72
size_t getSize() const override
Definition: ArrayDataType.cpp:61
~ArrayDataType()
Definition: ArrayDataType.cpp:33
bool isValid() const override
Determine whether this type has already been successfully validated.
Definition: ArrayDataType.cpp:56
void deleteInstance(void *address) const override
Delete this instance.
Definition: ArrayDataType.cpp:89
void * createInstance(unsigned int num) const override
Create one or more instances of this type.
Definition: ArrayDataType.cpp:78
std::string makeDeclaration(std::string declarator) const override
Definition: ArrayDataType.cpp:104
unsigned int getElementCount() const
Definition: ArrayDataType.cpp:117
ArrayDataType(const ArrayDataType &original)=delete
std::shared_ptr< const DataType > getSubType() const
Definition: ArrayDataType.cpp:125
std::string getTypeSpecName() const override
Get the Type Spec Name object.
Definition: ArrayDataType.cpp:99
Register and manage datatypes at runtime.
Definition: DataTypeInator.hpp:16
Abstract base class for a DataTypeVisitor.
Definition: DataTypeVisitor.hpp:20
Abstract base class for DataTypes.
Definition: DataType.hpp:11