Embedded Multicore Building Blocks V1.0.0
queue_attributes.h
1 /*
2  * Copyright (c) 2014-2017, Siemens AG. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24  * POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef EMBB_MTAPI_QUEUE_ATTRIBUTES_H_
28 #define EMBB_MTAPI_QUEUE_ATTRIBUTES_H_
29 
30 #include <embb/mtapi/c/mtapi.h>
31 #include <embb/mtapi/internal/check_status.h>
32 
33 namespace embb {
34 namespace mtapi {
35 
42  public:
48  mtapi_status_t status;
49  mtapi_queueattr_init(&attributes_, &status);
50  internal::CheckStatus(status);
51  }
52 
61  bool state
62  ) {
63  mtapi_status_t status;
64  mtapi_boolean_t st = state ? MTAPI_TRUE : MTAPI_FALSE;
65  mtapi_queueattr_set(&attributes_, MTAPI_QUEUE_GLOBAL,
66  &st, sizeof(st), &status);
67  internal::CheckStatus(status);
68  return *this;
69  }
70 
79  bool state
80  ) {
81  mtapi_status_t status;
82  mtapi_boolean_t st = state ? MTAPI_TRUE : MTAPI_FALSE;
83  mtapi_queueattr_set(&attributes_, MTAPI_QUEUE_ORDERED,
84  &st, sizeof(st), &status);
85  internal::CheckStatus(status);
86  return *this;
87  }
88 
98  bool state
99  ) {
100  mtapi_status_t status;
101  mtapi_boolean_t st = state ? MTAPI_TRUE : MTAPI_FALSE;
102  mtapi_queueattr_set(&attributes_, MTAPI_QUEUE_RETAIN,
103  &st, sizeof(st), &status);
104  internal::CheckStatus(status);
105  return *this;
106  }
107 
116  bool state
117  ) {
118  mtapi_status_t status;
119  mtapi_boolean_t st = state ? MTAPI_TRUE : MTAPI_FALSE;
120  mtapi_queueattr_set(&attributes_, MTAPI_QUEUE_DOMAIN_SHARED,
121  &st, sizeof(st), &status);
122  internal::CheckStatus(status);
123  return *this;
124  }
125 
134  mtapi_uint_t priority
135  ) {
136  mtapi_status_t status;
137  mtapi_queueattr_set(&attributes_, MTAPI_QUEUE_PRIORITY,
138  &priority, sizeof(priority), &status);
139  internal::CheckStatus(status);
140  return *this;
141  }
142 
150  mtapi_uint_t limit
151  ) {
152  mtapi_status_t status;
153  mtapi_queueattr_set(&attributes_, MTAPI_QUEUE_LIMIT,
154  &limit, sizeof(limit), &status);
155  internal::CheckStatus(status);
156  return *this;
157  }
158 
166  mtapi_queue_attributes_t const & GetInternal() const {
167  return attributes_;
168  }
169 
170  private:
171  mtapi_queue_attributes_t attributes_;
172 };
173 
174 } // namespace mtapi
175 } // namespace embb
176 
177 #endif // EMBB_MTAPI_QUEUE_ATTRIBUTES_H_
Definition: lock_free_mpmc_queue.h:40
QueueAttributes & SetLimit(mtapi_uint_t limit)
Sets the limit (capacity) of a Queue.
Definition: queue_attributes.h:149
QueueAttributes & SetDomainShared(bool state)
Sets the domain shared property of a Queue.
Definition: queue_attributes.h:115
QueueAttributes & SetRetain(bool state)
Sets the retain property of a Queue.
Definition: queue_attributes.h:97
QueueAttributes & SetGlobal(bool state)
Sets the global property of a Queue.
Definition: queue_attributes.h:60
QueueAttributes()
Constructs a QueueAttributes object.
Definition: queue_attributes.h:47
QueueAttributes & SetOrdered(bool state)
Sets the ordered property of a Queue.
Definition: queue_attributes.h:78
mtapi_queue_attributes_t const & GetInternal() const
Returns the internal representation of this object.
Definition: queue_attributes.h:166
QueueAttributes & SetPriority(mtapi_uint_t priority)
Sets the priority of a Queue.
Definition: queue_attributes.h:133
Contains attributes of a Queue.
Definition: queue_attributes.h:41