00001
00002
00003 #ifndef _GSTMM_STRUCTURE_H
00004 #define _GSTMM_STRUCTURE_H
00005
00006
00007 #include <glibmm.h>
00008
00009 #include <gstreamermm/clock.h>
00010 #include <gstreamermm/enums.h>
00011
00012
00013 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00014 extern "C" { typedef struct _GstStructure GstStructure; }
00015 #endif
00016
00017 namespace Gst
00018 {
00019
00020
00021
00022
00023 class Fraction
00024 {
00025 public:
00026 Fraction(int num, int den)
00027 : numerator(num),
00028 denominator(den)
00029 {}
00030
00031 Fraction()
00032 : numerator(0),
00033 denominator(0)
00034 {}
00035
00036 int numerator;
00037 int denominator;
00038 };
00039
00040 class Structure;
00041
00042
00043 class StructureValueProxy
00044 {
00045 public:
00046 StructureValueProxy(Structure& structure, const Glib::ustring& name);
00047
00048 void operator=(const Glib::ustring& src);
00049 void operator=(bool src);
00050 void operator=(double src);
00051 void operator=(int src);
00052 void operator=(const Fraction& src);
00053
00054 private:
00055 Structure& m_Structure;
00056 Glib::ustring m_Name;
00057 };
00058
00059 class Structure
00060 {
00061 public:
00062 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00063 typedef Structure CppObjectType;
00064 typedef GstStructure BaseObjectType;
00065
00066 static GType get_type() G_GNUC_CONST;
00067 #endif
00068
00069 Structure();
00070
00071 explicit Structure(GstStructure* gobject, bool make_a_copy = true);
00072
00073 Structure(const Structure& other);
00074 Structure& operator=(const Structure& other);
00075
00076 ~Structure();
00077
00078 void swap(Structure& other);
00079
00081 GstStructure* gobj() { return gobject_; }
00082
00084 const GstStructure* gobj() const { return gobject_; }
00085
00087 GstStructure* gobj_copy() const;
00088
00089 protected:
00090 GstStructure* gobject_;
00091
00092 private:
00093
00094
00095 public:
00096 typedef sigc::slot<bool, GQuark, const GValue*> ForeachSlot;
00097 typedef sigc::slot<bool, GQuark, GValue*> MapSlot;
00098
00099 public:
00100 Structure(const Glib::ustring& name);
00101 Structure(GQuark quark);
00102 Structure(const GstStructure* castitem);
00103
00104 StructureValueProxy operator[](const Glib::ustring& fieldname);
00105
00106 void clear();
00107 int size() const;
00108
00109
00110
00111
00112
00113
00114 void id_set_value(GQuark field, const Glib::ValueBase& value);
00115
00116
00117
00118
00119 void set_value(const Glib::ustring& fieldname, const Glib::ValueBase& value);
00120
00121
00122 void remove_field(const Glib::ustring& fieldname);
00123
00124 GType get_field_type(const Glib::ustring& fieldname) const;
00125 bool foreach(const ForeachSlot& slot);
00126
00127
00128 bool has_field(const Glib::ustring& fieldname) const;
00129
00130 bool has_field_typed(const Glib::ustring& fieldname, GType type) const;
00131
00132 bool get_boolean(const Glib::ustring& fieldname, bool& value) const;
00133
00134 bool get_int(const Glib::ustring& fieldname, int& value) const;
00135
00136 bool get_uint(const Glib::ustring& fieldname, guint& value) const;
00137
00138 bool get_fourcc(const Glib::ustring& fieldname, guint32& value) const;
00139
00140 bool get_double(const Glib::ustring& fieldname, double& value) const;
00141
00142 Glib::ustring get_string(const Glib::ustring& fieldname) const;
00143
00144 bool get_date(const Glib::ustring& fieldname, Glib::Date& value) const;
00145
00146 bool get_clock_time(const Glib::ustring& fieldname, ClockTime& value) const;
00147
00148 bool get_enum(const Glib::ustring& fieldname, GType enumtype, int& value) const;
00149
00150 bool get_fraction(const Glib::ustring& fieldname, int& value_numerator, int& value_denominator) const;
00151
00152 bool map_in_place(const MapSlot& slot);
00153
00154 static Structure create_from_string(const Glib::ustring& the_string);
00155
00156
00157 GQuark get_name_id() const;
00158
00159 Glib::ustring get_name() const;
00160
00161 bool has_name(const Glib::ustring& name) const;
00162
00163 void set_name(const Glib::ustring& name);
00164
00165 Glib::ustring to_string() const;
00166
00167 Glib::ustring nth_field_name(guint index) const;
00168
00169
00170 };
00171
00172 }
00173
00174
00175 namespace Gst
00176 {
00177
00182 inline void swap(Structure& lhs, Structure& rhs)
00183 { lhs.swap(rhs); }
00184
00185 }
00186
00187 namespace Glib
00188 {
00189
00198 Gst::Structure wrap(GstStructure* object, bool take_copy = false);
00199
00200 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00201 template <>
00202 class Value<Gst::Structure> : public Glib::Value_Boxed<Gst::Structure>
00203 {};
00204 #endif
00205
00206 }
00207
00208
00209 #endif
00210