membergroup.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * $Id: membergroup.cpp,v 1.19 2001/03/19 19:27:41 root Exp $
00004  *
00005  * Copyright (C) 1997-2008 by Dimitri van Heesch.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and its
00008  * documentation under the terms of the GNU General Public License is hereby 
00009  * granted. No representations are made about the suitability of this software 
00010  * for any purpose. It is provided "as is" without express or implied warranty.
00011  * See the GNU General Public License for more details.
00012  *
00013  * Documents produced by Doxygen are derivative works derived from the
00014  * input used in their production; they are not affected by this license.
00015  *
00016  */
00017 
00018 #include "qtbc.h"
00019 #include "membergroup.h"
00020 #include "memberlist.h"
00021 #include "outputlist.h"
00022 #include "util.h"
00023 #include "classdef.h"
00024 #include "namespacedef.h"
00025 #include "filedef.h"
00026 #include "language.h"
00027 #include "groupdef.h"
00028 #include "doxygen.h"
00029 #include "docparser.h"
00030 #include "marshal.h"
00031 
00032 //static QCString idToName(int id)
00033 //{
00034 //  QCString result;
00035 //  result.sprintf("mgroup_%d",id);
00036 //  return result;
00037 //}
00038 
00039 MemberGroup::MemberGroup()
00040 {
00041 }
00042 
00043 MemberGroup::MemberGroup(Definition *parent,
00044       int id,const char *hdr,const char *d,const char *docFile) 
00045 {
00046   //printf("New member group id=%d header=%s desc=%s\n",id,hdr,d);
00047   memberList      = new MemberList(MemberList::memberGroup);
00048   grpId           = id;
00049   grpHeader       = hdr;
00050   doc             = d;
00051   scope           = 0;
00052   inSameSection   = TRUE;
00053   inDeclSection   = 0;
00054   m_numDecMembers = -1;
00055   m_numDocMembers = -1;
00056   m_parent        = parent;
00057   m_docFile       = docFile;
00058   //printf("Member group docs=`%s'\n",doc.data());
00059 }
00060 
00061 MemberGroup::~MemberGroup()
00062 {
00063   delete memberList;
00064 }
00065 
00066 void MemberGroup::insertMember(MemberDef *md)
00067 {
00068   //printf("MemberGroup::insertMember m_parent=%s memberList=%p count=%d"
00069   //       " member section list: %p\n",
00070   //       m_parent ? m_parent->name().data() : "<null>",
00071   //       memberList->first() ? memberList->first()->getSectionList(m_parent) : 0,
00072   //       memberList->count(),
00073   //       md->getSectionList(m_parent));
00074   MemberDef *firstMd = memberList->first();
00075   if (inSameSection && memberList->count()>0 && 
00076       firstMd->getSectionList(m_parent)!=md->getSectionList(m_parent))
00077   {
00078     inSameSection=FALSE;
00079   }
00080   else if (inDeclSection==0)
00081   {
00082     inDeclSection = md->getSectionList(m_parent);
00083     //printf("inDeclSection=%p type=%d\n",inDeclSection,inDeclSection->listType());
00084   }
00085   memberList->append(md);
00086 
00087   // copy the group of the first member in the memberGroup
00088   GroupDef *gd;
00089   if (firstMd && (gd=firstMd->getGroupDef()))
00090   {
00091     md->setGroupDef(gd, firstMd->getGroupPri(), 
00092                     firstMd->getGroupFileName(), firstMd->getGroupStartLine(), 
00093                     firstMd->getGroupHasDocs());
00094     gd->insertMember(md);
00095   }
00096 }
00097 
00098 
00099 void MemberGroup::setAnchors(ClassDef *context)
00100 {
00101   ::setAnchors(context,'z',memberList,grpId);
00102 }
00103 
00104 void MemberGroup::writeDeclarations(OutputList &ol,
00105                ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd)
00106 {
00107   //printf("MemberGroup::writeDeclarations() memberList->count()=%d\n",memberList->count());
00108   memberList->writeDeclarations(ol,cd,nd,fd,gd,grpHeader,doc/*,TRUE,TRUE*/);
00109 }
00110 
00111 void MemberGroup::writePlainDeclarations(OutputList &ol,
00112                ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd
00113               )
00114 {
00115   //printf("MemberGroup::writePlainDeclarations() memberList->count()=%d\n",memberList->count());
00116   memberList->writePlainDeclarations(ol,cd,nd,fd,gd);
00117 }
00118 
00119 void MemberGroup::writeDocumentation(OutputList &ol,const char *scopeName,
00120                Definition *container)
00121 {
00122   memberList->writeDocumentation(ol,scopeName,container,0);
00123 }
00124 
00125 void MemberGroup::writeDocumentationPage(OutputList &ol,const char *scopeName,
00126                Definition *container)
00127 {
00128   memberList->writeDocumentationPage(ol,scopeName,container);
00129 }
00130 
00134 void MemberGroup::addToDeclarationSection()
00135 {
00136   if (inDeclSection)
00137   {
00138     //printf("Adding group %p to list %p (type=%d)\n",this,
00139     //                              inDeclSection,inDeclSection->listType());
00140     inDeclSection->addMemberGroup(this);
00141   }
00142 }
00143 
00144 int MemberGroup::countDecMembers(/*bool sectionPerType*/)
00145 {
00146   if (m_numDecMembers==-1) /* number of member not cached */
00147   {
00148     memberList->countDecMembers(/*TRUE,TRUE,sectionPerType*/);
00149     m_numDecMembers = memberList->numDecMembers();
00150   }
00151   return m_numDecMembers;
00152 }
00153 
00154 int MemberGroup::countDocMembers()
00155 {
00156   if (m_numDocMembers==-1)
00157   {
00158     memberList->countDocMembers();
00159     m_numDocMembers = memberList->numDocMembers();
00160   }
00161   return m_numDocMembers;
00162 }
00163 
00164 void MemberGroup::distributeMemberGroupDocumentation()
00165 {
00166   //printf("MemberGroup::distributeMemberGroupDocumentation() %s\n",grpHeader.data());
00167   MemberDef *md=memberList->first();
00168   if (md && !(md->documentation().isEmpty() && 
00169               md->briefDescription().isEmpty() && 
00170               md->inbodyDocumentation().isEmpty()
00171              )
00172      )
00173   {
00174     //printf("First member %s has documentation!\n",md->name().data());
00175     MemberDef *omd=memberList->next();
00176     while (omd)
00177     {
00178       if (omd->documentation().isEmpty() && omd->briefDescription().isEmpty() && omd->inbodyDocumentation().isEmpty())
00179       {
00180         //printf("Copying documentation to member %s\n",omd->name().data());
00181         omd->setBriefDescription(md->briefDescription(),md->briefFile(),md->briefLine());
00182         omd->setDocumentation(md->documentation(),md->docFile(),md->docLine());
00183         omd->setInbodyDocumentation(md->inbodyDocumentation(),md->inbodyFile(),md->inbodyLine());
00184       }
00185       omd=memberList->next();
00186     }
00187   }
00188 }
00189 
00190 int MemberGroup::varCount() const       
00191 { 
00192   return memberList->varCount(); 
00193 }
00194 
00195 int MemberGroup::funcCount() const      
00196 { 
00197   return memberList->funcCount(); 
00198 }
00199 
00200 int MemberGroup::enumCount() const      
00201 { 
00202   return memberList->enumCount(); 
00203 }
00204 
00205 int MemberGroup::enumValueCount() const 
00206 { 
00207   return memberList->enumValueCount(); 
00208 }
00209 
00210 int MemberGroup::typedefCount() const   
00211 { 
00212   return memberList->typedefCount(); 
00213 }
00214 
00215 int MemberGroup::protoCount() const     
00216 { 
00217   return memberList->protoCount(); 
00218 }
00219 
00220 int MemberGroup::defineCount() const    
00221 { 
00222   return memberList->defineCount(); 
00223 }
00224 
00225 int MemberGroup::friendCount() const    
00226 { 
00227   return memberList->friendCount(); 
00228 }
00229 
00230 int MemberGroup::numDecMembers() const  
00231 { 
00232   return memberList->numDecMembers(); 
00233 }
00234 
00235 int MemberGroup::numDocMembers() const  
00236 { 
00237   return memberList->numDocMembers(); 
00238 }
00239 
00240 void MemberGroup::setInGroup(bool b)
00241 {
00242   memberList->setInGroup(b);
00243 }
00244 
00245 void MemberGroup::addListReferences(Definition *def)
00246 {
00247   memberList->addListReferences(def);
00248 }
00249 
00250 void MemberGroup::findSectionsInDocumentation()
00251 {
00252   docFindSections(doc,0,this,m_docFile);
00253   memberList->findSectionsInDocumentation();
00254 }
00255 
00256 void MemberGroup::marshal(StorageIntf *s)
00257 {
00258   marshalMemberList(s,memberList);
00259   marshalObjPointer(s,inDeclSection); // reference only
00260   marshalInt(s,grpId);
00261   marshalQCString(s,grpHeader);
00262   marshalQCString(s,fileName);
00263   marshalObjPointer(s,scope);
00264   marshalQCString(s,doc);
00265   marshalBool(s,inSameSection);
00266   marshalInt(s,m_numDecMembers);
00267   marshalInt(s,m_numDocMembers);
00268   marshalObjPointer(s,m_parent);
00269   marshalQCString(s,m_docFile);
00270 }
00271 
00272 void MemberGroup::unmarshal(StorageIntf *s)
00273 {
00274   memberList      = unmarshalMemberList(s);
00275   inDeclSection   = (MemberList *)unmarshalObjPointer(s); 
00276   grpId           = unmarshalInt(s);
00277   grpHeader       = unmarshalQCString(s);
00278   fileName        = unmarshalQCString(s);
00279   scope           = (Definition *)unmarshalObjPointer(s);
00280   doc             = unmarshalQCString(s);
00281   inSameSection   = unmarshalBool(s);
00282   m_numDecMembers = unmarshalInt(s);
00283   m_numDocMembers = unmarshalInt(s);
00284   m_parent        = (Definition *)unmarshalObjPointer(s);
00285   m_docFile       = unmarshalQCString(s);
00286 }
00287 



Generated on Mon Mar 31 10:58:40 2008 by  doxygen 1.5.1