ad35de80e2b694c400591d312541d3b3ec024796
[openjpeg.git] / applications / jpip / opj_client / opj_dec_server / cache_manager.h
1 /*
2  * $Id: cache_manager.h 44 2011-02-15 12:32:29Z kaori $
3  *
4  * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
5  * Copyright (c) 2002-2011, Professor Benoit Macq
6  * Copyright (c) 2010-2011, Kaori Hagihara
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef         CACHE_MANAGER_H_
32 # define        CACHE_MANAGER_H_
33
34 #include "metadata_manager.h"
35 #include "ihdrbox_manager.h"
36
37 //! maximum length of target name
38 #define MAX_LENOFTARGET 128
39
40 //! maximum length of target identifier
41 #define MAX_LENOFTID 30
42
43 //! cache parameters
44 typedef struct cache_param{
45   char filename[MAX_LENOFTARGET];     //!< file name
46   char tid[MAX_LENOFTID];             //!< taregt identifier
47   int csn;                            //!< codestream number
48   char **cid;                         //!< dynamic array of channel identifiers
49   int numOfcid;                       //!< number of cids
50   metadatalist_param_t *metadatalist; //!< metadata-bin list
51   ihdrbox_param_t *ihdrbox;           //!< ihdrbox
52   struct cache_param *next;           //!< pointer to the next cache
53 } cache_param_t;
54
55 //!< cache list parameters
56 typedef struct cachelist_param{
57   cache_param_t *first; //!< first cache pointer of the list
58   cache_param_t *last;  //!< last  cache pointer of the list
59 } cachelist_param_t;
60
61
62 /**
63  * generate a cache list
64  *
65  * @return pointer to the generated cache list
66  */
67 cachelist_param_t * gene_cachelist();
68
69 /**
70  * delete cache list
71  *
72  * @param[in,out] cachelist address of the cache list pointer
73  */
74 void delete_cachelist(cachelist_param_t **cachelist);
75
76 /**
77  * generate a cache
78  *
79  * @param[in] targetname target file name
80  * @param[in] csn        codestream number
81  * @param[in] tid        target identifier
82  * @param[in] cid        channel identifier
83  * @return               pointer to the generated cache
84  */
85 cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid);
86
87 /**
88  * delete a cache
89  *
90  * @param[in] cache address of the cache pointer
91  */
92 void delete_cache( cache_param_t **cache);
93
94 /**
95  * insert a cache into list
96  *
97  * @param[in] cache     cache pointer
98  * @param[in] cachelist cache list pointer
99  */
100 void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist);
101
102
103 /**
104  * search a cache by target name
105  *
106  * @param[in] targetname target filename
107  * @param[in] cachelist  cache list pointer
108  * @return               found cache pointer
109  */
110 cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist);
111
112
113 /**
114  * search a cache by csn
115  *
116  * @param[in] csn        codestream number
117  * @param[in] cachelist  cache list pointer
118  * @return               found cache pointer
119  */
120 cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
121
122
123 /**
124  * search codestream number (csn) by cid
125  *
126  * @param[in] cid        channel identifer
127  * @param[in] cachelist  cache list pointer
128  * @return               found cache pointer
129  */
130 cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
131
132 /**
133  * add cid into a cache
134  *
135  * @param[in] cid   channel identifier
136  * @param[in] cache cache pointer
137  */
138 void add_cachecid( char *cid, cache_param_t *cache);
139
140
141 /**
142  * update tid of a cache
143  *
144  * @param[in] tid   target identifier
145  * @param[in] cache cache pointer
146  */
147 void update_cachetid( char *tid, cache_param_t *cache);
148
149
150 /**
151  * remove cid in cache
152  *
153  * @param[in] cid       channel identifier
154  * @param[in] cachelist cachelist pointer
155  */
156 void remove_cachecid( char *cid, cachelist_param_t *cachelist);
157
158
159 /**
160  * print cache parameters
161  *
162  * @param[in] cache cache pointer
163  */
164 void print_cache( cache_param_t *cache);
165
166 /**
167  * print all cache parameters
168  *
169  * @param[in] cachelist cache list pointer
170  */
171 void print_allcache( cachelist_param_t *cachelist);
172
173 #endif /* !CACHE_MANAGER_H_ */