UnitInterface.h 4.15 KB
Newer Older
1
2
3
//================================================================================
// Name        : UnitInterface.h
// Author      : Alessio Netti
Micha Müller's avatar
Micha Müller committed
4
// Contact     : info@dcdb.it
5
// Copyright   : Leibniz Supercomputing Centre
6
// Description : Interface for Units used by Operators.
7
8
9
10
11
12
13
14
15
16
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2019-2019 Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
Alessio Netti's avatar
Alessio Netti committed
17
//
18
19
20
21
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
Alessio Netti's avatar
Alessio Netti committed
22
//
23
24
25
26
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//================================================================================
Alessio Netti's avatar
Alessio Netti committed
27
28
29
30
31

#ifndef PROJECT_UNITINTERFACE_H
#define PROJECT_UNITINTERFACE_H

#include <vector>
32
#include "sensorbase.h"
Alessio Netti's avatar
Alessio Netti committed
33

Alessio Netti's avatar
Alessio Netti committed
34
35
36
// Defines how inputs must be constructed for the specified unit
typedef enum inputMode_t { SELECTIVE = 1, ALL = 2, ALL_RECURSIVE = 3 } inputMode_t;

Alessio Netti's avatar
Alessio Netti committed
37
/**
38
 * @brief Interface for Units used by Operators to perform data analytics.
Alessio Netti's avatar
Alessio Netti committed
39
 *
40
 * @details An Unit represents a logical entity on which an Operator operates,
41
42
 *          and is identified by its name, inputs and outputs.
 *
43
 * @ingroup operator
Alessio Netti's avatar
Alessio Netti committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 */
class UnitInterface {

public:

    /**
    * @brief            Class constructor
    */
    UnitInterface() {}

    /**
    * @brief            Class destructor
    */
    virtual ~UnitInterface() {}

59
60
61
62
63
64
65
66
    /**
    * @brief            Initializes the sensors in the unit
    *
    * @param cacheSize  size of the sensor cache 
    * @param flatten    if true, sensors in sub-units are also initialized
    */
    virtual void init(unsigned int cacheSize, bool flatten=false) = 0;

Alessio Netti's avatar
Alessio Netti committed
67
68
69
70
71
72
73
    /**
    * @brief            Sets the name of this unit
    *
    * @param name       The name of this unit
    */
    virtual void setName(const std::string& name) = 0;

Alessio Netti's avatar
Alessio Netti committed
74
75
76
77
78
79
80
81
82
    /**
    * @brief            Get the name of this unit
    *
    *                   A unit's name points to the logical entity that it represents; for example, it could be
    *                   "hpcsystem1.node44", or "node44.cpu10". All the outputs of the unit are then associated to its
    *                   entity, and all of the input are related to it as well.
    *
    * @return           The unit's name
    */
Alessio Netti's avatar
Alessio Netti committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    virtual std::string& getName() = 0;

    /**
    * @brief            Sets the input mode of this unit
    *
    * @param iMode      The input mode that was used for this unit
    */
    virtual void setInputMode(const inputMode_t iMode) = 0;

    /**
    * @brief            Get the input mode of this unit
    *
    * @return           The unit's input mode
    */
    virtual inputMode_t getInputMode() = 0;
Alessio Netti's avatar
Alessio Netti committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

    /**
    * @brief            Get the (base) input sensors of this unit
    *
    * @return           A vector of pointers to SensorBase objects that constitute this unit's input
    */
    virtual std::vector<SBasePtr>& getBaseInputs()  = 0;

    /**
    * @brief            Get the (base) output sensors of this unit
    *
    * @return           A vector of pointers to SensorBase objects that constitute this unit's output
    */
    virtual std::vector<SBasePtr>& getBaseOutputs() = 0;

113
114
115
116
117
118
119
120
    /**
    * @brief            Prints the current unit configuration
    *
    * @param ll         Logging level at which the configuration is printed
    * @param lg         Logger object to be used
    */
    virtual void printConfig(LOG_LEVEL ll, LOGGER& lg)       = 0;

Alessio Netti's avatar
Alessio Netti committed
121
122
123
124
125
126
};

//for better readability
using UnitPtr = std::shared_ptr<UnitInterface>;

#endif //PROJECT_UNITINTERFACE_H