00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: apt_obj_list.h 1708 2010-05-24 17:03:25Z achaloyan $ 00017 */ 00018 00019 #ifndef APT_OBJ_LIST_H 00020 #define APT_OBJ_LIST_H 00021 00022 /** 00023 * @file apt_obj_list.h 00024 * @brief List of Opaque void* Objects 00025 */ 00026 00027 #include "apt.h" 00028 00029 APT_BEGIN_EXTERN_C 00030 00031 00032 /** Opaque list declaration */ 00033 typedef struct apt_obj_list_t apt_obj_list_t; 00034 /** Opaque list element declaration */ 00035 typedef struct apt_list_elem_t apt_list_elem_t; 00036 00037 /** 00038 * Create list. 00039 * @param pool the pool to allocate list from 00040 * @return the created list 00041 */ 00042 APT_DECLARE(apt_obj_list_t*) apt_list_create(apr_pool_t *pool); 00043 00044 /** 00045 * Destroy list. 00046 * @param list the list to destroy 00047 */ 00048 APT_DECLARE(void) apt_list_destroy(apt_obj_list_t *list); 00049 00050 /** 00051 * Push object to the list as first in, first out. 00052 * @param list the list to push object to 00053 * @param obj the object to push 00054 * @param pool the pool to allocate list element from 00055 * @return the inserted element 00056 */ 00057 APT_DECLARE(apt_list_elem_t*) apt_list_push_back(apt_obj_list_t *list, void *obj, apr_pool_t *pool); 00058 00059 /** 00060 * Pop object from the list as first in, first out. 00061 * @param list the list to pop message from 00062 * @return the popped object (if any) 00063 */ 00064 APT_DECLARE(void*) apt_list_pop_front(apt_obj_list_t *list); 00065 00066 /** 00067 * Retrieve object of the first element in the list. 00068 * @param list the list to retrieve from 00069 */ 00070 APT_DECLARE(void*) apt_list_head(const apt_obj_list_t *list); 00071 00072 /** 00073 * Retrieve object of the last element in the list. 00074 * @param list the list to retrieve from 00075 */ 00076 APT_DECLARE(void*) apt_obj_list_tail(const apt_obj_list_t *list); 00077 00078 00079 /** 00080 * Retrieve the first element of the list. 00081 * @param list the list to retrieve from 00082 */ 00083 APT_DECLARE(apt_list_elem_t*) apt_list_first_elem_get(const apt_obj_list_t *list); 00084 00085 /** 00086 * Retrieve the last element of the list. 00087 * @param list the list to retrieve from 00088 */ 00089 APT_DECLARE(apt_list_elem_t*) apt_list_last_elem_get(const apt_obj_list_t *list); 00090 00091 /** 00092 * Retrieve the next element of the list. 00093 * @param list the list to retrieve from 00094 * @param elem the element to retrieve next element from 00095 */ 00096 APT_DECLARE(apt_list_elem_t*) apt_list_next_elem_get(const apt_obj_list_t *list, apt_list_elem_t *elem); 00097 00098 /** 00099 * Retrieve the prev element of the list. 00100 * @param list the list to retrieve from 00101 * @param elem the element to retrieve prev element from 00102 */ 00103 APT_DECLARE(apt_list_elem_t*) apt_list_prev_elem_get(const apt_obj_list_t *list, apt_list_elem_t *elem); 00104 00105 /** 00106 * Insert element to the list. 00107 * @param list the list to insert element to 00108 * @param elem the element to insert before 00109 * @param obj the object to insert 00110 * @param pool the pool to allocate list element from 00111 * @return the inserted element 00112 */ 00113 APT_DECLARE(apt_list_elem_t*) apt_list_elem_insert(apt_obj_list_t *list, apt_list_elem_t *elem, void *obj, apr_pool_t *pool); 00114 00115 /** 00116 * Remove element from the list. 00117 * @param list the list to remove element from 00118 * @param elem the element to remove 00119 * @return the next element (if any) 00120 */ 00121 APT_DECLARE(apt_list_elem_t*) apt_list_elem_remove(apt_obj_list_t *list, apt_list_elem_t *elem); 00122 00123 /** 00124 * Query whether the list is empty. 00125 * @param list the list to query 00126 * @return TRUE if empty, otherwise FALSE 00127 */ 00128 APT_DECLARE(apt_bool_t) apt_list_is_empty(const apt_obj_list_t *list); 00129 00130 /** 00131 * Retrieve the object associated with element. 00132 * @param elem the element to retrieve object from 00133 */ 00134 APT_DECLARE(void*) apt_list_elem_object_get(const apt_list_elem_t *elem); 00135 00136 00137 APT_END_EXTERN_C 00138 00139 #endif /* APT_OBJ_LIST_H */