gnomemm r1405 - in gstreamermm/trunk: . gstreamer/src tests



Author: jaalburqu
Date: Thu Mar 13 22:33:32 2008
New Revision: 1405
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1405&view=rev

Log:
2008-03-13  Josà Alburquerque  <jaalburqu svn gnome org>

	* gstreamer/src/event.ccg:
	* gstreamer/src/event.hg:
	* gstreamer/src/message.ccg:
	* gstreamer/src/message.hg:
	* gstreamer/src/query.ccg:
	* gstreamer/src/query.hg: Rewrote get_structure() methods to return a
	const Structure* (and only get the structure once because it never
	changes)

	* tests/test-event-wrap.cc:
	* tests/test-message-wrap.cc:
	* tests/test-query-wrap.cc: Rewrote tests to get structures and print
	their names (to verify that get_structure() methods work)

	* gstreamer/src/value.hg: Removed blank line

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/event.ccg
   gstreamermm/trunk/gstreamer/src/event.hg
   gstreamermm/trunk/gstreamer/src/message.ccg
   gstreamermm/trunk/gstreamer/src/message.hg
   gstreamermm/trunk/gstreamer/src/query.ccg
   gstreamermm/trunk/gstreamer/src/query.hg
   gstreamermm/trunk/gstreamer/src/value.hg
   gstreamermm/trunk/tests/test-event-wrap.cc
   gstreamermm/trunk/tests/test-message-wrap.cc
   gstreamermm/trunk/tests/test-query-wrap.cc

Modified: gstreamermm/trunk/gstreamer/src/event.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/event.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/event.ccg	Thu Mar 13 22:33:32 2008
@@ -24,10 +24,17 @@
 namespace Gst
 {
 
-const Structure& Event::get_structure()
+const Structure* Event::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_event_get_structure(gobj())));
-  return structure_;
+  static bool got_structure = false;
+
+  if(!got_structure) {
+    Structure temp(const_cast<GstStructure*>(gst_event_get_structure(gobj())), false);
+    structure_.swap(temp);
+    got_structure = true;
+  }
+
+  return &structure_;
 }
 
 bool Event::is_downstream() const

Modified: gstreamermm/trunk/gstreamer/src/event.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/event.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/event.hg	Thu Mar 13 22:33:32 2008
@@ -35,14 +35,10 @@
   _CLASS_GSTMINIOBJECT(Event, GstEvent, GST_EVENT, Gst::MiniObject, GstMiniObject)
 
 public:
-  /** Get the structure of an event.  Please note that when Structures are
-   * assigned, the original is copied which means that the copy may be
-   * modifiable but the original never is.  Also, if the original changes for
-   * any reason, the copy will not.
-   *
+  /** Get the structure of an event.
    * @return The Structure of the event (unmodifiable)
    */
-  const Structure& get_structure();
+  const Structure* get_structure();
 
 public:
   /** Wrap a GstEvent* in a C++ instance, creating an instance of a derived

Modified: gstreamermm/trunk/gstreamer/src/message.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/message.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/message.ccg	Thu Mar 13 22:33:32 2008
@@ -22,11 +22,18 @@
 namespace Gst
 {
 
-const Structure&
+const Structure*
 Message::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_message_get_structure(gobj())));
-  return structure_;
+  static bool got_structure = false;
+
+  if(!got_structure) {
+    Structure temp(const_cast<GstStructure*>(gst_message_get_structure(gobj())), false);
+    structure_.swap(temp);
+    got_structure = true;
+  }
+
+  return &structure_;
 }
 
 MessageApplication::MessageApplication(GstMessage* castitem)

Modified: gstreamermm/trunk/gstreamer/src/message.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/message.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/message.hg	Thu Mar 13 22:33:32 2008
@@ -35,14 +35,10 @@
  _CLASS_GSTMINIOBJECT(Message, GstMessage, GST_MESSAGE, Gst::MiniObject, GstMiniObject)
  _IGNORE(gst_message_ref, gst_message_unref)
 public:
-  /** Get the structure of a message.  Please note that when Structures are
-   * assigned, the original is copied which means that the copy may be
-   * modifiable but the original never is.  Also, if the original changes for
-   * any reason, the copy will not.
-   *
+  /** Get the structure of a message.
    * @return The Structure of the message (unmodifiable)
    */
-  const Structure& get_structure();
+  const Structure* get_structure();
 
 public:
   /** Wrap a GstMessage* in a C++ instance, creating an instance of a

Modified: gstreamermm/trunk/gstreamer/src/query.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/query.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/query.ccg	Thu Mar 13 22:33:32 2008
@@ -24,10 +24,17 @@
 namespace Gst
 {
 
-const Structure& Query::get_structure()
+const Structure* Query::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_query_get_structure(gobj())));
-  return structure_;
+  static bool got_structure = false;
+
+  if(!got_structure) {
+    Structure temp(const_cast<GstStructure*>(gst_query_get_structure(gobj())), false);
+    structure_.swap(temp);
+    got_structure = true;
+  }
+
+  return &structure_;
 }
 
 bool get_details(QueryType type, QueryTypeDefinition &def)

Modified: gstreamermm/trunk/gstreamer/src/query.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/query.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/query.hg	Thu Mar 13 22:33:32 2008
@@ -43,14 +43,10 @@
   _CLASS_GSTMINIOBJECT(Query, GstQuery, GST_QUERY, Gst::MiniObject, GstMiniObject)
 
 public:
-  /** Get the structure of a query.  Please note that when Structures are
-   * assigned, the original is copied which means that the copy may be
-   * modifiable but the original never is.  Also, if the original changes for
-   * any reason, the copy will not.
-   *
+  /** Get the structure of a query.
    * @return The Structure of the query (unmodifiable)
    */
-  const Structure& get_structure();
+  const Structure* get_structure();
 
 public:
   _MEMBER_GET(query_type, type, QueryType, GstQueryType)

Modified: gstreamermm/trunk/gstreamer/src/value.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/value.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/value.hg	Thu Mar 13 22:33:32 2008
@@ -60,7 +60,6 @@
   int denom;
 };
 
-
 /** Represents an integer range (min - max) for use to store in Structures of
  * Caps as a value representing a property (see GStreamer Application
  * Development Manual section 8.2.2 for explanation).  When the value is set,
@@ -129,7 +128,6 @@
   double max;
 };
 
-
 /** Represents a fractional range for use to store in Structures of Caps as a
  * value representing a property (see GStreamer Application Development Manual
  * section 8.2.2 for explanation).  When the value is set, it is transformed to

Modified: gstreamermm/trunk/tests/test-event-wrap.cc
==============================================================================
--- gstreamermm/trunk/tests/test-event-wrap.cc	(original)
+++ gstreamermm/trunk/tests/test-event-wrap.cc	Thu Mar 13 22:33:32 2008
@@ -36,5 +36,7 @@
   std::cout << "event is a Gst::EventLatency: " << (bool)event_latency  << std::endl;
   std::cout << "event type name: '" << Gst::get_name(event->get_event_type()) << "'" << std::endl;
 
+  std::cout << "Event structure name: '" << event->get_structure()->get_name() << "'" << std::endl;
+
   return 0;
 }

Modified: gstreamermm/trunk/tests/test-message-wrap.cc
==============================================================================
--- gstreamermm/trunk/tests/test-message-wrap.cc	(original)
+++ gstreamermm/trunk/tests/test-message-wrap.cc	Thu Mar 13 22:33:32 2008
@@ -40,5 +40,7 @@
   std::cout << "message is a Gst::MessageWarning: " << (bool)message_warning  << std::endl;
   std::cout << "message type name: '" << Gst::get_name(message->get_message_type()) << "'"  << std::endl;
 
+  std::cout << "Message structure name: '" << message->get_structure()->get_name() << "'" << std::endl;
+
   return 0;
 }

Modified: gstreamermm/trunk/tests/test-query-wrap.cc
==============================================================================
--- gstreamermm/trunk/tests/test-query-wrap.cc	(original)
+++ gstreamermm/trunk/tests/test-query-wrap.cc	Thu Mar 13 22:33:32 2008
@@ -36,5 +36,7 @@
   std::cout << "query is a Gst::QueryPosition: " << (bool)query_position  << std::endl;
   std::cout << "query type name: '" << Gst::get_name(query->get_query_type()) << "'" << std::endl;
 
+  std::cout << "Query structure name: '" << query->get_structure()->get_name() << "'" << std::endl;
+
   return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]