Skip to content

Commit 6c02319

Browse files
committed
refactors and renames
Signed-off-by: William Woodall <[email protected]>
1 parent e8c9d01 commit 6c02319

5 files changed

Lines changed: 74 additions & 42 deletions

File tree

rmw/include/rmw/init.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef RMW__RMW_H_
16-
#define RMW__RMW_H_
15+
#ifndef RMW__INIT_H_
16+
#define RMW__INIT_H_
1717

1818
#ifdef __cplusplus
1919
extern "C"
@@ -23,7 +23,7 @@ extern "C"
2323
#include <stdint.h>
2424

2525
#include "rmw/macros.h"
26-
#include "rmw/types.h"
26+
#include "rmw/ret_types.h"
2727
#include "rmw/visibility_control.h"
2828

2929
/// Implementation defined options structure used during rmw_init().
@@ -44,6 +44,7 @@ typedef struct RMW_PUBLIC_TYPE rmw_init_options_t {
4444
/// Implementation identifier, used to ensure two different implementations are not being mixed.
4545
const char * implementation_identifier;
4646
/// Implementation defined init options.
47+
/** May be NULL if there are no implementation defined options. */
4748
rmw_init_options_impl_t * impl;
4849
} rmw_init_options_t;
4950

@@ -60,23 +61,24 @@ rmw_get_default_init_options(void);
6061
/**
6162
* This should be defined by the rmw implementation.
6263
*/
63-
typedef struct rmw_init_context_impl_t rmw_init_context_impl_t;
64+
typedef struct rmw_context_impl_t rmw_context_impl_t;
6465

6566
/// Initialization context structure which is used to store init specific information.
66-
typedef struct RMW_PUBLIC_TYPE rmw_init_context_t {
67+
typedef struct RMW_PUBLIC_TYPE rmw_context_t {
6768
/// Locally (process local) unique ID that represents this init/shutdown cycle.
6869
uint64_t instance_id;
6970
/// Implementation identifier, used to ensure two different implementations are not being mixed.
7071
const char * implementation_identifier;
7172
/// Implementation defined init context information.
72-
rmw_init_context_impl_t * impl;
73-
} rmw_init_context_t;
73+
/** May be NULL if there is no implementation defined context information. */
74+
rmw_context_impl_t * impl;
75+
} rmw_context_t;
7476

7577
/// Return a zero initialized init context structure.
7678
RMW_PUBLIC
7779
RMW_WARN_UNUSED
78-
rmw_init_context_t
79-
rmw_get_zero_initialized_init_context(void);
80+
rmw_context_t
81+
rmw_get_zero_initialized_context(void);
8082

8183
/// Initialize the middleware with the given options, and yielding an init context.
8284
/**
@@ -106,7 +108,7 @@ rmw_get_zero_initialized_init_context(void);
106108
RMW_PUBLIC
107109
RMW_WARN_UNUSED
108110
rmw_ret_t
109-
rmw_init(const rmw_init_options_t * options, rmw_init_context_t * context);
111+
rmw_init(const rmw_init_options_t * options, rmw_context_t * context);
110112

111113
/// Shutdown the middleware for a given init context.
112114
/**
@@ -133,10 +135,10 @@ rmw_init(const rmw_init_options_t * options, rmw_init_context_t * context);
133135
RMW_PUBLIC
134136
RMW_WARN_UNUSED
135137
rmw_ret_t
136-
rmw_shutdown(rmw_init_context_t * context);
138+
rmw_shutdown(rmw_context_t * context);
137139

138140
#ifdef __cplusplus
139141
}
140142
#endif
141143

142-
#endif // RMW__RMW_H_
144+
#endif // RMW__INIT_H_

rmw/include/rmw/ret_types.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2014-2018 Open Source Robotics Foundation, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef RMW__RET_TYPES_H_
16+
#define RMW__RET_TYPES_H_
17+
18+
#ifdef __cplusplus
19+
extern "C"
20+
{
21+
#endif
22+
23+
#include <stdint.h>
24+
25+
typedef int32_t rmw_ret_t;
26+
#define RMW_RET_OK 0
27+
#define RMW_RET_ERROR 1
28+
#define RMW_RET_TIMEOUT 2
29+
30+
/// Failed to allocate memory return code.
31+
#define RMW_RET_BAD_ALLOC 10
32+
/// Invalid argument return code.
33+
#define RMW_RET_INVALID_ARGUMENT 11
34+
/// Incorrect rmw implementation.
35+
#define RMW_RET_INCORRECT_RMW_IMPLEMENTATION 12
36+
37+
#ifdef __cplusplus
38+
}
39+
#endif
40+
41+
#endif // RMW__RET_TYPES_H_

rmw/include/rmw/rmw.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ rmw_get_serialization_format(void);
124124
/// Create a node and return a handle to that node.
125125
/**
126126
* This function can fail, and therefore return `NULL`, if:
127-
* - init_context, name, namespace_, or security_options is `NULL`
128-
* - init_context, security_options is invalid
127+
* - context, name, namespace_, or security_options is `NULL`
128+
* - context, security_options is invalid
129129
* - memory allocation fails during node creation
130130
* - an unspecified error occurs
131131
*
132-
* The init_context must be non-null and valid, i.e. it has been initialized
132+
* The context must be non-null and valid, i.e. it has been initialized
133133
* by `rmw_init()` and has not been finalized by `rmw_shutdown()`.
134134
*
135135
* The name and namespace_ should be valid node name and namespace,
@@ -153,7 +153,7 @@ rmw_get_serialization_format(void);
153153
*
154154
* This should be defined by the rmw implementation.
155155
*
156-
* \param[in] init_context init context that this node should be associated with
156+
* \param[in] context init context that this node should be associated with
157157
* \param[in] name the node name
158158
* \param[in] namespace_ the node namespace
159159
* \param[in] domain_id the id of the domain that the node should join
@@ -164,7 +164,7 @@ RMW_PUBLIC
164164
RMW_WARN_UNUSED
165165
rmw_node_t *
166166
rmw_create_node(
167-
rmw_init_context_t * init_context,
167+
rmw_context_t * context,
168168
const char * name,
169169
const char * namespace_,
170170
size_t domain_id,
@@ -438,12 +438,12 @@ rmw_send_response(
438438
/// Create a guard condition and return a handle to that guard condition.
439439
/**
440440
* This function can fail, and therefore return `NULL`, if:
441-
* - init_context is `NULL`
442-
* - init_context is invalid
441+
* - context is `NULL`
442+
* - context is invalid
443443
* - memory allocation fails during guard condition creation
444444
* - an unspecified error occurs
445445
*
446-
* The init_context must be non-null and valid, i.e. it has been initialized
446+
* The context must be non-null and valid, i.e. it has been initialized
447447
* by `rmw_init()` and has not been finalized by `rmw_shutdown()`.
448448
*
449449
* <hr>
@@ -457,13 +457,13 @@ rmw_send_response(
457457
*
458458
* This should be defined by the rmw implementation.
459459
*
460-
* \param[in] init_context init context that this node should be associated with
460+
* \param[in] context init context that this node should be associated with
461461
* \return rmw guard condition handle or `NULL` if there was an error
462462
*/
463463
RMW_PUBLIC
464464
RMW_WARN_UNUSED
465465
rmw_guard_condition_t *
466-
rmw_create_guard_condition(rmw_init_context_t * init_context);
466+
rmw_create_guard_condition(rmw_context_t * context);
467467

468468

469469
/// Finalize a given guard condition handle, reclaim the resources, and deallocate the handle.

rmw/include/rmw/types.h

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,22 @@ extern "C"
2727
// map rcutils specific log levels to rmw speicfic type
2828
#include <rcutils/logging.h>
2929

30+
#include "rmw/init.h"
31+
#include "rmw/ret_types.h"
3032
#include "rmw/serialized_message.h"
3133
#include "rmw/visibility_control.h"
3234

33-
typedef int rmw_ret_t;
34-
#define RMW_RET_OK 0
35-
#define RMW_RET_ERROR 1
36-
#define RMW_RET_TIMEOUT 2
37-
38-
/// Failed to allocate memory return code.
39-
#define RMW_RET_BAD_ALLOC 10
40-
/// Invalid argument return code.
41-
#define RMW_RET_INVALID_ARGUMENT 11
42-
/// Incorrect rmw implementation.
43-
#define RMW_RET_INCORRECT_RMW_IMPLEMENTATION 12
44-
4535
// 24 bytes is the most memory needed to represent the GID by any current
4636
// implementation. It may need to be increased in the future.
4737
#define RMW_GID_STORAGE_SIZE 24
4838

49-
// forward declaration to avoid circular dependency
50-
typedef struct rmw_init_context_t rmw_init_context_t;
51-
5239
typedef struct RMW_PUBLIC_TYPE rmw_node_t
5340
{
5441
const char * implementation_identifier;
5542
void * data;
5643
const char * name;
5744
const char * namespace_;
58-
rmw_init_context_t * init_context;
45+
rmw_context_t * context;
5946
} rmw_node_t;
6047

6148
typedef struct RMW_PUBLIC_TYPE rmw_publisher_t
@@ -90,7 +77,7 @@ typedef struct RMW_PUBLIC_TYPE rmw_guard_condition_t
9077
{
9178
const char * implementation_identifier;
9279
void * data;
93-
rmw_init_context_t * init_context;
80+
rmw_context_t * context;
9481
} rmw_guard_condition_t;
9582

9683
/// Array of subscriber handles.

rmw/src/init.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include <stddef.h>
16+
1517
#include "rmw/init.h"
1618

1719
#ifdef __cplusplus
1820
extern "C"
1921
{
2022
#endif
2123

22-
rmw_init_context_t
23-
rmw_get_zero_initialized_init_context(void)
24+
rmw_context_t
25+
rmw_get_zero_initialized_context(void)
2426
{
25-
return (const rmw_init_context_t) {
27+
return (const rmw_context_t) {
2628
.instance_id = 0,
2729
.impl = NULL
2830
};

0 commit comments

Comments
 (0)