00001 /*************************************************************************** 00002 l1394csrdirectory.h - description 00003 ------------------- 00004 begin : Fri Oct 27 2000 00005 copyright : (C) 2000-2004 by Michael Repplinger 00006 email : repplinger@cs.uni-sb.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef L1394CSRDIRECTORY_H 00019 #define L1394CSRDIRECTORY_H 00020 00021 #include "l1394_qarray.h" 00022 //document_status : final 00023 //debug_status : 00024 00025 namespace L1394{ 00026 namespace internal{ 00027 class CsrDirectory; 00028 /*! \class DNode 00029 * \ingroup Internal 00030 * \brief A DNode represents a node of the CsrDirectory. 00031 * 00032 * There a four node types that store information the CsrRom: 00033 * The type is stored as integer value. 00034 * DNode-type immediate : <BR> 00035 * This DNode stores the information of an immediate entry in CsrRom. 00036 * 00037 * DNode-type offset : <BR> 00038 * This DNode stores the information of an offset entry in CsrRom. 00039 * 00040 * DNode-type leaf : <BR> 00041 * This DNode stores the information of an leaf entry in CsrRom. 00042 * 00043 * DNode type directory : <BR> 00044 * This DNode stores a pointer to a CsrDirectory in CsrRom. 00045 * 00046 * @author Michael Repplinger 00047 */ 00048 00049 00050 class DNode { 00051 00052 static const char *nodeType[]; 00053 static const char *keyValue[]; 00054 00055 public: 00056 00057 /*! \fn DNode() 00058 * \brief Constructor 00059 */ 00060 DNode(); 00061 00062 /*! \fn DNode(int type, QArray *node_info) 00063 * \brief Constructor 00064 * \param type : integer value for the DNode type. 00065 * \param node_info : pointer with the node information 00066 */ 00067 DNode(int type, QArray *node_info); 00068 00069 00070 /*! \fn DNode(int type, CsrDirectory* subdirectory) 00071 * \brief Constructor 00072 * \param type : integer value for DNode type 00073 * \param subdirectory : pointer to the subdirectory. 00074 */ 00075 DNode(int type, CsrDirectory *subdir); 00076 00077 00078 /*! \fn ~DNode() 00079 * \brief Destructor 00080 */ 00081 ~DNode(); 00082 00083 /*! \fn print() 00084 * \brief This method prints the content of a DNode to standard output. 00085 */ 00086 void print(); 00087 00088 00089 /*! \fn getType() const 00090 * \brief This method returns the type of a DNode. 00091 * \return int : the DNode type. 00092 */ 00093 int getType() const {return type;} 00094 00095 00096 /*! \fn getInfo() const 00097 * \brief This method returns a pointer to the information stored in the DNode. 00098 * \return QArray* : pointer to the information, NULL if it stores a subdirectory. 00099 */ 00100 QArray* getInfo() const {return leafInfo;} 00101 00102 00103 /*! \fn getSubDir() const 00104 * \brief This method returns the subdirectory of a DNode. 00105 * \return CsrDirectoy* : a pointer to the subdirectory, NULL if the DNode has no 00106 * subdirectory. 00107 */ 00108 CsrDirectory* getSubDir() const {return subDir;} 00109 00110 private: 00111 00112 int type; 00113 CsrDirectory *subDir; 00114 QArray *leafInfo; 00115 }; 00116 00117 00118 /*! \class CsrDirectory 00119 * \ingroup Internal 00120 * \brief An object of this class represent the CSR directory of a CSR rom. 00121 * 00122 * Every CSR rom has at least one CSR directory to store some information. 00123 * A CsrDirectory object represent a CSR directory and stores the information 00124 * in DNodes. 00125 * 00126 * For more information about CSR rom and the data structures see IEEE1212 00127 * specification. 00128 * 00129 * @author Michael Repplinger 00130 */ 00131 00132 00133 class CsrDirectory { 00134 00135 00136 public: 00137 00138 /*! \fn CsrDirectory(int i,CsrDirectory* ) 00139 * \brief Constructor for a directory of length i and parent directory p. 00140 * For a root directory the parent is NULL 00141 */ 00142 CsrDirectory(int i,CsrDirectory*); 00143 00144 /*! \fn ~CsrDirectory() 00145 * \brief Destructor 00146 */ 00147 ~CsrDirectory(); 00148 00149 00150 /*! \fn print() 00151 * \brief This method prints the content of a directory to standard output. 00152 */ 00153 void print() { for (int i=0; i<count; i++) root_directory[i]->print();} 00154 00155 00156 /*! \fn getParent() const 00157 * \brief This method returns the parent of a directory. 00158 * \return CsrDirectory* : returns a pointer to the parent directory, NULL if it's a root directory 00159 */ 00160 CsrDirectory* getParent() const { return parent;} 00161 00162 00163 /*! \fn findSubDir(int key_id, CsrDirectory* start_directory) 00164 * \brief This method searches a directory with a specific key_id. 00165 * 00166 * The key_id are the last 6 bit of the key 00167 * \param key_id : integer value for the key_id 00168 * \param start_directory : pointer to the start directory 00169 * \return CsrDirectory : pointer to the CsrDirectory with key_id, 00170 * NULL if no such directory exist. 00171 */ 00172 CsrDirectory *findSubDir(int key_id, CsrDirectory *startDirectory); 00173 00174 00175 /*! \fn getDNode(int i) 00176 * \brief This method returns the i'th DNode of the directory 00177 * \param i : integer value for the i'th DNode. 00178 * \return DNode* : pointer to the i'th entry of the directory 00179 */ 00180 DNode *getDNode(int i) {if (i < count) return root_directory[i]; else return NULL;} 00181 00182 00183 /*! \fn attach(DNode* entry) 00184 * \brief This method adds an DNode to the root_directory 00185 * \param entry : pointer to the new DNode. 00186 */ 00187 void attach(DNode *d) {if (count < max_count) { root_directory[count] = d; count++;}} 00188 00189 /*! \fn findNode(int key_id, CsrDirectory *start_directory) 00190 * \brief This method searches a node with key_id and returns a pointer to it. 00191 * 00192 * The search starts at start_directory. 00193 * \param key_id : integer value with the key_id 00194 * \param start_directory : pointer to the start directory. 00195 * \return DNode* : pointer to the directory node, NULL if no such DNode exist. 00196 */ 00197 DNode *findNode(int key_id, CsrDirectory *startDirectory); 00198 00199 00200 /*! \fn findNode(int key_id, CsrDirectory *startDirectory) 00201 * \brief This method searches a node with a specific key_id. 00202 * 00203 * The search start in this directory. 00204 * \param key_id : integer value with the key-id 00205 * \return DNode* : pointer to the DNode with key_id, NULL if no such DNode exist. 00206 */ 00207 DNode *findNode(int key_id) {return findNode(key_id, this);} 00208 00209 00210 /*! \fn getLength() const 00211 * \brief returns the size of the directory. 00212 * \return the size of the directory 00213 */ 00214 int getLength() const {return count;} 00215 00216 private: 00217 00218 //disable copy constructor 00219 CsrDirectory(const CsrDirectory&); 00220 00221 DNode **root_directory; 00222 CsrDirectory *parent; 00223 int max_count, count; 00224 }; 00225 } 00226 } 00227 #endif