Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Exposed_Policies / RT_Properties.cpp
blob5d68906672f13d0cccd09a4bdbf48ac4d1aee305
1 #include "RT_Properties.h"
3 #include "tao/ORB_Constants.h"
5 #include "ace/OS_NS_stdio.h"
6 #include "ace/OS_NS_string.h"
8 RT_Properties::RT_Properties ()
9 : priority_ (10)
11 ior_source_ = ACE_TEXT("poa_default.ior");
14 RT_Properties *
15 RT_Properties::read_from (const ACE_TCHAR *file_name)
17 FILE *fp = ACE_OS::fopen (file_name, "r");
19 RT_Properties *rt_properties = 0;
21 ACE_NEW_THROW_EX (rt_properties,
22 RT_Properties,
23 CORBA::NO_MEMORY (TAO::VMCID,
24 CORBA::COMPLETED_NO));
26 // @@ Angelo: what if the length is more than 255?
27 char string_field[256];
28 int int_field;
29 unsigned int i = 0;
30 int n_matched;
32 while (fscanf (fp, "%s", string_field) != EOF )
34 if (ACE_OS::strcmp (string_field, "Priority") == 0)
36 n_matched = fscanf (fp, "%d", &int_field);
37 ACE_UNUSED_ARG (n_matched);
39 rt_properties->priority (int_field);
41 else if (ACE_OS::strcmp (string_field, "Priority_Bands") == 0)
43 n_matched = fscanf (fp, "%d", &int_field);
44 ACE_UNUSED_ARG (n_matched);
46 rt_properties->priority_bands_.length (int_field);
48 else if (ACE_OS::strcmp (string_field, "Priority_Range") == 0)
50 n_matched = fscanf (fp, "%d", &int_field);
51 ACE_UNUSED_ARG (n_matched);
53 rt_properties->priority_bands_[i].low = int_field;
55 n_matched = fscanf (fp, "%d", &int_field);
56 ACE_UNUSED_ARG (n_matched);
58 rt_properties->priority_bands_[i].high = int_field;
60 ++i;
64 return rt_properties;
67 void
68 RT_Properties::priority (RTCORBA::Priority priority)
70 this->priority_ = priority;
73 RTCORBA::Priority
74 RT_Properties::priority ()
76 return this->priority_;
79 void
80 RT_Properties::priority_bands (const RTCORBA::PriorityBands& priority_bands)
82 this->priority_bands_ = priority_bands;
85 const RTCORBA::PriorityBands&
86 RT_Properties::priority_bands ()
88 return this->priority_bands_;
91 void
92 RT_Properties::ior_source (const ACE_TCHAR *s)
94 this->ior_source_ = s;
97 const ACE_TCHAR *
98 RT_Properties::ior_source ()
100 return this->ior_source_.c_str ();