Commit 65cd8020 authored by Lucas Russo's avatar Lucas Russo

src/libs/libbpmclient/*: refactoring to adhere to CLASS RFC

RFC located in http://rfc.zeromq.org/spec:21
parent 0ec3b03c
......@@ -72,6 +72,9 @@ LIBS = -lzmq -lczmq -lmlm -luuid
# General library flags -L<libdir>
LFLAGS =
# Source directory
SRC_DIR = src
# Specific board objects
OBJS_BOARD = ../../sm_io/modules/acq/ddr3_map.o
# Specific platform objects
......@@ -90,9 +93,10 @@ OBJS_EXTERNAL = ../../sm_io/modules/sm_io_codes.o \
boards_INCLUDE_DIRS = -I../../../include/boards/$(BOARD)
# Include directories
INCLUDE_DIRS = -I. -I../../../include -I../liberrhand -I../libhutils -I../libdisptable \
INCLUDE_DIRS = -I. -Iinclude -I../liberrhand -I../libhutils -I../libdisptable \
-I../libconvc \
$(boards_INCLUDE_DIRS) \
-I../../../include \
-I../../sm_io/modules \
-I../../sm_io/modules/fmc130m_4ch \
-I../../sm_io/modules/acq \
......@@ -113,7 +117,8 @@ OUT = $(LIBBPMCLIENT)
.SECONDEXPANSION:
# Library objects
$(LIBBPMCLIENT)_OBJS_LIB = bpm_client.o bpm_client_err.o bpm_client_rw_param.o
$(LIBBPMCLIENT)_OBJS_LIB = $(SRC_DIR)/bpm_client_core.o $(SRC_DIR)/bpm_client_err.o \
$(SRC_DIR)/bpm_client_rw_param.o
# Objects common for both server and client libraries.
common_OBJS = $(OBJS_BOARD) $(OBJS_PLATFORM) $(OBJS_EXTERNAL)
......@@ -133,8 +138,7 @@ $(LIBBPMCLIENT)_CODE_HEADERS = ../../sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch
../libhutils/hutils.h \
../libhutils/hutils_err.h \
../libhutils/hutils_math.h \
../libhutils/hutils_utils.h \
bpm_client_codes.h
../libhutils/hutils_utils.h
$(LIBBPMCLIENT)_FUNC_EXPORTS = ../../sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_exports.h \
../../sm_io/modules/acq/sm_io_acq_exports.h \
......@@ -149,7 +153,11 @@ $(LIBBPMCLIENT)_ACQ_HEADERS = \
../../../include/boards/$(BOARD)/priv_defs/$($(LIBBPMCLIENT)_ACQ_HEADER_BASENAME)_$(BOARD).h
$(LIBBPMCLIENT)_INST_ACQ_HEADERS = $($(LIBBPMCLIENT)_ACQ_HEADER_BASENAME).h
$(LIBBPMCLIENT)_HEADERS = $($(LIBBPMCLIENT)_OBJS_LIB:.o=.h) $($(LIBBPMCLIENT)_CODE_HEADERS) \
$(LIBBPMCLIENT)_HEADERS_LIB = include/bpm_client.h include/bpm_client_classes.h \
include/bpm_client_prelude.h include/bpm_client_codes.h \
$(subst src/,include/, $(patsubst %.o,%.h,$($(LIBBPMCLIENT)_OBJS_LIB)))
$(LIBBPMCLIENT)_HEADERS = $($(LIBBPMCLIENT)_HEADERS_LIB) $($(LIBBPMCLIENT)_CODE_HEADERS) \
$($(LIBBPMCLIENT)_FUNC_EXPORTS)
# Installation headers
......@@ -160,11 +168,11 @@ GIT_REVISION = $(shell git describe --dirty --always)
GIT_USER_NAME = $(shell git config --get user.name)
GIT_USER_EMAIL = $(shell git config --get user.email)
REVISION_NAME = bpm_client_revision
OBJ_REVISION = $(addsuffix .o, $(REVISION_NAME))
revision_OBJS = $(SRC_DIR)/bpm_client_revision.o
revision_SRCS = $(patsubst %.o,%.c,$(revision_OBJS))
OBJS_all = $(common_OBJS) $($(LIBBPMCLIENT)_OBJS) \
$(OBJ_REVISION)
$(revision_OBJS)
# Libraries suffixes
LIB_STATIC_SUFFIX = .a
......@@ -184,18 +192,19 @@ TARGET_SHARED_VER = $(addsuffix $(LIB_SHARED_SUFFIX).$(LIB_VER), $(OUT))
all: $(TARGET_STATIC) $(TARGET_SHARED_VER) pre_inst
# Compile static library
%.a: $$($$*_OBJS) $(OBJ_REVISION)
%.a: $$($$*_OBJS) $(revision_OBJS)
$(AR) rcs $@ $^
# Compile dynamic library
%.so.$(LIB_VER): $$($$*_OBJS) $(OBJ_REVISION)
%.so.$(LIB_VER): $$($$*_OBJS) $(revision_OBJS)
$(CC) -shared -fPIC -Wl,-soname,$@ -o $@ $^ $(LDFLAGS) $(LIBS)
$(REVISION_NAME).o: $(REVISION_NAME).c
$(CC) $(CFLAGS) -DGIT_REVISION="\"$(GIT_REVISION)\"" \
# Special rule for the revision object
$(revision_OBJS): $(revision_SRCS)
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -DGIT_REVISION="\"$(GIT_REVISION)\"" \
-DGIT_USER_NAME="\"$(GIT_USER_NAME)\"" \
-DGIT_USER_EMAIL="\"$(GIT_USER_EMAIL)\"" \
-c $<
-c $< -o $@
# Pull in dependency info for *existing* .o files and don't complain if the
# corresponding .d file is not found
......
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _BPM_CLIENT_H_
#define _BPM_CLIENT_H_
#include "bpm_client_classes.h"
#endif
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _BPM_CLIENT_CLASSES_H_
#define _BPM_CLIENT_CLASSES_H_
/* Set up environment for the application */
#include "bpm_client_prelude.h"
/* External dependencies */
#include <czmq.h>
#include <malamute.h>
/* Internal libraries dependencies */
#include "acq_chan.h"
/* General dependencies */
#include "bpm_client_codes.h"
/* BPM version macros for compile-time API detection */
#define BPM_CLIENT_VERSION_MAJOR 0
#define BPM_CLIENT_VERSION_MINOR 0
#define BPM_CLIENT_VERSION_PATCH 1
#define BPM_CLIENT_MAKE_VERSION(major, minor, patch) \
((major) * 10000 + (minor) * 100 + (patch))
#define BPM_CLIENT_VERSION \
BPM_CLIENT_MAKE_VERSION(BPM_CLIENT_VERSION_MAJOR, BPM_CLIENT_VERSION_MINOR, \
BPM_CLIENT_VERSION_PATCH)
#if defined (__WINDOWS__)
# if defined LIBBPM_CLIENT_STATIC
# define BPM_CLIENT_EXPORT
# elif defined LIBBPM_CLIENT_EXPORTS
# define BPM_CLIENT_EXPORT __declspec(dllexport)
# else
# define BPM_CLIENT_EXPORT __declspec(dllimport)
# endif
#else
# define BPM_CLIENT_EXPORT
#endif
/* Opaque class structures to allow forward references */
/* Public API classes */
/* Forward bpm_client_err_e declaration enumeration */
typedef enum _bpm_client_err_e bpm_client_err_e;
/* Opaque bpm_client_t structure */
typedef struct _bpm_client_t bpm_client_t;
/* BPM CLIENT */
#include "bpm_client_err.h"
#include "bpm_client_rw_param.h"
#include "bpm_client_core.h"
#endif
......@@ -5,17 +5,12 @@
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _BPM_CLIENT_H_
#define _BPM_CLIENT_H_
#ifndef _BPM_CLIENT_CORE_H_
#define _BPM_CLIENT_CORE_H_
#include <inttypes.h>
#include <malamute.h>
#include "bpm_client_codes.h"
#include "bpm_client_err.h"
#include "acq_chan.h" /* SMIO acq channel definition */
typedef struct _bpm_client_t bpm_client_t;
#ifdef __cplusplus
extern "C" {
#endif
/********************************************************/
/************************ Our API ***********************/
......@@ -757,5 +752,8 @@ bpm_client_err_e bpm_get_afc_diag_build_user_email (bpm_client_t *self, char *se
bpm_client_err_e func_polling (bpm_client_t *self, char *name,
char *service, uint32_t *input, uint32_t *output, int timeout);
#ifdef __cplusplus
}
#endif
#endif
......@@ -11,6 +11,10 @@
#ifndef _BPM_CLIENT_ERR_H_
#define _BPM_CLIENT_ERR_H_
#ifdef __cplusplus
extern "C" {
#endif
enum _bpm_client_err_e
{
BPM_CLIENT_SUCCESS = 0, /* No error */
......@@ -25,9 +29,11 @@ enum _bpm_client_err_e
BPM_CLIENT_ERR_END /* End of enum marker */
};
typedef enum _bpm_client_err_e bpm_client_err_e;
/* Convert enumeration type to string */
const char * bpm_client_err_str (bpm_client_err_e err);
#ifdef __cplusplus
}
#endif
#endif
/*
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _BPM_CLIENT_PRELUDE_H_
#define _BPM_CLIENT_PRELUDE_H_
/* External dependencies */
#include <inttypes.h>
#include <sys/types.h>
#include <stdbool.h>
#endif
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _BPM_CLIENT_REVISION_H_
#define _BPM_CLIENT_REVISION_H_
#ifdef __cplusplus
extern "C" {
#endif
extern const char *build_revision;
extern const char *build_date;
extern const char *build_user_name;
extern const char *build_user_email;
#ifdef __cplusplus
}
#endif
#endif
......@@ -8,12 +8,9 @@
#ifndef _BPM_CLIENT_RW_PARAM_H_
#define _BPM_CLIENT_RW_PARAM_H_
#include <inttypes.h>
#include <malamute.h>
#include "bpm_client_codes.h"
#include "bpm_client_rw_param_codes.h"
#include "bpm_client_err.h"
#ifdef __cplusplus
extern "C" {
#endif
#define READ_MODE 1
#define WRITE_MODE 0
......@@ -87,5 +84,8 @@ bpm_client_err_e param_client_read_gen (bpm_client_t *self, char *service,
bpm_client_err_e param_client_read_double (bpm_client_t *self, char *service,
uint32_t operation, double *param_out);
#ifdef __cplusplus
}
#endif
#endif
......@@ -8,6 +8,10 @@
#ifndef _BPM_CLIENT_RW_PARAM_CODES_
#define _BPM_CLIENT_RW_PARAM_CODES_
#ifdef __cplusplus
extern "C" {
#endif
/* Messaging Reply OPCODES */
#define RW_REPLY_SIZE (sizeof(uint32_t))
#define RW_REPLY_TYPE uint32_t
......@@ -23,4 +27,8 @@
#define PARAM_OK 0
#define PARAM_ERR 1
#ifdef __cplusplus
}
#endif
#endif
......@@ -6,14 +6,10 @@
*/
#include "bpm_client.h"
/* Private headers */
#include "errhand.h"
#include "sm_io_acq_codes.h"
#include "sm_io_dsp_codes.h"
#include "sm_io_swap_codes.h"
#include "sm_io_swap_useful_macros.h"
#include "bpm_client_rw_param_codes.h"
#include "bpm_client_rw_param.h"
#include "sm_io_swap_useful_macros.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
#ifdef ASSERT_TEST
......@@ -1961,8 +1957,6 @@ bpm_client_err_e bpm_get_afc_diag_build_user_email (bpm_client_t *self, char *se
rw, revision_data, sizeof (*revision_data));
}
/**************** Helper Function ****************/
static bpm_client_err_e _func_polling (bpm_client_t *self, char *name, char *service, uint32_t *input, uint32_t *output, int timeout);
......
......@@ -8,7 +8,7 @@
/* Error definitions and output stringification based on the work available
* at the libsllp project repository: https://github.com/brunoseivam/libsllp */
#include "bpm_client_err.h"
#include "bpm_client.h"
static const char *bpm_client_err [BPM_CLIENT_ERR_END] =
{
......
/*
* Copyright (C) 2015 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#include "bpm_client.h"
const char *build_revision = GIT_REVISION;
const char *build_date = __DATE__ " " __TIME__;
......@@ -5,11 +5,11 @@
* Released according to the GNU LGPL, version 3 or any later version.
*/
#include "errhand.h"
#include "bpm_client.h"
#include "bpm_client_rw_param.h"
/* Private headers */
#include "errhand.h"
#include "bpm_client_rw_param_codes.h"
#include "bpm_client_revision.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
#ifdef ASSERT_TEST
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment