This file is indexed.

/usr/include/CLAM/ReadingRegion.hxx is in libclam-dev 1.4.0-5build1.

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
/*
 * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
 *                         UNIVERSITAT POMPEU FABRA
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef ReadingRegion_hxx
#define ReadingRegion_hxx

#include "Region.hxx"
#include "StreamImpl.hxx"

namespace CLAM
{

template<class WritingRegion>
class ReadingRegion : public Region
{
	typedef typename WritingRegion::ProperStream ProperStream;
	typedef typename WritingRegion::ProperToken ProperToken;

public:
	ReadingRegion();
	~ReadingRegion();

	void LinkAndNotifySizeToStream( ProperStream& stream );
	ProperStream& Stream();
	/** Condition of overlap between reading and writing regions.
		Returns true if are not overlapping so it can consume
	*/
	bool CanConsume();
	/**
		This method must be called when the data of the reading-region has been
		already readen (consumed) and we want to advance the region position
		for further	readings (consumes)
	*/
	void Consume();
	void LinkProducerRegion( Region& writing);
	
	// const?? TODO
	ProperToken& operator[](int offset);

	Region* ProducerRegion();
	void RemoveProducer();
	
 	ReadingRegionsIterator BeginReaders();
	ReadingRegionsIterator EndReaders();

private:
	void SizeChanged(const int & newSize);

	ProperStream* mAttachedStream;
	Region* mProducingRegion;
};

/////// Implementation ////////

template<class WritingRegion>
ReadingRegion<WritingRegion>::ReadingRegion() 
		: mAttachedStream(0), mProducingRegion(0)
{
}

template<class WritingRegion>
ReadingRegion<WritingRegion>::~ReadingRegion()
{
	if(mProducingRegion)
		mProducingRegion->RemoveRegion( *this );
}

template<class WritingRegion>
void ReadingRegion<WritingRegion>::LinkAndNotifySizeToStream( ProperStream& stream )
{
	mAttachedStream = &stream;
	mAttachedStream->NewReadingRegionSize( *this );
}

template<class WritingRegion>
typename ReadingRegion<WritingRegion>::ProperStream & ReadingRegion<WritingRegion>::Stream()
{
	return *(mAttachedStream);
}

template<class WritingRegion>
bool ReadingRegion<WritingRegion>::CanConsume()
{
	if(!mProducingRegion)
		return false;
	return ProducerRegion()->Pos() >= Pos()+Size();
}

template<class WritingRegion>
void ReadingRegion<WritingRegion>::Consume()
{
	CLAM_DEBUG_ASSERT( CanConsume(), "ReadingRegion::Consume() - region can't consume" );
	Pos( Pos() + Hop() );
	mAttachedStream->ReaderHasAdvanced( *this );
}

template<class WritingRegion>
void ReadingRegion<WritingRegion>::LinkProducerRegion( Region& writing)
{
	mProducingRegion = &writing;
	// it starts at the same position than the writer is in this exact moment
	Pos( writing.Pos() );
	BeginDistance( writing.BeginDistance() );
}

template<class WritingRegion>
typename ReadingRegion<WritingRegion>::ProperToken & ReadingRegion<WritingRegion>::operator[](int offset)
{
	CLAM_DEBUG_ASSERT( mAttachedStream, "ReadingRegion operator[] - No attached stream" );
	CLAM_DEBUG_ASSERT( 0 <= offset && offset < Size(), "ReadingRegion operator[] - Index out of bounds" );
	CLAM_DEBUG_ASSERT( CanConsume(), "ReadingRegion operator[] - region can't consume" );

	int physicalIndex = BeginDistance() + offset;

	return mAttachedStream->operator[](physicalIndex);
}

template<class WritingRegion>
Region* ReadingRegion<WritingRegion>::ProducerRegion()
{
	return mProducingRegion;
}

	template<class WritingRegion>
void ReadingRegion<WritingRegion>::RemoveProducer()
{
	mProducingRegion = 0;
	mAttachedStream = 0;
}

template<class WritingRegion>
typename ReadingRegion<WritingRegion>::ReadingRegionsIterator ReadingRegion<WritingRegion>::BeginReaders()
{
	throw 0; 
}

template<class WritingRegion>
typename ReadingRegion<WritingRegion>::ReadingRegionsIterator ReadingRegion<WritingRegion>::EndReaders()
{
	throw 0; 
}

template<class WritingRegion>
void ReadingRegion<WritingRegion>::SizeChanged(const int & newSize)
{
	if (mAttachedStream)
		mAttachedStream->NewReadingRegionSize(*this);
}

} // namespace CLAM

#endif // __ReadingRegion_hxx__