LCIO  "2.7.4"
 All Classes Namespaces Functions Variables Typedefs Friends Pages
LCEventImpl.h
1 #ifndef EVENT_LCEVENTIMPL_H
2 #define EVENT_LCEVENTIMPL_H 1
3 
4 #include <string>
5 #include <map>
6 #include <set>
7 #include "EVENT/LCEvent.h"
8 #include "EVENT/LCCollection.h"
9 // #include "EVENT/LCRelation.h"
10 #include "EVENT/LCIO.h"
11 #include "LCIOTypes.h"
12 #include "AccessChecked.h"
13 #include "LCParametersImpl.h"
14 
15 namespace IMPL{
16 
17  //class EVENT::LCCollection ;
18 
19  typedef std::map<std::string,EVENT::LCCollection*> LCCollectionMap ;
20  typedef std::set<EVENT::LCCollection*> LCCollectionSet ;
21  // typedef std::map<std::string,EVENT::LCRelation*> LCRelationMap ;
22 
31  class LCEventImpl : public EVENT::LCEvent, public AccessChecked {
32 
33  public:
34  LCEventImpl() ;
38  // LCEventImpl(const EVENT::LCEvent& evt) ; // copy c'tor
39 
42  virtual ~LCEventImpl() ;
43 
46  virtual int getRunNumber() const ;
47 
50  virtual int getEventNumber() const ;
51 
54  virtual const std::string & getDetectorName() const ;
55 
58  virtual EVENT::long64 getTimeStamp() const ;
59 
62  virtual double getWeight() const ;
63 
66  virtual const std::vector<std::string> * getCollectionNames() const;
67 
72  virtual EVENT::LCCollection * getCollection(const std::string & name) const
73  throw (EVENT::DataNotAvailableException, std::exception) ;
74 
83  virtual EVENT::LCCollection * takeCollection(const std::string & name) const
84  throw (EVENT::DataNotAvailableException, std::exception ) ;
85 
93  virtual void addCollection(EVENT::LCCollection * col, const std::string & name)
94  throw (EVENT::EventException, std::exception) ;
95 
101  virtual void removeCollection(const std::string & name) throw (EVENT::ReadOnlyException, std::exception) ;
102 
103 
104 // //fg20040528: added relations to the event
105 // /** Returns the names of the relations in the event.
106 // */
107 // virtual const std::vector<std::string> * getRelationNames() const ;
108 
109 // /** Returns the relation for the given name.
110 // *
111 // * @throws DataNotAvailableException
112 // */
113 // virtual EVENT::LCRelation * getRelation(const std::string & name) const throw (EVENT::DataNotAvailableException, std::exception) ;
114 
115 // /** Adds a relation with the given name. Throws an exception if the name already
116 // * exists in the event. NB: Adding relations is allowed even when the event is 'read only'.
117 // *
118 // *@throws EventException
119 // */
120 // virtual void addRelation(EVENT::LCRelation * col, const std::string & name) throw (EVENT::EventException, std::exception) ;
121 
122 // /** Removes (and deletes) the relation with name (if it exists in the event).
123 // * Throws an exception if the event is 'read only' as defined by the read mode in LCReader.
124 // *
125 // *@throws ReadOnlyException
126 // */
127 // virtual void removeRelation(const std::string & name) throw (EVENT::ReadOnlyException, std::exception) ;
128 
131  virtual const EVENT::LCParameters & getParameters() const { return _params ; }
132 
135  virtual EVENT::LCParameters & parameters() { return _params ; }
136 
137  //---- set methods -----
140  void setRunNumber( int rn ) ;
141 
144  void setEventNumber( int en ) ;
145 
148  void setDetectorName(const std::string& dn ) ;
149 
152  void setTimeStamp(EVENT::long64 ts) ;
153 
156  void setWeight(double w) ;
157 
158  protected:
159  void setAccessMode( int accessMode ) ;
160 
164  bool validateCollectionName( const char* name ) ;
165 
166  // data members - declared protected to be accessible
167  // for friends of sub classes ...
168 
169  protected:
170  int _runNumber ;
171  int _eventNumber ;
172  EVENT::long64 _timeStamp ;
173  std::string _detectorName ;
174 
175  // map has to be defined mutable in order to use _map[] for const methods ...
176  mutable LCCollectionMap _colMap ;
177  mutable std::vector<std::string> _colNames ;
178 
179  LCParametersImpl _params ;
180 
181  // set of collections that are not owned by the event anymore
182  mutable LCCollectionSet _notOwned ;
183 
184 
185  }; // class
186 
187 } // namespace IMPL
188 
189 #endif /* ifndef EVENT_LCEVENTIMPL_H */
void setTimeStamp(EVENT::long64 ts)
Sets the event time stamp.
Definition: LCEventImpl.cc:191
void setWeight(double w)
Set the event weight.
Definition: LCEventImpl.cc:197
virtual EVENT::long64 getTimeStamp() const
Returns the time stamp of the event.
Definition: LCEventImpl.cc:73
Implementation of the main event class.
Definition: LCEventImpl.h:31
virtual const std::string & getDetectorName() const
Returns the name of the detector setup used in the simulation.
Definition: LCEventImpl.cc:68
virtual const std::vector< std::string > * getCollectionNames() const
Returns the names of the collections in the event.
Definition: LCEventImpl.cc:85
virtual double getWeight() const
Returns the event weight.
Definition: LCEventImpl.cc:77
virtual int getRunNumber() const
Return the run number off this event.
Definition: LCEventImpl.cc:58
long long long64
64 bit signed integer,e.g.to be used for timestamps
Definition: LCIOTypes.h:14
virtual void addCollection(EVENT::LCCollection *col, const std::string &name)
Adds a collection with the given name (has to be a valid C/C++ variable name).
Definition: LCEventImpl.cc:136
Implementation of Simple interface to store generic named parameters of type int, float and string...
Definition: LCParametersImpl.h:35
void setEventNumber(int en)
Sets the event number.
Definition: LCEventImpl.cc:179
virtual int getEventNumber() const
Returns this event's number .
Definition: LCEventImpl.cc:63
EventException used for errors accessing the event data.
Definition: Exceptions.h:44
Simple interface to store generic named parameters of type int, float and string. ...
Definition: LCParameters.h:28
virtual EVENT::LCCollection * getCollection(const std::string &name) const
Returns the collection for the given name.
Definition: LCEventImpl.cc:100
virtual ~LCEventImpl()
Copy contructor, creates a deep copy of the event.
Definition: LCEventImpl.cc:43
void setRunNumber(int rn)
Sets the run number.
Definition: LCEventImpl.cc:173
virtual EVENT::LCParameters & parameters()
Parameters defined for this run.
Definition: LCEventImpl.h:135
bool validateCollectionName(const char *name)
Tests the validity of a collection name.
Definition: LCEventImpl.cc:226
The main event interface.
Definition: LCEvent.h:30
EventException used for data not available.
Definition: Exceptions.h:60
The generic collection used in LCIO.
Definition: LCCollection.h:29
void setDetectorName(const std::string &dn)
Sets the detector name.
Definition: LCEventImpl.cc:185
virtual EVENT::LCCollection * takeCollection(const std::string &name) const
Returns the collection for the given name and transfers the ownership of the collection to the caller...
Definition: LCEventImpl.cc:121
virtual void removeCollection(const std::string &name)
Removes (and deletes) the collection with name (if it exists in the event).
Definition: LCEventImpl.cc:163
virtual const EVENT::LCParameters & getParameters() const
Returns the names of the relations in the event.
Definition: LCEventImpl.h:131
Controls access to objects.
Definition: AccessChecked.h:17
EventException used for signaling a 'read only exception'.
Definition: Exceptions.h:74