diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-01 16:40:54 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-02 00:33:21 +0100 |
commit | ef5051b59270b324968cb91304fb25f622b80329 (patch) | |
tree | f5006a3c012a6d476761d6d5df2c039f223dea14 | |
parent | 02e2e6df7f089b121bc3599c8e267ffa7f9e46fb (diff) |
make ring header only
Change-Id: If8a52d12cb145120be4477ee79f8cdc55329c36c
-rw-r--r-- | sw/Library_sw.mk | 1 | ||||
-rw-r--r-- | sw/inc/ring.hxx | 52 | ||||
-rw-r--r-- | sw/source/core/bastyp/ring.cxx | 80 |
3 files changed, 47 insertions, 86 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index d51615bafe53..c4753150a5c8 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -129,7 +129,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/bastyp/checkit \ sw/source/core/bastyp/index \ sw/source/core/bastyp/init \ - sw/source/core/bastyp/ring \ sw/source/core/bastyp/swcache \ sw/source/core/bastyp/swrect \ sw/source/core/bastyp/swregion \ diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx index 4dc03308bdfe..90e3465e8065 100644 --- a/sw/inc/ring.hxx +++ b/sw/inc/ring.hxx @@ -22,23 +22,37 @@ #include <swdllapi.h> #include <swtypes.hxx> #include <boost/iterator/iterator_facade.hpp> +#include <boost/intrusive/circular_list_algorithms.hpp> class Ring_node_traits; class RingIterator; class SW_DLLPUBLIC Ring { + struct Ring_node_traits + { + typedef Ring node; + typedef Ring* node_ptr; + typedef const Ring* const_node_ptr; + static node_ptr get_next(const_node_ptr n) { return n->GetNext(); }; + static void set_next(node_ptr n, node_ptr next) { n->pNext = next; }; + static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); }; + static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; }; + }; friend class Ring_node_traits; + typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo; Ring* pNext; Ring* pPrev; ///< In order to speed up inserting and deleting. protected: - Ring(); + Ring() + { algo::init_header(this); } Ring( Ring * ); public: typedef RingIterator iterator; typedef RingIterator const_iterator; - virtual ~Ring(); + virtual ~Ring() + { algo::unlink(this); }; void MoveTo( Ring *pDestRing ); void MoveRingTo( Ring *pDestRing ); @@ -49,9 +63,39 @@ public: iterator beginRing(); iterator endRing(); - sal_uInt32 numberOf() const; + sal_uInt32 numberOf() const + { return algo::count(this); } }; +inline Ring::Ring( Ring *pObj ) +{ + if( !pObj ) + algo::init_header(this); + else + algo::link_before(pObj, this); +} + +inline void Ring::MoveTo(Ring *pDestRing) +{ + // insert into "new" + if( pDestRing ) + { + if(algo::unique(this)) + algo::link_before(pDestRing, this); + else + algo::transfer(pDestRing, this); + } + else + algo::unlink(this); + +} + +inline void Ring::MoveRingTo(Ring *pDestRing) +{ + std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext)); + std::swap(*(&pPrev), *(&pDestRing->pPrev)); +} + class RingIterator : public boost::iterator_facade< RingIterator , Ring @@ -88,8 +132,6 @@ inline Ring::iterator Ring::beginRing() inline Ring::iterator Ring::endRing() { return Ring::iterator(this, false); }; - - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/bastyp/ring.cxx b/sw/source/core/bastyp/ring.cxx deleted file mode 100644 index b7ce9c062d08..000000000000 --- a/sw/source/core/bastyp/ring.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "ring.hxx" -#include <boost/intrusive/circular_list_algorithms.hpp> - -struct Ring_node_traits -{ - typedef Ring node; - typedef Ring* node_ptr; - typedef const Ring* const_node_ptr; - static node_ptr get_next(const_node_ptr n) { return n->GetNext(); }; - static void set_next(node_ptr n, node_ptr next) { n->pNext = next; }; - static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); }; - static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; }; -}; -typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo; - - -Ring::Ring() -{ - algo::init_header(this); -} - -Ring::Ring( Ring *pObj ) -{ - if( !pObj ) - algo::init_header(this); - else - algo::link_before(pObj, this); -} - -Ring::~Ring() -{ - algo::unlink(this); -} - -void Ring::MoveTo(Ring *pDestRing) -{ - // insert into "new" - if( pDestRing ) - { - if(algo::unique(this)) - algo::link_before(pDestRing, this); - else - algo::transfer(pDestRing, this); - } - else - algo::unlink(this); - -} - -void Ring::MoveRingTo(Ring *pDestRing) -{ - std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext)); - std::swap(*(&pPrev), *(&pDestRing->pPrev)); -} - -sal_uInt32 Ring::numberOf() const -{ - return algo::count(this); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |