Statistics
| Branch: | Revision:

root / src / scave / vectorfilereader.h @ e1750c09

History | View | Annotate | Download (2.35 KB)

1
//=========================================================================
2
//  VECTORFILEREADER.H - part of
3
//                  OMNeT++/OMNEST
4
//           Discrete System Simulation in C++
5
//
6
//  Author: Andras Varga
7
//
8
//=========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 1992-2008 Andras Varga
12
  Copyright (C) 2006-2008 OpenSim Ltd.
13

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

    
18
#ifndef _VECTORFILEREADER_H_
19
#define _VECTORFILEREADER_H_
20

    
21
#include <map>
22
#include <string>
23
#include "platmisc.h"
24
#include "node.h"
25
#include "nodetype.h"
26
#include "commonnodes.h"
27
#include "filereader.h"
28
#include "linetokenizer.h"
29
#include "resultfilemanager.h"
30

    
31
NAMESPACE_BEGIN
32

    
33
// read in 64K chunks (apparently it doesn't matter much if we use a bigger buffer)
34
#define VECFILEREADER_BUFSIZE  (64*1024)
35

    
36
// shared with indexedvectorfilereadernode
37
Datum parseColumns(char **tokens, int numtokens, const std::string &columns, const char* file, int64 lineno, file_offset_t offset);
38

    
39
/**
40
 * Producer node which reads an output vector file.
41
 */
42
class SCAVE_API VectorFileReaderNode : public ReaderNode
43
{
44
    public:
45
        typedef std::vector<Port> PortVector;
46
        typedef std::map<int,PortVector> Portmap;
47
        typedef std::string ColumnSpec;
48
        typedef std::map<int,ColumnSpec> ColumnMap;
49
    private:
50
        Portmap ports;
51
        ColumnMap columns;
52
        LineTokenizer tokenizer;
53
        bool fFinished;
54

    
55
    public:
56
        VectorFileReaderNode(const char *filename, size_t bufferSize = VECFILEREADER_BUFSIZE);
57
        virtual ~VectorFileReaderNode();
58

    
59
        Port *addVector(const VectorResult &vector);
60

    
61
        virtual bool isReady() const;
62
        virtual void process();
63
        virtual bool isFinished() const;
64
};
65

    
66

    
67
class SCAVE_API VectorFileReaderNodeType : public ReaderNodeType
68
{
69
    public:
70
        virtual const char *getName() const {return "vectorfilereader";}
71
        virtual const char *getDescription() const;
72
        virtual void getAttributes(StringMap& attrs) const;
73
        virtual Node *create(DataflowManager *mgr, StringMap& attrs) const;
74
        virtual Port *getPort(Node *node, const char *portname) const;
75
};
76

    
77

    
78
NAMESPACE_END
79

    
80

    
81
#endif
82

    
83