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

link.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 _LINK
00021 
00022 #define _LINK
00023 
00024 #include "textid_map.h"
00025 #include "id_generator.h"
00026 #include "relation_type.h"
00027 
00028 class CSemanticLinkList;
00029 class CSemanticConcept;
00030 class CFindPathConfig;
00031 class CConceptMap;
00032 
00033 
00035 class CSemanticLink
00036 {
00037         public:
00039                 bool Load(FILE        *a_fp,
00040                           CConceptMap &a_conceptMap);
00041 
00043                 bool Save(FILE *a_fp)
00044                 {
00045                         if (!a_fp)
00046                         {
00047                                 return false;
00048                         }
00049 
00050                         fwrite(&m_sourceID, sizeof(SemanticID), 1, a_fp);
00051 
00052                         fwrite(&m_destID, sizeof(SemanticID), 1, a_fp);
00053 
00054                         fwrite(&m_linkID, sizeof(SemanticID), 1, a_fp);
00055 
00056                         fwrite(&m_type, sizeof(RelationType), 1, a_fp);
00057 
00058                         return true;
00059                 }
00060 
00062                 bool FindPathTo(const SemanticID       a_dstID,
00063                                                     CFindPathConfig &a_config);
00064 
00066                 RelationType GetType() const
00067                 {
00068                         return m_type;
00069                 }
00070 
00072                 void SetType(const RelationType a_type)
00073                 {
00074                         m_type = a_type;
00075                 }
00076 
00078                 CSemanticConcept *GetSource()
00079                 {
00080                         return m_source;
00081                 }
00082 
00084                 CSemanticConcept *GetDest()
00085                 {
00086                         return m_dest;
00087                 }
00088 
00090                 SemanticID GetSourceID() const
00091                 {
00092                         return m_sourceID;
00093                 }
00094 
00096                 SemanticID GetDestID() const
00097                 {
00098                         return m_destID;
00099                 }
00100 
00102                 void SetSource(CSemanticConcept *a_concept);
00103 
00105                 void SetDest(CSemanticConcept *a_concept);
00106 
00108                 void SetSourceID(const SemanticID a_id)
00109                 {
00110                         m_sourceID = a_id;
00111 
00112                         m_source   = NULL;
00113                 }
00114 
00116                 void SetDestID(const SemanticID a_id)
00117                 {
00118                         m_destID = a_id;
00119 
00120                         m_dest   = NULL;
00121                 }
00122 
00124                 SemanticID GetID() const
00125                 {
00126                         return m_linkID;
00127                 }
00128 
00130                 void SetID(const SemanticID a_id)
00131                 {
00132                         m_linkID = a_id;
00133                 }
00134 
00136                 CSemanticLink();
00137 
00139                 ~CSemanticLink()
00140                 {
00141                         // NOTE: source/dest concepts not deallocated as this
00142                         // is performed centrally by the main concept map
00143                 }
00144 
00145         private:
00147                 SemanticID m_sourceID;
00148 
00150                 SemanticID m_destID;
00151 
00153                 SemanticID m_linkID;
00154 
00156                 RelationType m_type;
00157 
00159                 CSemanticConcept *m_source;
00160 
00162                 CSemanticConcept *m_dest;
00163 };
00164 
00165 #endif
00166 

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