Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
04e06509
Commit
04e06509
authored
Oct 16, 2017
by
Celine Mercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All DMS opened by a program are now listed and closed with atexit system
parent
5ddd1d9a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
3 deletions
+100
-3
python/obitools3/dms/capi/obidms.pxd
python/obitools3/dms/capi/obidms.pxd
+2
-1
python/obitools3/dms/dms.pyx
python/obitools3/dms/dms.pyx
+7
-2
src/obidms.c
src/obidms.c
+73
-0
src/obidms.h
src/obidms.h
+18
-0
No files found.
python/obitools3/dms/capi/obidms.pxd
View file @
04e06509
...
...
@@ -17,6 +17,7 @@ cdef extern from "obidms.h" nogil:
int
obi_close_dms
(
OBIDMS_p
dms
)
char
*
obi_dms_get_dms_path
(
OBIDMS_p
dms
)
char
*
obi_dms_get_full_path
(
OBIDMS_p
dms
,
const_char_p
path_name
)
void
obi_close_atexit
()
obiversion_t
obi_import_column
(
const
char
*
dms_path_1
,
const
char
*
dms_path_2
,
const
char
*
column_name
,
obiversion_t
version_number
)
int
obi_import_view
(
const
char
*
dms_path_1
,
const
char
*
dms_path_2
,
const
char
*
view_name_1
,
const
char
*
view_name_2
)
python/obitools3/dms/dms.pyx
View file @
04e06509
#cython: language_level=3
from
libc.stdlib
cimport
free
from
libc.stdlib
cimport
free
,
atexit
from
cpython.list
cimport
PyList_Size
from
.capi.obidms
cimport
obi_open_dms
,
\
obi_create_dms
,
\
obi_close_dms
,
\
obi_dms_exists
,
\
obi_dms_get_full_path
obi_dms_get_full_path
,
\
obi_close_atexit
from
.capi.obitypes
cimport
const_char_p
...
...
@@ -30,6 +31,10 @@ cdef class DMS(OBIWrapper):
cdef
inline
OBIDMS_p
pointer
(
self
):
return
<
OBIDMS_p
>
(
self
.
_pointer
)
@
staticmethod
def
obi_atexit
():
atexit
(
obi_close_atexit
)
@
staticmethod
def
open_or_new
(
object
dms_name
)
:
cdef
OBIDMS_p
pointer
...
...
src/obidms.c
View file @
04e06509
...
...
@@ -34,6 +34,10 @@
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
// Initialize global list of opened DMS
OBIDMS_p
global_opened_dms_list
[
MAX_NB_OPENED_DMS
+
1
]
=
{
0
};
/**************************************************************************
*
* D E C L A R A T I O N O F T H E P R I V A T E F U N C T I O N S
...
...
@@ -98,6 +102,31 @@ static char* build_infos_file_name(const char* dms_name);
int
create_dms_infos_file
(
int
dms_file_descriptor
,
const
char
*
dms_name
);
/**
* Internal function adding a DMS in the global list of DMS opened by a program.
*
* @param dms A pointer on the DMS to add.
*
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since October 2017
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
static
int
list_dms
(
OBIDMS_p
dms
);
/**
* Internal function removing a DMS from the global list of DMS opened by a program.
*
* @param dms A pointer on the DMS to remove.
*
* @since October 2017
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
static
void
unlist_dms
(
OBIDMS_p
dms
);
/************************************************************************
*
* D E F I N I T I O N O F T H E P R I V A T E F U N C T I O N S
...
...
@@ -202,11 +231,39 @@ int create_dms_infos_file(int dms_file_descriptor, const char* dms_name)
return
-
1
;
}
return
0
;
}
static
int
list_dms
(
OBIDMS_p
dms
)
{
int
i
=
0
;
while
(
global_opened_dms_list
[
i
]
!=
NULL
)
i
++
;
if
(
i
==
(
MAX_NB_OPENED_DMS
-
1
))
{
obi_set_errno
(
OBIDMS_UNKNOWN_ERROR
);
obidebug
(
1
,
"
\n
Error opening a DMS: maximum number of DMS opened by a program reached"
);
return
-
1
;
}
global_opened_dms_list
[
i
]
=
dms
;
return
0
;
}
static
void
unlist_dms
(
OBIDMS_p
dms
)
{
int
i
=
0
;
while
(
global_opened_dms_list
[
i
]
!=
dms
)
i
++
;
while
(
global_opened_dms_list
[
i
]
!=
NULL
)
{
global_opened_dms_list
[
i
]
=
global_opened_dms_list
[
i
+
1
];
i
++
;
}
}
/**********************************************************************
*
* D E F I N I T I O N O F T H E P U B L I C F U N C T I O N S
...
...
@@ -538,6 +595,9 @@ OBIDMS_p obi_open_dms(const char* dms_path)
dms
->
opened_indexers
=
(
Opened_indexers_list_p
)
malloc
(
sizeof
(
Opened_indexers_list_t
));
(
dms
->
opened_indexers
)
->
nb_opened_indexers
=
0
;
// Add in the global list of opened DMS
list_dms
(
dms
);
return
dms
;
}
...
...
@@ -617,6 +677,10 @@ int obi_close_dms(OBIDMS_p dms)
free
(
dms
);
return
-
1
;
}
// Remove DMS from global list of opened DMS
unlist_dms
(
dms
);
free
(
dms
);
}
...
...
@@ -1085,5 +1149,14 @@ int obi_import_view(const char* dms_path_1, const char* dms_path_2, const char*
}
void
obi_close_atexit
()
{
int
i
=
0
;
while
(
global_opened_dms_list
[
i
]
!=
NULL
)
{
obi_close_dms
(
global_opened_dms_list
[
i
]);
i
++
;
}
}
src/obidms.h
View file @
04e06509
...
...
@@ -36,6 +36,8 @@
*/
#define MAX_NB_OPENED_COLUMNS (1000)
/**< The maximum number of columns open at the same time.
*/
#define MAX_NB_OPENED_DMS (1000)
/**< The maximum number of DMS open at the same time for a given program.
*/
#define MAX_NB_OPENED_INDEXERS (1000)
/**< The maximum number of indexers open at the same time.
*/
#define MAX_PATH_LEN (1024)
/**< Maximum length for the character string defining a
...
...
@@ -121,6 +123,12 @@ typedef struct OBIDMS {
}
OBIDMS_t
,
*
OBIDMS_p
;
/**
* @brief Global Array of DMS pointers listing all the DMS opened by a program.
*/
extern
OBIDMS_p
global_opened_dms_list
[
MAX_NB_OPENED_DMS
+
1
];
/**
* @brief Checks if an OBIDMS exists.
*
...
...
@@ -403,4 +411,14 @@ obiversion_t obi_import_column(const char* dms_path_1, const char* dms_path_2, c
int
obi_import_view
(
const
char
*
dms_path_1
,
const
char
*
dms_path_2
,
const
char
*
view_name_1
,
const
char
*
view_name_2
);
/**
* @brief Closes all DMS in the global list of opened DMS.
* To be executed 'at exit' of programs.
*
* @since October 2017
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
void
obi_close_atexit
();
#endif
/* OBIDMS_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment