CMS 3D CMS Logo

IgWebTreeService Class Reference

#include <Iguana/WebFramework/interface/IgWebTreeService.h>

Inheritance diagram for IgWebTreeService:

IgWebService

List of all members.

Public Types

typedef lat::Hook1
< std::string, IgRepresentable * > 
MenuHook

Public Member Functions

void browse (Arguments *arguments)
void getRepID (Arguments *arguments)
 IgWebTreeService (IgState *state)
void registerMenuHook (MenuHook hook)
void twigMenu (Arguments *arguments)
IgUIDModeluidModel (void)

Static Public Member Functions

static const char * catalogLabel (void)

Private Types

typedef std::list< MenuHookMenuHooks

Private Attributes

MenuHooks m_menuHooks
IgStatem_state
IgUIDModelm_uidModel


Detailed Description

Definition at line 24 of file IgWebTreeService.h.


Member Typedef Documentation

typedef lat::Hook1<std::string, IgRepresentable *> IgWebTreeService::MenuHook

Definition at line 39 of file IgWebTreeService.h.

typedef std::list< MenuHook > IgWebTreeService::MenuHooks [private]

Definition at line 46 of file IgWebTreeService.h.


Constructor & Destructor Documentation

IgWebTreeService::IgWebTreeService ( IgState state  ) 

Definition at line 35 of file IgWebTreeService.cc.

References browse(), lat::CreateCallback(), getRepID(), IgWebService::registerCallback(), and twigMenu().

00036     : IgWebService (state),
00037       m_uidModel (new IgUIDModel ())
00038 {
00039     registerCallback ("browse", lat::CreateCallback (this, &IgWebTreeService::browse));
00040     registerCallback ("getRepID", lat::CreateCallback (this, &IgWebTreeService::getRepID));
00041     registerCallback ("twigMenu", lat::CreateCallback (this, &IgWebTreeService::twigMenu));
00042 }


Member Function Documentation

void IgWebTreeService::browse ( Arguments arguments  ) 

Definition at line 89 of file IgWebTreeService.cc.

References IgWebService::Arguments::args(), ASSERT, TestMuL1L2Filter_cff::cerr, IgTwig::child(), IgTwig::children(), IgUIDRep::context(), dd, IgXMLModel::document(), lat::endl(), IgTwig::expand(), IgTwig::FLAGS_MASK, DBSPlugin::get(), i, IgTwig::lookup(), IgRepSet::lookup(), IgUIDModel::lookup(), m_uidModel, IgRepContext::object(), IgWebService::Arguments::outputDevice(), IgDocumentData::root(), IgTwig::SELF_MASK, IgTwig::selfTraverse(), IgTwig::selfVisible(), IgWebService::sendError(), IgWebService::state(), IgWebService::Arguments::state(), IgTwig::STRUCTURE_MASK, target, and IgRepSet::update().

Referenced by IgWebTreeService().

00090 {
00091     qApp->lock ();
00092     
00093     IgState *state = arguments->state ();    
00094     QIODevice *outputDevice = arguments->outputDevice ();
00095     ArgumentsMap &args = *(arguments->args ());
00096     
00097     IgDocumentData *dd = IgDocumentData::get (state);
00098         
00099     std::string documentName = "";
00100     
00101     if (args.find ("doc") != args.end ())
00102     {
00103         documentName = args["doc"];
00104     }
00105     
00106     IgTwig *twig = dynamic_cast <IgTwig *> (dd->root (documentName));
00107     
00108     if (twig)
00109     {
00110         twig->selfTraverse (true);
00111         IgAjaxTreeModel model (m_uidModel);
00112 
00113         IgTwig *target;
00114         
00115         if (args.find ("i") != args.end ())
00116         {
00117             IgUIDRep * rep = m_uidModel->lookup (atoi (args["i"].c_str ()));        
00118             ASSERT (rep);           
00119             target = dynamic_cast <IgTwig *> (rep->context ()->object ());
00120             ASSERT (target);
00121         }
00122         else if (args.find ("t") != args.end ())
00123         {
00124             target = dynamic_cast <IgTwig *> (twig->lookup (args["t"]));
00125             ASSERT (target);
00126         }
00127         else
00128         {
00129             this->sendError (outputDevice);
00130             return;         
00131         }
00132             
00133             
00134         ASSERT (target);
00135                 
00136         target->selfTraverse (true);
00137 
00138         if (args.find ("setVisible") != args.end ())
00139         {
00140             if (args["setVisible"] == "1")
00141             {
00142                 target->selfVisible (true);
00143             }
00144             else
00145             {
00146                 target->selfVisible (false);            
00147             }
00148         }
00149 
00150         IgRepSet::lookup (target, &model, true);
00151         IgRepSet::update (target, IgTwig::SELF_MASK 
00152                           | IgTwig::STRUCTURE_MASK 
00153                           | IgTwig::FLAGS_MASK);                
00154         target->expand ();
00155         
00156         IgRepSet::lookup (target, &model, true);
00157         
00158         for (unsigned int i = 0; 
00159              i < target->children ();
00160              i++)
00161         {
00162             IgRepSet::lookup (target->child (i), 
00163                               &model, 
00164                               true);        
00165         }
00166 
00167         QTextStream os (outputDevice);
00168         // os.setEncoding (QTextStream::UnicodeUTF8);
00169         os << "HTTP/1.1 200 Ok\r\n"
00170             "content-type: text/xml; charset=UTF-8\r\n"
00171             "\r\n"
00172             "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
00173            << model.document ()->toString () << "\r\n";
00174                     
00175         std::cerr << model.document ()->toString () << std::endl;
00176     }
00177     qApp->unlock ();
00178     
00179 }

const char * IgWebTreeService::catalogLabel ( void   )  [static]

Definition at line 224 of file IgWebTreeService.cc.

00225 {
00226     return "Tree";    
00227 }

void IgWebTreeService::getRepID ( Arguments arguments  ) 

Definition at line 45 of file IgWebTreeService.cc.

References IgWebService::Arguments::args(), ASSERT, dd, DBSPlugin::get(), IgUIDRep::id(), IgTwig::lookup(), IgRepSet::lookup(), m_uidModel, IgWebService::Arguments::outputDevice(), IgDocumentData::root(), IgWebService::sendError(), IgWebService::Arguments::state(), IgWebService::state(), and target.

Referenced by IgWebTreeService().

00046 {
00047     IgState *state = arguments->state ();    
00048     QIODevice *outputDevice = arguments->outputDevice ();
00049     ArgumentsMap &args = *(arguments->args ());
00050     
00051     IgDocumentData *dd = IgDocumentData::get (state);
00052     ASSERT (dd);
00053     
00054     std::string documentName = "";
00055     
00056     if (args.find ("doc") != args.end ())
00057     {
00058         documentName = args["doc"];
00059     }
00060     
00061     IgTwig *twig = dynamic_cast <IgTwig *> (dd->root (documentName));
00062 
00063     if (twig)
00064     {
00065         if (args.find ("t") == args.end ())
00066         {
00067             this->sendError (outputDevice);         
00068         }
00069        
00070         IgTwig *target = dynamic_cast <IgTwig *> (twig->lookup (args["t"]));
00071         ASSERT (target);
00072         IgUIDRep *uidRep 
00073             = dynamic_cast <IgUIDRep *> (IgRepSet::lookup (target, 
00074                                                            m_uidModel, 
00075                                                            true));
00076         ASSERT (uidRep);
00077         QTextStream os (outputDevice);
00078         // os.setEncoding (QTextStream::UnicodeUTF8);
00079         os << "HTTP/1.1 200 Ok\r\n"
00080             "content-type: text/xml; charset=UTF-8\r\n"
00081             "\r\n"
00082             "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
00083            << "<uid>" << uidRep->id () << "</uid>"
00084            << "\r\n";   
00085     }        
00086 }

void IgWebTreeService::registerMenuHook ( MenuHook  hook  ) 

Definition at line 211 of file IgWebTreeService.cc.

References m_menuHooks.

00212 {
00213     m_menuHooks.push_back (hook);    
00214 }

void IgWebTreeService::twigMenu ( Arguments arguments  ) 

Definition at line 182 of file IgWebTreeService.cc.

References IgWebService::Arguments::args(), ASSERT, IgUIDRep::context(), i, IgUIDModel::lookup(), m_menuHooks, m_uidModel, IgRepContext::object(), IgWebService::Arguments::outputDevice(), and IgWebService::sendXML().

Referenced by IgWebTreeService().

00183 {
00184     QIODevice *outputDevice  = arguments->outputDevice ();
00185     ArgumentsMap &args = *(arguments->args ());
00186 
00187     if (args.find ("i") == args.end ())
00188         return;
00189     
00190     IgUIDRep *rep = m_uidModel->lookup (atoi (args["i"].c_str ()));
00191     ASSERT (rep);
00192     
00193     IgRepresentable *object = rep->context ()->object ();
00194 
00195     for (MenuHooks::iterator i = m_menuHooks.begin ();  
00196          i != m_menuHooks.end ();
00197          i++)
00198     {
00199         std::string xmlMenuDescription = (*i)(object);
00200         if (xmlMenuDescription != "")
00201         {
00202             this->sendXML (outputDevice, xmlMenuDescription);
00203             return;
00204         }       
00205     }    
00206 
00207     this->sendXML (outputDevice, "<menu name=\"default\"/>");    
00208 }

IgUIDModel * IgWebTreeService::uidModel ( void   ) 

Definition at line 218 of file IgWebTreeService.cc.

References m_uidModel.

Referenced by VisWebRootService::browse().

00219 {
00220     return m_uidModel;    
00221 }


Member Data Documentation

MenuHooks IgWebTreeService::m_menuHooks [private]

Definition at line 47 of file IgWebTreeService.h.

Referenced by registerMenuHook(), and twigMenu().

IgState* IgWebTreeService::m_state [private]

Reimplemented from IgWebService.

Definition at line 43 of file IgWebTreeService.h.

IgUIDModel* IgWebTreeService::m_uidModel [private]

Definition at line 44 of file IgWebTreeService.h.

Referenced by browse(), getRepID(), twigMenu(), and uidModel().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:49 2009 for CMSSW by  doxygen 1.5.4