00001 // Copyright 2009-2010 Sandia Corporation. Under the terms 00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. 00003 // Government retains certain rights in this software. 00004 // 00005 // Copyright (c) 2009-2010, Sandia Corporation 00006 // All rights reserved. 00007 // 00008 // This file is part of the SST software package. For license 00009 // information, see the LICENSE file in the top level directory of the 00010 // distribution. 00011 00012 00013 #ifndef SST_LINKMAP_H 00014 #define SST_LINKMAP_H 00015 00016 #include <vector> 00017 #include <string> 00018 #include <map> 00019 00020 #include <sst/core/sst.h> 00021 #include <sst/core/event.h> 00022 #include <sst/core/eventQueue.h> 00023 00024 namespace SST { 00025 00026 #define _LM_DBG( fmt, args...) __DBG( DBG_LINKMAP, LinkMap, fmt, ## args ) 00027 00028 class Link; 00029 00030 class LinkMap { 00031 00032 private: 00033 std::map<std::string,Link*> linkMap; 00034 00035 public: 00036 LinkMap() {} 00037 ~LinkMap() {} 00038 00039 void insertLink(std::string name, Link* link) { 00040 linkMap.insert(std::pair<std::string,Link*>(name,link)); 00041 } 00042 00043 Link* getLink(std::string name) { 00044 std::map<std::string,Link*>::iterator it = linkMap.find(name); 00045 if ( it == linkMap.end() ) return NULL; 00046 else return it->second; 00047 } 00048 00049 // FIXME: Cludge for now 00050 std::map<std::string,Link*>& getLinkMap() { 00051 return linkMap; 00052 } 00053 00054 }; 00055 00056 00057 00058 // /** Structure for tracking and connecting Links */ 00059 // class LinkMap { 00060 // protected: 00061 // typedef std::map< std::string, Link* > linkMap_t; 00062 00063 // public: 00064 // LinkMap( ComponentId_t id = -1 ); 00065 00066 // /** Create a Link object, assigning a name and event handler. 00067 // Returns the link object, or NULL if a link by that name already 00068 // exists. 00069 00070 // @param name Name of the link. This name should match the <name> 00071 // of the link for that component in the XML file. 00072 00073 // @param handler The event handler to handle events from this 00074 // link. If NULL, the link must be polled for incoming events. 00075 // */ 00076 // Link* LinkAdd( std::string name, Event::Handler_t* handler = NULL ); 00077 // Link* LinkAdd( std::string, Link* ); 00078 00079 // /** Create a link to yourself. 00080 00081 // @param name Name for the Link 00082 // @param handler The event handler to handle events from this 00083 // link. If NULL, the link must be polled for incoming events. 00084 // */ 00085 // Link* selfLink( std::string name, Event::Handler_t* handler = NULL ); 00086 00087 // /** Return the Link by name. 00088 // @params name name of the link to be returned */ 00089 // Link* LinkGet( std::string name ); 00090 // /** Return the nth link to this component */ 00091 // // Link* LinkGet( unsigned int num ); 00092 00093 // int LinkConnect( std::string str_name, Link* link, Cycle_t lat ); 00094 00095 // protected: 00096 // /** Unique component ID */ 00097 // ComponentId_t myId; 00098 00099 // linkMap_t linkMap; 00100 // NewLinkMap* myLinks; 00101 00102 // private: 00103 00104 // LinkMap( const LinkMap& l ); 00105 00106 00107 // friend class boost::serialization::access; 00108 // template<class Archive> 00109 // void serialize(Archive & ar, const unsigned int version ) 00110 // { 00111 // ar & BOOST_SERIALIZATION_NVP( myId ); 00112 // ar & BOOST_SERIALIZATION_NVP( linkMap ); 00113 // } 00114 // }; 00115 00116 00117 00118 } // namespace SST 00119 00120 #endif // SST_LINKMAP_H