QtGStreamer  0.10.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
bin.h
00001 /*
00002     Copyright (C) 2009-2010  George Kiagiadakis <kiagiadakis.george@gmail.com>
00003     Copyright (C) 2011 Collabora Ltd.
00004       @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
00005 
00006     This library is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU Lesser General Public License as published
00008     by the Free Software Foundation; either version 2.1 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public License
00017     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 #ifndef QGST_BIN_H
00020 #define QGST_BIN_H
00021 
00022 #ifdef Q_MOC_RUN
00023 #define BOOST_TT_HAS_OPERATOR_HPP_INCLUDED
00024 #endif
00025 
00026 #include "element.h"
00027 #include "childproxy.h"
00028 
00029 #ifdef Q_CC_MSVC
00030 # pragma warning(push)
00031 # pragma warning(disable:4250) //Bin inherits QGst::Object::ref/unref via dominance
00032 #endif
00033 
00034 #if !QGLIB_HAVE_CXX0X
00035 # include <boost/preprocessor.hpp>
00036 #endif
00037 
00038 namespace QGst {
00039 
00049 class QTGSTREAMER_EXPORT Bin : public Element, public ChildProxy
00050 {
00051     QGST_WRAPPER(Bin)
00052 public:
00054     static BinPtr create(const char *name = NULL);
00055 
00057     enum BinFromDescriptionOption { //codegen: skip=true
00058         NoGhost = 0, 
00059         Ghost = 1 
00060     };
00061 
00070     static BinPtr fromDescription(const char *description,
00071                                   BinFromDescriptionOption ghostUnlinkedPads = Ghost);
00073     static inline BinPtr fromDescription(const QString & description,
00074                                          BinFromDescriptionOption ghostUnlinkedPads = Ghost);
00075 
00082     bool add(const ElementPtr & element);
00083 
00084 #if QGLIB_HAVE_CXX0X
00085 
00086 # ifndef DOXYGEN_RUN
00087 private:
00088     inline void add() {} //terminate condition for the variadic template recursion
00089 public:
00090 # endif
00091 
00099     template <typename First, typename Second, typename... Rest>
00100     inline void add(const First & first, const Second & second, const Rest & ... rest)
00101     {
00102         add(first);
00103         add(second);
00104         add(rest...);
00105     }
00106 
00107 #else //QGLIB_HAVE_CXX0X
00108 
00109 # ifndef QGST_BIN_ADD_MAX_ARGS
00110 #  define QGST_BIN_ADD_MAX_ARGS 10
00111 # endif
00112 
00113 # define QGST_BIN_ADD_DECLARATION(z, n, data) \
00114     inline void add(BOOST_PP_ENUM_PARAMS(n, const ElementPtr & e)) \
00115     { \
00116         add(e0); \
00117         add(BOOST_PP_ENUM_SHIFTED_PARAMS(n, e)); \
00118     };
00119 
00120     BOOST_PP_REPEAT_FROM_TO(2, BOOST_PP_INC(QGST_BIN_ADD_MAX_ARGS), QGST_BIN_ADD_DECLARATION, dummy)
00121 
00122 # undef QGST_BIN_ADD_DECLARATION
00123 
00124 #endif //QGLIB_HAVE_CXX0X
00125 
00131     bool remove(const ElementPtr & element);
00132 
00136     enum RecursionType { //codegen: skip=true
00138         RecurseDown,
00142         RecurseUp
00143     };
00144 
00151     ElementPtr getElementByName(const char *name, RecursionType recursionType = RecurseDown) const;
00152 
00154     ElementPtr getElementByInterface(QGlib::Type interfaceType) const;
00155 
00162     template <typename T> QGlib::RefPointer<T> getElementByInterface() const;
00163 
00167     PadPtr findUnlinkedPad(PadDirection direction) const;
00168 
00169     bool recalculateLatency();
00170 };
00171 
00172 inline BinPtr Bin::fromDescription(const QString & description,
00173                                    BinFromDescriptionOption ghostUnlinkedPads)
00174 {
00175     return fromDescription(description.toUtf8().constData(), ghostUnlinkedPads);
00176 }
00177 
00178 template <typename T>
00179 QGlib::RefPointer<T> Bin::getElementByInterface() const
00180 {
00181     ElementPtr p = getElementByInterface(QGlib::GetType<T>());
00182     return p.dynamicCast<T>();
00183 }
00184 
00185 } //namespace QGst
00186 
00187 QGST_REGISTER_TYPE(QGst::Bin)
00188 
00189 #ifdef Q_CC_MSVC
00190 # pragma warning(pop)
00191 #endif
00192 
00193 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator