TCL_obj_graphcode.h
Go to the documentation of this file.
1 /*
2  @copyright Russell Standish 2000-2013
3  @author Russell Standish
4  This file is part of EcoLab
5 
6  Open source licensed under the MIT license. See LICENSE for details.
7 */
8 
12 #ifndef TCL_OBJ_GRAPHCODE_H
13 #define TCL_OBJ_GRAPHCODE_H
14 #include "TCL_obj_stl.h"
15 #include "graphcode.h"
16 
17 namespace ecolab
18 {
20 
21  inline void keys_of(const GRAPHCODE_NS::omap& o)
22  {
23  tclreturn r;
24  for (GRAPHCODE_NS::omap::const_iterator i=o.begin(); i!=o.end(); i++)
25  r<<i->ID;
26  }
27 
28  template <>
29  class TCL_obj_of<GRAPHCODE_NS::omap,GRAPHCODE_NS::GraphID_t>: TCL_obj_of_base
30  {
31  GRAPHCODE_NS::omap& obj;
32  string desc;
33  public:
34  TCL_obj_of(GRAPHCODE_NS::omap& o, const string& d): obj(o), desc(d) {}
35  string operator()(const char* index)
36  {
37  string elname=desc+"("+index+")";
39  if ((Tobj=dynamic_cast<GRAPHCODE_NS::object*>
40  (&*(obj[idx<GRAPHCODE_NS::GraphID_t>()(index)]))))
41  Tobj->TCL_obj(elname);
42  return elname;
43  }
44  void keys_of() {ecolab::keys_of(obj);}
45  };
46 
47  void TCL_obj(TCL_obj_t& targ, const string& desc, GRAPHCODE_NS::omap& arg)
48  {
49  TCL_obj(targ,desc+".size",arg,&GRAPHCODE_NS::omap::size);
50  Tcl_CreateCommand(interp(),(desc+".@is_map").c_str(),
51  (Tcl_CmdProc*)null_proc,NULL,NULL);
52  ClientData c=(ClientData)new TCL_obj_of<GRAPHCODE_NS::omap, GRAPHCODE_NS::GraphID_t>(arg,desc);
53  Tcl_CreateCommand(interp(),(desc+".@elem").c_str(),(Tcl_CmdProc*)elem,c,
54  (Tcl_CmdDeleteProc*)del_obj);
55  Tcl_CreateCommand(interp(),(desc+".#keys").c_str(),(Tcl_CmdProc*)keys,c,
56  (Tcl_CmdDeleteProc*)del_obj);
57  // c=(ClientData)new TCL_obj_of_count<GRAPHCODE_NS::omap,GRAPHCODE_NS::GraphID_t>(arg,desc);
58  // Tcl_CreateCommand(interp,(desc+".count").c_str(),(Tcl_CmdProc*)elem,c,
59  // (Tcl_CmdDeleteProc*)del_obj);
60  }
61 }
62 
63 #endif
Definition: graphcode.h:295
Tcl_Interp * interp()
default interpreter. Set to NULL when interp() is destroyed
Definition: tcl++.h:222
Definition: graphcode.h:187
Definition: TCL_obj_stl.h:30
TCL_obj support for STL containers.
Definition: TCL_obj_stl.h:185
_OPENMP
Definition: accessor.h:16
TCL_obj descriptor object.
Definition: TCL_obj_base.h:327
Definition: graphcode.h:74
Definition: TCL_obj_stl.h:244