00001 /*******************************************************************\ 00002 00003 SESAME project software license 00004 00005 Copyright (C) 2002, 2003 University of Amsterdam 00006 00007 This program is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 as published by the Free Software Foundation; either version 2 00010 of the License, or (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00020 02111-1307, USA. 00021 00022 For information regarding the SESAME software project see 00023 http://sesamesim.sourceforge.net or email 00024 jcofflan@users.sourceforge.net 00025 00026 \*******************************************************************/ 00027 00036 #ifndef MAPPINGCONTAINER_H 00037 #define MAPPINGCONTAINER_H 00038 00039 #include <map> 00040 #include <list> 00041 #include <string> 00042 00043 #include "mappingobj.h" 00044 #include "tracecontext.h" 00045 #include "channelmapping.h" 00046 00047 class MappingContainer: public TraceContext, public MappingObj { 00048 // Attributes 00049 private: 00050 typedef std::map<std::string, MappingObj *> children_t; 00051 children_t children; 00052 typedef std::list<MappingObj *> child_list_t; 00053 child_list_t child_list; 00054 typedef std::map<std::string, int> comm_channel_map_t; 00055 comm_channel_map_t comm_channel_map; 00056 00057 // Operations 00058 public: 00059 MappingContainer(const char *name); 00060 virtual ~MappingContainer() {} 00061 00062 MappingObj *getChild(const char *name); 00063 ChannelMapping *getChannel(const char *name); 00064 MappingContainer *getContainer(const char *name); 00065 00071 mapping_obj_t getType() {return MAPPING_CONTAINER;} 00072 00073 // Begin TraceContext interface 00077 virtual TraceContext *getChildContext(const char *name) 00078 {return getContainer(name);} 00082 virtual TraceChannel *getChildChannel(const char *name) 00083 {return getChannel(name);} 00087 virtual TraceContext *getParentContext() 00088 {return (MappingContainer *)getParent();} 00089 00090 virtual int getCommChannelID(const std::string name); 00091 00095 virtual void collectChannels(BasicArray<TraceChannel *> &array); 00096 // End TraceContext interface 00097 00098 protected: 00099 void addContainer(MappingContainer *container); 00100 void addChannel(ChannelMapping *channel); 00101 void addCommChannelMap(const std::string name, const int id); 00102 00103 friend class MappingSAXHandler; 00104 }; 00105 00106 #endif