sim, kvm: make KvmVM a System parameter
[gem5.git] / ext / dsent / model / optical_graph / OpticalNode.h
1 /* Copyright (c) 2012 Massachusetts Institute of Technology
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 */
21
22 #ifndef __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__
23 #define __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__
24
25 #include "model/OpticalModel.h"
26 #include "util/CommonType.h"
27
28 namespace DSENT
29 {
30 class OpticalNode;
31
32 //TODO: Change to detector
33 typedef std::pair<OpticalNode*, double> DetectorEntry;
34 typedef std::vector<DetectorEntry> DetectorTable;
35
36 class OpticalNode
37 {
38 public:
39 // The starting visited number flag of all optical nodes
40 static const int OPTICAL_NODE_INIT_VISITED_NUM;
41
42 // The types of optical nodes that can exist
43 enum Type
44 {
45 WAVEGUIDE,
46 LASER,
47 MODULATOR,
48 FILTER,
49 DETECTOR
50 };
51
52 public:
53 OpticalNode(Type type_, const String& instance_name_, OpticalModel* model_, const WavelengthGroup& wavelengths_);
54 ~OpticalNode();
55
56 public:
57 // Get the type of optical node
58 Type getType() const;
59 // Return instance name
60 const String& getInstanceName() const;
61 // Get the downstream optical nodes
62 vector<OpticalNode*>* getDownstreamNodes() const;
63 // Connect the downstream optical node
64 void addDownstreamNode(OpticalNode* node_);
65 // Return the node's parent model
66 OpticalModel* getModel();
67 const OpticalModel* getModel() const;
68 // Get wavelength groups
69 WavelengthGroup getWavelengths() const;
70 // Returns whether the node is expecting a set of wavelengths
71 bool isExpected(const WavelengthGroup& wavelengths_) const;
72
73 // Trace wavelengths, find and put all found lasers, modulators, and detectors
74 //virtual void traceWavelengths(const WavelengthGroup& wavelengths_, OpticalNode* laser_,
75 // OpticalNode* modulator_, DetectorTable* detectors_, double current_loss_) const;
76
77 //-----------------------------------------------------------------
78 // Node variables for wavelength tracing
79 //-----------------------------------------------------------------
80 // Loss incurred at this optical node
81 void setLoss(double loss_);
82 double getLoss() const;
83 // Visited number marker
84 void setVisitedNum(int visited_num_);
85 int getVisitedNum() const;
86 //-----------------------------------------------------------------
87
88
89 private:
90 // Disable copy constructor
91 OpticalNode(const OpticalNode& node_);
92
93 private:
94 // The type of optical node
95 const Type m_type_;
96 // Name of this instance
97 String m_instance_name_;
98 // A pointer to the model that contains this node
99 OpticalModel* m_model_;
100 // Downstream optical node
101 vector<OpticalNode*>* m_downstream_nodes_;
102 // Path visited count (so that you don't have to clear it)
103 int m_visited_num_;
104 // The amount of loss incurred at this optical node
105 double m_loss_;
106 // The wavelengths this optical node is supposed to see
107 const WavelengthGroup m_wavelengths_;
108 };
109
110 } // namespace DSENT
111
112 #endif // __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__
113