/usr/include/music/port.hh is in libmusic-dev 1.0.7-1.1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | /*
* This file is part of MUSIC.
* Copyright (C) 2007, 2008, 2009 INCF
*
* MUSIC is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* MUSIC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MUSIC_PORT_HH
#include <mpi.h>
#include <string>
#include <music/data_map.hh>
#include <music/index_map.hh>
#include <music/event.hh>
#include <music/message.hh>
#include <music/connector.hh>
#include <music/sampler.hh>
#include <music/event_router.hh>
#include <music/connectivity.hh>
#include <music/spatial.hh>
namespace MUSIC {
class Setup;
class Port {
public:
Port () { }
Port (Setup* s, std::string identifier);
virtual void buildTable () { };
virtual void setupCleanup () { };
bool isConnected ();
bool hasWidth ();
int width ();
protected:
std::string portName_;
Setup* setup_;
ConnectivityInfo* ConnectivityInfo_;
void assertOutput ();
void assertInput ();
private:
void checkConnected (std::string action);
bool isMapped_;
};
// A redistribution_port is a port with the ability to route
// globally indexed data items from a sender MPI process to the
// correct receiver MPI process. Examples are cont_ports and
// event_ports.
class RedistributionPort : public virtual Port {
};
// A ticking port is a port which needs to be updated at every tick ()
class TickingPort : public virtual Port {
public:
virtual void tick () = 0;
};
class OutputPort : public virtual Port {
};
class InputPort : public virtual Port {
};
class OutputRedistributionPort : public OutputPort,
public RedistributionPort {
protected:
SpatialOutputNegotiator* spatialNegotiator;
virtual OutputConnector* makeOutputConnector (ConnectorInfo connInfo) = 0;
virtual void mapImpl (IndexMap* indices,
Index::Type type,
int maxBuffered,
int dataSize);
public:
OutputRedistributionPort () : spatialNegotiator (0) { }
void setupCleanup ();
};
class InputRedistributionPort : public OutputPort,
public RedistributionPort {
protected:
InputRedistributionPort () : spatialNegotiator (0) { }
SpatialInputNegotiator* spatialNegotiator;
virtual InputConnector* makeInputConnector (ConnectorInfo connInfo) = 0;
void mapImpl (IndexMap* indices,
Index::Type type,
double accLatency,
int maxBuffered,
bool interpolate);
public:
void setupCleanup ();
};
class ContPort : virtual public Port {
protected:
Sampler sampler;
MPI::Datatype type_;
};
class ContOutputPort : public ContPort,
public OutputRedistributionPort,
public TickingPort {
void mapImpl (DataMap* indices, int maxBuffered);
OutputConnector* makeOutputConnector (ConnectorInfo connInfo);
public:
ContOutputPort (Setup* s, std::string id)
: Port (s, id) { }
void map (DataMap* dmap);
void map (DataMap* dmap, int maxBuffered);
void tick ();
};
class ContInputPort : public ContPort, public InputRedistributionPort {
double delay_;
void mapImpl (DataMap* dmap,
double delay,
int maxBuffered,
bool interpolate);
InputConnector* makeInputConnector (ConnectorInfo connInfo);
public:
ContInputPort (Setup* s, std::string id)
: Port (s, id) { }
void map (DataMap* dmap, double delay = 0.0, bool interpolate = true);
void map (DataMap* dmap, int maxBuffered, bool interpolate = true);
void map (DataMap* dmap,
double delay,
int maxBuffered,
bool interpolate = true);
};
class EventPort : public virtual Port {
};
class EventOutputPort : public EventPort,
public OutputRedistributionPort {
EventRoutingMap* routingMap;
EventRouter router;
public:
EventOutputPort (Setup* s, std::string id);
void map (IndexMap* indices, Index::Type type);
void map (IndexMap* indices, Index::Type type, int maxBuffered);
OutputConnector* makeOutputConnector (ConnectorInfo connInfo);
void buildTable ();
void insertEvent (double t, GlobalIndex id);
void insertEvent (double t, LocalIndex id);
};
class EventInputPort : public EventPort,
public InputRedistributionPort {
private:
Index::Type type_;
EventHandlerPtr handleEvent_;
public:
EventInputPort (Setup* s, std::string id);
void map (IndexMap* indices,
EventHandlerGlobalIndex* handleEvent,
double accLatency = 0.0);
void map (IndexMap* indices,
EventHandlerLocalIndex* handleEvent,
double accLatency = 0.0);
void map (IndexMap* indices,
EventHandlerGlobalIndex* handleEvent,
double accLatency,
int maxBuffered);
void map (IndexMap* indices,
EventHandlerLocalIndex* handleEvent,
double accLatency,
int maxBuffered);
protected:
void mapImpl (IndexMap* indices,
Index::Type type,
EventHandlerPtr handleEvent,
double accLatency,
int maxBuffered);
InputConnector* makeInputConnector (ConnectorInfo connInfo);
// Facilities to support the C interface
public:
EventHandlerGlobalIndexProxy*
allocEventHandlerGlobalIndexProxy (void (*) (double, int));
EventHandlerLocalIndexProxy*
allocEventHandlerLocalIndexProxy (void (*) (double, int));
private:
EventHandlerGlobalIndexProxy cEventHandlerGlobalIndex;
EventHandlerLocalIndexProxy cEventHandlerLocalIndex;
};
class MessagePort : public virtual Port {
protected:
int rank_;
public:
MessagePort (Setup* s);
};
class MessageOutputPort : public MessagePort,
public OutputRedistributionPort {
std::vector<FIBO*> buffers;
public:
MessageOutputPort (Setup* s, std::string id);
void map ();
void map (int maxBuffered);
void insertMessage (double t, void* msg, size_t size);
protected:
void mapImpl (int maxBuffered);
OutputConnector* makeOutputConnector (ConnectorInfo connInfo);
};
class MessageInputPort : public MessagePort,
public InputRedistributionPort {
MessageHandler* handleMessage_;
public:
MessageInputPort (Setup* s, std::string id);
void map (MessageHandler* handler = 0, double accLatency = 0.0);
void map (int maxBuffered);
void map (double accLatency, int maxBuffered);
void map (MessageHandler* handler, int maxBuffered);
void map (MessageHandler* handler, double accLatency, int maxBuffered);
protected:
void mapImpl (MessageHandler* handleEvent,
double accLatency,
int maxBuffered);
InputConnector* makeInputConnector (ConnectorInfo connInfo);
public:
MessageHandlerProxy*
allocMessageHandlerProxy (void (*) (double, void*, size_t));
private:
MessageHandlerProxy cMessageHandler;
};
}
#define MUSIC_PORT_HH
#endif
|