// PropDispatch.h #ifndef PropDispatch_H #define PropDispatch_H // This is propagator dispatcher. Propagators are registered for each // pair of intial and final surface types. The appropriate propagator // is then invoked when any of the usual propagator methods are called. // // Objstream example: // // [ propd PropDispatch // begin_surfs = string( "SurfCyl" "SurfCyl" "SurfDCA" ) // end_surfs = string( "SurfCyl" "SurfDCA" "SurfCyl" ) // propagators = @( propc propcd propdc ) // ] #include "Propagator.h" #include #include "ptr/Ptr.h" #include "ptr/NullPolicy.h" #include "PropagatorPtr.h" namespace trf { class PropDispatch : public Propagator { private: // typedefs // A pair of surface types. typedef std::pair TypePair; // Comparator for surface type pairs. typedef std::less Cmp; // Map of propagators indexed by surface type pairs. typedef std::map PropMap; public: // static methods // Return the type name. static TypeName get_type_name() { return "PropDispatch"; } // Return the creator. static ObjCreator get_creator(); // Return the type. static Type get_static_type() { return get_creator(); } private: // attributes // map of propagators PropMap _props; private: // methods // output stream void ostr(std::ostream& stream) const; public: // methods // constructor PropDispatch(); // destructor ~PropDispatch(); // Return the type. Type get_type() const { return get_static_type(); } // Write object data. ObjData write_data() const; // register a propagator // return nonzero for error (e.g. surface pair already used) int add_propagator(Type stype1, Type stype2, const PropagatorPtr& pprop); // Return the number of registrations. int get_propagator_count() const; // Return the propagator for a specified pair of surfaces. const PropagatorPtr& get_propagator(Type stype1, Type stype2) const; // Clone, i.e. create a copy on the free store. Propagator* new_propagator() const; // propagate a track without error PropStat vec_prop(VTrack& trv, const Surface& srf, TrackDerivative* pder =0) const; // propagate a track without error in the specified direction PropStat vec_dir_prop( VTrack& trv, const Surface& srf, PropDir dir, TrackDerivative* pder =0 ) const; // propagate a track with error PropStat err_prop(ETrack& trv, const Surface& srf, TrackDerivative* pder =0) const; // propagate a track with error in the specified direction PropStat err_dir_prop(ETrack& trv, const Surface& srf, PropDir dir, TrackDerivative* pder =0) const; }; } // end namespace trf #endif