CObject
CCArrayQueue.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Brendan Bruner
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * bbruner@ualberta.ca
17  * Jun 24, 2016
18  */
22 #ifndef UTIL_CCARRAYQUEUE_H_
23 #define UTIL_CCARRAYQUEUE_H_
24 
25 #include <Class.h>
26 #include <CError.h>
27 #include "CIQueue.h"
28 
29 
30 /************************************************************************/
31 /* Declare class and vtable. */
32 /************************************************************************/
65 {
66  /* Super class must always be first member */
67  /* of a class' struct. */
68  struct CObject cobject;
69 
70  /* Implement the CIQueue interface. */
71  struct CIQueue ciqueue;
72 
73  /* Private member variables. */
74  struct
75  {
76  size_t size;
77  size_t max_size;
78  size_t element_size;
79  size_t head;
80  size_t tail;
81  unsigned char is_static;
82  unsigned char* queueBase;
83  } _;
84 };
85 
92 {
93  /* Space for a copy of the super class' virtual table must */
94  /* be the first member of a class virtual table declaration. */
95  struct CObject_VTable cobject_override;
96 
97  /* Since we are overriding the destructor, we need to keep */
98  /* keep a reference to the super class' implementation of */
99  /* the destructor. */
100  const struct CObject_VTable* cobject;
101 
102  /* Space for a copy of the implemented interface's virtual table */
103  struct CIQueue_VTable ciqueue_override;
104 };
105 
113 
114 
115 /************************************************************************/
116 /* Constructor */
117 /************************************************************************/
137 CError CCArrayQueue( struct CCArrayQueue* self, size_t element_size, size_t queue_size);
138 
157 CError CCArrayQueueStatic( struct CCArrayQueue* self, void* memory, size_t element_size, size_t queue_size );
158 
159 
160 #endif /* UTIL_CCARRAYQUEUE_H_ */
const struct CCArrayQueue_VTable * CCArrayQueue_GetVTable()
Definition: CCArrayQueue.c:149
CError CCArrayQueue(struct CCArrayQueue *self, size_t element_size, size_t queue_size)
Definition: CCArrayQueue.c:178
Base class.
Definition: Class.h:283
Queue data structure interface.
Definition: CIQueue.h:70
CIQueue virtual table.
Definition: CIQueue.h:82
CObject&#39;s virtual table declaration.
Definition: Class.h:306
Array implementation of CIQueue interface.
Definition: CCArrayQueue.h:64
CError CCArrayQueueStatic(struct CCArrayQueue *self, void *memory, size_t element_size, size_t queue_size)
Definition: CCArrayQueue.c:209
Virtual table for struct CCArrayQueue.
Definition: CCArrayQueue.h:91