Quantum Fog  0.9.3
C_PORT_RELATED.h
1 #pragma once
2 
3 
4 #include "QFog_constants.h"
5 //******************************************
6 class C_CIRCLE
7 {
8 public:
9  Point its_center;
10  SInt16 its_radius;
11 
12  C_CIRCLE();
13  C_CIRCLE(const Point & pt, USHORT rad);
14 
15  BOOLEAN pt_is_in(const Point & pt) const;
16  BOOLEAN intersects_rect(const Rect & rect) const;
17 };
18 //******************************************
19 /*
20 An s (source) port shoots arrows.
21 A d (destination) port is a target for arrows.
22 An s/d ports is both an s port and a d port. It belongs to the intersection
23 of the set of s and d ports.
24 What constitutes a port:
25 (1) its_center = the location (a Point) of the customs office,
26  which lies at the center of the port.
27 (2) If the port is a d port:
28  its_arriving_nds = A list of the nd_ids for all the arriving nodes.
29  its_cur_s_load = the current number of arriving nodes
30  its_max_s_load
31 (2) If the port is an s port:
32  its_departing_nds = A list of the nd_id's for all the departing nodes.
33  its_cur_d_load = the current number of departing nodes
34  its_max_d_load
35 (3)its_docking_rad = arrow docking radius
36 (4)its_greeting_rad = arrow greeting radius = radius of
37  circle inside of which port notices ships and greets them.
38 
39 If port is an object of C_PORT, then
40  cir = C_CIRCLE(port.its_center, port.its_docking_rad)
41 will be referred to as a docking circle and
42  cir = C_CIRCLE(port.its_center, port.its_greeting_rad)
43 will be referred to as a greeting circle.
44 
45 For the custom node,
46 for example, we will assume that there is
47  an s/d port which can carry s and d loads of any size.
48 For the BEAM_SPL,
49 on the other hand, we will assume that there are two s-only ports and two d-only ports,
50 each of which can carry a maximum load of one.
51 */
52 
53 //******************************************
55 {
56 public:
57  USHORT its_nd_id; // node id number
58  USHORT its_sub_nd_id; //numerical id distinguishing the ports of that node
59 
60  C_PORT_NAME();
61  C_PORT_NAME(USHORT nd_id, USHORT sub_nd_id);
62 
63  friend BOOLEAN operator==(const C_PORT_NAME & pn1, const C_PORT_NAME & pn2);
64  friend BOOLEAN operator!=(const C_PORT_NAME & pn1, const C_PORT_NAME & pn2);
65 
66  friend LStream & operator<<( LStream & out_bd, const C_PORT_NAME & pn);
67  friend LStream & operator>>( LStream & in_bd, C_PORT_NAME & pn);
68 
69 };
70 #pragma mark -
71 
72 
73 
74 #pragma mark ----C_CIRCLE----
75 //******************************************
76 inline
77 BOOLEAN C_CIRCLE::pt_is_in(
78 const Point & pt) //in
79 const
80 {
81  return(
82  sqrt( pow(DOUBLE(pt.h - its_center.h), 2) +
83  pow(DOUBLE(pt.v - its_center.v), 2) )
84  <= its_radius
85  );
86 }
87 #pragma mark ----C_PORT_NAME----
88 //******************************************
89 inline
90 BOOLEAN operator==(
91 const C_PORT_NAME & pn1, //in
92 const C_PORT_NAME & pn2) //in
93 {
94  return(
95  (pn1.its_nd_id == pn2.its_nd_id)&&
96  (pn1.its_sub_nd_id == pn2.its_sub_nd_id)
97  );
98 }
99 //******************************************
100 inline
101 BOOLEAN operator!=(
102 const C_PORT_NAME & pn1, //in
103 const C_PORT_NAME & pn2) //in
104 {
105  return !(pn1==pn2);
106 }
107 
Definition: C_PORT_RELATED.h:54
Definition: C_PORT_RELATED.h:6