本文整理汇总了C++中InvalidStateException函数的典型用法代码示例。如果您正苦于以下问题:C++ InvalidStateException函数的具体用法?C++ InvalidStateException怎么用?C++ InvalidStateException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InvalidStateException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
void MpiLauncher::destroy(bool force)
{
pid_t pid=0;
int status=0;
string pidFile;
{
ScopedMutexLock lock(_mutex);
if (_pid == 0 || _waiting) {
throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
<< " MPI launcher already destroyed");
}
_waiting = true;
pid = _pid;
status = _status;
pidFile = mpi::getLauncherPidFile(_installPath, _queryId, _launchId);
if (pid > 0) {
if (!force) {
scheduleKillTimer();
} else { // kill right away
boost::shared_ptr<boost::asio::deadline_timer> dummyTimer;
boost::system::error_code dummyErr;
handleKillTimeout(dummyTimer, dummyErr);
}
}
if (force) {
_inError=true;
}
}
if (pid < 0) {
completeLaunch(-pid, pidFile, status);
return;
}
bool rc = waitForExit(pid,&status);
assert(rc); rc=rc;
{
ScopedMutexLock lock(_mutex);
if (!_waiting || pid != _pid) {
throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
<< " MPI launcher is corrupted after collecting process exit code";
}
_pid = -pid;
_status = status;
if (_killTimer) {
size_t n = _killTimer->cancel();
assert(n<2); n=n;
}
}
completeLaunch(pid, pidFile, status);
}
示例2: InvalidStateException
void SharedFile::truncate(uint64_t size, bool force)
{
if (!_file) {
throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__);
}
if (_region && !force) {
throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__);
}
_region.reset();
if (::truncate(getName().c_str(), size) != 0) {
int err = errno;
throw SystemErrorException(err, REL_FILE, __FUNCTION__, __LINE__);
}
}
示例3: throw
Pkcs7SignedData* Pkcs7SignedDataBuilder::doFinal()
throw (InvalidStateException, Pkcs7Exception)
{
int rc;
Pkcs7SignedData *ret;
if (this->state != Pkcs7Builder::UPDATE)
{
throw InvalidStateException("Pkcs7SignedDataBuilder::dofinal");
}
rc = BIO_flush(this->p7bio);
if (!rc)
{
BIO_free(this->p7bio);
this->p7bio = NULL;
this->state = Pkcs7Builder::NO_INIT;
throw Pkcs7Exception(Pkcs7Exception::INTERNAL_ERROR, "Pkcs7SignedDataBuilder::dofinal", true);
}
rc = PKCS7_dataFinal(this->pkcs7, this->p7bio);
if (!rc)
{
BIO_free(this->p7bio);
this->p7bio = NULL;
PKCS7_free(this->pkcs7);
this->pkcs7 = NULL;
this->state = Pkcs7Builder::NO_INIT;
throw Pkcs7Exception(Pkcs7Exception::INTERNAL_ERROR, "Pkcs7SignedDataBuilder::dofinal", true);
}
this->state = Pkcs7Builder::NO_INIT;
BIO_free(this->p7bio);
this->p7bio = NULL;
ret = new Pkcs7SignedData(this->pkcs7);
this->pkcs7 = NULL;
return ret;
}
示例4: InvalidStateException
void AppLayer::OnSendResult(bool aSuccess)
{
if(!mSending)
throw InvalidStateException(LOCATION, "No Active Send");
assert(mSendQueue.size() > 0);
mSending = false;
FunctionCodes func = mSendQueue.front()->GetFunction();
mSendQueue.pop_front();
if(func == FC_CONFIRM) {
assert(mConfirmSending);
mConfirmSending = false;
}
else {
if(aSuccess) {
if(func == FC_UNSOLICITED_RESPONSE) mUnsolicited.OnSendSuccess();
else mSolicited.OnSendSuccess();
}
else {
if(func == FC_UNSOLICITED_RESPONSE) mUnsolicited.OnSendFailure();
else mSolicited.OnSendFailure();
}
}
this->CheckForSend();
}
示例5: throw
void MpiSlaveProxy::waitForExit(std::shared_ptr<MpiOperatorContext>& ctx)
{
if (!_connection) {
throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__)
<< "No connection to MPI slave");
}
LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForExit: launchId="<<_launchId);
MpiOperatorContext::LaunchErrorChecker errChecker =
boost::bind(&checkTimeout,
mpi::getTimeInSecs(),
static_cast<double>(_MPI_SLAVE_RESPONSE_TIMEOUT),
_1, _2);
std::shared_ptr<scidb::ClientMessageDescription> msg = ctx->popMsg(_launchId, errChecker);
assert(msg);
LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForExit: "
<<" ctx = " << msg->getClientContext().get()
<<", msg type = "<< msg->getMessageType()
<<", queryID = "<<msg->getQueryId());
if (msg->getMessageType() != scidb::SYSTEM_NONE_MSG_ID) {
throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR)
<< "MPI slave returned invalid status");
}
assert(!msg->getClientContext());
_connection.reset();
}
示例6: InvalidStateException
void LinkLayer::OnLowerLayerUp()
{
if(mIsOnline)
throw InvalidStateException(LOCATION, "LowerLayerUp");
mIsOnline = true;
if(mpUpperLayer) mpUpperLayer->OnLowerLayerUp();
}
示例7: InvalidStateException
/** \brief Check whether the collection is valid.
*
* This function verifies that the collection is valid. If not, an
* exception is raised. Many other functions from the various collection
* functions are calling this function before accessing data.
*
* \exception InvalidStateException
* This exception is raised if the m_valid field is currently false and
* thus most of the collection data is considered invalid.
*/
void FileCollection::mustBeValid() const
{
if(!m_valid)
{
throw InvalidStateException("Attempted to access an invalid FileCollection");
}
}
示例8: InvalidStateException
/**********************************************************************************************
*
* ReadReference
*
* Reference = EntityReference | CharacterReference ;
*
* CharacterReference = "&#" [0-9]+ ";" | "&#x" [0-9a-fA-F]+ ";" ;
*
* EntityReference = "<" | "&" | ">" | """ | "'" ;
*
*********************************************************************************************/
void XMLParser::ReadReference () {
if (current == '&') ReadCharacter ();
else throw InvalidStateException ();
if (current == '#') {
if (current == 'x') {
/* hexadecimal encoded unicode character. */
while (ReadCharacter ()) {
// TODO ...
if (current == ';') break;
}
} else {
/* decimal encoded unicode character. */
do {
// TODO ...
if (current == ';') break;
} while (ReadCharacter ());
}
} else {
/* named entity */
do {
// TODO ...
if (current == ';') break;
} while (ReadCharacter ());
}
}
示例9: GetWidth
//=================================================================
// Texture3D::GetVolumeData
//---------------------------------------
void Texture3D::GetVolumeData(VolumeData &volume) const
{
if( Bind() )
{
// Make sure our volume has correct data size
// we may have to recreate it
UInt32 ownWidth = GetWidth();
UInt32 ownHeight = GetHeight();
UInt32 ownDepth = GetWidth();
if( ownWidth != volume.GetWidth()
|| ownHeight != volume.GetHeight()
|| ownDepth != volume.GetDepth() )
{
volume.Create( ownWidth, ownHeight, ownDepth );
}
UInt8 *volumeData = volume.GetData();
glGetTexImage(
GL_TEXTURE_3D,
MIP_MAP_LEVEL_0,
GL_RGBA,
GL_UNSIGNED_BYTE,
(GLvoid*) volumeData
);
}
else
{
throw InvalidStateException();
}
}
示例10: Read
APDU MockAppLayer::Read()
{
if(mFragments.size() == 0) throw InvalidStateException(LOCATION, "no more fragments");
APDU frag = mFragments.front();
frag.Interpret();
mFragments.pop_front();
return frag;
}
示例11: Get
const T& Get() const {
if (!m_data) {
throw InvalidStateException("Object is empty.");
}
if (std::type_index(typeid(T)) != m_data->Type()) {
throw std::bad_cast("Types don't match.");
}
return *reinterpret_cast<const T*>(m_data->Get());
}
示例12: switch
bool ControlTaskBase::GetSelectBit()
{
switch(mState) {
case(SELECT): return true;
case(OPERATE): return false;
default:
throw InvalidStateException(LOCATION, "INVALID");
}
}
示例13: ReadFunction
FunctionCodes MockAppLayer::ReadFunction()
{
if(mFragments.size() == 0) throw InvalidStateException(LOCATION, "No more fragments");
else {
FunctionCodes func = mFragments.front().GetFunction();
mFragments.pop_front();
return func;
}
}
示例14: InvalidStateException
/** \brief Define the level of compression to use by this FileEntry.
*
* This function saves the level of compression the library should use
* to compress the file before saving it in the output file.
*
* \note
* If the StorageMethod is set to STORED, then the compression level is
* ignored, but it is left unchanged.
*
* \exception InvalidStateException
* This function raises this exception if the specified level is out of
* the allowed range.
*
* \param[in] level The compression level to use to compress the file data.
*/
void FileEntry::setLevel(CompressionLevel level)
{
if(level < COMPRESSION_LEVEL_DEFAULT || level > COMPRESSION_LEVEL_MAXIMUM)
{
throw InvalidStateException("level must be between COMPRESSION_LEVEL_DEFAULT and COMPRESSION_LEVEL_MAXIMUM");
}
if(isDirectory())
{
if(level >= COMPRESSION_LEVEL_MINIMUM)
{
throw InvalidStateException("directories cannot be marked with a compression level other than COMPRESSION_LEVEL_NONE (defaults will also work");
}
m_compression_level = COMPRESSION_LEVEL_NONE;
}
else
{
m_compression_level = level;
}
}
示例15: InvalidStateException
/** \brief Write the ZipEndOfCentralDirectory structure to a stream.
*
* This function writes the currently defined end of central
* directory to disk. This entry is expected to be written at
* the very end of a Zip archive file.
*
* \note
* If the output pointer is not valid, the function will throw
* via the various zipWrite() it uses.
*
* \note
* The function does not change the output pointer of the stream
* before writing to it.
*
* \exception FileCollectionException
* This function throws this exception if the data cannot be saved. In
* general this means there are too many entries, the size is too large
* or the comment is more than 64Kb (some of which will be resolved with
* Zip64 support.)
*
* \param[in] os The output stream where the data is to be saved.
*/
void ZipEndOfCentralDirectory::write(std::ostream& os)
{
/** \TODO
* Add support for 64 bit Zip archive. This would allow for pretty
* much all the following conditions to be dropped out.
*/
if(m_zip_comment.length() > 65535)
{
throw InvalidStateException("the Zip archive comment is too large");
}
if(m_central_directory_entries > 65535)
{
throw InvalidStateException("the number of entries in the Zip archive is too large");
}
// Solaris defines _ILP32 for 32 bit platforms
#if !defined(_ILP32)
if(m_central_directory_size >= 0x100000000UL
|| m_central_directory_offset >= 0x100000000L)
{
throw FileCollectionException("the Zip archive size or offset are too large"); // LCOV_EXCL_LINE
}
#endif
uint16_t const disk_number(0);
uint16_t const central_directory_entries(m_central_directory_entries);
uint32_t const central_directory_size(m_central_directory_size);
uint32_t const central_directory_offset(m_central_directory_offset);
uint16_t const comment_len(m_zip_comment.length());
// the total number of entries, across all disks is the same in our
// case so we use one number for both fields
zipWrite(os, g_signature); // 32
zipWrite(os, disk_number); // 16
zipWrite(os, disk_number); // 16
zipWrite(os, central_directory_entries); // 16
zipWrite(os, central_directory_entries); // 16
zipWrite(os, central_directory_size); // 32
zipWrite(os, central_directory_offset); // 32
zipWrite(os, comment_len); // 16
zipWrite(os, m_zip_comment); // string
}