40 #ifndef _inputsequencecontainer_cpp
41 #define _inputsequencecontainer_cpp
43 #include "Input/sequencecontainer.h"
45 #include "exception.h"
55 DeviceIndex(std::numeric_limits<
UInt32>::max()),
61 this->SequenceTimer->
Reset();
72 this->SequenceTimer->
Reset();
78 this->SequencedInputs.
clear();
84 if( Codes.size() < 3 )
87 "A sequence with only one(or less) actual MetaCode isn't a sequence.");
89 if( NullCode != Codes.back() )
95 if( std::numeric_limits<Int32>::max() == ID )
96 { MEZZ_EXCEPTION(
Exception::PARAMETERS_EXCEPTION,
"Attempting to use max value of Int32 as an ID for an input sequence. This value is reserved for error conditions."); }
103 MetaCodeContainer Key(this->CurrSequenceCache.begin(),this->CurrSequenceCache.end());
104 Key.push_back(this->SequencedInputs.
endSymbol());
106 SequencedInputIterator SeqIt = this->SequencedInputs.
find(Key);
108 if( SeqIt == this->SequencedInputs.
end() )
return Ret;
111 Ret.
SetCode(Input::COMPOUNDINPUT_CUSTOMSEQUENCE);
125 this->SequencedInputs.
insert(Codes,SequenceID);
126 if( this->MaxSequenceSize < Codes.size() - 1 )
127 this->MaxSequenceSize = Codes.size() - 1;
133 return this->SequencedInputs.
hasKey(Codes);
139 SequencedInputIterator SqIt = this->SequencedInputs.
find(Codes);
140 if( SqIt != this->SequencedInputs.
end() )
return *(SqIt->second);
141 else return std::numeric_limits<Int32>::max();
151 this->SequencedInputs.
erase(Codes);
156 this->SequencedInputs.
clear();
164 return static_cast<UInt32>(this->SequencedInputs.
size());
172 if(this->SequencedInputs.
empty())
176 if( this->SequenceTimer->
IsStopped() ) this->CurrSequenceCache.clear();
177 else this->SequenceTimer->
Reset();
180 for( ConstMetaCodeIterator MCIt = NormalCodes.begin() ; MCIt != NormalCodes.end() ; ++MCIt )
182 if( this->CurrSequenceCache.empty() )
184 MetaCodeContainer TestVec;
185 TestVec.push_back( (*MCIt) );
186 TestVec.push_back(NullMetaCode);
187 SequencedInputIterator SeqIt = this->SequencedInputs.
startsWith(TestVec);
188 if( SeqIt != this->SequencedInputs.
end() )
190 this->CurrSequenceCache.push_back( (*MCIt) );
191 this->SequenceTimer->
Start();
194 this->CurrSequenceCache.push_back( (*MCIt) );
195 if( this->MaxSequenceSize == this->CurrSequenceCache.size() )
199 this->CurrSequenceCache.erase(this->CurrSequenceCache.begin());
201 else if( this->MaxSequenceSize < this->CurrSequenceCache.size() )
203 MEZZ_EXCEPTION(
Exception::INVALID_STATE_EXCEPTION,
"Somehow managed to have the sequence cache in this SequenceContainer jump to more than 1 greater than the longest stored sequence. "
204 "Don't know how that happened, but if you see this error then the class needs a patch.");
208 if( NullMetaCode != New )
209 SequenceCodes.push_back(New);