Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

dist_tree.h

Go to the documentation of this file.
00001 /***
00002  * Copyright (c) 2005, SkeTo Project
00003  * All rights reserved.
00004  */
00012 #ifndef __DIST_TREE_H__
00013 #define __DIST_TREE_H__
00014 
00015 #include "node.h"
00016 #include <fstream>
00017 
00018 class tree_skeletons;
00019 
00023 template< typename A >
00024 class dist_tree
00025 {
00026   friend class tree_skeletons;
00027 
00029   // Member variables
00030 private:
00032   node< A >* local_root;
00034   node< int >* global_root;
00036   node< int >* global_node;
00037 
00039   int proc_parent;
00041   int proc_leftchild;
00043   int proc_rightchild;
00044 
00046   // constructor and destructor
00053 private:
00054   dist_tree( );
00055 
00062 private:
00063   template< typename B >
00064   dist_tree( const dist_tree< B >* tree );
00065   
00069 public:
00070   ~dist_tree( );
00071 
00073   // access methods
00074 public:
00075   inline const node< A >*
00076   get_local_root( ) const;
00077 
00078   inline const node< int >*
00079   get_global_root( ) const;
00080 
00081   inline const node< int >*
00082   get_global_node( ) const;
00083 
00084   inline int
00085   get_proc_parent( ) const;
00086   
00087   inline int
00088   get_proc_leftchild( ) const;
00089   
00090   inline int
00091   get_proc_rightchild( ) const;
00092   
00094   // Private Utilities
00095 
00104 private:
00105   template< typename B >
00106   void copy_shape( const dist_tree< B >* tree );
00107 
00108 private:
00109   node< int >* copy_shape_rec( const node< int >* root,
00110                    const node< int >* orgPointer );
00111 
00113   // Input and Output
00114 
00130 public:
00131   static dist_tree< A >* read_from_file( const char* filename );
00132 
00133 private:
00134   void read_from_file_create_global_tree( const int* flags,
00135                       const int* localsizes );
00136 
00146 private:
00147   node< int >* read_from_file_create_global_tree_rec( const int** flags,
00148                               const int** localsizes,
00149                               int *count,
00150                               int parentflag,
00151                               int parentcount );
00152 
00153 private:
00154   void read_from_file_create_subtree( const int* flags,
00155                       const A* values );
00156 
00157 private:
00158   static node< A >* read_from_file_create_subtree_rec( const int** flags,
00159                                const A** values );
00160 
00171 public:
00172   bool write_to_file( const char* filename ) const;
00173 
00174 private:
00175   void write_to_file_global_rec( const node< int >* tree,
00176                  std::fstream &fout ) const;
00177   
00178 private:
00179   void write_to_file_other_subtree( node< int > *root,
00180                     int *proc,
00181                     std::fstream &fout,
00182                     const int TAG ) const;
00183 
00190 public:
00191   void print( ) const;
00192 
00193 private:
00194   template< typename B >
00195   void print_rec( node< B >* root ) const;
00196 
00197 public:
00198   void setroot( const A& val );
00199 };
00200 
00201 #include "dist_tree.tpp"
00202 
00203 #endif /* __DIST_TREE_H__ */

Generated on Wed Jan 18 22:19:29 2006 for SkeTo -- Skeleton Library in Tokyo by  doxygen 1.4.4