1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
//$Id$
#include "RT_Properties.h"
#include "tao/ORB_Constants.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_string.h"
ACE_RCSID (ExposedPolicies, RT_Properties, "$Id$")
RT_Properties::RT_Properties (void)
: priority_ (10)
{
ior_source_ = ACE_TEXT("poa_default.ior");
}
RT_Properties::~RT_Properties (void)
{
// No-Op.
}
RT_Properties *
RT_Properties::read_from (const ACE_TCHAR *file_name)
{
FILE *fp = ACE_OS::fopen (file_name, "r");
RT_Properties *rt_properties = 0;
ACE_NEW_THROW_EX (rt_properties,
RT_Properties,
CORBA::NO_MEMORY (TAO::VMCID,
CORBA::COMPLETED_NO));
// @@ Angelo: what if the length is more than 255?
char string_field[256];
int int_field;
unsigned int i = 0;
int n_matched;
while (fscanf (fp, "%s", string_field) != EOF )
{
if (ACE_OS::strcmp (string_field, "Priority") == 0)
{
n_matched = fscanf (fp, "%d", &int_field);
rt_properties->priority (int_field);
}
else if (ACE_OS::strcmp (string_field, "Priority_Bands") == 0)
{
n_matched = fscanf (fp, "%d", &int_field);
rt_properties->priority_bands_.length (int_field);
}
else if (ACE_OS::strcmp (string_field, "Priority_Range") == 0)
{
n_matched = fscanf (fp, "%d", &int_field);
rt_properties->priority_bands_[i].low = int_field;
n_matched = fscanf (fp, "%d", &int_field);
rt_properties->priority_bands_[i].high = int_field;
++i;
}
}
return rt_properties;
}
void
RT_Properties::priority (RTCORBA::Priority priority)
{
this->priority_ = priority;
}
RTCORBA::Priority
RT_Properties::priority (void)
{
return this->priority_;
}
void
RT_Properties::priority_bands (const RTCORBA::PriorityBands& priority_bands)
{
this->priority_bands_ = priority_bands;
}
const RTCORBA::PriorityBands&
RT_Properties::priority_bands (void)
{
return this->priority_bands_;
}
void
RT_Properties::ior_source (const ACE_TCHAR *s)
{
this->ior_source_ = s;
}
const ACE_TCHAR *
RT_Properties::ior_source (void)
{
return this->ior_source_.c_str ();
}
|