Project

General

Profile

Statistics
| Branch: | Revision:

root / src / scave / vectorfilewriter.h @ a3be1d55

History | View | Annotate | Download (2.37 KB)

1
//=========================================================================
2
//  VECTORFILEWRITER.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 _VECTORFILEWRITER_H_
19
#define _VECTORFILEWRITER_H_
20

    
21
#include <vector>
22
#include "node.h"
23
#include "nodetype.h"
24
#include "resultfilemanager.h"
25

    
26
NAMESPACE_BEGIN
27

    
28
/**
29
 * Consumer node which writes an output vector file.
30
 */
31
class SCAVE_API VectorFileWriterNode : public Node
32
{
33
    public:
34
        struct Pair {
35
            int id;
36
            std::string moduleName;
37
            std::string name;
38
            std::string columns;
39
            Port port;
40

    
41
            Pair(int id, const char *moduleName, const char *name, const char *columns, Node *owner) : port(owner)
42
                {this->id = id; this->moduleName = moduleName; this->name = name; this->columns = columns; }
43
        };
44
        typedef std::vector<Pair> PortVector;
45

    
46
    private:
47
        PortVector ports;
48
        std::string fileName;
49
        std::string fileHeader;
50
        FILE *f;
51
        int prec;
52

    
53
    public:
54
        VectorFileWriterNode(const char *filename, const char *fileHeader=NULL);
55
        virtual ~VectorFileWriterNode();
56

    
57
        Port *addVector(const VectorResult &vector);
58
        void setPrecision(int prec) {this->prec = prec;}
59

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

    
65
class SCAVE_API VectorFileWriterNodeType : public NodeType
66
{
67
    public:
68
        virtual const char *getName() const {return "vectorfilewriter";}
69
        virtual const char *getCategory() const {return "multi-port sink";}
70
        virtual const char *getDescription() const;
71
        virtual bool isHidden() const {return true;}
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
NAMESPACE_END
78

    
79

    
80
#endif
81

    
82