A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PDBObject.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 
19 #ifndef PDBOBJECT_H
20 #define PDBOBJECT_H
21 
22 #include "DataTypes.h"
23 #include <memory>
24 
25 using namespace std;
26 // create a smart pointer for PDBObjectPtr objects
27 class PDBObject;
28 typedef shared_ptr<PDBObject> PDBObjectPtr;
29 
38 class PDBObject {
39 
40 public:
41  // Create a PDBObject instance.
42  PDBObject();
43  PDBObject(void* dataIn, DatabaseID dbId, UserTypeID typeId, SetID setId, size_t dataSize);
44  ~PDBObject();
45 
46  // To free an object, we need to make sure whether the raw data encapsulated is in shared memory
47  // or not.
48  // If it is in shared memory, the raw data is just a part of a page, which will be finally
49  // released by shared memory manager.
50  // If it is not in shared memory, we can release it right now.
51  void freeObject();
52 
53 
58  // Return a pointer to the raw data.
59  void* getRaw() const {
60  return rawBytes;
61  }
62 
63  // Return the size of the raw data.
64  size_t getSize() const {
65  return size;
66  }
67 
68  // return the offset in shared memory of the raw data.
69  size_t getShmOffset() const {
70  return shmOffset;
71  }
72 
73  // return SetID of the object.
74  UserTypeID getSetID() const {
75  return setId;
76  }
77 
78  // return TypeID of the object.
80  return typeId;
81  }
82 
83  // return the DatabaseID of the object.
85  return dbId;
86  }
87 
88  // set raw data.
89  void setRaw(void* data) {
90  this->rawBytes = data;
91  }
92 
93  // set size.
94  void setSize(size_t size) {
95  this->size = size;
96  }
97 
98  // set offset in shared memory.
99  void setShmOffset(size_t size) {
100  this->shmOffset = size;
101  }
102 
103  // set SetID.
104  void setSetID(SetID setId) {
105  this->setId = setId;
106  }
107 
108  // set TypeID.
109  void setTypeID(UserTypeID typeId) {
110  this->typeId = typeId;
111  }
112 
113  // set DatabaseID.
115  this->dbId = dbId;
116  }
117 
118 private:
119  void* rawBytes;
123  size_t size;
124  size_t shmOffset;
125 };
126 
127 #endif /* PDBOBJECT_H */
unsigned int SetID
Definition: DataTypes.h:31
size_t size
Definition: PDBObject.h:123
void setDatabaseID(DatabaseID dbId)
Definition: PDBObject.h:114
UserTypeID typeId
Definition: PDBObject.h:121
void * getRaw() const
Definition: PDBObject.h:59
SetID setId
Definition: PDBObject.h:122
size_t getShmOffset() const
Definition: PDBObject.h:69
UserTypeID getTypeID() const
Definition: PDBObject.h:79
void * rawBytes
Definition: PDBObject.h:119
DatabaseID dbId
Definition: PDBObject.h:120
unsigned int DatabaseID
Definition: DataTypes.h:29
UserTypeID getSetID() const
Definition: PDBObject.h:74
void setShmOffset(size_t size)
Definition: PDBObject.h:99
size_t getSize() const
Definition: PDBObject.h:64
DatabaseID getDatabaseID() const
Definition: PDBObject.h:84
void setRaw(void *data)
Definition: PDBObject.h:89
void setTypeID(UserTypeID typeId)
Definition: PDBObject.h:109
size_t shmOffset
Definition: PDBObject.h:124
void setSetID(SetID setId)
Definition: PDBObject.h:104
shared_ptr< PDBObject > PDBObjectPtr
Definition: PDBObject.h:27
void setSize(size_t size)
Definition: PDBObject.h:94
unsigned int UserTypeID
Definition: DataTypes.h:25