cluster.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, Trent Waddington
00003  *
00004  * See the file "LICENSE.TERMS" for information on usage and
00005  * redistribution of this file, and for a DISCLAIMER OF ALL
00006  * WARRANTIES.
00007  *
00008  */
00009 
00010 /*==============================================================================
00011  * FILE:       cluster.h
00012  * OVERVIEW:   Definition of the classes that describe a Cluster, a grouping
00013  *         of functions irrespective of relationship.  For example, the
00014  *         Object Oriented Programming concept of a Class is a Cluster. 
00015  *         Clusters can contain other Clusters to form a tree.
00016  *============================================================================*/
00017 
00018 /*
00019  * $Revision: 1.10 $
00020  * 03 May 04 - Trent: Created
00021  */
00022 
00023 #ifndef __CLUSTER_H__
00024 #define __CLUSTER_H__
00025 
00026 #include <list>
00027 #include <vector>
00028 #include <map>
00029 #include <set>
00030 #include <string>
00031 #include <fstream>
00032 #include "memo.h"
00033 
00034 class XMLProgParser;
00035 class Cluster;
00036 
00037 class Cluster
00038 {
00039 protected:
00040         std::string name;
00041         std::vector<Cluster*> children;
00042         Cluster     *parent;
00043         std::ofstream out;
00044         std::string stream_ext;
00045 
00046 public:
00047                     Cluster() : name(""), parent(NULL) { }
00048                     Cluster(const char *name) : name(name), parent(NULL) { }
00049 virtual             ~Cluster() {}
00050         const       char *getName() { return name.c_str(); }
00051         void        setName(const char *nam) { name = nam; }
00052         unsigned int getNumChildren() { return children.size(); }
00053         Cluster     *getChild(int n) { return children[n]; }
00054         void        addChild(Cluster *n);
00055         void        removeChild(Cluster *n);
00056         Cluster     *getParent() { return parent; }
00057         bool        hasChildren() { return children.size() > 0; }
00058         void        openStream(const char *ext);
00059         void        openStreams(const char *ext);
00060         void        closeStreams();
00061         std::ofstream &getStream() { return out; }
00062         const char  *makeDirs();
00063         const char  *getOutPath(const char *ext);
00064         Cluster     *find(const char *nam);
00065 virtual bool        isAggregate() { return false; }
00066 
00067         void        printTree(std::ostream &out);
00068 protected:
00069 
00070     friend class XMLProgParser;
00071 };
00072 
00073 class Module : public Cluster
00074 {
00075 public:
00076     Module(const char *name) : Cluster(name) { }
00077 };
00078 
00079 class Class : public Cluster
00080 {
00081 protected:
00082     CompoundType *type;
00083 
00084 public:
00085     Class(const char *name) : Cluster(name) { type = new CompoundType(); }
00086 
00087     // A Class tends to be aggregated into the parent Module, 
00088     // this isn't the case with Java, but hey, we're not doing that yet.
00089     virtual bool isAggregate() { return true; }
00090 };
00091 
00092 #endif /*__CLUSTER_H__*/
00093 

Generated on Tue Sep 19 21:18:15 2006 for Boomerang by  doxygen 1.4.6