Skip to content
Permalink
Browse files

Make working with filter groups less restrictive.

Filter groups could not be manipulated once they had been assigned to an IO object.  Now they can be freely manipulated up to the time the IO object is opened.

Also, move the filter group into the IO object's context so they don't need to be tracked separately.
  • Loading branch information...
dwsteele committed Jun 4, 2019
1 parent 92e04ea commit 4b91259de8d7feec6d33d154032169aa32c879e3
@@ -350,6 +350,25 @@ ioFilterGroupClose(IoFilterGroup *this)
FUNCTION_LOG_RETURN_VOID();
}

/***********************************************************************************************************************************
Move the object to a new context
***********************************************************************************************************************************/
IoFilterGroup *
ioFilterGroupMove(IoFilterGroup *this, MemContext *parentNew)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(IO_FILTER_GROUP, this);
FUNCTION_TEST_PARAM(MEM_CONTEXT, parentNew);
FUNCTION_TEST_END();

ASSERT(parentNew != NULL);

if (this != NULL)
memContextMove(this->memContext, parentNew);

FUNCTION_TEST_RETURN(this);
}

/***********************************************************************************************************************************
Is the filter group done processing?
***********************************************************************************************************************************/
@@ -34,6 +34,8 @@ void ioFilterGroupOpen(IoFilterGroup *this);
void ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output);
void ioFilterGroupClose(IoFilterGroup *this);

IoFilterGroup *ioFilterGroupMove(IoFilterGroup *this, MemContext *parentNew);

/***********************************************************************************************************************************
Getters
***********************************************************************************************************************************/
@@ -363,7 +363,7 @@ Get/set filters
Filters must be set before open and cannot be reset.
***********************************************************************************************************************************/
const IoFilterGroup *
IoFilterGroup *
ioReadFilterGroup(const IoRead *this)
{
FUNCTION_TEST_BEGIN();
@@ -389,7 +389,7 @@ ioReadFilterGroupSet(IoRead *this, IoFilterGroup *filterGroup)
ASSERT(!this->opened && !this->closed);
ASSERT(!ioReadBlock(this));

this->filterGroup = filterGroup;
this->filterGroup = ioFilterGroupMove(filterGroup, this->memContext);

FUNCTION_LOG_RETURN_VOID();
}
@@ -33,7 +33,7 @@ Getters/Setters
***********************************************************************************************************************************/
bool ioReadBlock(const IoRead *this);
bool ioReadEof(const IoRead *this);
const IoFilterGroup *ioReadFilterGroup(const IoRead *this);
IoFilterGroup *ioReadFilterGroup(const IoRead *this);
void ioReadFilterGroupSet(IoRead *this, IoFilterGroup *filterGroup);
int ioReadHandle(const IoRead *this);

@@ -269,15 +269,14 @@ Get/set filters
Filters must be set before open and cannot be reset.
***********************************************************************************************************************************/
const IoFilterGroup *
IoFilterGroup *
ioWriteFilterGroup(const IoWrite *this)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(IO_WRITE, this);
FUNCTION_TEST_END();

ASSERT(this != NULL);
ASSERT(this->opened && this->closed);

FUNCTION_TEST_RETURN(this->filterGroup);
}
@@ -300,7 +299,7 @@ ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup)
this->filterGroupSet = true;
#endif

this->filterGroup = filterGroup;
this->filterGroup = ioFilterGroupMove(filterGroup, this->memContext);

FUNCTION_LOG_RETURN_VOID();
}
@@ -33,7 +33,7 @@ void ioWriteClose(IoWrite *this);
/***********************************************************************************************************************************
Getters/Setters
***********************************************************************************************************************************/
const IoFilterGroup *ioWriteFilterGroup(const IoWrite *this);
IoFilterGroup *ioWriteFilterGroup(const IoWrite *this);
void ioWriteFilterGroupSet(IoWrite *this, IoFilterGroup *filterGroup);
int ioWriteHandle(const IoWrite *this);

@@ -286,6 +286,7 @@ testRun(void)

TEST_ASSIGN(bufferRead, ioBufferReadNew(bufferOriginal), "create buffer read object");
IoFilterGroup *filterGroup = NULL;
TEST_RESULT_VOID(ioFilterGroupMove(filterGroup, memContextTop()), "move null filter group is a noop");
TEST_ASSIGN(filterGroup, ioFilterGroupNew(), " create new filter group");
IoFilter *sizeFilter = ioSizeNew();
TEST_RESULT_PTR(ioFilterGroupAdd(filterGroup, sizeFilter), filterGroup, " add filter to filter group");

0 comments on commit 4b91259

Please sign in to comment.
You can’t perform that action at this time.