OpticalNode.h revision 10447:a465576671d4
1#ifndef __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__
2#define __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__
3
4#include "model/OpticalModel.h"
5#include "util/CommonType.h"
6
7namespace DSENT
8{
9    class OpticalNode;
10
11    //TODO: Change to detector
12    typedef std::pair<OpticalNode*, double> DetectorEntry;
13    typedef std::vector<DetectorEntry> DetectorTable;
14
15    class OpticalNode
16    {
17        public:
18            // The starting visited number flag of all optical nodes
19            static const int OPTICAL_NODE_INIT_VISITED_NUM;
20
21            // The types of optical nodes that can exist
22            enum Type
23            {
24                WAVEGUIDE,
25                LASER,
26                MODULATOR,
27                FILTER,
28                DETECTOR
29            };
30
31        public:
32            OpticalNode(Type type_, const String& instance_name_, OpticalModel* model_, const WavelengthGroup& wavelengths_);
33            ~OpticalNode();
34
35        public:
36            // Get the type of optical node
37            Type getType() const;
38            // Return instance name
39            const String& getInstanceName() const;
40            // Get the downstream optical nodes
41            vector<OpticalNode*>* getDownstreamNodes() const;
42            // Connect the downstream optical node
43            void addDownstreamNode(OpticalNode* node_);
44            // Return the node's parent model
45            OpticalModel* getModel();
46            const OpticalModel* getModel() const;
47            // Get wavelength groups
48            WavelengthGroup getWavelengths() const;
49            // Returns whether the node is expecting a set of wavelengths
50            bool isExpected(const WavelengthGroup& wavelengths_) const;
51
52            // Trace wavelengths, find and put all found lasers, modulators, and detectors
53            //virtual void traceWavelengths(const WavelengthGroup& wavelengths_, OpticalNode* laser_,
54            //    OpticalNode* modulator_, DetectorTable* detectors_, double current_loss_) const;
55
56            //-----------------------------------------------------------------
57            // Node variables for wavelength tracing
58            //-----------------------------------------------------------------
59            // Loss incurred at this optical node
60            void setLoss(double loss_);
61            double getLoss() const;
62            // Visited number marker
63            void setVisitedNum(int visited_num_);
64            int getVisitedNum() const;
65            //-----------------------------------------------------------------
66
67
68        private:
69            // Disable copy constructor
70            OpticalNode(const OpticalNode& node_);
71
72        private:
73            // The type of optical node
74            const Type m_type_;
75            // Name of this instance
76            String m_instance_name_;
77            // A pointer to the model that contains this node
78            OpticalModel* m_model_;
79            // Downstream optical node
80            vector<OpticalNode*>* m_downstream_nodes_;
81            // Path visited count (so that you don't have to clear it)
82            int m_visited_num_;
83            // The amount of loss incurred at this optical node
84            double m_loss_;
85            // The wavelengths this optical node is supposed to see
86            const WavelengthGroup m_wavelengths_;
87    };
88
89} // namespace DSENT
90
91#endif // __DSENT_MODEL_OPTICALGRAPH_OPTICALNODE_H__
92
93