• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 58,  comments - 75,  trackbacks - 0

            connection BOOST_SIGNALS_SIGNAL::connect(const slot_type& in_slot, //引發slot的構造,主要初始化存儲信號源信息的結構
                                        connect_position at)
            {
             using boost::BOOST_SIGNALS_NAMESPACE::detail::stored_group;

             if (!in_slot.is_active())
             {
              return BOOST_SIGNALS_NAMESPACE::connection();
                }

             return impl->connect_slot(in_slot.get_slot_function(), stored_group(),
                        in_slot.get_data(), at); //調用了signal_base_impl的connect_slot
            }

            slot的構造函數簡版偽碼

            slot(const function& f) : slot_function(get_invocable_slot(f, tag_type(f)))
            {
             this->data.reset(new data_t);

             basic_connection* con = new basic_connection();

             con->signal = static_cast<void*>(this);
             con->signal_data = 0;
             con->blocked_ = false ;
             con->signal_disconnect = &bound_object_destructed;

             data->watch_bound_objects.reset(con);
             data->watch_bound_objects.set_controlling(true);
            }

            connection signal_base_impl::connect_slot(const any& slot_, //這里其實傳入的是function
                               const stored_group& name,
                               shared_ptr<slot_base::data_t> data, //slot構造的用來存儲信號源信息的結構
                               connect_position at)
            {
             data->watch_bound_objects.set_controlling(false);
             scoped_connection safe_connection(data->watch_bound_objects);

             std::auto_ptr<iterator> saved_iter(new iterator);

             iterator pos = slots_.insert(name, data->watch_bound_objects, slot_, at); //將連接與function插入到map中

             *saved_iter = pos;

             data->watch_bound_objects.get_connection()->signal = this; //連接的signal
             data->watch_bound_objects.get_connection()->signal_data = saved_iter.release(); //在容器中的迭代位子
             data->watch_bound_objects.get_connection()->signal_disconnect = &signal_base_impl::slot_disconnected; //斷開連接的函數

             pos->first.set_controlling();
             return safe_connection.release();
            }

            //map的插入,將一個連接和function組成一個pair,插入到map中
            named_slot_map::iterator
            named_slot_map::insert(const stored_group& name, const connection& con,
                                   const any& slot, connect_position at)
            {
              group_iterator group;
              if (name.empty()) {
                switch (at) {
                case at_front: group = groups.begin(); break;
                case at_back: group = back; break;
                }
              } else {
                group = groups.find(name);
                if (group == groups.end()) {
                  slot_container_type::value_type v(name, group_list());
                  group = groups.insert(v).first;
                }
              }
              iterator it;
              it.group = group;
              it.last_group = groups.end();

              switch (at) {
              case at_back:
                group->second.push_back(connection_slot_pair(con, slot));
                it.slot_ = group->second.end();
                it.slot_assigned = true;
                --(it.slot_);
                break;

              case at_front:
                group->second.push_front(connection_slot_pair(con, slot));
                it.slot_ = group->second.begin();
                it.slot_assigned = true;
                break;
              }
              return it;
            }

            連接的結構
            struct basic_connection
            {
             void* signal; //signal對象指針,是這個connection的管理者
             void* signal_data; //在signal中的slot管理器中的迭代器對象的指針
             void (*signal_disconnect)(void*, void*); //解除連接的函數執政
             bool blocked_;

             std::list<bound_object> bound_objects;
            };

            class BOOST_SIGNALS_DECL connection :
              private less_than_comparable1<connection>,
              private equality_comparable1<connection>
            {
            public:
              connection() : con(), controlling_connection(false) {}
              connection(const connection&);
              ~connection();

              // Block he connection: if the connection is still active, there
              // will be no notification
              void block(bool should_block = true) { con->blocked_ = should_block; }
              void unblock() { con->blocked_ = false; }
              bool blocked() const { return !connected() || con->blocked_; }

              // Disconnect the signal and slot, if they are connected
              void disconnect() const;

              // Returns true if the signal and slot are connected
              bool connected() const { return con.get() && con->signal_disconnect; }

              // Comparison of connections
              bool operator==(const connection& other) const;
              bool operator<(const connection& other) const;

              // Connection assignment
              connection& operator=(const connection& other) ;

              // Swap connections
              void swap(connection& other);

            public: // TBD: CHANGE THIS
              // Set whether this connection object is controlling or not
              void set_controlling(bool control = true)
              { controlling_connection = control; }

              shared_ptr<BOOST_SIGNALS_NAMESPACE::detail::basic_connection>
              get_connection() const
              { return con; }

            private:
              friend class detail::signal_base_impl;
              friend class detail::slot_base;
              friend class trackable;

              // Reset this connection to refer to a different actual connection
              void reset(BOOST_SIGNALS_NAMESPACE::detail::basic_connection*);

              // Add a bound object to this connection (not for users)
              void add_bound_object(const BOOST_SIGNALS_NAMESPACE::detail::bound_object& b);

              friend class BOOST_SIGNALS_NAMESPACE::detail::bound_objects_visitor;

              // Pointer to the actual contents of the connection
              shared_ptr<BOOST_SIGNALS_NAMESPACE::detail::basic_connection> con;

              // True if the destruction of this connection object should disconnect
              bool controlling_connection;
            };

            posted on 2007-04-23 15:04 walkspeed 閱讀(576) 評論(0)  編輯 收藏 引用 所屬分類: boost學習

            <2007年5月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            常用鏈接

            留言簿(4)

            隨筆分類(64)

            隨筆檔案(58)

            文章分類(3)

            文章檔案(3)

            相冊

            收藏夾(9)

            C++零碎

            好友

            搜索

            •  

            積分與排名

            • 積分 - 160843
            • 排名 - 163

            最新評論

            閱讀排行榜

            評論排行榜

            日韩精品国产自在久久现线拍 | 亚洲一本综合久久| 久久国产精品久久久| 欧美性猛交xxxx免费看久久久| 亚洲精品NV久久久久久久久久| 久久亚洲AV无码精品色午夜 | 99久久做夜夜爱天天做精品| 久久精品中文无码资源站| 国内精品免费久久影院| 国产美女亚洲精品久久久综合 | 亚洲va国产va天堂va久久| 久久精品视频网| 97久久国产露脸精品国产| 四虎国产精品免费久久5151 | 免费国产99久久久香蕉| 免费精品久久天干天干| 精品久久人人爽天天玩人人妻| 亚洲AV日韩精品久久久久| 日日狠狠久久偷偷色综合免费| 久久狠狠高潮亚洲精品| 伊人久久综合无码成人网| 无码8090精品久久一区| 国产69精品久久久久9999| 99re这里只有精品热久久| 99久久精品免费看国产一区二区三区| 精品国产青草久久久久福利| 久久青草国产手机看片福利盒子| 亚洲AV日韩精品久久久久久| 久久毛片一区二区| 久久这里只有精品首页| 色99久久久久高潮综合影院| 久久久精品国产亚洲成人满18免费网站 | AV无码久久久久不卡网站下载| 精品一二三区久久aaa片| 久久婷婷是五月综合色狠狠| 久久亚洲天堂| 性做久久久久久久久| 人人妻久久人人澡人人爽人人精品| 久久婷婷人人澡人人| 四虎久久影院| 亚洲国产精品无码久久|