#ifndef SWITCHDRIVER_HEADER #define SWITCHDRIVER_HEADER 1 //////////////////////////////////////////////////////////////// //! rcsid="$Id: SwitchDriver.hh,v 1.2 2000/12/13 15:58:27 ees1cg Exp $" //! file="amma/Drivers/Video/Switch/SwitchDriver.hh" //! lib=Studio //! userlevel=Default //! author="Charles Galambos" //! date="13/12/2000" //! docentry="default.Charles Galambos" #include "amma/RCHandleA.hh" #include "amma/DList.hh" #include "amma/String.hh" #include "amma/BinStream.hh" #include "amma/DP/Signal1.hh" namespace StudioN { //: Resources for switch. enum SwitchResourceT { SWITCH_DESTINATION, SWITCH_SOURCE, SWITCH_MATRIX }; enum SwitchXPointStateT { SWITCH_OFF, SWITCH_ON, SWITCH_LOCKED, SWITCH_PROTECTED }; //: Switch connection. class ConnectionC { public: ConnectionC() : state(SWITCH_OFF) {} //: Default constructor. ConnectionC(const StringC &nmatrixId, const StringC &nsrc, const StringC &ndest, SwitchXPointStateT nstate = SWITCH_OFF, const StringC &nattr = StringC() ) : matrixId(nmatrixId), src(nsrc), dest(ndest), state(nstate), attr(nattr) {} //: Default constructor. StringC &MatrixId() { return matrixId; } //: Access matrix id. StringC &Src() { return src; } //: Access source address.. StringC &Dest() { return dest; } //: Access destination address. SwitchXPointStateT &State() { return state; } //: Get switch state. StringC &Attr() { return attr; } //: Get connection attrib. const StringC &MatrixId() const { return matrixId; } //: Access matrix id. const StringC &Src() const { return src; } //: Access source address.. const StringC &Dest() const { return dest; } //: Access destination address. const SwitchXPointStateT &State() const { return state; } //: Get switch state. const StringC &Attr() const { return attr; } //: Get connection attrib. protected: StringC matrixId; StringC src; StringC dest; SwitchXPointStateT state; StringC attr; }; ostream &operator<<(ostream &strm,const ConnectionC &con); istream &operator>>(istream &strm,ConnectionC &con); BinOStreamC &operator<<(BinOStreamC &strm,const ConnectionC &con); BinIStreamC &operator>>(BinIStreamC &strm,ConnectionC &con); //: Body class for video switch controller. class SwitchDriverBodyC : public BodyRefCounterVC { public: SwitchDriverBodyC(); //: Default constructor. virtual BooleanT Save(BinOStreamC &os) const; //: Save model to a stream. virtual StringC SwitchID(const StringC &matrixId); //: Get identifier for the switch. virtual StringC SwitchMedia(const StringC &matrixId); //: Get media type for switch. // e.g. Video-SDI,Video-Component,Audio-Analog .... virtual DListC ListResources(const StringC &matrixId,SwitchResourceT rtype); //: List sources available. virtual DListC ListConnections(const StringC &matrixId); //: List sources available. virtual BooleanT Connect(const StringC &matrixId,const StringC &src,const StringC &dest,const StringC &attr = StringC("")); //: Connect source to destination. virtual BooleanT Disconnect(const StringC &matrixId,const StringC &src,const StringC &dest,const StringC &attr = StringC("")); //: Connect source to destination. BooleanT Disconnect(const ConnectionC &con) { return Disconnect(con.MatrixId(),con.Src(),con.Dest(),con.Attr()); } //: Connect source to destination. virtual BooleanT Connect(const DListC &cons); //: Make a set of connections. // If any of the connections aren't possible, the whole command // fails and no changes are made. virtual BooleanT IsConnected(const StringC &matrixId,const StringC &src,const StringC &dest); //: Test if connection is present. BooleanT IsConnected(const ConnectionC &con) { return IsConnected(con.MatrixId(),con.Src(),con.Dest()); } //: Test if connection is present. Signal1C &SigConnect() { return sigConnect; } //: Connection changed signal. protected: Signal1C sigConnect; }; //: Video switch controller. class SwitchDriverC : public RCHandleC { public: SwitchDriverC() {} //: Default constructor. // Creates an invalid handle. protected: SwitchDriverC(SwitchDriverBodyC &bod) : RCHandleC(bod) {} //: Body constructor SwitchDriverBodyC &Body() { return RCHandleC::Body(); } //: Access body. const SwitchDriverBodyC &Body() const { return RCHandleC::Body(); } //: Access body. public: StringC SwitchID(const StringC &matrixId) { return Body().SwitchID(matrixId); } //: Get identifier for the switch. StringC SwitchMedia(const StringC &matrixId) { return Body().SwitchMedia(matrixId); } //: Get media type for switch. // e.g. Video-SDI,Video-Component,Audio-Analog .... DListC ListResources(const StringC &matrixId,SwitchResourceT rtype) { return Body().ListResources(matrixId,rtype); } //: List sources available. BooleanT Connect(const StringC &matrixId,const StringC &src,const StringC &dest,const StringC &attr = StringC("")) { return Body().Connect(matrixId,src,dest,attr); } //: Connect source to destination. BooleanT Connect(const ConnectionC &con) { return Body().Connect(con.MatrixId(),con.Src(),con.Dest(),con.Attr()); } //: Connect source to destination. BooleanT Connect(const DListC &cons) { return Body().Connect(cons); } //: Make a set of connections. // If any of the connections aren't possible, the whole command // fails and no changes are made. BooleanT Disconnect(const StringC &matrixId,const StringC &src,const StringC &dest,const StringC &attr = StringC("")) { return Body().Disconnect(matrixId,src,dest,attr); } //: Connect source to destination. BooleanT Disconnect(const ConnectionC &con) { return Body().Disconnect(con); } //: Connect source to destination. DListC ListConnections(const StringC &matrixId) { return Body().ListConnections(matrixId); } //: List sources available. BooleanT IsConnected(const StringC &matrixId,const StringC &src,const StringC &dest) { return Body().IsConnected(matrixId,src,dest); } //: Test if connection is present. BooleanT IsConnected(const ConnectionC &con) { return Body().IsConnected(con); } //: Test if connection is present. Signal1C &SigConnect() { return Body().SigConnect(); } //: Connection changed signal. BooleanT Save(BinOStreamC &os) const { return Body().Save(os); } //: Save model to a stream. }; inline BinOStreamC &operator<<(BinOStreamC &strm,const SwitchDriverC &sm) { assert(sm.IsValid()); sm.Save(strm); return strm; } //: Write out a switch model. } #endif