Add a new device descriptor object.
As the name already indicates, a device descriptor is lightweight object which describes a single device. Currently, the api supports getting the device name (vendor and product) and model number. But this can extended with other features when necessary.
This commit is contained in:
parent
fbe712fc8f
commit
a78cf2f939
@ -4,6 +4,7 @@ libdivecomputer_HEADERS = \
|
|||||||
common.h \
|
common.h \
|
||||||
utils.h \
|
utils.h \
|
||||||
buffer.h \
|
buffer.h \
|
||||||
|
descriptor.h \
|
||||||
iterator.h \
|
iterator.h \
|
||||||
device.h \
|
device.h \
|
||||||
parser.h \
|
parser.h \
|
||||||
|
|||||||
48
include/libdivecomputer/descriptor.h
Normal file
48
include/libdivecomputer/descriptor.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* libdivecomputer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Jef Driesen
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DC_DESCRIPTOR_H
|
||||||
|
#define DC_DESCRIPTOR_H
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
typedef struct dc_descriptor_t dc_descriptor_t;
|
||||||
|
|
||||||
|
const char *
|
||||||
|
dc_descriptor_get_vendor (dc_descriptor_t *descriptor);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
dc_descriptor_get_product (dc_descriptor_t *descriptor);
|
||||||
|
|
||||||
|
dc_family_t
|
||||||
|
dc_descriptor_get_type (dc_descriptor_t *descriptor);
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
dc_descriptor_get_model (dc_descriptor_t *descriptor);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* DC_DESCRIPTOR_H */
|
||||||
@ -11,6 +11,7 @@ libdivecomputer_la_LDFLAGS = \
|
|||||||
|
|
||||||
libdivecomputer_la_SOURCES = \
|
libdivecomputer_la_SOURCES = \
|
||||||
version.c \
|
version.c \
|
||||||
|
descriptor.c \
|
||||||
iterator-private.h iterator.c \
|
iterator-private.h iterator.c \
|
||||||
device-private.h device.c \
|
device-private.h device.c \
|
||||||
parser-private.h parser.c \
|
parser-private.h parser.c \
|
||||||
|
|||||||
68
src/descriptor.c
Normal file
68
src/descriptor.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* libdivecomputer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Jef Driesen
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <libdivecomputer/descriptor.h>
|
||||||
|
|
||||||
|
struct dc_descriptor_t {
|
||||||
|
const char *vendor;
|
||||||
|
const char *product;
|
||||||
|
dc_family_t type;
|
||||||
|
unsigned int model;
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *
|
||||||
|
dc_descriptor_get_vendor (dc_descriptor_t *descriptor)
|
||||||
|
{
|
||||||
|
if (descriptor == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return descriptor->vendor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
dc_descriptor_get_product (dc_descriptor_t *descriptor)
|
||||||
|
{
|
||||||
|
if (descriptor == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return descriptor->product;
|
||||||
|
}
|
||||||
|
|
||||||
|
dc_family_t
|
||||||
|
dc_descriptor_get_type (dc_descriptor_t *descriptor)
|
||||||
|
{
|
||||||
|
if (descriptor == NULL)
|
||||||
|
return DC_FAMILY_NULL;
|
||||||
|
|
||||||
|
return descriptor->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
dc_descriptor_get_model (dc_descriptor_t *descriptor)
|
||||||
|
{
|
||||||
|
if (descriptor == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return descriptor->model;
|
||||||
|
}
|
||||||
@ -20,6 +20,11 @@ dc_datetime_mktime
|
|||||||
dc_iterator_next
|
dc_iterator_next
|
||||||
dc_iterator_free
|
dc_iterator_free
|
||||||
|
|
||||||
|
dc_descriptor_get_vendor
|
||||||
|
dc_descriptor_get_product
|
||||||
|
dc_descriptor_get_type
|
||||||
|
dc_descriptor_get_model
|
||||||
|
|
||||||
dc_parser_get_type
|
dc_parser_get_type
|
||||||
dc_parser_set_data
|
dc_parser_set_data
|
||||||
dc_parser_get_datetime
|
dc_parser_get_datetime
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user