Panda3D
threadPriority.cxx
1 // Filename: threadPriority.cxx
2 // Created by: drose (26Sep08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "threadPriority.h"
16 #include "pnotify.h" // nassertr
17 #include "pipeline.h"
18 
19 ostream &
20 operator << (ostream &out, ThreadPriority pri) {
21  switch (pri) {
22  case TP_low:
23  return out << "low";
24 
25  case TP_normal:
26  return out << "normal";
27 
28  case TP_high:
29  return out << "high";
30 
31  case TP_urgent:
32  return out << "urgent";
33  }
34 
35  pipeline_cat->error()
36  << "Invalid ThreadPriority value: " << (int)pri << "\n";
37  nassertr(false, out);
38  return out;
39 }
40 
41 istream &
42 operator >> (istream &in, ThreadPriority &pri) {
43  string word;
44  in >> word;
45  if (word == "low") {
46  pri = TP_low;
47 
48  } else if (word == "normal") {
49  pri = TP_normal;
50 
51  } else if (word == "high") {
52  pri = TP_high;
53 
54  } else if (word == "urgent") {
55  pri = TP_urgent;
56 
57  } else {
58  pri = TP_normal;
59  pipeline_cat->error()
60  << "Invalid ThreadPriority string: " << word << "\n";
61  nassertr(false, in);
62  }
63 
64  return in;
65 }