bpp-core  2.1.0
BasicTNode.h
Go to the documentation of this file.
00001 // 
00002 // File:    BasicTNode.h
00003 // Author:  Sylvain Gaillard
00004 // Created: 13/01/2011 16:39:23
00005 // 
00006 
00007 /*
00008 Copyright or © or Copr. CNRS, (January 12, 2011)
00009 
00010 This software is a computer program whose purpose is to provide utilitary
00011 classes. This file belongs to the Bio++ Project.
00012 
00013 This software is governed by the CeCILL  license under French law and
00014 abiding by the rules of distribution of free software.  You can  use, 
00015 modify and/ or redistribute the software under the terms of the CeCILL
00016 license as circulated by CEA, CNRS and INRIA at the following URL
00017 "http://www.cecill.info". 
00018 
00019 As a counterpart to the access to the source code and  rights to copy,
00020 modify and redistribute granted by the license, users are provided only
00021 with a limited warranty  and the software's author,  the holder of the
00022 economic rights,  and the successive licensors  have only  limited
00023 liability. 
00024 
00025 In this respect, the user's attention is drawn to the risks associated
00026 with loading,  using,  modifying and/or developing or reproducing the
00027 software by the user in light of its specific status of free software,
00028 that may mean  that it is complicated to manipulate,  and  that  also
00029 therefore means  that it is reserved for developers  and  experienced
00030 professionals having in-depth computer knowledge. Users are therefore
00031 encouraged to load and test the software's suitability as regards their
00032 requirements in conditions enabling the security of their systems and/or 
00033 data to be ensured and,  more generally, to use and operate it in the 
00034 same conditions as regards security. 
00035 
00036 The fact that you are presently reading this means that you have had
00037 knowledge of the CeCILL license and that you accept its terms.
00038 */
00039 
00040 #ifndef _BPP_GRAPH_BASICTNODE_H_
00041 #define _BPP_GRAPH_BASICTNODE_H_
00042 
00043 #include "TNode.h"
00044 #include "../Exceptions.h"
00045 
00046 namespace bpp {
00054   class BasicTNode: public TNode {
00055     private:
00056       std::vector< BasicTNode * > sons_;
00057       BasicTNode * father_;
00058 
00059     public:
00063       BasicTNode(): sons_(), father_(0) {};
00064 
00071       virtual ~BasicTNode();
00072 
00076       BasicTNode(const BasicTNode& node);
00077 
00081       BasicTNode& operator=(const BasicTNode& node);
00082 
00083       BasicTNode* clone() const {
00084         return new BasicTNode(* this);
00085       }
00086 
00087       // Neighbors
00088 
00089       const BasicTNode* getNeighbor(int pos) const;
00090       BasicTNode* getNeighbor(int pos);
00091 
00092       int degree() const { return sons_.size() - 1 + father_ ? 1 : 0; }
00093 
00094       const BasicTNode* operator[](int i) const;
00095       BasicTNode* operator[](int i);
00096 
00097       // Fathers
00098 
00102       bool hasFather() const { return father_ ? true : false; }
00103       bool hasFathers() const { return father_ ? true : false; }
00104       int getNumberOfFathers() const { return father_ ? 1 : 0; }
00105 
00106       const BasicTNode* getFather(int pos) const;
00107       BasicTNode* getFather(int pos);
00108       const BasicTNode* getFather() const;
00109       BasicTNode* getFather();
00110 
00114       virtual bool isFather(const BasicTNode* node) const;
00115 
00119       virtual void addFather(BasicTNode* node);
00120 
00126       virtual BasicTNode* removeFather();
00127 
00128       // Sons
00129 
00130       bool hasSons() const { return !sons_.empty(); }
00131       int getNumberOfSons() const { return static_cast<int>(sons_.size()); }
00132       const BasicTNode* getSon(int pos) const;
00133       BasicTNode* getSon(int pos);
00134 
00138       virtual bool isSon(const BasicTNode* node) const;
00139 
00143       virtual void addSon(BasicTNode* node);
00144 
00148       virtual void removeSon(BasicTNode* son);
00149 
00156       virtual BasicTNode* removeSon(int pos);
00157   };
00158 }
00159 
00160 #endif //_BPP_GRAPH_BASICTNODE_H_
 All Classes Namespaces Files Functions Variables Typedefs Friends