1 /* Copyright (c) 2012 Massachusetts Institute of Technology
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:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
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
22 #ifndef __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__
23 #define __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__
25 #include "model/OpticalModel.h"
26 #include "util/CommonType.h"
32 //TODO: Change to detector
33 typedef std::pair
<OpticalNode
*, double> DetectorEntry
;
34 typedef std::vector
<DetectorEntry
> DetectorTable
;
39 // The starting visited number flag of all optical nodes
40 static const int OPTICAL_NODE_INIT_VISITED_NUM
;
42 // The types of optical nodes that can exist
53 OpticalNode(Type type_
, const String
& instance_name_
, OpticalModel
* model_
, const WavelengthGroup
& wavelengths_
);
57 // Get the type of optical node
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;
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;
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 //-----------------------------------------------------------------
90 // Disable copy constructor
91 OpticalNode(const OpticalNode
& node_
);
94 // The type of optical node
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)
104 // The amount of loss incurred at this optical node
106 // The wavelengths this optical node is supposed to see
107 const WavelengthGroup m_wavelengths_
;
112 #endif // __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__