2 * $Id: cache_manager.h 44 2011-02-15 12:32:29Z kaori $
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
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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.
31 #ifndef CACHE_MANAGER_H_
32 # define CACHE_MANAGER_H_
34 #include "metadata_manager.h"
35 #include "ihdrbox_manager.h"
37 //! maximum length of target name
38 #define MAX_LENOFTARGET 128
40 //! maximum length of target identifier
41 #define MAX_LENOFTID 30
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
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
63 * generate a cache list
65 * @return pointer to the generated cache list
67 cachelist_param_t * gene_cachelist();
72 * @param[in,out] cachelist address of the cache list pointer
74 void delete_cachelist(cachelist_param_t **cachelist);
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
85 cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid);
90 * @param[in] cache address of the cache pointer
92 void delete_cache( cache_param_t **cache);
95 * insert a cache into list
97 * @param[in] cache cache pointer
98 * @param[in] cachelist cache list pointer
100 void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist);
104 * search a cache by target name
106 * @param[in] targetname target filename
107 * @param[in] cachelist cache list pointer
108 * @return found cache pointer
110 cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist);
114 * search a cache by csn
116 * @param[in] csn codestream number
117 * @param[in] cachelist cache list pointer
118 * @return found cache pointer
120 cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
124 * search codestream number (csn) by cid
126 * @param[in] cid channel identifer
127 * @param[in] cachelist cache list pointer
128 * @return found cache pointer
130 cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
133 * add cid into a cache
135 * @param[in] cid channel identifier
136 * @param[in] cache cache pointer
138 void add_cachecid( char *cid, cache_param_t *cache);
142 * update tid of a cache
144 * @param[in] tid target identifier
145 * @param[in] cache cache pointer
147 void update_cachetid( char *tid, cache_param_t *cache);
151 * remove cid in cache
153 * @param[in] cid channel identifier
154 * @param[in] cachelist cachelist pointer
156 void remove_cachecid( char *cid, cachelist_param_t *cachelist);
160 * print cache parameters
162 * @param[in] cache cache pointer
164 void print_cache( cache_param_t *cache);
167 * print all cache parameters
169 * @param[in] cachelist cache list pointer
171 void print_allcache( cachelist_param_t *cachelist);
173 #endif /* !CACHE_MANAGER_H_ */