[gstreamermm] Pad: Make constructors handle errors as in GhostPad.
- From: José Alburquerque <jaalburqu src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gstreamermm] Pad: Make constructors handle errors as in GhostPad.
- Date: Tue, 22 Dec 2009 22:22:10 +0000 (UTC)
commit 5bd4fd83c6d5efc250ff0fb81b4ddc93a13ab699
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Tue Dec 22 17:12:16 2009 -0500
Pad: Make constructors handle errors as in GhostPad.
* gstreamer/src/pad.ccg (Pad): Corrected casting in _CONSTRUCT macros
and included error handling in constructors that might be dealing with
null PadTemplates. Used Glib::unwrap() for templates that might be
null.
* gstreamer/src/ghostpad.ccg (GhostPad): Use Glib::unwrap() as above
in constructors.
* gstreamer/src/pad.hg (Pad): Added docs to constructors.
(create):
* gstreamer/src/ghostpad.hg (create): Added docs about exceptions that
might be thrown because of calls to create() methods.
* gstreamer/src/audioclock.ccg (AudioClock): Check for an empty "name"
property in _CONSTRUCT macro.
* gstreamer/src/iterator.hg (IteratorBase, IteratorBasic, Iterator):
* gstreamer/src/ringbuffer.hg (RingBufferSpec): Use explicit in
constructors with default arguments that might be interpreted as
single parameter constructors.
ChangeLog | 21 +++++++++++++++++++++
gstreamer/src/audioclock.ccg | 2 +-
gstreamer/src/ghostpad.ccg | 4 ++--
gstreamer/src/ghostpad.hg | 16 ++++++++++------
gstreamer/src/iterator.hg | 6 +++---
gstreamer/src/pad.ccg | 30 +++++++++++++++++++++++-------
gstreamer/src/pad.hg | 30 +++++++++++++++++++++++++++---
gstreamer/src/ringbuffer.hg | 3 ++-
8 files changed, 89 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4766d55..98eda47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2009-12-22 José Alburquerque <jaalburqu svn gnome org>
+
+ Pad: Make constructors handle errors as in GhostPad.
+
+ * gstreamer/src/pad.ccg (Pad): Corrected casting in _CONSTRUCT macros
+ and included error handling in constructors that might be dealing with
+ null PadTemplates. Used Glib::unwrap() for templates that might be
+ null.
+ * gstreamer/src/ghostpad.ccg (GhostPad): Use Glib::unwrap() as above
+ in constructors.
+ * gstreamer/src/pad.hg (Pad): Added docs to constructors.
+ (create):
+ * gstreamer/src/ghostpad.hg (create): Added docs about exceptions that
+ might be thrown because of calls to create() methods.
+ * gstreamer/src/audioclock.ccg (AudioClock): Check for an empty "name"
+ property in _CONSTRUCT macro.
+ * gstreamer/src/iterator.hg (IteratorBase, IteratorBasic, Iterator):
+ * gstreamer/src/ringbuffer.hg (RingBufferSpec): Use explicit in
+ constructors with default arguments that might be interpreted as
+ single parameter constructors.
+
2009-12-20 José Alburquerque <jaalburqu svn gnome org>
Make exception handling code in classes accessible globally.
diff --git a/gstreamer/src/audioclock.ccg b/gstreamer/src/audioclock.ccg
index d199290..2b6b169 100644
--- a/gstreamer/src/audioclock.ccg
+++ b/gstreamer/src/audioclock.ccg
@@ -55,7 +55,7 @@ namespace Gst
{
AudioClock::AudioClock(const Glib::ustring& name, const SlotGetTime& time_slot)
- : _CONSTRUCT("name", name.c_str())
+ : _CONSTRUCT("name", (name.empty() ? static_cast<char*>(0) : name.c_str()))
{
// The slot is dynamically allocated because it is called each time the time
// is gotten.
diff --git a/gstreamer/src/ghostpad.ccg b/gstreamer/src/ghostpad.ccg
index 29d7bff..cc33cca 100644
--- a/gstreamer/src/ghostpad.ccg
+++ b/gstreamer/src/ghostpad.ccg
@@ -69,7 +69,7 @@ GhostPad::GhostPad( const Glib::RefPtr<Gst::Pad>& target,
: _CONSTRUCT("name", (name.empty() ? static_cast<char*>(0) : name.c_str()),
"direction",
(target ? static_cast<GstPadDirection>(target->get_direction()) : GST_PAD_UNKNOWN),
- "template", (templ ? templ->gobj() : static_cast<GstPadTemplate*>(0)))
+ "template", Glib::unwrap(templ))
{
if(!target || !templ)
gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
@@ -92,7 +92,7 @@ GhostPad::GhostPad( const Glib::RefPtr<Gst::PadTemplate>& templ,
const Glib::ustring& name)
: _CONSTRUCT("name", (name.empty() ? static_cast<char*>(0) : name.c_str()),
"direction", (templ ? static_cast<GstPadDirection>(templ->get_direction()) : GST_PAD_UNKNOWN),
- "template", (templ ? templ->gobj() : static_cast<GstPadTemplate*>(0)))
+ "template", Glib::unwrap(templ))
{
if(!templ)
gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
diff --git a/gstreamer/src/ghostpad.hg b/gstreamer/src/ghostpad.hg
index 6753df9..be439c2 100644
--- a/gstreamer/src/ghostpad.hg
+++ b/gstreamer/src/ghostpad.hg
@@ -52,7 +52,7 @@ protected:
* @param target The target pad.
* @param name The name of the Gst::GhostPad.
*
- * @throws std::runtime_error if Gst::GhostPad construction fails.
+ * @throw std::runtime_error if Gst::GhostPad construction fails.
*/
GhostPad(const Glib::RefPtr<Gst::Pad>& target, const Glib::ustring& name);
@@ -60,7 +60,7 @@ protected:
* @param direction The direction of the Gst::GhostPad.
* @param name The name of the Gst::GhostPad.
*
- * @throws std::runtime_error if Gst::GhostPad construction fails.
+ * @throw std::runtime_error if Gst::GhostPad construction fails.
*/
GhostPad(PadDirection direction, const Glib::ustring& name);
@@ -69,7 +69,7 @@ protected:
* @param templ The pad template.
* @param name The name of the Gst::GhostPad.
*
- * @throws std::runtime_error if Gst::GhostPad construction fails.
+ * @throw std::runtime_error if Gst::GhostPad construction fails.
*/
GhostPad(const Glib::RefPtr<Gst::Pad>& target,
const Glib::RefPtr<Gst::PadTemplate>& templ, const Glib::ustring& name);
@@ -78,7 +78,7 @@ protected:
* @param templ The pad template.
* @param name The name of the Gst::GhostPad.
*
- * @throws std::runtime_error if Gst::GhostPad construction fails.
+ * @throw std::runtime_error if Gst::GhostPad construction fails.
*/
GhostPad(const Glib::RefPtr<Gst::PadTemplate>& templ,
const Glib::ustring& name);
@@ -90,7 +90,8 @@ public:
*
* @param target The pad to ghost.
* @param name The (optional) name of the new pad.
- * @returns A new Gst::GhostPad, or an empty RefPtr in case of an error.
+ * @return A new Gst::GhostPad, or an empty RefPtr in case of an error.
+ * @throw std::runtime_error if Gst::GhostPad construction fails.
*/
_WRAP_CREATE(const Glib::RefPtr<Gst::Pad>& target,
const Glib::ustring& name = Glib::ustring())
@@ -103,7 +104,8 @@ public:
*
* @param dir The direction of the Gst::GhostPad.
* @param name The (optional) name of the new Gst::GhostPad.
- * @return A new Gst::GhostPad, or an empty RefPtr in case of an error.
+ * @return A new Gst::GhostPad, or an empty RefPtr in case of an error.
+ * @throw std::runtime_error if Gst::GhostPad construction fails.
*/
_WRAP_CREATE( PadDirection dir,
const Glib::ustring& name = Glib::ustring())
@@ -116,6 +118,7 @@ public:
* @param templ The Gst::PadTemplate to use on the Gst::GhostPad.
* @param name The (optional) name of the new Gst::GhostPad.
* @return A new Gst::GhostPad, or an empty RefPtr in case of an error.
+ * @throw std::runtime_error if Gst::GhostPad construction fails.
*/
_WRAP_CREATE(const Glib::RefPtr<Gst::Pad>& target,
const Glib::RefPtr<Gst::PadTemplate>& templ,
@@ -127,6 +130,7 @@ public:
* @param templ The Gst::PadTemplate to create the Gst::GhostPad from.
* @param name The (optional) name of the new Gst::GhostPad.
* @return A new Gst::GhostPad, or an empty RefPtr in case of an error.
+ * @throw std::runtime_error if Gst::GhostPad construction fails.
*/
_WRAP_CREATE(const Glib::RefPtr<Gst::PadTemplate>& templ,
const Glib::ustring& name = Glib::ustring())
diff --git a/gstreamer/src/iterator.hg b/gstreamer/src/iterator.hg
index b417c16..40b40bc 100644
--- a/gstreamer/src/iterator.hg
+++ b/gstreamer/src/iterator.hg
@@ -104,7 +104,7 @@ protected:
* @param take_ownership Whether to take over the underlying C object. If
* true, C object is freed when wrapper is destroyed.
*/
- IteratorBase(GstIterator* castitem, bool take_ownership=true);
+ explicit IteratorBase(GstIterator* castitem, bool take_ownership=true);
/** Assignment operator. It replaces the contents of the iterator with the
* contents of the new one freeing the underlying C object if a
@@ -151,7 +151,7 @@ public:
* @param take_ownership Whether to take over the underlying C object. If
* true, C object is freed when wrapper is destroyed.
*/
- IteratorBasic(GstIterator* castitem, bool take_ownership=true);
+ explicit IteratorBasic(GstIterator* castitem, bool take_ownership=true);
/** Resynchronizes the iterator and moves the iterator to the first item.
*
@@ -205,7 +205,7 @@ public:
* @param take_ownership Whether to take over the underlying C object. If
* true, C object is freed when wrapper is destroyed.
*/
- Iterator(GstIterator* castitem, bool take_ownership=true);
+ explicit Iterator(GstIterator* castitem, bool take_ownership=true);
/** Moves to the next iterator item.
*
diff --git a/gstreamer/src/pad.ccg b/gstreamer/src/pad.ccg
index 490ed7c..945d07b 100644
--- a/gstreamer/src/pad.ccg
+++ b/gstreamer/src/pad.ccg
@@ -90,18 +90,34 @@ namespace Gst
{
Pad::Pad(PadDirection dir)
- : _CONSTRUCT("name", 0, "direction", dir)
+ : _CONSTRUCT("name", static_cast<char*>(0), "direction", dir)
{}
Pad::Pad(const Glib::RefPtr<const Gst::PadTemplate>& templ,
- const Glib::ustring& name) : _CONSTRUCT("name", name.c_str(), "direction",
- templ->get_direction(), "template", templ->gobj())
-{}
+ const Glib::ustring& name)
+ : _CONSTRUCT("name", (name.empty() ? static_cast<char*>(0) : name.c_str()),
+ "direction", (templ ? static_cast<GstPadDirection>(templ->get_direction())
+ : GST_PAD_UNKNOWN),
+ "template", Glib::unwrap(templ))
+{
+ if(!templ)
+ gstreamermm_handle_error(
+ "Gst::Pad::Pad(const Glib::RefPtr<Gst::PadTemplate>&, "
+ "const Glib::ustring&): Failed to construct pad (name = " + name + ") "
+ "from null template.");
+}
Pad::Pad(const Glib::RefPtr<const Gst::PadTemplate>& templ)
- : _CONSTRUCT("name", 0, "direction", templ->get_direction(), "template",
- templ->gobj())
-{}
+ : _CONSTRUCT("name", static_cast<char*>(0),
+ "direction", (templ ? static_cast<GstPadDirection>(templ->get_direction())
+ : GST_PAD_UNKNOWN),
+ "template", Glib::unwrap(templ))
+{
+ if(!templ)
+ gstreamermm_handle_error(
+ "Gst::Pad::Pad(const Glib::RefPtr<Gst::PadTemplate>&): Failed to "
+ "construct pad from null template.");
+}
// This is handcoded because the documentation tells us that we need to copy
// the Caps
diff --git a/gstreamer/src/pad.hg b/gstreamer/src/pad.hg
index 6efc35f..6ce19a8 100644
--- a/gstreamer/src/pad.hg
+++ b/gstreamer/src/pad.hg
@@ -80,10 +80,32 @@ class Pad : public Object
_CLASS_GOBJECT(Pad, GstPad, GST_PAD, Object, GstObject)
protected:
+ /** Constructs a Pad given a name and a direction.
+ * @param name The desired name of the pad.
+ * @param direction The desired direction of the pad.
+ */
_WRAP_CTOR(Pad(const Glib::ustring& name, PadDirection direction), gst_pad_new)
- explicit Pad(PadDirection dir);
- Pad(const Glib::RefPtr<const Gst::PadTemplate>& templ, const Glib::ustring& name);
- Pad(const Glib::RefPtr<const Gst::PadTemplate>& templ);
+
+ /** Constructs a Pad given a direction without specifying a name. A unique
+ * name will be assigned to the pad.
+ * @param direction the direction of the pad.
+ */
+ explicit Pad(PadDirection direction);
+
+ /** Constructs a Pad from a PadTemplate with the specified name.
+ * @param templ The PadTemplate.
+ * @param name The desired name of the pad.
+ * @throw std::runtime_error if construction fails.
+ */
+ Pad(const Glib::RefPtr<const Gst::PadTemplate>& templ,
+ const Glib::ustring& name);
+
+ /** Constructs a Pad from a PadTemplate without specifying a name. A unique
+ * name will ge assigned to the pad.
+ * @param templ The PadTemplate.
+ * @throw std::runtime_error if construction fails.
+ */
+ explicit Pad(const Glib::RefPtr<const Gst::PadTemplate>& templ);
public:
/** For example,
@@ -120,6 +142,7 @@ public:
* @param templ The pad template to use.
* @param name The name of the element.
* @return A new Gst::Pad, or a null RefPtr<> in case of an error.
+ * @throw std::runtime_error if construction fails.
*/
_WRAP_CREATE(const Glib::RefPtr<const Gst::PadTemplate>& pad_template)
@@ -128,6 +151,7 @@ public:
*
* @param templ The pad template to use.
* @return A new Gst::Pad, or a null RefPtr<> in case of an error.
+ * @throw std::runtime_error if construction fails.
*/
_WRAP_CREATE(const Glib::RefPtr<const Gst::PadTemplate>& pad_template, const Glib::ustring& name)
diff --git a/gstreamer/src/ringbuffer.hg b/gstreamer/src/ringbuffer.hg
index 0476389..b4c47cb 100644
--- a/gstreamer/src/ringbuffer.hg
+++ b/gstreamer/src/ringbuffer.hg
@@ -81,7 +81,8 @@ public:
int segsize = 0, int segtotal = 0, int seglatency = 0);
/// Construct a Gst::RingBufferSpec from a GstRingBufferSpec.
- RingBufferSpec(GstRingBufferSpec& castitem, bool take_ownership = false);
+ explicit RingBufferSpec(GstRingBufferSpec& castitem,
+ bool take_ownership = false);
/** Copy constructor.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]