Use signals2 rather than sigc++
authorCarl Hetherington <cth@carlh.net>
Thu, 25 Oct 2012 19:52:58 +0000 (20:52 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 25 Oct 2012 19:52:58 +0000 (20:52 +0100)
19 files changed:
examples/make_dcp.cc
src/asset.h
src/asset_map.cc
src/dcp.cc
src/dcp.h
src/mxf_asset.cc
src/mxf_asset.h
src/picture_asset.cc
src/picture_asset.h
src/picture_frame.cc
src/sound_asset.cc
src/sound_asset.h
src/subtitle_asset.cc
src/util.cc
src/util.h
src/wscript
test/tests.cc
tools/dcpinfo.cc
wscript

index a84a19c1594dedfd066e1a5413c12e6df8c3b2fd..e1d8353bc3e79f0a6449fc8bd8a302ddc090cbe8 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <vector>
 #include <string>
-#include <sigc++/sigc++.h>
 
 /* If you are using an installed libdcp, these #includes would need to be changed to
 #include <libdcp/dcp.h>
@@ -74,7 +73,7 @@ main ()
           for 2K projectors.
        */
        boost::shared_ptr<libdcp::MonoPictureAsset> picture_asset (
-               new libdcp::MonoPictureAsset (sigc::ptr_fun (&video_frame), "My Film DCP", "video.mxf", 0, 24, 48, 1998, 1080)
+               new libdcp::MonoPictureAsset (video_frame, "My Film DCP", "video.mxf", 0, 24, 48, 1998, 1080)
                );
 
        /* Now we will create a `sound asset', which is made up of a WAV file for each channel of audio.  Here we're using
index d518a5b9d5fcac81568db70e3718b60fe2dcd462..c40ec91b2483947c09f06615023373d0cb0f51c4 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <string>
 #include <boost/filesystem.hpp>
-#include <sigc++/sigc++.h>
 #include "types.h"
 
 namespace ASDCP {
index 4d6b1870c39f22c8b8e6874a2283f59a6aa77a60..4fda0a899aaad86d5014f7191b3755afddf14672 100644 (file)
@@ -24,8 +24,9 @@
 #include "asset_map.h"
 #include "util.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::list;
+using boost::shared_ptr;
 using namespace libdcp;
 
 AssetMap::AssetMap (string file)
index afb4f134a3a4c1bcbf89892a9f45e9646db9ee96..5db29beba7a2dafe1732b01a1ed7ae2919ae9313 100644 (file)
 #include "asset_map.h"
 #include "reel.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::list;
+using std::stringstream;
+using std::ofstream;
+using std::ostream;
+using boost::shared_ptr;
 using namespace libdcp;
 
 DCP::DCP (string directory)
        : _directory (directory)
 {
-       filesystem::create_directories (directory);
+       boost::filesystem::create_directories (directory);
 }
 
 void
@@ -62,7 +66,7 @@ DCP::write_xml () const
        string pkl_path = write_pkl (pkl_uuid);
        
        write_volindex ();
-       write_assetmap (pkl_uuid, filesystem::file_size (pkl_path));
+       write_assetmap (pkl_uuid, boost::filesystem::file_size (pkl_path));
 }
 
 std::string
@@ -70,7 +74,7 @@ DCP::write_pkl (string pkl_uuid) const
 {
        assert (!_cpls.empty ());
        
-       filesystem::path p;
+       boost::filesystem::path p;
        p /= _directory;
        stringstream s;
        s << pkl_uuid << "_pkl.xml";
@@ -105,7 +109,7 @@ DCP::write_pkl (string pkl_uuid) const
 void
 DCP::write_volindex () const
 {
-       filesystem::path p;
+       boost::filesystem::path p;
        p /= _directory;
        p /= "VOLINDEX.xml";
        ofstream vi (p.string().c_str());
@@ -119,7 +123,7 @@ DCP::write_volindex () const
 void
 DCP::write_assetmap (string pkl_uuid, int pkl_length) const
 {
-       filesystem::path p;
+       boost::filesystem::path p;
        p /= _directory;
        p /= "ASSETMAP.xml";
        ofstream am (p.string().c_str());
@@ -167,14 +171,14 @@ DCP::read (bool require_mxfs)
 
        shared_ptr<AssetMap> asset_map;
        try {
-               filesystem::path p = _directory;
+               boost::filesystem::path p = _directory;
                p /= "ASSETMAP";
-               if (filesystem::exists (p)) {
+               if (boost::filesystem::exists (p)) {
                        asset_map.reset (new AssetMap (p.string ()));
                } else {
                        p = _directory;
                        p /= "ASSETMAP.xml";
-                       if (filesystem::exists (p)) {
+                       if (boost::filesystem::exists (p)) {
                                asset_map.reset (new AssetMap (p.string ()));
                        } else {
                                throw DCPReadError ("could not find AssetMap file");
@@ -190,7 +194,7 @@ DCP::read (bool require_mxfs)
                        throw XMLError ("unsupported asset chunk count");
                }
 
-               filesystem::path t = _directory;
+               boost::filesystem::path t = _directory;
                t /= (*i)->chunks.front()->path;
                
                if (ends_with (t.string(), ".mxf") || ends_with (t.string(), ".ttf")) {
@@ -421,7 +425,7 @@ CPL::add_reel (shared_ptr<const Reel> reel)
 void
 CPL::write_xml () const
 {
-       filesystem::path p;
+       boost::filesystem::path p;
        p /= _directory;
        stringstream s;
        s << _uuid << "_cpl.xml";
@@ -455,7 +459,7 @@ CPL::write_xml () const
        os.close ();
 
        _digest = make_digest (p.string (), 0);
-       _length = filesystem::file_size (p.string ());
+       _length = boost::filesystem::file_size (p.string ());
 }
 
 void
index fcb85168dd6e2f731f23624e79db59dc8a934c1d..d4f6aff9aba9a64a377da1caed718eb789b4b1f8 100644 (file)
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -27,7 +27,7 @@
 #include <string>
 #include <vector>
 #include <boost/shared_ptr.hpp>
-#include <sigc++/sigc++.h>
+#include <boost/signals2.hpp>
 #include "types.h"
 
 namespace xmlpp {
@@ -153,7 +153,7 @@ public:
        /** Emitted with a parameter between 0 and 1 to indicate progress
         *  for long jobs.
         */
-       sigc::signal1<void, float> Progress;
+       boost::signals2::signal<void (float)> Progress;
 
 private:
 
index ead97b9e5b261876482a15bfc8f3be9051b59bbf..95412d0cdda42a4e01b8e188e09050ae0c27fe22 100644 (file)
 #include "util.h"
 #include "metadata.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::list;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
 using namespace libdcp;
 
-MXFAsset::MXFAsset (string directory, string file_name, sigc::signal1<void, float>* progress, int fps, int entry_point, int length)
+MXFAsset::MXFAsset (string directory, string file_name, boost::signals2::signal<void (float)>* progress, int fps, int entry_point, int length)
        : Asset (directory, file_name)
        , _progress (progress)
        , _fps (fps)
index 240e042da87dfc5d5a3d693a619ba07e3549d0ce..03f2aa6b486f8427695aba558f8649d9658ca319 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef LIBDCP_MXF_ASSET_H
 #define LIBDCP_MXF_ASSET_H
 
+#include <boost/signals2.hpp>
 #include "asset.h"
 
 namespace libdcp
@@ -36,7 +37,7 @@ public:
         *  @param entry_point The entry point of this MXF; ie the first frame that should be used.
         *  @param length Length in frames.
         */
-       MXFAsset (std::string directory, std::string file_name, sigc::signal1<void, float>* progress, int fps, int entry_point, int length);
+       MXFAsset (std::string directory, std::string file_name, boost::signals2::signal<void (float)>* progress, int fps, int entry_point, int length);
 
        virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
        
@@ -49,7 +50,7 @@ protected:
        void fill_writer_info (ASDCP::WriterInfo* w) const;
 
        /** Signal to emit to report progress */
-       sigc::signal1<void, float>* _progress;
+       boost::signals2::signal<void (float)>* _progress;
        /** Frames per second */
        int _fps;
        int _entry_point;
index 12dfd1aa5e87745746d06109191437866f482640..ef5d40d4685ed6b961e20b45f551f72418468073 100644 (file)
 #include "exceptions.h"
 #include "picture_frame.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::ostream;
+using std::list;
+using std::vector;
+using std::max;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+using boost::lexical_cast;
 using namespace libdcp;
 
-PictureAsset::PictureAsset (string directory, string mxf_name, sigc::signal1<void, float>* progress, int fps, int entry_point, int length)
+PictureAsset::PictureAsset (string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int entry_point, int length)
        : MXFAsset (directory, mxf_name, progress, fps, entry_point, length)
        , _width (0)
        , _height (0)
@@ -125,10 +131,10 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<s
 
 
 MonoPictureAsset::MonoPictureAsset (
-       sigc::slot<string, int> get_path,
+       boost::function<string (int)> get_path,
        string directory,
        string mxf_name,
-       sigc::signal1<void, float>* progress,
+       boost::signals2::signal<void (float)>* progress,
        int fps,
        int length,
        int width,
@@ -144,7 +150,7 @@ MonoPictureAsset::MonoPictureAsset (
        vector<string> const & files,
        string directory,
        string mxf_name,
-       sigc::signal1<void, float>* progress,
+       boost::signals2::signal<void (float)>* progress,
        int fps,
        int length,
        int width,
@@ -153,7 +159,7 @@ MonoPictureAsset::MonoPictureAsset (
 {
        _width = width;
        _height = height;
-       construct (sigc::bind (sigc::mem_fun (*this, &MonoPictureAsset::path_from_list), files));
+       construct (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files));
 }
 
 MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name, int fps, int entry_point, int length)
@@ -174,7 +180,7 @@ MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name, int fps,
 }
 
 void
-MonoPictureAsset::construct (sigc::slot<string, int> get_path)
+MonoPictureAsset::construct (boost::function<string (int)> get_path)
 {
        ASDCP::JP2K::CodestreamParser j2k_parser;
        ASDCP::JP2K::FrameBuffer frame_buffer (4 * Kumu::Megabyte);
index da3eb7d00e9f5e7bfdb21bfc143e8c1833d86ea5..08eb338ae19a182cf6d372d5fdba177f7fbbff3a 100644 (file)
@@ -34,7 +34,7 @@ class StereoPictureFrame;
 class PictureAsset : public MXFAsset
 {
 public:
-       PictureAsset (std::string directory, std::string mxf_name, sigc::signal1<void, float>* progress, int fps, int entry_point, int length);
+       PictureAsset (std::string directory, std::string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int entry_point, int length);
        
        /** Write details of this asset to a CPL stream.
         *  @param s Stream.
@@ -83,7 +83,7 @@ public:
                std::vector<std::string> const & files,
                std::string directory,
                std::string mxf_name,
-               sigc::signal1<void, float>* progress,
+               boost::signals2::signal<void (float)>* progress,
                int fps,
                int length,
                int width,
@@ -102,10 +102,10 @@ public:
         *  @param height Height of images in pixels.
         */
        MonoPictureAsset (
-               sigc::slot<std::string, int> get_path,
+               boost::function<std::string (int)> get_path,
                std::string directory,
                std::string mxf_name,
-               sigc::signal1<void, float>* progress,
+               boost::signals2::signal<void (float)>* progress,
                int fps,
                int length,
                int width,
@@ -119,7 +119,7 @@ public:
 
 private:
        std::string path_from_list (int f, std::vector<std::string> const & files) const;
-       void construct (sigc::slot<std::string, int>);
+       void construct (boost::function<std::string (int)>);
 };
 
 /** A 3D (stereoscopic) picture asset */       
index 06788da561646a5ce38283ad97657acc12c5d78a..a2b90a0b5d9786f0ab52e6878955061cfad01ba4 100644 (file)
@@ -26,8 +26,8 @@
 #include "lut.h"
 #include "util.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using boost::shared_ptr;
 using namespace libdcp;
 
 /** Make a picture frame from a 2D (monoscopic) asset.
index 9ec3b2f905f4258941ed51f0d95e7f077cb1722c..0d0e1cd4e7408c0ebe09af61dee2aeb262edbe72 100644 (file)
 #include "exceptions.h"
 #include "sound_frame.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::stringstream;
+using std::ostream;
+using std::vector;
+using std::list;
+using boost::shared_ptr;
+using boost::lexical_cast;
 using namespace libdcp;
 
 SoundAsset::SoundAsset (
-       vector<string> const & files, string directory, string mxf_name, sigc::signal1<void, float>* progress, int fps, int length
+       vector<string> const & files, string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int length
        )
        : MXFAsset (directory, mxf_name, progress, fps, 0, length)
        , _channels (files.size ())
        , _sampling_rate (0)
 {
-       construct (sigc::bind (sigc::mem_fun (*this, &SoundAsset::path_from_channel), files));
+       construct (boost::bind (&SoundAsset::path_from_channel, this, _1, files));
 }
 
 SoundAsset::SoundAsset (
-       sigc::slot<string, Channel> get_path, string directory, string mxf_name, sigc::signal1<void, float>* progress, int fps, int length, int channels
+       boost::function<string (Channel)> get_path,
+       string directory,
+       string mxf_name,
+       boost::signals2::signal<void (float)>* progress,
+       int fps, int length, int channels
        )
        : MXFAsset (directory, mxf_name, progress, fps, 0, length)
        , _channels (channels)
@@ -84,7 +93,7 @@ SoundAsset::path_from_channel (Channel channel, vector<string> const & files)
 }
 
 void
-SoundAsset::construct (sigc::slot<string, Channel> get_path)
+SoundAsset::construct (boost::function<string (Channel)> get_path)
 {
        ASDCP::Rational asdcp_fps (_fps, 1);
        
index a19d67268241fccddd40d7a12f5e5a44e1bcb0b7..3189c0674471d08141bbb45d4e301155dc38936f 100644 (file)
@@ -49,7 +49,7 @@ public:
                std::vector<std::string> const & files,
                std::string directory,
                std::string mxf_name,
-               sigc::signal1<void, float>* progress,
+               boost::signals2::signal<void (float)>* progress,
                int fps,
                int length
                );
@@ -65,10 +65,10 @@ public:
         *  @param channels Number of audio channels.
         */
        SoundAsset (
-               sigc::slot<std::string, Channel> get_path,
+               boost::function<std::string (Channel)> get_path,
                std::string directory,
                std::string mxf_name,
-               sigc::signal1<void, float>* progress,
+               boost::signals2::signal<void (float)>* progress,
                int fps,
                int length,
                int channels
@@ -100,7 +100,7 @@ public:
        }
 
 private:
-       void construct (sigc::slot<std::string, Channel> get_path);
+       void construct (boost::function<std::string (Channel)> get_path);
        std::string path_from_channel (Channel channel, std::vector<std::string> const & files);
 
        /** Number of channels in the asset */
index 8e15ba1acffb1681a89a913af105b245e7fcec85..9f1aa9d98bd0f6ed7994161cc461e6f7ab84d1f7 100644 (file)
 #include "subtitle_asset.h"
 #include "util.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::list;
+using std::ostream;
+using std::ofstream;
+using std::stringstream;
+using boost::shared_ptr;
+using boost::lexical_cast;
 using namespace libdcp;
 
 SubtitleAsset::SubtitleAsset (string directory, string xml_file)
index 220411809cc5afa9811442563d27657f6ed6fad1..c5ddb611b4ec0f1eeaadaefcbd9afd0f39ae9f42 100644 (file)
 #include "argb_frame.h"
 #include "lut.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::stringstream;
+using std::min;
+using std::max;
+using boost::shared_ptr;
 using namespace libdcp;
 
 string
@@ -51,9 +54,9 @@ libdcp::make_uuid ()
 }
 
 string
-libdcp::make_digest (string filename, sigc::signal1<void, float>* progress)
+libdcp::make_digest (string filename, boost::signals2::signal<void (float)>* progress)
 {
-       int const file_size = filesystem::file_size (filename);
+       int const file_size = boost::filesystem::file_size (filename);
        
        Kumu::FileReader reader;
        if (ASDCP_FAILURE (reader.OpenRead (filename.c_str ()))) {
index fd0ea5e9221fd9f38a5a8b0872be673262ea71f4..7056db6a372fe4def5fbe0cce8baa83b4a6a5e0a 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <string>
 #include <stdint.h>
-#include <sigc++/sigc++.h>
+#include <boost/signals2.hpp>
 #include <openjpeg.h>
 #include "types.h"
 
@@ -42,7 +42,7 @@ extern std::string make_uuid ();
  *  progress; the parameter will start at 0.5 and proceed to 1.
  *  @return Digest.
  */
-extern std::string make_digest (std::string filename, sigc::signal1<void, float>* progress);
+extern std::string make_digest (std::string filename, boost::signals2::signal<void (float)>* progress);
 
 extern std::string content_kind_to_string (ContentKind kind);
 extern ContentKind content_kind_from_string (std::string kind);
index 037695b80f5a5f8407b58fe1728932c277682e80..6c7f23926ac5354886df076deedd9767af18bab2 100644 (file)
@@ -3,7 +3,7 @@ def build(bld):
     obj.name = 'libdcp'
     obj.target = 'dcp'
     obj.export_includes = ['.']
-    obj.uselib = 'BOOST_FILESYSTEM OPENSSL SIGC++ LIBXML++ OPENJPEG'
+    obj.uselib = 'BOOST_FILESYSTEM BOOST_SIGNALS2 OPENSSL SIGC++ LIBXML++ OPENJPEG'
     obj.use = 'libkumu-libdcp libasdcp-libdcp'
     obj.source = """
                  asset.cc
index cad7b910350ac8161145b036d9a8f1e3055ad4c6..ef25b7c8d6fb85eb9ef84a9f390da2636b01e47e 100644 (file)
 #define BOOST_TEST_MODULE libdcp_test
 #include <boost/test/unit_test.hpp>
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::vector;
+using std::list;
+using boost::shared_ptr;
 
 string
 j2c (int)
@@ -61,13 +63,13 @@ BOOST_AUTO_TEST_CASE (dcp_test)
        t->product_name = "OpenDCP";
        t->product_version = "0.0.25";
        t->issue_date = "2012-07-17T04:45:18+00:00";
-       filesystem::remove_all ("build/test/foo");
-       filesystem::create_directories ("build/test/foo");
+       boost::filesystem::remove_all ("build/test/foo");
+       boost::filesystem::create_directories ("build/test/foo");
        libdcp::DCP d ("build/test/foo");
        shared_ptr<libdcp::CPL> cpl (new libdcp::CPL ("build/test/foo", "A Test DCP", libdcp::FEATURE, 24, 24));
 
        shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset (
-                                                        sigc::ptr_fun (&j2c),
+                                                        j2c,
                                                         "build/test/foo",
                                                         "video.mxf",
                                                         &d.Progress,
@@ -78,15 +80,15 @@ BOOST_AUTO_TEST_CASE (dcp_test)
                                                         ));
 
        shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset (
-                                                 sigc::ptr_fun (&wav),
-                                                 "build/test/foo",
-                                                 "audio.mxf",
-                                                 &(d.Progress),
-                                                 24,
-                                                 24,
-                                                 2
-                                                 ));
-
+                                                  wav,
+                                                  "build/test/foo",
+                                                  "audio.mxf",
+                                                  &(d.Progress),
+                                                  24,
+                                                  24,
+                                                  2
+                                                  ));
+       
        cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ())));
        d.add_cpl (cpl);
 
index 4f149f37a9b8596c45be332c25fa4ed05b135b7b..0c4b9b1a392591bb4897cbb4ecc46441627d7ce6 100644 (file)
@@ -9,8 +9,11 @@
 #include "picture_asset.h"
 #include "subtitle_asset.h"
 
-using namespace std;
-using namespace boost;
+using std::string;
+using std::cerr;
+using std::cout;
+using std::list;
+using boost::shared_ptr;
 using namespace libdcp;
 
 static void
@@ -58,7 +61,7 @@ main (int argc, char* argv[])
                exit (EXIT_FAILURE);
        }
 
-       if (!filesystem::exists (argv[optind])) {
+       if (!boost::filesystem::exists (argv[optind])) {
                cerr << argv[0] << ": DCP " << argv[optind] << " not found.\n";
                exit (EXIT_FAILURE);
        }
diff --git a/wscript b/wscript
index 9beb9c00db21b2cc3520393cbfee9548bcb9ac6c..fe5eb810ab56e7de284aa492a94ba961a44c2580 100644 (file)
--- a/wscript
+++ b/wscript
@@ -23,7 +23,6 @@ def configure(conf):
         conf.env.append_value('CXXFLAGS', '-DLIBDCP_POSIX')
 
     conf.check_cfg(package = 'openssl', args = '--cflags --libs', uselib_store = 'OPENSSL', mandatory = True)
-    conf.check_cfg(package = 'sigc++-2.0', args = '--cflags --libs', uselib_store = 'SIGC++', mandatory = True)
     conf.check_cfg(package = 'libxml++-2.6', args = '--cflags --libs', uselib_store = 'LIBXML++', mandatory = True)
 
     conf.check_cc(fragment  = """
@@ -54,6 +53,13 @@ def configure(conf):
                    lib = ['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
                    uselib_store = 'BOOST_FILESYSTEM')
 
+    conf.check_cxx(fragment = """
+                             #include <boost/signals2.hpp>\n
+                             int main() { boost::signals2::signal<void (int)> x; }\n
+                             """,
+                   msg = 'Checking for boost signals2 library',
+                   uselib_store = 'BOOST_SIGNALS2')
+
     lut.make_luts()
 
     conf.recurse('test')