sos_cam.h

来自「SOS操作系统用于无线传感器网络节点的源代码」· C头文件 代码 · 共 52 行

H
52
字号
#ifndef SOS_CAM_H
#define SOS_CAM_H

#include "sos_types.h"
#include "pid.h"

typedef uint16_t sos_cam_t;

/**
 * bind a new key to a new value
 *
 * @param sos_com_t  key
 * @param void*      value
 * @return SOS_OK for success, negative for failure (when key already exists)
 */
extern int8_t ker_cam_add(sos_cam_t key, void *value);

/**
 * bind an old key to a new value
 *
 * @param sos_com_t  key
 * @param void*      new_value
 * @return void*     the old value if exists, NULL if not
 */
extern void* ker_cam_reassign(sos_cam_t key, void *new_value);

/**
 * unbind a key from a vlaue and remove it from the key set
 *
 * @param sos_com_t  key
 * @return the value that was mapped to the key
 */
extern void* ker_cam_remove(sos_cam_t key);

/**
 * find the value (if any) that is bound to a key
 *
 * @param sos_com_t  key
 * @return the value mapped to the key
 */
extern void* ker_cam_lookup(sos_cam_t key);


static inline sos_cam_t ker_cam_key( sos_pid_t pid, uint8_t id )
{
	return (((sos_cam_t) pid) << 8) | id;
}


#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?