Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

find_cfg.h

Go to the documentation of this file.
00001 /*  This file is part of OMCSNetCPP
00002 
00003     OMCSNetCPP is free software; you can redistribute it and/or modify
00004     it under the terms of the GNU Lesser General Public License as published by
00005     the Free Software Foundation; either version 2.1 of the License, or
00006     (at your option) any later version.
00007 
00008     OMCSNetCPP is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011     GNU Lesser General Public License for more details.
00012 
00013     You should have received a copy of the GNU Lesser General Public License
00014     along with OMCSNetCPP; if not, write to the Free Software
00015     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016  */
00017 
00020 #ifndef _FIND_CFG
00021 
00022 #define _FIND_CFG
00023 
00024 #include "concept_map.h"
00025 #include "link_list.h"
00026 #include "debug.h"
00027 
00028 class CSemanticConcept;
00029 
00030 
00032 class CFindPathConfig
00033 {
00034         public:
00036                 bool AllowVisit()
00037                 {
00038                         if (m_curNodeVisits >= m_maxNodeVisits)
00039                         {
00040                                 return false;
00041                         }
00042 
00043                         if (m_resultsList.size() >= m_maxNodeResults)
00044                         {
00045                                 return false;
00046                         }
00047 
00048                         return true;
00049                 }
00050 
00052                 void VisitNode()
00053                 {
00054                         m_curNodeVisits++;
00055                 }
00056 
00058                 void VisitLink(CSemanticLink *a_link)
00059                 {
00060                         m_currentPath->Store(a_link);
00061                 }
00062 
00064                 bool CheckCurrentPath(CSemanticLink *a_link)
00065                 {
00066                         return m_currentPath->Lookup(a_link);
00067                 }
00068 
00070                 void SetCurrentPath(CSemanticLinkList *a_list)
00071                 {
00072                         if (a_list)
00073                         {
00074                                 delete m_currentPath;
00075 
00076                                 m_currentPath = a_list->Clone();
00077                         }
00078                 }
00079 
00081                 void LeaveNode()
00082                 {
00083                 }
00084 
00086                 void LeaveLink()
00087                 {
00088                         m_currentPath->Remove();
00089                 }
00090 
00092                 void AddPathToResults()
00093                 {
00094                         CSemanticLinkList *a_list = m_currentPath->Clone();
00095 
00096                         DPRINT("adding result path of size %d\n",
00097                                 a_list->GetSize());
00098 
00099                         m_resultsList.push_back(a_list);
00100                 }
00101 
00103                 u_int GetNumResults() const
00104                 {
00105                         return m_resultsList.size();
00106                 }
00107 
00109                 CSemanticLinkList *GetResult(const u_int a_index)
00110                 {
00111                         u_int l_count = 0;
00112 
00113                         CResultsList_ci i;
00114 
00115                         for (i = m_resultsList.begin();i != m_resultsList.end();
00116                              ++i)
00117                         {
00118                                 if (a_index == l_count)
00119                                 {
00120                                         return (*i);
00121                                 }
00122 
00123                                 l_count++;
00124                         }
00125 
00126                         return NULL;
00127                 }
00128 
00130                 u_int GetNumNodeVisits() const
00131                 {
00132                         return m_curNodeVisits;
00133                 }
00134 
00136                 CSemanticLinkList *GetQueuePath()
00137                 {
00138                         CResultsList_i i;
00139 
00140                         i = m_pathQueue.begin();
00141 
00142                         if (m_pathQueue.end() != i)
00143                         {
00144                                 CSemanticLinkList *l_list = (*i);
00145 
00146                                 m_pathQueue.pop_front();
00147 
00148                                 return l_list;
00149                         }
00150 
00151                         return NULL;
00152                 }
00153 
00155                 void QueuePath()
00156                 {
00157                         CSemanticLinkList *l_list = m_currentPath->Clone();
00158 
00159                         m_pathQueue.push_back(l_list);
00160                 }
00161 
00163                 CFindPathConfig()
00164                 {
00165                         m_maxNodeVisits  = 50000;
00166                         m_maxNodeResults = 200;
00167 
00168                         m_curNodeVisits = 0;
00169                         m_curNodeDepth  = 0;
00170 
00171                         m_currentPath = new CSemanticLinkList;
00172                 }
00173 
00175                 ~CFindPathConfig() {}
00176 
00177         private:
00179                 u_int m_maxNodeVisits;
00181                 u_int m_maxNodeResults;
00182 
00184                 u_int m_curNodeVisits;
00186                 u_int m_curNodeDepth;
00187 
00189                 CSemanticLinkList *m_currentPath;
00190 
00192                 typedef std::list<CSemanticLinkList *>  CResultsList;
00193 
00195                 typedef CResultsList::iterator          CResultsList_i;
00197                 typedef CResultsList::const_iterator    CResultsList_ci;
00198 
00200                 CResultsList m_resultsList;
00201 
00203                 CResultsList m_pathQueue;
00204 };
00205 
00206 #endif
00207 

Generated on Tue Sep 16 09:43:49 2003 for OMCSNetCPP by doxygen 1.3.3