12 extern src::severity_logger<severity_level>
lg;
31 pugi::xml_document
doc;
34 pugi::xml_attribute
getAttribute(pugi::xml_node, std::string);
35 pugi::xml_node
findNode(pugi::xml_node,
int uuid);
36 pugi::xml_node
findNode(pugi::xml_node, std::string);
67 void updateChildren(
int, std::string, std::vector<SimplePanelData*> &);
68 void updateChildren(
int, std::string, std::string, std::string, std::vector<std::pair<int, int>>&);
78 doc.load_file(xmlfile.c_str());
79 pugi::xml_node root_node;
81 root_node =
doc.child(
"Callbacks");
84 root_node =
doc.child(
"KeyDictionaries");
87 root_node =
doc.child(
"Colors");
90 root_node =
doc.child(
"ProcDb");
93 root_node =
doc.child(
"Screen");
96 root_node =
doc.child(
"ProcInfo");
99 root_node =
doc.child(
"Column");
116 pugi::xml_text txt_obj = node.text();
117 parser<<txt_obj.get();
118 std::vector<std::string> words = parser.
Words();
119 words.erase(words.begin());
120 words.erase(words.end()-1);
121 parser.setSeparator(
',');
122 for(
auto word: words)
126 std::vector<std::string> colorstring = parser.Words();
134 int uuid = std::stoi(attr.value());
137 pugi::xml_node child_node =
findNode(
doc.child(
"ProcDb"),
"FieldProperties");
138 pugi::xml_text txt_obj = child_node.text();
140 parser<<txt_obj.get();
141 std::vector<std::string> words = parser.
Words();
142 words.erase(words.begin());
143 words.erase(words.end()-1);
145 parser.setSeparator(
',');
146 for(
auto line: words)
149 int field = std::stoi((parser.Words()[0]));
150 std::string prop = (parser.Words()[1]);
151 std::string type = (parser.Words()[2]);
152 database->field_prop_dict[field] = std::make_pair(prop, type);
153 database->prop_type_dict[prop] = type;
182 int uuid = std::stoi(attr.value());
185 pinfo->sortkey = (
getAttribute(node,
"SortKey")).value();
186 int db_uuid = std::stoi((
getAttribute(node,
"ProcDb")).value());
193 int uuid = std::stoi(attr.value());
197 int pinfo_uuid = std::stoi(attr.value());
200 int viewp_uuid = std::stoi(attr.value());
202 pugi::xml_node child_node =
findNode(node,
"ProcViews");
203 pugi::xml_text txt_obj = child_node.text();
205 parser<<txt_obj.get();
206 std::vector<std::string> words;
207 words = parser.
Words();
208 for(
auto view_id: words)
209 pclms->proc_views.push_back(std::stoi(view_id));
216 pugi::xml_attribute attr;
217 for(attr=node.first_attribute(); attr; attr = attr.next_attribute())
219 if (strcmp(attr.name(), attr_name.c_str()) == 0)
227 for(pugi::xml_node node_keydict=root.first_child(); node_keydict; node_keydict = node_keydict.next_sibling())
229 int uuid = std::stoi((
getAttribute(node_keydict,
"Uuid").value()));
232 for(pugi::xml_node node_keyacts=node_keydict.first_child(); node_keyacts; node_keyacts = node_keyacts.next_sibling())
234 int key = std::stol((
getAttribute(node_keyacts,
"Key").value()), NULL, 0);
235 std::vector<Action> vec_actions;
236 for(pugi::xml_node node_act=node_keyacts.first_child(); node_act; node_act = node_act.next_sibling())
239 parser<<(node_act.text()).get();
240 std::vector<std::string> words = parser.Words();
241 vec_actions.push_back(
Action{std::stoi(words[0]), words[1]});
244 key_dict.addKeyActions(key, vec_actions);
254 pugi::xml_text txt_obj = root.text();
255 parser<<txt_obj.get();
256 std::vector<std::string> words = parser.
Words();
257 words.erase(words.begin());
258 words.erase(words.end()-1);
261 parser.setSeparator(
',');
262 for(
auto word: words)
265 std::vector<std::string> obj_func_pair = parser.Words();
266 if (obj_func_pair[0] ==
"Screen")
268 if (obj_func_pair[1] ==
"refresh")
271 else if (obj_func_pair[0] ==
"View")
274 else if (obj_func_pair[0] ==
"SimplePanelData")
276 if (obj_func_pair[1] ==
"Down")
278 if (obj_func_pair[1] ==
"Up")
280 if (obj_func_pair[1] ==
"editModeOn")
282 if (obj_func_pair[1] ==
"editModeOff")
284 if (obj_func_pair[1] ==
"insertIntoLeftNbr")
286 if (obj_func_pair[1] ==
"insertIntoRightNbr")
288 if (obj_func_pair[1] ==
"addIntoLeftNbr")
290 if (obj_func_pair[1] ==
"addIntoRightNbr")
292 if (obj_func_pair[1] ==
"moveIntoLeftNbr")
294 if (obj_func_pair[1] ==
"moveIntoRightNbr")
296 if (obj_func_pair[1] ==
"toggleEditMode")
298 if (obj_func_pair[1] ==
"deleteColumn")
300 if (obj_func_pair[1] ==
"insertColumn")
302 if (obj_func_pair[1] ==
"moveLeft")
304 if (obj_func_pair[1] ==
"moveRight")
306 if (obj_func_pair[1] ==
"refresh")
308 if (obj_func_pair[1] ==
"remove")
312 else if (obj_func_pair[0] ==
"Columns")
314 if(obj_func_pair[1] ==
"markPid")
316 if(obj_func_pair[1] ==
"read")
319 else if(obj_func_pair[0] ==
"ProcInfo")
321 if(obj_func_pair[1] ==
"kill")
326 if (obj_func_pair[1] ==
"next")
328 if (obj_func_pair[1] ==
"stale")
346 if (container_type ==
"inf_int")
348 else if (container_type ==
"inf_float")
350 else if (container_type ==
"inf_string")
356 if (container_type ==
"inf_int")
358 else if (container_type ==
"inf_float")
360 else if (container_type ==
"inf_string")
382 if (strcmp(node.name(),
"Screen") == 0)
384 if(pugi::xml_attribute attr =
getAttribute(node,
"Uuid"))
386 int uuid = std::stoi(attr.value());
394 std::stringstream ss;
395 ss<<
"createTreeFirstPass: failed to find attribute Uuid in "<<node.name()<<
"\n";
396 throw std::runtime_error(ss.str());
399 else if (strcmp((
char*)node.name(),
"View")==0)
401 if(pugi::xml_attribute attr =
getAttribute(node,
"Uuid"))
403 int uuid = std::stoi(attr.value());
411 std::stringstream ss;
412 ss<<
"createTreeFirstPass: failed to find attribute Uuid in "<<node.name()<<
"\n";
413 throw std::runtime_error(ss.str());
416 else if (strcmp(node.name(),
"Panel") == 0)
418 if(pugi::xml_attribute attr =
getAttribute(node,
"Uuid"))
420 int uuid = std::stoi(attr.value());
421 if(pugi::xml_attribute attr =
getAttribute(node,
"Type"))
423 int type = std::stoi(attr.value());
424 if(pugi::xml_attribute attr =
getAttribute(node,
"ContainerData"))
427 throw std::runtime_error(
"failed to find ContainerData in Panel\n");
430 throw std::runtime_error(
"failed to find Type in Panel\n");
433 throw std::runtime_error(
"failed to find UUID in Screen \n");
435 else if (strcmp(node.name(),
"ColumnsPanelData") == 0)
445 for(pugi::xml_node child_node = node.first_child(); child_node; child_node = child_node.next_sibling())
452 if (pugi::xml_attribute attr=
getAttribute(node,
"Uuid"))
454 if(std::stoi(attr.value()) == uuid)
458 for(pugi::xml_node child=node.first_child(); child; child=child.next_sibling())
460 if (pugi::xml_node return_node =
findNode(child, uuid))
467 return pugi::xml_node();
472 if (strcmp(name.c_str(), node.name()) == 0)
476 for(pugi::xml_node child=node.first_child(); child; child=child.next_sibling())
478 if (pugi::xml_node return_node =
findNode(child, name))
484 return pugi::xml_node();
489 pugi::xml_node node =
findNode(
doc.child(
"Screen"), uuid);
492 std::stringstream ss;
493 ss<<
"updateObjFromAttrib: node corresponding to uuid "<<uuid<<
" not found \n";
494 throw std::runtime_error(ss.str());
496 if(pugi::xml_attribute attr=
getAttribute(node, attr_name))
501 std::stringstream ss;
502 ss<<
"failed to find "<<attr_name<<
" in object "<<uuid<<
"\n";
503 throw std::runtime_error(ss.str());
509 pugi::xml_node node =
findNode(
doc.child(
"Screen"), uuid);
512 std::stringstream ss;
513 ss<<
"updateObjFromAttrib: node corresponding to uuid "<<uuid<<
" not found \n";
514 throw std::runtime_error(ss.str());
516 if(pugi::xml_attribute attr=
getAttribute(node, attr_name))
521 std::stringstream ss;
522 ss<<
"failed to find "<<attr_name<<
" in object "<<uuid<<
"\n";
523 throw std::runtime_error(ss.str());
529 pugi::xml_node node =
findNode(
doc.child(
"Screen"), uuid);
532 std::stringstream ss;
533 ss<<
"updateObjFromAttrib: node corresponding to uuid "<<uuid<<
" not found \n";
534 throw std::runtime_error(ss.str());
538 attr1_val = std::stoi(attr.value());
541 std::stringstream ss;
542 ss<<
"failed to find "<<attr1<<
" in object "<<uuid<<
"\n";
543 throw std::runtime_error(ss.str());
547 attr2_val = std::stoi(attr.value());
550 std::stringstream ss;
551 ss<<
"failed to find "<<attr2<<
" in object "<<uuid<<
"\n";
552 throw std::runtime_error(ss.str());
559 pugi::xml_node root =
findNode(
doc.child(
"Screen"), uuid);
560 pugi::xml_node child =
findNode(root, child_name);
561 pugi::xml_text txt_obj = child.text();
564 std::stringstream ss;
565 ss<<
"failure to read object list from panel "<<uuid<<
", empty list\n";
566 throw std::runtime_error(ss.str());
568 pugi::xml_attribute attr =
getAttribute(child,
"Separator");
569 int capacity = std::stoi((
getAttribute(child,
"Capacity").value()));
571 parser<<txt_obj.get();
572 object_list.reserve(capacity);
573 for(
auto word: parser.Words())
588 pugi::xml_node root =
findNode(
doc.child(
"Screen"), uuid);
589 pugi::xml_node child =
findNode(root, child_name);
590 pugi::xml_text txt_obj = child.text();
593 std::stringstream ss;
594 ss<<
"failure to read object list from panel "<<uuid<<
", empty list\n";
595 throw std::runtime_error(ss.str());
597 pugi::xml_attribute attr =
getAttribute(child,
"Separator");
598 int capacity = std::stoi((
getAttribute(child,
"Capacity").value()));
601 parser<<txt_obj.get();
602 std::vector<std::string> words = parser.Words();
603 words.erase(words.begin());
604 words.erase(words.end()-1);
606 parser.setSeparator(
',');
607 object_list.reserve(capacity);
608 for(
auto word: words)
611 std::vector<std::string> info = parser.Words();
612 object_list.push_back(
new Info(info[0], info[1], info[2]));
619 pugi::xml_node root =
findNode(
doc.child(
"Screen"), uuid);
620 pugi::xml_node_iterator it;
621 for(it=root.begin(); it != root.end(); it++)
623 if (strcmp(it->name(), child_name.c_str()) == 0)
625 pugi::xml_attribute attr =
getAttribute(*it, child_attr);
626 if (strcmp(attr.value(), child_attr_val.c_str())==0)
630 if (it == root.end())
634 int sm_uuid = std::stoi(attr.value());
642 pugi::xml_node child =
findNode(*it,
"Transitions");
643 pugi::xml_text txt_obj = child.text();
646 std::stringstream ss;
647 ss<<
"failure to read object list from panel "<<uuid<<
", empty list\n";
648 throw std::runtime_error(ss.str());
650 parser<<txt_obj.get();
651 std::vector<std::string> words = parser.Words();
652 words.erase(words.begin());
653 words.erase(words.end()-1);
655 parser.setSeparator(
',');
656 for(
auto word: words)
659 std::vector<std::string> transn = parser.Words();
660 sm.
addTransition(std::stol(transn[1],NULL,0),std::stoi(transn[0],NULL,0),std::stoi(transn[2],NULL,0));
668 pugi::xml_node view_node =
findNode(
doc.child(
"Screen"), uuid);
669 pugi::xml_node child_node;
670 for(child_node = view_node.first_child(); child_node; child_node=child_node.next_sibling())
672 if(strcmp(child_node.name(), (child_name).c_str())==0)
677 pugi::xml_text txt_obj = child_node.text();
679 parser<<txt_obj.get();
680 std::vector<std::string> nbr_lines = parser.
Words();
681 nbr_lines.erase(nbr_lines.begin());
682 nbr_lines.erase(nbr_lines.end()-1);
683 parser.setSeparator(
',');
686 std::vector<std::string> panels_uuids;
688 for(
auto word: nbr_lines)
691 panels_uuids = parser.Words();
695 nbrs[
funcPDict.
getPanel(std::stoi(panels_uuids[0]))] = std::make_pair(leftNbr, rightNbr);
696 panels_uuids.clear();
703 pugi::xml_node view_node =
findNode(
doc.child(
"Screen"), uuid);
704 pugi::xml_node child_node;
705 for(child_node = view_node.first_child(); child_node; child_node = child_node.next_sibling())
707 if (strcmp(child_node.name(), (child_name).c_str()) == 0)
714 for(pugi::xml_node color_node = child_node.first_child(); color_node; color_node = color_node.next_sibling())
716 if (strcmp(color_node.name(),
"Editing") == 0)
718 if (strcmp(color_node.name(),
"Selection") == 0)
720 if (strcmp(color_node.name(),
"Header") == 0)
726 void XMLTree::updateChildren(
int uuid,std::string main_attrib, std::string sub_attrib1, std::string sub_attrib2, std::vector<std::pair<int, int>>& panels_yx)
728 pugi::xml_node view_node =
findNode(
doc.child(
"Screen"), uuid);
729 pugi::xml_node positions_node =
findNode(view_node, main_attrib);
731 for(pugi::xml_node pos_node=positions_node.first_child(); pos_node; pos_node=pos_node.next_sibling())
733 panels_yx.reserve(n_children);
734 for(pugi::xml_node pos_node=positions_node.first_child(); pos_node; pos_node=pos_node.next_sibling())
736 std::pair<int, int> temp;
737 temp.first = std::stoi((
getAttribute(pos_node,sub_attrib1)).value());
738 temp.second = std::stoi((
getAttribute(pos_node,sub_attrib2)).value());
739 panels_yx.push_back(temp);
745 pugi::xml_node root =
findNode(
doc.child(
"Screen"), uuid);
747 for(pugi::xml_node child=root.first_child(); child; child = child.next_sibling())
749 views.reserve(n_children);
752 for(pugi::xml_node child=root.first_child(); child; child = child.next_sibling())
754 if (strcmp((
char*)child.name(),
"View") != 0)
758 int uuid = std::stoi(attr.value());
760 pview->
win = newwin(40, 140, 0, 0);
770 updateChildren(uuid,
"PanelPositions",
"YPos",
"XPos", pview->panels_yx);
773 for(
auto panel: pview->panels)
775 panel->setBasicColor(pview->basic_color_pair);
776 panel->setSelectionColor(pview->selection_color_pair);
777 panel->setEditingColor(pview->editing_color_pair);
778 panel->setHeaderColor(pview->header_color_pair);
780 for(
auto panel:pview->panels)
782 for(
int i=0; i<pview->panels_yx.size(); i++)
783 pview->panels[i]->moveTo(pview->panels_yx[i].first, pview->panels_yx[i].second);
784 views.push_back(pview);
790 int root_uuid = uuid;
791 pugi::xml_node root =
findNode(
doc.child(
"Screen"), uuid);
793 for(pugi::xml_node child=root.first_child(); child; child = child.next_sibling())
795 panels.reserve(n_children);
799 for(pugi::xml_node child=root.first_child(); child; child = child.next_sibling())
801 if (strcmp((
char*)child.name(),
"Panel") != 0)
804 int uuid = std::stoi(attr.value());
805 pugi::xml_attribute container=
getAttribute(child,
"ContainerData");
814 BOOST_LOG_SEV(
lg, info)<<
"Panel: "<<uuid<<
" Ht: "<<ppanel->
height<<
" Wd: "<<ppanel->
width;
816 ppanel->
panel = new_panel(ppanel->
win);
819 if (container.value() ==
"info_int")
821 else if (container.value() ==
"info_float")
823 else if (container.value() ==
"info_string")
825 else if (strcmp(container.value(),
"panels")==0)
829 panels.push_back(ppanel);
836 pugi::xml_node child_node =
findNode(
doc.child(
"Screen"), uuid);
837 pugi::xml_node prop_node =
findNode(child_node,
"Columns");
839 pugi::xml_text txt_obj = prop_node.text();
840 parser<<txt_obj.get();
841 std::vector<std::string> lines = parser.
Words();
842 lines.erase(lines.begin());
843 lines.erase(lines.end()-1);
845 parser.setSeparator(
',');
847 for(
auto line: lines)
850 std::string clm_prop_name = (parser.Words())[0];
851 int clm_width = std::stoi((parser.Words())[1]);
852 dict[clm_prop_name] = clm_width;
860 pugi::xml_node proc_node =
findNode(
doc.child(
"Screen"), pPanel->
uuid);
861 for(pugi::xml_node child_node = proc_node.first_child(); child_node; child_node = child_node.next_sibling())
863 if(strcmp(child_node.name(),
"ActiveProc") == 0)
865 pugi::xml_text txt_obj = child_node.text();
869 if(strcmp(child_node.name(),
"ProcDb") == 0)
871 pugi::xml_text txt_obj = child_node.text();
874 if(strcmp(child_node.name(),
"SortKey") == 0)
876 pugi::xml_text txt_obj = child_node.text();
908 BOOST_LOG_SEV(
lg, debug)<<
"--> XMLTree::updatePoly-Browse-InfoPorc-string";
910 pPanel->selected = pPanel->object_list.size();
911 pPanel->refreshItemList();
int width
width and height in panel window in ncurses units.
responsible for parsing strings in a line, specfied by some character separator
virtual void insertColumn()
mock
void updateViewPanelColors(int, std::string, View *)
void addProcInfo(int, ProcInfo *)
adds ProcInfo object pointer to private object_type dictionary
void read()
invokes ProcDb update based on properties currently on display in ProcViewPanel
void setCurrState(int state)
sets current state
ProcInfo * getProcInfo(int)
returns pointer to ProcInfo object of given uuid
ScreenManager * getScreen(int)
returns pointer to ScreenManager object of given uuid
void updateObjFromAttrib(int, std::string, View *&)
int editing_color_pair
index of color_pair used for selected menu item in edit mode
virtual void toggleEditMode()
mock
MapOfKeyDicts mapKeyDict
global variable for accessing key dictionaries by their uuid
void addTransition(int, int, int)
add a single transition i.e. tuple (key_input, curr_state, next_state)
derived from BrowsePanelData. capable of editing items in ncurses menu list.
void parseCallbacks(pugi::xml_node)
void updateObjFromNodeVal(int, std::string, std::vector< InfoProc< std::string > * > &)
void parseProcInfo(pugi::xml_node)
void parseColors(pugi::xml_node)
WINDOW * win
pointer to window associated with the view, contained panels' windows are derived from it
void addColumn(int, Columns *)
adds Columns object pointer to private object_type dictionary
char toChar(std::string str1)
converts string to its equivalent char value.
virtual void insertIntoLeftNbr()
mock
void parseDatabase(pugi::xml_node)
void refreshItemList() override
intended to be used with browse panels. tears down menu and re-initializes with items in object_list
std::vector< std::pair< int, int > > panels_yx
vector of contained panels' window positions within view window
void createTreeFirstPass(pugi::xml_node node)
StateMachine smKeys
Keys statemachine.
std::vector< View * > views
collection of view object pointers
std::map< std::string, int > prop_wid_dict
dictionary of column width assigned to each process property
virtual void insertIntoRightNbr()
mock
void parseKeyDictionaries(pugi::xml_node)
int selected
item selected in menu, 0 being header item
void addDatabase(int, ProcDb *)
adds ProcDb object pointer to private object_type dictionary
WINDOW * win
window attached to the panel
data structure that hold property values for processes. contains facilities to enable their proper ac...
ScreenManager * instantiate()
StateMachine smViews
Views statemachine.
std::string sort_key
sorting key - some process's properties name
virtual void addIntoRightNbr()
mock
std::vector< T * > object_list
vector of pointers to generic type containing value that goes into menu item.
virtual void moveIntoLeftNbr()
mock
2nd level UI object. Responsible for switching between panels and resolving key input
void addSm(int, StateMachine *)
adds StateMachine object pointer to private object_type dictionary
SimplePanelData * getPanel(int)
returns pointer to SimplePanelData object of given uuid
pugi::xml_attribute getAttribute(pugi::xml_node, std::string)
panel data structure responsible for displaying of property values for all live processes.
void updatePolymorphicPanel(BrowsePanelData< InfoProc< int >> *)
int header_color_pair
index of color_pair used for panel header
virtual void editModeOff()
mock
virtual void editModeOn()
mock
std::map< int, std::pair< int, int > > colors
std::vector< std::string > Words() const
returns a vector of parsed strings stored in StringParser::words
virtual void setHeader(std::string)
mock
virtual void remove()
mock
src::severity_logger< severity_level > lg
void updateChildren(int, std::string, std::vector< View * > &)
void addScreen(int, ScreenManager *)
adds ScreenManager object pointer to private object_type dictionary
data structure that defines type of entry from which panel menu entrires obtain their c-string data
Top Level UI object. Responsible to switching between views and capturing key input.
derived from SimplePanelData. capable of storing list of item in a ncurses menu object.
holds a dictionary of key values and corresponding Action list. Provides API to resolve the keys
ProcDb * proc_database
pointer reference to ProcDb object
virtual void addIntoLeftNbr()
mock
SimplePanelData * active_proc_panel
reference to panel data structure containing property names to be displayed. clm_names,...
pugi::xml_node findNode(pugi::xml_node, int uuid)
View * currView
pointer to current view object
int selection_color_pair
index of color_pair used for selected menu item in non-edit mode
virtual void moveLeft()
mock
void registerFunc(std::string func_name, void(ScreenManager::*)())
registers ScreenManager class member methods
data structure that defines type of entry from which panel menu entries obtain their c-string data
StateMachine smKeys
Keys statemachine.
Base class in heirarchy of UI objects responsible to storing the content associated with a panel and ...
void addView(int, View *)
adds ScreenManager object pointer to private object_type dictionary
interfaces with linux API to read process information and update ProcDb with it
void addKeyDict(int, KeyDict)
adds key dictionary corresponding to the supplied key_dict_uuid
void refresh()
refreshes screen
ProcDb * getDatabase(int)
returns pointer to ProcDb object of given uuid
void addPanel(int, SimplePanelData *)
adds SimplePanelData object pointer to private object_type dictionary
statemachine that uses integer corresponding to object uuids to represent states
PANEL * panel
panel to which the data structure is associated
void next()
same as StateMachine::next(int) except that reads key input from global
virtual void moveIntoRightNbr()
mock
virtual void refresh()
mock
void stale()
sets changed to false
View * getView(int)
returns pointer to View object of given uuid
std::map< std::string, int > color_map
dictionary containing color_pair number corresponding to each color_name
virtual void deleteColumn()
mock
void createPanel(int, int, std::string)
void parseColumn(pugi::xml_node)
responsible for managing the flow of information between ProcViewPanel, ProcDb and ProcInfo
virtual void moveRight()
mock