Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4Queue/MainGo4Queue.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include <iostream.h>
00017 
00018 #include "TApplication.h"
00019 #include "TH1.h"
00020 
00021 #include "TGo4BufferQueue.h"
00022 #include "TGo4ObjectQueue.h"
00023 
00024 void usage(char **args);
00025 
00026 //______________________________________________________________________________
00027 int main(int argc, char **argv)
00028 {
00029    TApplication theApp("App", &argc, argv);
00030 
00031    TNamed *com = new TNamed("named object", "this is a test");
00032 
00033    TH1F *histo = new TH1F("histogram", "this is a test histogram", 100, 0., 1.);
00034    histo->Fill(0.2);
00035    TH1F *histo2 = new TH1F("histogram 2", "this is a test histogram", 100, 0., 1.);
00036    histo2->Fill(0.7);
00037    TH1* histo3=0;
00038    TGo4ObjectQueue objectq("My object queue");
00039    TGo4BufferQueue bufferq("My buffer queue");
00040 
00041    objectq.AddObject(histo,kTRUE);
00042    delete histo;
00043    cout << "deleted the first histo after cloning" << endl;
00044    objectq.AddObject(com);
00045    TObject* output=0;
00046    while(! (objectq.IsEmpty()) )
00047        {
00048            output= objectq.WaitObject();
00049            cout << "object from object queue:"<< endl;
00050            cout << output->ClassName() << endl;
00051            cout << output->GetName() << endl;
00052            if (output->InheritsFrom("TH1"))
00053                {
00054                     histo3= dynamic_cast<TH1*>(output);
00055                     dynamic_cast<TH1*>(output)->Draw();
00056                }
00057        }
00058 
00059 
00060     bufferq.AddBufferFromObject(histo2);
00061     bufferq.AddBufferFromObject(com);
00062     bufferq.AddBufferFromObject(histo3);
00063 
00064 
00065    TBuffer* mess=0;
00066    while(!bufferq.IsEmpty())
00067        {
00068            mess= bufferq.WaitBuffer();
00069 
00070            //TMessage* mess = dynamic_cast<TMessage*> (buf);
00071            //TClass* cl= buf->ReadClass();
00072            cout << "got buffer from buffer queue:"<< endl;
00073            mess->SetReadMode();
00074            mess->Reset();
00075            mess->InitMap();
00076            TClass* cl = mess->ReadClass();
00077            cout << "Class: " << cl << endl;
00078            if(cl)
00079               cout << "Classname: " << cl->GetName() << endl;
00080            cout << "Reading object from buffer..."<< endl;
00081            mess->Reset();
00082            output=mess->ReadObject(cl);
00083            if(output==0)
00084               {
00085                   cout << "zero object" <<endl;
00086                  exit(0);
00087               }
00088 
00089            cout << output->ClassName() << endl;
00090            cout << output->GetName() << endl;
00091            if (output->InheritsFrom("TH1"))
00092                {
00093                     dynamic_cast<TH1*>(output)->Draw();
00094                }
00095          objectq.AddObjectFromBuffer(mess);
00096          objectq.AddObjectFromBuffer(mess);
00097          objectq.AddObject(com);
00098          objectq.AddObjectFromBuffer(mess);
00099       }
00100 
00101        bufferq.AddBuffer(mess);
00102        bufferq.AddBuffer(mess);
00103        bufferq.AddBuffer(mess);
00104 
00105     while(! (objectq.IsEmpty()) )
00106        {
00107            output= objectq.WaitObject();
00108            cout << "object from object queue second pass:"<< endl;
00109            cout << output->ClassName() << endl;
00110            cout << output->GetName() << endl;
00111            if (output->InheritsFrom("TH1"))
00112                {
00113 
00114                     dynamic_cast<TH1*>(output)->Draw();
00115                }
00116        }
00117 
00118 
00119     while(!bufferq.IsEmpty())
00120        {
00121            mess= bufferq.WaitBuffer();
00122 
00123            //TMessage* mess = dynamic_cast<TMessage*> (buf);
00124            //TClass* cl= buf->ReadClass();
00125            cout << "got buffer from buffer queue second time:"<< endl;
00126            mess->SetReadMode();
00127            mess->Reset();
00128            mess->InitMap();
00129            TClass* cl = mess->ReadClass();
00130            cout << "Class: " << cl << endl;
00131            if(cl)
00132               cout << "Classname: " << cl->GetName() << endl;
00133            cout << "Reading object from buffer..."<< endl;
00134            mess->Reset();
00135            output=mess->ReadObject(cl);
00136            if(output==0)
00137               {
00138                   cout << "zero object" <<endl;
00139                  exit(0);
00140               }
00141 
00142            cout << output->ClassName() << endl;
00143            cout << output->GetName() << endl;
00144            if (output->InheritsFrom("TH1"))
00145                {
00146                     dynamic_cast<TH1*>(output)->Draw();
00147                }
00148 
00149       }
00150 
00151 
00152    theApp.Run();
00153    return 0;
00154 }
00155 
00156 void usage(char **args)
00157 {
00158   cout << "Usage: " << args[0] << " \n";
00159   exit(1);
00160 }
00161 
00162 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:04 2005 for Go4-v2.10-5 by doxygen1.2.15