[Phylobase-commits] r769 - in pkg/src: . ncl

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 29 22:51:20 CEST 2010


Author: francois
Date: 2010-03-29 22:51:20 +0200 (Mon, 29 Mar 2010)
New Revision: 769

Modified:
   pkg/src/ncl/ncl.h
   pkg/src/ncl/nxsallocatematrix.h
   pkg/src/ncl/nxsassumptionsblock.h
   pkg/src/ncl/nxsblock.h
   pkg/src/ncl/nxscdiscretematrix.h
   pkg/src/ncl/nxscharactersblock.h
   pkg/src/ncl/nxscxxdiscretematrix.h
   pkg/src/ncl/nxsdatablock.h
   pkg/src/ncl/nxsdefs.h
   pkg/src/ncl/nxsdiscretedatum.h
   pkg/src/ncl/nxsdistancedatum.h
   pkg/src/ncl/nxsdistancesblock.h
   pkg/src/ncl/nxsexception.h
   pkg/src/ncl/nxsmultiformat.h
   pkg/src/ncl/nxspublicblocks.h
   pkg/src/ncl/nxsreader.h
   pkg/src/ncl/nxssetreader.h
   pkg/src/ncl/nxsstring.h
   pkg/src/ncl/nxstaxablock.h
   pkg/src/ncl/nxstoken.h
   pkg/src/ncl/nxstreesblock.h
   pkg/src/ncl/nxsunalignedblock.h
   pkg/src/ncl/nxsutilcopy.h
   pkg/src/nxsassumptionsblock.cpp
   pkg/src/nxsblock.cpp
   pkg/src/nxscharactersblock.cpp
   pkg/src/nxscxxdiscretematrix.cpp
   pkg/src/nxsdatablock.cpp
   pkg/src/nxsdistancesblock.cpp
   pkg/src/nxsexception.cpp
   pkg/src/nxsmultiformat.cpp
   pkg/src/nxspublicblocks.cpp
   pkg/src/nxsreader.cpp
   pkg/src/nxssetreader.cpp
   pkg/src/nxsstring.cpp
   pkg/src/nxstaxablock.cpp
   pkg/src/nxstoken.cpp
   pkg/src/nxstreesblock.cpp
   pkg/src/nxsunalignedblock.cpp
Log:
pushing ncl 2.1.11 into trunk

Modified: pkg/src/ncl/ncl.h
===================================================================
--- pkg/src/ncl/ncl.h	2010-03-29 20:49:59 UTC (rev 768)
+++ pkg/src/ncl/ncl.h	2010-03-29 20:51:20 UTC (rev 769)
@@ -13,7 +13,7 @@
 //	GNU General Public License for more details.
 //
 //	You should have received a copy of the GNU General Public License
-//	along with NCL; if not, write to the Free Software Foundation, Inc., 
+//	along with NCL; if not, write to the Free Software Foundation, Inc.,
 //	59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
 
@@ -72,8 +72,11 @@
 #	endif
 #endif
 #include <vector>
-using namespace std;
 
+# if ! defined (NCL_AVOID_USING_STD)
+	using namespace std;
+#endif
+
 #if defined( __BORLANDC__ )
 #	include <dos.h>
 #endif

Modified: pkg/src/ncl/nxsallocatematrix.h
===================================================================
--- pkg/src/ncl/nxsallocatematrix.h	2010-03-29 20:49:59 UTC (rev 768)
+++ pkg/src/ncl/nxsallocatematrix.h	2010-03-29 20:51:20 UTC (rev 769)
@@ -13,7 +13,7 @@
 //	GNU General Public License for more details.
 //
 //	You should have received a copy of the GNU General Public License
-//	along with NCL; if not, write to the Free Software Foundation, Inc., 
+//	along with NCL; if not, write to the Free Software Foundation, Inc.,
 //	59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 // This code is based on code developed by Mark Holder for the CIPRES project
@@ -27,25 +27,29 @@
 T *** NewThreeDArray(unsigned f , unsigned s , unsigned t);
 template<typename T>
 T ** NewTwoDArray(unsigned f , unsigned s);
-template<typename T> 
+template<typename T>
 void DeleteThreeDArray(T ***& ptr);
 template<typename T>
 void DeleteTwoDArray(T **& ptr);
 
-/*--------------------------------------------------------------------------------------------------------------------------
-| Allocates a three dimensional array of doubles as one contiguous block of memory
-| the dimensions are f two dimensional arrays that are s by t.  
-| the array is set up so that 
-| for(i = 0 ; i < f ; i++)
-|	for (j = 0 ; j < s ; j++)
-|		for (k = 0 ; k < t; k++)
-|			array[i][j][k];
-|
-| would be the same order of access as: 
-| 
-|	T *ptr = **array;
-|	for (i = 0 ; i < f*s*t ; i++)
-|		*ptr++;
+/*!
+ Allocates a three dimensional array of doubles as one contiguous block of memory
+ the dimensions are f two dimensional arrays that are s by t.
+
+	The pointer should be freed by a call to DeleteThreeDArray
+
+ the array is set up so that
+ for(i = 0 ; i < f ; i++)
+	for (j = 0 ; j < s ; j++)
+		for (k = 0 ; k < t; k++)
+			array[i][j][k];
+
+ would be the same order of access as:
+
+	T *ptr = **array;
+	for (i = 0 ; i < f*s*t ; i++)
+		*ptr++;
+
 */
 template<typename T> T *** NewThreeDArray(unsigned f , unsigned s , unsigned t)
 	{
@@ -67,8 +71,8 @@
 	return ptr;
 	}
 
-/*--------------------------------------------------------------------------------------------------------------------------
-| Delete a Three Dimensional Array that has been allocated using NewThreeDArray and sets the pointer to NULL
+/*!
+ Delete a Three Dimensional Array that has been allocated using NewThreeDArray and sets the pointer to NULL
 */
 template<typename T> void DeleteThreeDArray	(T *** & ptr)
 	{
@@ -83,21 +87,24 @@
 		}
 	ptr = NULL;
 	}
-	
-/*--------------------------------------------------------------------------------------------------------------------------
-| 	Allocates a two dimensional array of doubles as one contiguous block of memory
-| 	the dimensions are f by s.  
-| 	the array is set up so that 
-| 	
-|	for(i = 0 ; i < f ; i++)
-|		for (j = 0 ; j < s ; j++)
-|			array[i][j];
-| 	
-|	would be the same order of access as: 
-| 
-|  	T *ptr = **array;
-|	for (i = 0 ; i < f*s*t ; i++)
-|		*ptr++;
+
+/*!
+ 	Allocates a two dimensional array of doubles as one contiguous block of memory
+ 	the dimensions are f by s.
+
+	The pointer should be freed by a call to DeleteTwoDArray
+
+ 	The array is set up so that:
+
+	for(i = 0 ; i < f ; i++)
+		for (j = 0 ; j < s ; j++)
+			array[i][j];
+
+	would be the same order of access as:
+
+  	T *ptr = **array;
+	for (i = 0 ; i < f*s*t ; i++)
+		*ptr++;
 */
 template<typename T> T **NewTwoDArray(unsigned f , unsigned s)
 	{
@@ -110,8 +117,8 @@
 	return ptr;
 	}
 
-/*--------------------------------------------------------------------------------------------------------------------------
-| Delete a 2 Dimensional Array NewTwoDArray and set the ptr to NULL
+/*!
+ Delete a 2 Dimensional Array NewTwoDArray and set the ptr to NULL
 */
 template<typename T> inline void DeleteTwoDArray	(T ** & ptr)
 	{
@@ -123,43 +130,65 @@
 		}
 	}
 
+
 template<typename T>
 class ScopedThreeDMatrix
 	{
 	public:
 		T *** ptr;
 
-		T *** GetAlias() const 
+		/*! returns an alias to the memory, but does not "surrender" the
+			ownership of the pointer to the caller
+		*/
+		T *** GetAlias() const
 			{
 			return ptr;
 			}
+		/*! Creates a new matrix.  See NewThreeDArray() for argument  explanation */
 		ScopedThreeDMatrix(unsigned f = 0, unsigned s = 0, unsigned t = 0)
 			:ptr(NULL)
 			{
 			Initialize(f, s, t);
 			}
+		/*! Frees the old matrix, and creates a new matrix.  See NewThreeDArray() for argument explanation  */
 		void Initialize(unsigned f = 0, unsigned s = 0, unsigned t = 0)
 			{
+			Free();
 			if (f > 0 && s > 0 && t > 0)
 				ptr = NewThreeDArray<T>(f, s, t);
-			else
-				DeleteThreeDArray<T>(ptr);
 			}
+		/*! returns an alias to the memory, and "forgets" about the memory.
+			The caller is responsible for assuring that DeleteThreeDArray is
+			called on the pointer.
+		*/
 		T ***Surrender()
 			{
 			T ***temp = ptr;
 			ptr = NULL;
 			return temp;
-			}		
+			}
 		~ScopedThreeDMatrix()
 			{
-			//POL-23Dec2008 was "if (!ptr)", which obviously caused a memory leak
-			if (ptr)
+			Free();
+			}
+		/*! Releases the memory. */
+		void Free()
+			{
+			if (ptr != NULL)
+				{
 				DeleteThreeDArray<T>(ptr);
+				ptr = 0L;
+				}
 			}
 	};
 
 
+/*!
+	Simple memory-management class for a 2-D array that is allocated using NewTwoDArray
+
+	Memory is deleted when the instance goes out of scope, unless Surrender is called.
+
+*/
 template<typename T>
 class ScopedTwoDMatrix
 	{
@@ -167,33 +196,52 @@
 	public:
 		T ** ptr;
 
-		T ** GetAlias() const 
+		/*! returns an alias to the memory, but does not "surrender" the
+			ownership of the pointer to the caller
+		*/
+		T ** GetAlias() const
 			{
 			return ptr;
 			}
+		/*! Creates a new matrix.  See NewTwoDArray() for argument explanation  */
 		ScopedTwoDMatrix(unsigned f = 0, unsigned s = 0)
 			:ptr(NULL)
 			{
 			Initialize(f, s);
 			}
+		/*! Frees the old matrix, and creates a new matrix.  See NewTwoDArray() for argument explanation  */
 		void Initialize(unsigned f, unsigned s)
 			{
+			Free();
 			if (f > 0 && s > 0)
 				ptr = NewTwoDArray<T>(f, s);
-			else
-				DeleteTwoDArray<T>(ptr);
 			}
+		/*! returns an alias to the memory, and "forgets" about the memory.
+			The caller is responsible for assuring that DeleteTwoDArray is
+			called on the pointer.
+		*/
 		T **Surrender()
 			{
 			T** temp = ptr;
 			ptr = NULL;
 			return temp;
 			}
+
 		~ScopedTwoDMatrix()
 			{
+			Free();
+			}
+
+		/*! Releases the memory. */
+		void Free()
+			{
 			if (ptr != NULL)
+				{
 				DeleteTwoDArray<T>(ptr);
+				ptr = 0L;
+				}
 			}
+
 	};
 
 typedef ScopedTwoDMatrix<double> ScopedDblTwoDMatrix;

Modified: pkg/src/ncl/nxsassumptionsblock.h
===================================================================
--- pkg/src/ncl/nxsassumptionsblock.h	2010-03-29 20:49:59 UTC (rev 768)
+++ pkg/src/ncl/nxsassumptionsblock.h	2010-03-29 20:51:20 UTC (rev 769)
@@ -13,7 +13,7 @@
 //	GNU General Public License for more details.
 //
 //	You should have received a copy of the GNU General Public License
-//	along with NCL; if not, write to the Free Software Foundation, Inc., 
+//	along with NCL; if not, write to the Free Software Foundation, Inc.,
 //	59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
 
@@ -38,17 +38,21 @@
 	{
 	public:
   		virtual void	SetCallback(NxsCharactersBlockAPI *p) = 0;
-  		
 
-		
+
+
 		virtual void SetCharBlockPtr(NxsCharactersBlockAPI * c, NxsBlockLinkStatus s) = 0;
 		virtual void SetTaxaBlockPtr(NxsTaxaBlockAPI *, NxsBlockLinkStatus s) = 0;
 		virtual void SetTreesBlockPtr(NxsTreesBlockAPI *, NxsBlockLinkStatus s) = 0;
 
-		virtual NxsCharactersBlockAPI * GetCharBlockPtr(int *status=NULL) = 0;
-		virtual NxsTaxaBlockAPI * GetTaxaBlockPtr(int *status=NULL) = 0;
-		virtual NxsTreesBlockAPI * GetTreesBlockPtr(int *status=NULL) = 0;
+		virtual NxsCharactersBlockAPI * GetCharBlockPtr(int *status=NULL) = 0; /*v2.1to2.2 13 */
+		virtual NxsTaxaBlockAPI * GetTaxaBlockPtr(int *status=NULL) = 0; /*v2.1to2.2 13 */
+		virtual NxsTreesBlockAPI * GetTreesBlockPtr(int *status=NULL) = 0; /*v2.1to2.2 13 */
 
+		/* i14 */ /*v2.1to2.2 14 */
+		/* i15 */ /*v2.1to2.2 15 */
+		/* i16 */ /*v2.1to2.2 16 */
+
 		virtual void AddCharPartition(const std::string & name, const NxsPartition &) = 0;
 		virtual void AddTaxPartition(const std::string & name, const NxsPartition &) = 0;
 		virtual void AddTreePartition(const std::string & name, const NxsPartition &) = 0;
@@ -69,17 +73,17 @@
 		virtual void SetGapsAsNewstate(bool v) = 0;
  	};
 
-/*----------------------------------------------------------------------------------------------------------------------
-|	This class handles reading and storage for the NxsReader block ASSUMPTIONS. It overrides the member functions Read 
-|	and Reset, which are abstract virtual functions in the base class NxsBlock. Adding a new data member? Don't forget
-|	to:
-|~
-|	o Describe it in the class declaration using a C-style comment.
-|	o Initialize it (unless it is self-initializing) in the constructor and re-initialize it in the Reset function.
-|	o Describe the initial state in the constructor documentation.
-|	o Delete memory allocated to it in both the destructor and Reset function.
-|	o Report it in some way in the Report function.
-|~
+/*!
+	This class handles reading and storage for the NxsReader block ASSUMPTIONS. It overrides the member functions Read
+	and Reset, which are abstract virtual functions in the base class NxsBlock. Adding a new data member? Don't forget
+	to:
+~
+	o Describe it in the class declaration using a C-style comment.
+	o Initialize it (unless it is self-initializing) in the constructor and re-initialize it in the Reset function.
+	o Describe the initial state in the constructor documentation.
+	o Delete memory allocated to it in both the destructor and Reset function.
+	o Report it in some way in the Report function.
+~
 */
 class NxsAssumptionsBlock
   : public NxsAssumptionsBlockAPI
@@ -91,8 +95,8 @@
 		SETS_BLOCK_READ,
 		CODONS_BLOCK_READ
 		};
-		
-	
+
+
 	public:
 							NxsAssumptionsBlock(NxsTaxaBlockAPI *t);
 		virtual				~NxsAssumptionsBlock();
@@ -103,25 +107,26 @@
 		void				SetCallback(NxsCharactersBlockAPI *p);
 
 		int					GetNumCharSets() const;
-		void				GetCharSetNames(NxsStringVector &names) const;
-		const NxsUnsignedSet *GetCharSet(NxsString nm) const;
+		/* i17 */ /*v2.1to2.2 17 */
+		void				GetCharSetNames(NxsStringVector &names) const; /*v2.1to2.2 3 */
+		const NxsUnsignedSet *GetCharSet(NxsString nm) const; /*v2.1to2.2 4 */
 
-		int					GetNumCharPartitions();
-		void				GetCharPartitionNames(vector<std::string> &names);
+		int					GetNumCharPartitions(); /*v2.1to2.2 6 */
+		void				GetCharPartitionNames(vector<std::string> &names); /*v2.1to2.2 6 */
 		const NxsPartition		*GetCharPartition(std::string nm) const;
 
-		int					GetNumTaxSets();
-		void				GetTaxSetNames(NxsStringVector &names);
-		NxsUnsignedSet		&GetTaxSet(NxsString nm);
+		int					GetNumTaxSets(); /*v2.1to2.2 6 */
+		void				GetTaxSetNames(NxsStringVector &names); /*v2.1to2.2 3 */ /*v2.1to2.2 6 */
+		NxsUnsignedSet &	GetTaxSet(NxsString nm); /*v2.1to2.2 6 */ /*v2.1to2.2 8 */ /*v2.1to2.2 4 */
 
-		int					GetNumExSets();
-		void				GetExSetNames(NxsStringVector &names);
-		NxsUnsignedSet		&GetExSet(NxsString nm);
-		NxsString			GetDefExSetName();
-		void				ApplyExset(NxsString nm);
+		int					GetNumExSets();/*v2.1to2.2 6 */
+		void				GetExSetNames(NxsStringVector &names); /*v2.1to2.2 3 */ /*v2.1to2.2 6 */
+		NxsUnsignedSet &	GetExSet(NxsString nm); /*v2.1to2.2 6 */ /*v2.1to2.2 8 */ /*v2.1to2.2 4 */
+		NxsString			GetDefExSetName(); /*v2.1to2.2 6 */ /*v2.1to2.2 4 */
+		void				ApplyExset(NxsString nm); /*v2.1to2.2 4 */
 
 		virtual void		Read(NxsToken& token);
-		virtual void		Report(std::ostream& out) NCL_COULD_BE_CONST ;
+		virtual void		Report(std::ostream& out) NCL_COULD_BE_CONST ; /*v2.1to2.2 1 */
 		virtual void		Reset();
 		virtual void 		WriteAsNexus(std::ostream &out) const;
 
@@ -145,13 +150,13 @@
 		void				SetCharLinkStatus(NxsBlockLinkStatus s);
 		void				SetTaxaLinkStatus(NxsBlockLinkStatus s);
 		void				SetTreesLinkStatus(NxsBlockLinkStatus s);
-		
+
 		void				SetCharBlockPtr(NxsCharactersBlockAPI * c, NxsBlockLinkStatus s);
 		void				SetTaxaBlockPtr(NxsTaxaBlockAPI *, NxsBlockLinkStatus s);
 		void				SetTreesBlockPtr(NxsTreesBlockAPI *, NxsBlockLinkStatus s);
-		NxsCharactersBlockAPI * GetCharBlockPtr(int *status=NULL);
-		NxsTaxaBlockAPI *	GetTaxaBlockPtr(int *status=NULL);
-		NxsTreesBlockAPI *	GetTreesBlockPtr(int *status=NULL);
+		NxsCharactersBlockAPI * GetCharBlockPtr(int *status=NULL); /*v2.1to2.2 13 */
+		NxsTaxaBlockAPI *	GetTaxaBlockPtr(int *status=NULL); /*v2.1to2.2 13 */
+		NxsTreesBlockAPI *	GetTreesBlockPtr(int *status=NULL); /*v2.1to2.2 13 */
 
 		NxsTransformationManager & GetNxsTransformationManagerRef()
 			{
@@ -160,13 +165,13 @@
 		NxsGeneticCodesManager & GetNxsGeneticCodesManagerRef()
 			{
 			return codesMgr;
-			}			
+			}
 		virtual void AddCharPartition(const std::string & name, const NxsPartition &);
 		virtual void AddTaxPartition(const std::string & name, const NxsPartition &);
 		virtual void AddTreePartition(const std::string & name, const NxsPartition &);
 		virtual void AddCodeSet(const std::string & name, const NxsPartition &, bool asterisked);
 		virtual void AddCodonPosSet(const std::string & name, const NxsPartition &, bool asterisked);
-		
+
 		/*---------------------------------------------------------------------------------------
 		| Results in aliasing of the taxa, trees, and characters blocks!
 		*/
@@ -180,7 +185,7 @@
 		/*---------------------------------------------------------------------------------------
 		| Results in aliasing of the taxa, trees, and characters blocks!
 		|
-		| passedRefOfOwnedBlock is set to this->true to avoid double deletion (other 
+		| passedRefOfOwnedBlock is set to this->true to avoid double deletion (other
 		|	retains ownership of these blocks
 		*/
 		virtual void CopyAssumptionsContents(const NxsAssumptionsBlock &other)
@@ -222,8 +227,8 @@
 			{
 			gapsAsNewstate = v;
 			}
-		
 
+
 	protected:
 		typedef std::vector<NxsAssumptionsBlockAPI *> VecAssumpBlockPtr;
 
@@ -234,7 +239,7 @@
 
 
 		VecBlockPtr 		GetCreatedTaxaBlocks();
-		virtual unsigned	TaxonLabelToNumber(NxsString s) const;
+		virtual unsigned	TaxonLabelToNumber(NxsString s) const; /*v2.1to2.2 4 */
 
 		void				HandleCharPartition(NxsToken& token);
 		void				HandleCharSet(NxsToken& token);
@@ -249,7 +254,7 @@
 		void				HandleTypeSet(NxsToken& token);
 		void				HandleUserType(NxsToken& token);
 		void				HandleWeightSet(NxsToken& token);
-		
+
 		void				WriteCharSet(std::ostream &out) const
 			{
 			NxsWriteSetCommand("CHARSET", charsets, out);
@@ -287,16 +292,19 @@
 			{
 			NxsWritePartitionCommand("CodonPosSet", codonPosSets, out, def_codonPosSet.c_str());
 			}
-
+		NameOfAssumpBlockAsRead	GetIDOfBlockTypeIDFromParse() const
+			{
+			return readAs;
+			}
 	private:
 		NxsAssumptionsBlockAPI  *GetAssumptionsBlockForCharTitle(const char *title, NxsToken &token, const char *cmd);
 		NxsAssumptionsBlockAPI  *GetAssumptionsBlockForTaxaTitle(const char *title, NxsToken &token, const char *cmd);
 		NxsAssumptionsBlockAPI  *GetAssumptionsBlockForTreesTitle(const char *title, NxsToken &token, const char *cmd);
-		
+
 		NxsAssumptionsBlockAPI  *GetAssumptionsBlockForCharBlock(NxsCharactersBlockAPI *, NxsBlockLinkStatus, NxsToken &token);
 		NxsAssumptionsBlockAPI  *GetAssumptionsBlockForTaxaBlock(NxsTaxaBlockAPI *, NxsBlockLinkStatus, NxsToken &token);
 		NxsAssumptionsBlockAPI  *GetAssumptionsBlockForTreesBlock(NxsTreesBlockAPI *, NxsBlockLinkStatus, NxsToken &token);
-		
+
 		NxsAssumptionsBlockAPI  *CreateNewAssumptionsBlock(NxsToken &token);
 		NxsAssumptionsBlockAPI *DealWithPossibleParensInCharDependentCmd(NxsToken &token, const char *cmd, const std::vector<std::string> *unsupported = NULL, bool * isVect = false);
 		bool					HasAssumptionsBlockCommands() const;
@@ -314,18 +322,18 @@
 		NxsUnsignedSetMap	taxsets;
 		NxsUnsignedSetMap	treesets;
 		NxsUnsignedSetMap	exsets;
-		
+
 		NxsPartitionsByName charPartitions;
 		NxsPartitionsByName taxPartitions;
 		NxsPartitionsByName treePartitions;
 
 		NxsString			def_exset;			/* the default exset */
-		
+
 		NxsPartitionsByName codonPosSets;
 		NxsString			def_codonPosSet;	/* the default codonPosSet */
 		NxsPartitionsByName codeSets;
 		NxsString			def_codeSet;		/* the default codeSet */
-	
+
 		int					charLinkStatus;
 		int					taxaLinkStatus;
 		int					treesLinkStatus;

Modified: pkg/src/ncl/nxsblock.h
===================================================================
--- pkg/src/ncl/nxsblock.h	2010-03-29 20:49:59 UTC (rev 768)
+++ pkg/src/ncl/nxsblock.h	2010-03-29 20:51:20 UTC (rev 769)
@@ -13,7 +13,7 @@
 //	GNU General Public License for more details.
 //
 //	You should have received a copy of the GNU General Public License
-//	along with NCL; if not, write to the Free Software Foundation, Inc., 
+//	along with NCL; if not, write to the Free Software Foundation, Inc.,
 //	59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
 #ifndef NCL_NXSBLOCK_H
@@ -33,18 +33,46 @@
 typedef std::pair<const NxsBlock *, std::string> BlockUniqueID;
 typedef std::map<BlockUniqueID, NxsBlock *> NxsBlockMapper;
 
+
+
+/*! This is the base class for the block interfaces that correspond to blocks
+that hold ordered lists (TAXA, CHARACTERS, TREES).
+
+	This interface is used internally during parsing, and is usually NOT
+	called directly by client code.
+*/
 class NxsLabelToIndicesMapper
 	{
 	public:
 		virtual ~NxsLabelToIndicesMapper(){}
 		virtual unsigned GetMaxIndex() const = 0;
-		virtual unsigned GetIndicesForLabel(const std::string &label, NxsUnsignedSet *inds) const = 0;
-			/* Returns true if the set replaces an old set*/
+		/* Adds the 0-based indices corresponding to a label to the set.
+
+		 \returns the number of indices that correspond to the label (and the number
+		 of items that would be added to *inds if inds points to an empty set).
+		*/
+		virtual unsigned GetIndicesForLabel(const std::string &label, /* label, set name or string with the 1-based numeric representation of the object */
+											NxsUnsignedSet *inds /* The set of indices to add the taxa indices to (can be 0L). */
+											) const = 0;
+		/* Confusingly named function.
+			This function looks for the index set than is named `label` in the NxsLabelToIndicesMapper
+			It adds the indices from this set into `toFill` (if toFill is not NULL).
+			\returns the size of the set which was named label (the number of indices that were inserted).
+		*/
 		virtual unsigned GetIndexSet(const std::string &label, NxsUnsignedSet * toFill) const = 0;
+		/* Adds set `inds` to the collection of sets and gives it the name `label`
+			\returns true if the set replaced an existing set (in this case a warning will be issued - which can generate an NxsException, if the client code wants warning to generate exceptions).
+		*/
 		virtual bool AddNewIndexSet(const std::string &label, const NxsUnsignedSet & inds) = 0;
+		/* Adds partition `inds` to the collection of partition and gives it the name `label`
+			\returns true if the set replaced an existing partition (in this case a warning will be issued - which can generate an NxsException, if the client code wants warning to generate exceptions).
+		*/
 		virtual bool AddNewPartition(const std::string &label, const NxsPartition & inds) = 0;
 
-		/// AppendNewLabel is only overloaded in Taxa and State LabelToIndexMappers
+		/* Adds a new label to the collection of valid labels
+			AppendNewLabel is only overloaded in Taxa and State LabelToIndexMappers, all other
+			NxsLabelToIndicesMapper instances \throw NxsUnimplementedException
+		*/
 		virtual unsigned AppendNewLabel(std::string &/*label*/)
 			{
 			throw NxsUnimplementedException("AppendNewLabel called on fixed label interface");
@@ -57,19 +85,19 @@
 class NxsSetVectorItemValidator;
 
 std::string GetBlockIDTitleString(NxsBlock &);
-/*----------------------------------------------------------------------------------------------------------------------
-|	This is the base class from which all block classes are derived. A NxsBlock-derived class encapsulates a Nexus block
-|	(e.g. DATA block, TREES block, etc.). The abstract virtual function Read must be overridden for each derived class 
-|	to provide the ability to read everything following the block name (which is read by the NxsReader object) to the 
-|	end or endblock statement. Derived classes must provide their own data storage and access functions. The abstract
-|	virtual function Report must be overridden to provide some feedback to user on contents of block. The abstract
-|	virtual function Reset must be overridden to empty the block of all its contents, restoring it to its 
-|	just-constructed state.
+/*!
+	This is the base class from which all block classes are derived. A NxsBlock-derived class encapsulates a Nexus block
+	(e.g. DATA block, TREES block, etc.). The abstract virtual function Read must be overridden for each derived class
+	to provide the ability to read everything following the block name (which is read by the NxsReader object) to the
+	end or endblock statement. Derived classes must provide their own data storage and access functions. The abstract
+	virtual function Report must be overridden to provide some feedback to user on contents of block. The abstract
+	virtual function Reset must be overridden to empty the block of all its contents, restoring it to its
+	just-constructed state.
 */
 class NxsBlock
 	{
 	friend class NxsReader;
-
+		/* i20 */ /*v2.1to2.2 20 */
 	public:
 		enum NxsBlockLinkStatus
 			{
@@ -98,16 +126,16 @@
 			{
 			return token.Equals(id);
 			}
-			
+
 		NxsString			GetID() const;
-		bool				IsEmpty() NCL_COULD_BE_CONST ;
+		bool				IsEmpty() NCL_COULD_BE_CONST ; /*v2.1to2.2 1 */
 
 		void				Enable();
 		void				Disable();
-		bool				IsEnabled() NCL_COULD_BE_CONST ;
-		bool				IsUserSupplied() NCL_COULD_BE_CONST ;
+		bool				IsEnabled() NCL_COULD_BE_CONST ; /*v2.1to2.2 1 */
+		bool				IsUserSupplied() NCL_COULD_BE_CONST ; /*v2.1to2.2 1 */
 
-		virtual unsigned	CharLabelToNumber(NxsString s) NCL_COULD_BE_CONST ;
+		virtual unsigned	CharLabelToNumber(NxsString s) NCL_COULD_BE_CONST ; /*v2.1to2.2 1 */
 		virtual unsigned	TaxonLabelToNumber(NxsString s) const;
 
 		virtual void		SkippingCommand(NxsString commandName);
@@ -117,19 +145,19 @@
 		virtual void		HandleLinkCommand(NxsToken &token);
 		virtual void		HandleTitleCommand(NxsToken &token);
 
-		virtual void		Report(std::ostream &out) NCL_COULD_BE_CONST ;
+		virtual void		Report(std::ostream &out) NCL_COULD_BE_CONST ; /*v2.1to2.2 1 */
 		virtual void		Reset();
 
 		mutable NxsString	errormsg;			/* workspace for creating error messages */
 
-			
+
 		virtual VecBlockPtr GetImpliedBlocks();
 		virtual VecConstBlockPtr	GetImpliedBlocksConst() const;
 		BlockUniqueID		GetInstanceIdentifier() const
 			{
 			return BlockUniqueID(this, GetInstanceName());
 			}
-			
+		/* i21 */ /*v2.1to2.2 21 */
 		const std::string  &GetInstanceName() const
 			{
 			return title;
@@ -149,26 +177,27 @@
 		void SetTitle(const std::string &t, bool autogeneratedTitle)
 			{
 			title = t;
+			/* i19 */ /*v2.1to2.2 19 */
 			autoTitle = autogeneratedTitle;
 			}
 		bool IsAutoGeneratedTitle() const
 			{
 			return autoTitle;
 			}
-		void StoreSkippedCommands(bool v) 
+		void StoreSkippedCommands(bool v)
 			{
 			storeSkippedCommands = v;
 			}
-		void ClearStoredSkippedCommands() 
+		void ClearStoredSkippedCommands()
 			{
 			skippedCommands.clear();
 			}
-			
+
 		/*----------------------------------------------------------------------------------------
 		| Copies all NxsBlock fields - execept  the `nexusReader` and `next` pointers.
 		|	Aliasing of Block pointers results in very dangerous implication of copying for
 		|	many subclasses of NxsBlock.
-		| Copying of blocks should be restricted to empty blocks without linkages (e.g. 
+		| Copying of blocks should be restricted to empty blocks without linkages (e.g.
 		|	the CloneFactory mechanism requires some form of copy, but should typically be used with
 		|	empty blocks.
 		*/
@@ -181,13 +210,14 @@
 			isUserSupplied = other.isUserSupplied;
 			id = other.id;
 			title = other.title;
+			/* i19 */ /*v2.1to2.2 19 */
 			blockIDString = other.blockIDString;
 			linkAPI = other.linkAPI;
 			storeSkippedCommands = other.storeSkippedCommands;
 			skippedCommands = other.skippedCommands;
 			autoTitle = other.autoTitle;
 			}
-			
+
 		virtual NxsBlock * Clone() const
 			{
 			NxsBlock * b = new NxsBlock();
@@ -196,7 +226,7 @@
 			b->next = NULL;
 			return b;
 			}
-		
+
 		unsigned			ReadVectorPartitionDef(NxsPartition &np, NxsLabelToIndicesMapper &ltm, const std::string & partName, const char * ptype, const char * cmd, NxsToken & token, bool warnAsterisked, bool demandAllInds, NxsSetVectorItemValidator & v);
 		void 				ReadPartitionDef(NxsPartition &np, NxsLabelToIndicesMapper &ltm, const std::string & partName, const char * ptype, const char * cmd, NxsToken & token, bool warnAsterisked, bool demandAllInds, bool storeAsPartition);
 		virtual bool		TolerateEOFInBlock() const
@@ -209,13 +239,19 @@
 		void				WriteBasicBlockCommands(std::ostream & out) const;
 		virtual void		WriteSkippedCommands(std::ostream & out) const;
 		// used internally to deal with multiple blocks spawning the same TAXA block
-		virtual bool 		SwapEquivalentTaxaBlock(NxsTaxaBlockAPI * ) 
+		virtual bool 		SwapEquivalentTaxaBlock(NxsTaxaBlockAPI * )
 		{
 			return false;
 		}
+		/*! This is the argument from the BLOCKID command.  It should be unique, but
+			that is dependent on the file being valid (NCL does not verify uniqueness).
+
+			This is not the ID used to identify block type. \ref BlockTypeIDDiscussion
+		*/
+		std::string GetBlockIDCommandString() const { return blockIDString; }
 	protected:
 		void				SkipCommand(NxsToken & token);
-		
+
 		NxsCommandResult	HandleBasicBlockCommands(NxsToken & token);
 		void				DemandEndSemicolon(NxsToken &token, const char *contextString) const;
 		void				DemandEquals(NxsToken &token, const char *contextString) const;
@@ -229,60 +265,94 @@
 		bool				isUserSupplied;		/* true if this object has been read from a file; false otherwise */
 		NxsReader			*nexusReader;		/* pointer to the Nexus file reader object */
 		NxsBlock			*next;				/* DEPRECATED field pointer to next block in list */
-		NxsString			id;					/* holds name of block (e.g., "DATA", "TREES", etc.) */
+		NxsString			id;					/* holds name of block (e.g., "DATA", "TREES", etc.) \ref BlockTypeIDDiscussion */
 		std::string			title;				/* holds the title of the block empty by default */
 		std::string 		blockIDString; 		/* Mesquite generates these. I don't know what they are for */
 		bool				linkAPI;
 		bool				autoTitle;			/* true if the title was generated internally*/
 		bool				storeSkippedCommands;
 		std::list<ProcessedNxsCommand> skippedCommands; /* commands accumulate by SkipCommand or by some other means */
-		
+
 		virtual void		Read(NxsToken &token);
+		/* i22 */ /*v2.1to2.2 22 */
 		private:
 			NxsBlock &operator=(const NxsBlock &other); /*intentionally not defined because of aliasing issues */
 
 	};
 
+/*! This abstract class defines the interface for a factory that can generate NxsBlocks.
+
+	When the NxsReader::Execute() method encounters a block that it needs to handle, it will first check the registered "singelton"
+		blocks (a block that has been added to it using NxsReader::Add(), those NxsBlock instances are recycled).
+		If no singleton block says that it can read that block of NEXUS (see NxsBlock::CanReadBlockType()), then the NxsReader
+		will walk through its list of factories calling NxsBlockFactory::GetBlockReaderForID() for each until it gets a
+		non-NULL pointer.
+
+	If there is an exception during the parsing of that block BlockError will be called for the factory instance that generated the block
+
+	If the block returns "false" from NxsBlock::IsEnabled() method, then BlockSkipped will be called by the NxsReader using
+		 the factory instance that generated the block
+
+	Blocks generated by factories but used successfully in a parse have to be deleted by the client code (See \ref memoryManagement discussion).
+
+*/
 class NxsBlockFactory
 	{
 	public:
 		virtual ~NxsBlockFactory()
 			{
 			}
-		virtual NxsBlock  *	GetBlockReaderForID(const std::string & id, NxsReader *reader, NxsToken *token) = 0;
+		/*! \returns a NxsBlock instance with NxsBlock::Read method that is capable of parsing a NEXUS block of type `id`
+		*/
+		virtual NxsBlock  *	GetBlockReaderForID(const std::string & id, /*!< The type of block that needs to be read see \ref BlockTypeIDDiscussion */
+												NxsReader *reader,  /*!< a pointer to the NxsReader controlling the parse. Can be NULL. Usually not needed for an implementation of this method */
+												NxsToken *token  /*!< a pointer to the NxsToken that is generating token. Can be NULL. Usually not needed for an implementation of this method */
+												) = 0;
+
+		/*! base-class implementation deletes the block (the NxsReader will not retain a reference to the block, so failing to delete can
+			lead to memory leaks if you do not have some fancy memory management scheme).
+
+			If there is an exception during the parsing of that block BlockError will be called for the factory instance that generated the block
+		*/
 		virtual void		BlockError(NxsBlock *b)
 			{
 			delete b;
 			}
+		/*! base-class implementation deletes the block (the NxsReader will not retain a reference to the block, so failing to delete can
+			lead to memory leaks if you do not have some fancy memory management scheme).
+
+		If the block returns "false" from NxsBlock::IsEnabled() method, then BlockSkipped will be called by the NxsReader using
+			 the factory instance that generated the block
+		*/
 		virtual void BlockSkipped(NxsBlock *b)
 			{
 			delete b;
 			}
 	};
 
-/*----------------------------------------------------------------------------------------------------------------------
-|	Sets the nexusReader data member of the NxsBlock object to 'nxsptr'.
+/*!
+	Sets the nexusReader data member of the NxsBlock object to 'nxsptr'.
 */
 inline void NxsBlock::SetNexus(
   NxsReader *nxsptr)	/* pointer to a NxsReader object */
 	{
 	nexusReader = nxsptr;
 	}
-/*----------------------------------------------------------------------------------------------------------------------
-|	Gets the nexusReader data member of the NxsBlock object to 'nxsptr'.
+/*!
+	Gets the nexusReader data member of the NxsBlock object to 'nxsptr'.
 */
 inline NxsReader * NxsBlock::GetNexus() const
 	{
 	return nexusReader;
 	}
- 
 
-/*----------------------------------------------------------------------------------------------------------------------
-|	Advances the token, and raise an exception if it is not an equals sign.
-|
-| 	Sets errormsg and raises a NxsException on failure.
-|	`contextString` is used in error messages:
-|		"Expecting '=' ${contextString} but found..."
+
+/*!
+	Advances the token, and raise an exception if it is not an equals sign.
+
+ 	Sets errormsg and raises a NxsException on failure.
+	`contextString` is used in error messages:
+		"Expecting '=' ${contextString} but found..."
 */
 inline void NxsBlock::DemandEquals(NxsToken &token, const char *contextString) const
 	{

Modified: pkg/src/ncl/nxscdiscretematrix.h
===================================================================
--- pkg/src/ncl/nxscdiscretematrix.h	2010-03-29 20:49:59 UTC (rev 768)
+++ pkg/src/ncl/nxscdiscretematrix.h	2010-03-29 20:51:20 UTC (rev 769)
@@ -13,7 +13,7 @@
 //	GNU General Public License for more details.
 //
 //	You should have received a copy of the GNU General Public License
-//	along with NCL; if not, write to the Free Software Foundation, Inc., 
+//	along with NCL; if not, write to the Free Software Foundation, Inc.,
 //	59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 // This code is based on code developed by Mark Holder for the CIPRES project
@@ -55,35 +55,35 @@
 	/* For size_t */
 #if defined(HAVE_STDDEF_H)
 #	include <stddef.h>
-#endif 
+#endif
 
 
 #ifdef __cplusplus
-extern "C" 
+extern "C"
 {
 #endif
 
-	
-typedef int8_t NxsCDiscreteState_t; /** type used to enumerate possible states.	
+
+typedef int8_t NxsCDiscreteState_t; /** type used to enumerate possible states.
 								-1 is used for gaps, other negative flags may be added later.
 								This size limits the maximum number of states allowed. */
 typedef int8_t NxsCDiscreteStateSet; /** type used to refer to unique combinations of states (the "fundamental" states and ambiguity codes)
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/phylobase -r 769


More information about the Phylobase-commits mailing list