Project

General

Profile

Statistics
| Branch: | Revision:

root / src / sim / parsim / cfilecomm.h @ 81ad8b66

History | View | Annotate | Download (2.86 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  CFILECOMM.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 __CFILECOMM_H__
22
#define __CFILECOMM_H__
23
24
#include "cparsimcomm.h"
25
#include "simutil.h"
26
27
NAMESPACE_BEGIN
28
29
30
/**
31
 * Implementation of the communications layer which works via files.
32
 * Every message is created as a file in a communications directory.
33
 *
34
 * It is VERY slow, and only useful for understanding, debugging or
35
 * demonstrating parallel simulation.
36
 *
37
 * @ingroup Parsim
38
 */
39
class SIM_API cFileCommunications : public cParsimCommunications
40
{
41
  protected:
42
    int numPartitions;
43
    int myProcId;
44
45
    int seqNum;
46
    opp_string commDirPrefix;
47
    opp_string readDirPrefix;
48
    bool preserveReadFiles;
49
50
  public:
51
    /**
52
     * Constructor.
53
     */
54
    cFileCommunications();
55
56
    /**
57
     * Destructor.
58
     */
59
    virtual ~cFileCommunications();
60
61
    /** @name Redefined methods from cParsimCommunications */
62
    //@{
63
    /**
64
     * Init the library.
65
     */
66
    virtual void init();
67
68
    /**
69
     * Shutdown the communications library.
70
     */
71
    virtual void shutdown();
72
73
    /**
74
     * Returns total number of partitions.
75
     */
76
    virtual int getNumPartitions() const;
77
78
    /**
79
     * Returns the id of this partition.
80
     */
81
    virtual int getProcId() const;
82
83
    /**
84
     * Creates an empty buffer of type cFileCommBuffer.
85
     */
86
    virtual cCommBuffer *createCommBuffer();
87
88
    /**
89
     * Recycle communication buffer after use.
90
     */
91
    virtual void recycleCommBuffer(cCommBuffer *buffer);
92
93
    /**
94
     * Sends packed data with given tag to destination.
95
     */
96
    virtual void send(cCommBuffer *buffer, int tag, int destination);
97
98
    /**
99
     * Receives packed data with given tag from given destination.
100
     * Normally returns true; false is returned if blocking was interrupted by the user.
101
     */
102
    virtual bool receiveBlocking(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId);
103
104
    /**
105
     * Receives packed data with given tag from given destination.
106
     * Call is non-blocking -- it returns true if something has been
107
     * received, false otherwise.
108
     */
109
    virtual bool receiveNonblocking(int filtTag, cCommBuffer *buffer,  int& receivedTag, int& sourceProcId);
110
    //@}
111
};
112
113
NAMESPACE_END
114
115
116
#endif
117