ns-3 PLC model
model/plc-node.h
00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
00002 /*
00003  * Copyright (c) 2012 University of British Columbia, Vancouver
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation;
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  * Author: Alexander Schloegl <alexander.schloegl@gmx.de>
00019  */
00020 
00021 #ifndef PLC_NODE_H_
00022 #define PLC_NODE_H_
00023 
00024 #include <map>
00025 #include <set>
00026 #include <list>
00027 #include <string>
00028 
00029 #include <ns3/object.h>
00030 #include <ns3/type-id.h>
00031 #include <ns3/vector.h>
00032 
00033 #include "plc-defs.h"
00034 #include "plc-time.h"
00035 #include "plc-value.h"
00036 #include "plc-edge.h"
00037 #include "plc-outlet.h"
00038 #include "plc-backbone.h"
00039 
00040 namespace ns3 {
00041 
00042 class PLC_Graph;
00043 class PLC_Line;
00044 class PLC_Outlet;
00045 class PLC_Channel;
00046 
00055 class PLC_Node : public Object
00056 {
00057         friend class PLC_Graph;
00058         friend class PLC_Outlet;
00059 
00060 public:
00061         static TypeId GetTypeId (void);
00062 
00063         PLC_Node ();
00064         ~PLC_Node ();
00065 
00070         Vector3D GetPosition (void) { return m_position; }
00071 
00076         void SetPosition (Vector3D pos) { m_position = pos; }
00077 
00084         void SetPosition(double pos_x, double pos_y, double pos_z);
00085 
00092         void SetImpedance(Ptr<PLC_Impedance> impedance);
00093 
00098         Ptr<PLC_Impedance> GetImpedancePtr (void) { return m_impedance; }
00099 
00104         PLC_Impedance *GetImpedancePeekPtr (void) const { return PeekPointer(m_impedance); }
00105 
00110         unsigned int GetVertexId (void) { return m_vertex_id; }
00111 
00116         Ptr<PLC_Outlet> GetOutlet (void) { return this->m_outlet; }
00117 
00122         PLC_Outlet *GetOutletPeekPtr (void);
00123 
00128         bool HasOutlet (void) { return m_outlet == NULL ? false : true; }
00129 
00134         bool IsOpenCircuit (void)       { return m_open_circuit; }
00135 
00139         void OpenCircuit (void)         { m_open_circuit = true; }
00140 
00144         void CloseCircuit (void);
00145 
00146 
00154         void AddEdge (Ptr<PLC_Node> to, Ptr<PLC_Edge> edge);
00155 
00160         size_t GetNumEdges (void) { return m_edges.size(); }
00161 
00167         PLC_Edge *GetEdge (PLC_Node *node);
00168 
00172         PLC_NodeOutEdgesMap GetEdges (void);
00173 
00181         void AssociateBackboneBranch (Ptr<PLC_BackboneBranch> backboneBranch);
00182 
00187         PLC_NodeOutEdgesMap::iterator OutEdgesBegin (void) { return m_edges.begin(); }
00188 
00193         PLC_NodeOutEdgesMap::iterator OutEdgesEnd (void) { return m_edges.end(); }
00194 
00199         void SetName(std::string name) { m_name = name; }
00200 
00205         std::string GetName(void) { return m_name; }
00206 
00210         void Lock(void) { m_node_mutex.Lock(); }
00211 
00215         void Unlock(void) { m_node_mutex.Unlock(); }
00216 
00221         bool IsTimeVariant(void);
00222 
00227         Ptr<PLC_Graph> GetGraph(void) { return this->m_graph; }
00228 
00232         Ptr<PLC_Channel> GetChannel(void);
00233 
00238         void SetGraph(Ptr<PLC_Graph> graph);
00239 
00245         void SetOutlet(Ptr<PLC_Outlet> outlet);
00246 
00247         static uint64_t GetImpedanceHashSum(void) { return m_impedance_hash_sum; }
00248 
00249 protected:
00250         virtual void DoStart(void);
00251         virtual void DoDispose(void);
00252 
00253         static uint64_t m_impedance_hash_sum;
00254 
00255         Vector3D m_position;
00256         mutable PLC_Mutex       m_node_mutex;
00257         unsigned int m_vertex_id;
00258         bool m_open_circuit;
00259 
00260         Ptr<PLC_Graph>          m_graph;
00261         Ptr<PLC_Impedance>      m_impedance;
00262         Ptr<PLC_Outlet>         m_outlet;
00263 
00264         PLC_NodeOutEdgesMap m_edges;
00265         std::set<Ptr<PLC_BackboneBranch> > m_associated_backbone_branches;
00266 
00267         std::string m_name;
00268 };
00269 
00270 }
00271 
00272 #endif /* PLC_NODE_H_ */
 All Classes Functions Variables Enumerations