This file is indexed.

/usr/include/choreonoid-1.1/cnoid/src/Base/ItemList.h is in libcnoid-dev 1.1.0+dfsg-6.1+b4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/**
   @author Shin'ichiro Nakaoka
*/

#ifndef CNOID_GUIBASE_ITEM_LIST_H_INCLUDED
#define CNOID_GUIBASE_ITEM_LIST_H_INCLUDED

#include <deque>
#include <boost/intrusive_ptr.hpp>
#include "exportdecl.h"

namespace cnoid {

    class Item;
    typedef boost::intrusive_ptr<Item> ItemPtr;

    template <class ItemType> class ItemList;

    /**
       @if jp
       アイテムコンテナにおいて、
       自身の対象とする型のアイテムのみを追加するためのインタフェースとなる抽象クラス。
       @endif
    */
    class CNOID_EXPORT ItemListBase
    {
    public:

        ItemListBase() { }

        /**
           @if jp
           代入演算子。
           
           コピー元リストが保持するアイテムのうち、
           コピー先リスとの型に適合するものだけがコピーされる。
           @endif
        */
        template <class LhsType> inline ItemListBase& operator=(const ItemList<LhsType>& org) {
            clear();
            for(size_t i=0; i < org.size(); ++i){ 
                this->appendIfTypeMatches(org[i]); 
            }
            return *this;
        }
    
        virtual ~ItemListBase() { }

        /**
           @if jp
           アイテムを追加する。

           @param item 追加するアイテム。
           このアイテムの型がItemListBaseが対象としている型と一致しているときのみ、
           実際に追加が行われる。
           @endif
        */
        virtual bool appendIfTypeMatches(ItemPtr item) = 0;

        virtual void clear() = 0;
    };


    /**
       @if jp
       対象とする型のアイテムのみを保持するアイテムリスト。
       @endif
    */
    template <class ItemType = Item>
    class ItemList : public ItemListBase
    {
        typedef boost::intrusive_ptr<ItemType> ItemTypePtr;
        typedef std::deque<ItemTypePtr> Container;

    public:

        typedef typename Container::iterator iterator;

        ItemList() { }
        
        /**
           @if jp
           コピーコンストラクタ。
         
           コピー元リストが保持するアイテムのうち、
           コピー先リスとの型に適合するものだけがコピーされる。
           @endif
        */
        template <class LhsType> ItemList(const ItemList<LhsType>& org){
            for(size_t i=0; i < org.size(); ++i){ 
                this->appendIfTypeMatches(org[i]); 
            }
        }

        ItemList(const ItemList& org) : items(org.items) { }

        /**
           @if jp
           代入演算子。

           コピー元リストが保持するアイテムのうち、
           コピー先リスとの型に適合するものだけがコピーされる。
           @endif
        */
        template <class LhsType> inline ItemList& operator=(const ItemList<LhsType>& org){
            static_cast<ItemListBase>(*this) = org;
            return *this;
        }

        inline ItemList& operator=(const ItemList& org){
            items = org.items;
            return *this;
        }

        virtual ~ItemList() { }

        inline bool operator==(const ItemList<ItemType>& lhs){
            return (items == lhs.items);
        }

        inline bool operator!=(const ItemList<ItemType>& lhs){
            return (items != lhs.items);
        }
        
        inline bool empty() const {
            return items.empty();
        }

        inline size_t size() const { 
            return items.size();
        }

        inline iterator begin() {
            return items.begin();
        }

        inline iterator end() {
            return items.end();
        }

        inline ItemType* back() const {
            return items.back().get();
        }

        inline ItemType* front() const {
            return items.front().get();
        }

        inline ItemType* operator[](size_t i) const {
            return items[i].get();
        }

        inline void clear(){
            items.clear();
        }

        inline void append(ItemTypePtr item){
            items.push_back(item);
        }

        inline void push_front(ItemTypePtr item){
            items.push_front(item);
        }
        
        inline void push_back(ItemTypePtr item){
            items.push_back(item);
        }

        inline void pop_front(){
            items.pop_front();
        }
        
        inline void pop_back(){
            items.pop_back();
        }

        virtual bool appendIfTypeMatches(ItemPtr item){
            ItemTypePtr castedItem = boost::dynamic_pointer_cast<ItemType>(item);
            if(castedItem){
                items.push_back(castedItem);
            }
            return castedItem;
        }

        inline boost::intrusive_ptr<ItemType> toSingle(bool allowFromMultiItems = false) const {
            return (items.size() == 1 || (allowFromMultiItems && !items.empty())) ?
                items[0] : ItemTypePtr();
        }

        template <class ItemType2>
        inline boost::intrusive_ptr<ItemType2> extractSingle(bool allowFromMultiItems = false) const {
            const ItemList<ItemType2> narrowdItems(*this);
            return (narrowdItems.size() == 1 || (allowFromMultiItems && !narrowdItems.empty())) ?
                narrowdItems[0] : boost::intrusive_ptr<ItemType2>();
        }

    protected:
        Container items;
    };

}


#endif