Project

General

Profile

Statistics
| Branch: | Revision:

root / src / sim / parsim / cproxygate.h @ e1750c09

History | View | Annotate | Download (3.99 KB)

1
//=========================================================================
2
//  CPROXYGATE.H - 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
#ifndef __CPROXYGATE_H
22
#define __CPROXYGATE_H
23

    
24
#include "cgate.h"
25

    
26
NAMESPACE_BEGIN
27

    
28
// forward declaration
29
class cParsimPartition;
30

    
31
/**
32
 * A gate that belongs to a cross-partition link and represents
33
 * the remote gate on the local partition. cProxyGate's belong to
34
 * cPlaceholderModule objects, which represent a "remote" module
35
 * in the local partition.
36
 *
37
 * This class basically exists so that we can override the deliver()
38
 * method of cGate so that it doesn't pass arriving messages
39
 * to the module object but to parallel simulation layer (cParsimPartition)
40
 * instead -- so cParsimPartition can deliver them to the remote partition.
41
 *
42
 * cProxyGate contains the address of the corresponding remote gate as
43
 * a (procId, moduleId, gateId) triplet:
44
 *
45
 * - procId is a partition identifier (also used by cParsimCommunications;
46
 *   in the MPI implementation of cParsimCommunications it maps to MPI_rank)
47
 *
48
 * - moduleId and gateId identify the target ("to-") gate on the remote partition.
49
 *
50
 * @ingroup Parsim
51
 */
52
class SIM_API cProxyGate : public cGate // noncopyable
53
{
54
    friend class cPlaceholderModule;
55
  private:
56
    cParsimPartition *partition;
57
    short remoteProcId;
58
    int remoteModuleId;
59
    int remoteGateId;
60
    void *data;
61

    
62
  protected:
63
    // internal: constructor is protected because only cPlaceholderModule
64
    // is allowed to create instances
65
    explicit cProxyGate();
66

    
67
  public:
68
    /** @name Redefined cObject member functions */
69
    //@{
70
    /**
71
     * Redefined here to display remoteProcId, remoteModId and remoteGateId.
72
     */
73
    virtual std::string info() const;
74
    //@}
75

    
76
    /** @name Redefined cGate member functions */
77
    //@{
78
    /**
79
     * Redefined to pass message to the parallel simulation layer,
80
     * cParsimPartition.
81
     *
82
     * Invokes the cParsimPartition::processOutgoingMessage() method
83
     * to transmit the message, then deletes the message object.
84
     */
85
    virtual bool deliver(cMessage *msg, simtime_t at);
86
    //@}
87

    
88
    /** @name Address of remote gate */
89
    //@{
90

    
91
    /**
92
     * Sets remote gate address.
93
     */
94
    void setRemoteGate(short procId, int moduleId, int gateId);
95

    
96
    /**
97
     * Returns partition where remote gate resides.
98
     */
99
    short getRemoteProcId()   {return remoteProcId;}
100

    
101
    /**
102
     * Returns module Id in remote partition where remote gate resides.
103
     */
104
    int getRemoteModuleId() {return remoteModuleId;}
105

    
106
    /**
107
     * Returns Id of remote gate in remote partition and remote module.
108
     */
109
    int getRemoteGateId()   {return remoteGateId;}
110
    //@}
111

    
112
    /** @name cParsimPartition pointer */
113
    //@{
114
    /**
115
     * Sets cParsimPartition object.
116
     */
117
    void setPartition(cParsimPartition *seg) {partition=seg;}
118
    /**
119
     * Returns pointer to cParsimPartition object.
120
     */
121
    cParsimPartition *getPartition()   {return partition;}
122
    //@}
123

    
124
    /** @name Generic associated data pointer */
125
    //@{
126
    /**
127
     * Sets the data pointer in this object. This pointer is used by the
128
     * parallel simulation synchronizaton layer (cParsimSynchronizer)
129
     * to store additional information about the gate.
130
     */
131
    void setSynchData(void *data) {this->data = data;}
132
    /**
133
     * Returns the data pointer in this object.
134
     */
135
    void *getSynchData()   {return data;}
136
    //@}
137
};
138

    
139
NAMESPACE_END
140

    
141

    
142
#endif
143