Revision 37cd5dc2 src/urt_core.c

View differences:

src/urt_core.c
73 73
  core._status = URT_STATUS_OK;
74 74
  urtEventSourceInit(&core._evtSource);
75 75
  urtMutexInit(&core._lock);
76
  #if (URT_CFG_PUBSUB_ENABLED)
76
# if (URT_CFG_PUBSUB_ENABLED)
77 77
    core._topics = NULL;
78
  #endif /* URT_CFG_PUBSUB_ENABLED */
79
  #if (URT_CFG_RPC_ENABLED)
78
# endif /* URT_CFG_PUBSUB_ENABLED */
79
# if (URT_CFG_RPC_ENABLED)
80 80
    core.urt_service_t = NULL;
81
  #endif /* URT_CFG_RPC_ENABLED */
81
# endif /* URT_CFG_RPC_ENABLED */
82 82
  return;
83 83
}
84 84

  
......
117 117
    return &core._evtSource;
118 118
}
119 119

  
120

  
121
/**
122
 * @brief   Get Core nodes.
123
 *
124
 * @return  Nodes registered to the core.
125
 */
126
urt_node_t* urtCoreGetNodes(void)
127
{
128
    return core._nodes;
129
}
130

  
131
void urtCoreSetNodes(urt_node_t* node)
132
{
133
    core._nodes = node;
134
    return;
135
}
136

  
137 120
/**
138 121
 * @brief   Start threads of all nodes of the Core.
139 122
 */
......
237 220
}
238 221

  
239 222
/**
223
 * @brief   Get Core nodes.
224
 *
225
 * @return  Nodes registered to the core.
226
 */
227
urt_node_t* urtCoreGetNodes(void)
228
{
229
  return core._nodes;
230
}
231

  
232

  
233
/**
234
 * @brief   Prepend node to core's list of nodes.
235
 *
236
 * @param[in] node The node to prepend. Must not be NULL.
237
 */
238
void urtCoreAddNode(urt_node_t* node)
239
{
240
  urtDebugAssert(node);
241

  
242
  node->next = core._nodes;
243
  core._nodes = node;
244
  return;
245
}
246

  
247

  
248
/**
240 249
 * @brief   Get the topic of the Core.
241 250
 *
242 251
 * @param[in] id  Identifier of the topic to retrieve.
243 252
 *
244 253
 * @return  Returns a pointer to the requested service. Returns NULL if no service matches the given ID.
245 254
 */
246
#if (URT_CFG_PUBSUB_ENABLED)
247
  urt_topic_t* urtCoreGetTopic(urt_topicid_t id)
255
# if (URT_CFG_PUBSUB_ENABLED)
256

  
257
/**
258
 * @brief   Append topic to core's list of topics.
259
 *
260
 * @param[in] node The topic to append.
261
 */
262
void urtCoreAddTopic(urt_topic_t* topic)
263
{
264
  urt_topic_t* lastTopic = core._topics;
265
  while (lastTopic->next != NULL)
248 266
  {
249
      urtMutexLock(&core._lock);
250
      urt_topic_t* topic = core._topics;
251
      while (topic != NULL && topic->id < id)
252
          topic = topic->next;
253
      urtMutexUnlock(&core._lock);
254
      if (topic != NULL && topic->id == id)
255
          return topic;
256
      else
257
        return NULL;
267
    lastTopic = lastTopic->next;
258 268
  }
259
#endif /* URT_CFG_PUBSUB_ENABLED */
269
  lastTopic->next = topic;
270
  return;
271
}
272

  
273
/**
274
 * @brief   Get core's list of topics.
275
 *
276
 * @return  The first topic of the core.
277
 */
278
urt_topic_t* urtCoreGetTopic(urt_topicid_t id)
279
{
280
  urtMutexLock(&core._lock);
281
  urt_topic_t* topic = core._topics;
282
  while (topic != NULL && topic->id < id)
283
      topic = topic->next;
284
  urtMutexUnlock(&core._lock);
285
  if (topic != NULL && topic->id == id)
286
      return topic;
287
  else
288
    return NULL;
289
}
290
# endif /* URT_CFG_PUBSUB_ENABLED */
260 291

  
261 292

  
293
# if (URT_CFG_RPC_ENABLED)
262 294
/**
263 295
 * @brief   Get the service of the Core.
264 296
 *
265 297
 * @param[in] id  Identifier of the service to retrieve.
266 298
 *
267 299
 * @return Returns a pointer to the requested service. Returns NULL if no service matches the given ID.
268
 */  
269
#if (URT_CFG_RPC_ENABLED)
270
  urt_service_t urtCoreGetService(urt_serviceid_t id) {return urt_service_t;}
271
#endif /* URT_CFG_RPC_ENABLED */
300
 */
301
urt_service_t urtCoreGetService(urt_serviceid_t id) {return urt_service_t;}
302
# endif /* URT_CFG_RPC_ENABLED */
272 303

  
273 304

  

Also available in: Unified diff