Project

General

Profile

Statistics
| Branch: | Revision:

root / src / sim / parsim / cproxygate.cc @ 81ad8b66

History | View | Annotate | Download (1.91 KB)

1
//=========================================================================
2
//  CPROXYGATE.CC - part of
3
//
4
//                   OMNeT++/OMNEST
5
//           Discrete System Simulation in C++
6
//
7
//  Author: Andras Varga, 2003
8
//          Dept. of Electrical and Computer Systems Engineering,
9
//          Monash University, Melbourne, Australia
10
//
11
//=========================================================================
12

    
13
/*--------------------------------------------------------------*
14
  Copyright (C) 2003-2008 Andras Varga
15
  Copyright (C) 2006-2008 OpenSim Ltd.
16

17
  This file is distributed WITHOUT ANY WARRANTY. See the file
18
  `license' for details on this and other legal matters.
19
*--------------------------------------------------------------*/
20

    
21
#include <stdlib.h>
22
#include <stdio.h>
23
#include <string.h>
24
#include <sstream>
25
#include "cproxygate.h"
26
#include "cparsimpartition.h"
27
#include "cmodule.h"
28
#include "cmessage.h"
29

    
30
USING_NAMESPACE
31

    
32

    
33
cProxyGate::cProxyGate() : cGate()
34
{
35
    partition = NULL;
36
    remoteProcId = -1;
37
    remoteModuleId = -1;
38
    remoteGateId = -1;
39
    data = NULL;
40
}
41

    
42
std::string cProxyGate::info() const
43
{
44
    std::stringstream out;
45
    out << "remote:(procId=" << remoteProcId << ",modId=" << remoteModuleId << ",gateId=" << remoteGateId << ") ",
46
    out << cGate::info();
47
    return out.str();
48
}
49

    
50
bool cProxyGate::deliver(cMessage *msg, simtime_t t)
51
{
52
    ASSERT(nextgatep==NULL);
53
    ASSERT(partition!=NULL);
54
    if (remoteProcId==-1)
55
        throw cRuntimeError(this, "cannot deliver message '%s': not connected to remote gate", msg->getName());
56

    
57
    msg->setArrivalTime(t);  // merge arrival time into message
58
    partition->processOutgoingMessage(msg, remoteProcId, remoteModuleId, remoteGateId, data);
59
    return false;  // meaning message should be deleted
60
}
61

    
62
void cProxyGate::setRemoteGate(short procId, int moduleId, int gateId)
63
{
64
    remoteProcId = procId;
65
    remoteModuleId = moduleId;
66
    remoteGateId = gateId;
67
}
68

    
69