void AudioParamTimeline::insertEvent(const ParamEvent& event)
{
    // Sanity check the event. Be super careful we're not getting infected with NaN or Inf.
    bool isValid = event.type() < ParamEvent::LastType
        && isValidNumber(event.value())
        && isValidNumber(event.time())
        && isValidNumber(event.timeConstant())
        && isValidNumber(event.duration())
        && event.duration() >= 0;

    ASSERT(isValid);
    if (!isValid)
        return;
        
    std::lock_guard<Lock> lock(m_eventsMutex);
    
    unsigned i = 0;
    float insertTime = event.time();
    for (auto& paramEvent : m_events) {
        // Overwrite same event type and time.
        if (paramEvent.time() == insertTime && paramEvent.type() == event.type()) {
            paramEvent = event;
            return;
        }

        if (paramEvent.time() > insertTime)
            break;

        ++i;
    }

    m_events.insert(i, event);
}
Esempio n. 2
0
void getIP(vector<string> &res, string &sol, string s, int start, int level) {
    if (level == 4) {
	    if (start == s.length()) {
		    sol.pop_back();
		    res.push_back(sol);
	    }
	    return;
    }
    if (start == s.length()) return;
    
    // push 1 number
    int len = sol.length();
    if (isValidNumber(s.substr(start, 1))) {
	    sol += s.substr(start, 1) + ".";
	    getIP(res, sol, s, start+1, level+1);
	    sol.resize(len);
    }
    // push 2 numbers
    if (start+2 <= s.length() && isValidNumber(s.substr(start, 2))) {
	    sol += s.substr(start, 2) + ".";
	    getIP(res, sol, s, start+2, level+1);
	    sol.resize(len);
    }
    // push 3 numbers
    if (start+3 <= s.length() && isValidNumber(s.substr(start, 3))) {
	    sol += s.substr(start, 3) + ".";
	    getIP(res, sol, s, start+3, level+1);
	    sol.resize(len);
    }
}
void AudioParamTimeline::insertEvent(const ParamEvent& event)
{
    // Sanity check the event. Be super careful we're not getting infected with NaN or Inf.
    bool isValid = event.type() < ParamEvent::LastType
                   && isValidNumber(event.value())
                   && isValidNumber(event.time())
                   && isValidNumber(event.timeConstant())
                   && isValidNumber(event.duration())
                   && event.duration() >= 0;

    ASSERT(isValid);
    if (!isValid)
        return;

    MutexLocker locker(m_eventsLock);

    unsigned i = 0;
    float insertTime = event.time();
    for (i = 0; i < m_events.size(); ++i) {
        // Overwrite same event type and time.
        if (m_events[i].time() == insertTime && m_events[i].type() == event.type()) {
            m_events[i] = event;
            return;
        }

        if (m_events[i].time() > insertTime)
            break;
    }

    m_events.insert(i, event);
}
Esempio n. 4
0
    /*!
        \fn bool QDBusUtil::isValidBusName(const QString &busName)
        Returns true if \a busName is a valid bus name.

        A valid bus name is either a valid unique connection name or follows the rules:
        \list
          \o is not empty
          \o does not exceed 255 characters in length
          \o be composed of dot-separated string components that contain only ASCII letters, digits,
             hyphens or underscores ("_"), but don't start with a digit
          \o contains at least two such elements
        \endlist

        \sa isValidUniqueConnectionName()
    */
    bool isValidBusName(const QString &busName)
    {
        if (busName.isEmpty() || busName.length() > DBUS_MAXIMUM_NAME_LENGTH)
            return false;

        if (busName.startsWith(QLatin1Char(':')))
            return isValidUniqueConnectionName(busName);

        QStringList parts = busName.split(QLatin1Char('.'));
        if (parts.count() < 1)
            return false;

        for (int i = 0; i < parts.count(); ++i) {
            const QString &part = parts.at(i);
            if (part.isEmpty())
                return false;

            const QChar *c = part.unicode();
            if (isValidNumber(c[0]))
                return false;
            for (int j = 0; j < part.length(); ++j)
                if (!isValidCharacter(c[j]))
                    return false;
        }

        return true;
    }
Esempio n. 5
0
//自分の数字を決める
void Human::SelectMyNumber(){
	do{
		//人間は標準入力で数字を決める
		cout << this->name << " >> My number is ..";
		cin >> this->number;
	} while (isValidNumber(this->number) == false);
}
Esempio n. 6
0
bool SR865::setSensivity(const int &new_sensivity) const
{
    if (!isValidNumber(this->sensivityList, new_sensivity))
        return false;

    QString command = "SCAL " + QString::number(new_sensivity);
    return sendCommand(command);
}
Esempio n. 7
0
bool SR865::setCurrentInputGain(const int &new_currentInputGain) const
{
    if (!isValidNumber(this->currrentInputGainList, new_currentInputGain))
        return false;

    QString command = "ICUR " + QString::number(new_currentInputGain);
    return sendCommand(command);
}
Esempio n. 8
0
bool SR865::setVoltageInputRange(const int &new_voltageInputRange) const
{
    if (!isValidNumber(this->voltageInputRangeList, new_voltageInputRange))
        return false;

    QString command = "IRNG " + QString::number(new_voltageInputRange);
    return sendCommand(command);
}
Esempio n. 9
0
bool SR865::setVoltageInputCoupling(const int &new_voltageInputCoupling) const
{
    if (!isValidNumber(this->voltageInputCouplingList, new_voltageInputCoupling))
        return false;

    QString command = "ICPL " + QString::number(new_voltageInputCoupling);
    return sendCommand(command);
}
Esempio n. 10
0
bool SR865::setSignalInput(const int &new_signalInput) const
{
    if (!isValidNumber(this->signalInputList, new_signalInput))
        return false;

    QString command = "IVMD " + QString::number(new_signalInput);
    return sendCommand(command);
}
Esempio n. 11
0
bool SR865::setReferenceSource(const int &new_source) const
{
    if (!isValidNumber(this->referenceSourceList, new_source))
        return false;

    QString command = "RSRC " + QString::number(new_source);
    return sendCommand(command);
}
Esempio n. 12
0
double SR865::getOUTP(const int &i) const
{
    if (!isValidNumber(this->outputNumberListLongName, i))
        return 0;

    QString command = "OUTP? " + QString::number(i);
    return ask(command).trimmed().toDouble();
}
Esempio n. 13
0
bool DS345::setModulationType(const int &new_type) const
{
    if (!isValidNumber(this->modulationTypeList, new_type))
        return false;

    QString command = "MTYP " + QString::number(new_type);
    return sendCommand(command);
}
Esempio n. 14
0
bool DS345::setModulationFunction(const int &new_function) const
{
    if (!isValidNumber(this->modulationFunctionList, new_function))
        return false;

    QString command = "MDWF " + QString::number(new_function);
    return sendCommand(command);
}
Esempio n. 15
0
bool SR865::setTimeConstant(const int &new_timeConstant) const
{
    if (!isValidNumber(this->timeConstantList, new_timeConstant))
        return false;

    QString command = "OFLT " + QString::number(new_timeConstant);
    return sendCommand(command);
}
Esempio n. 16
0
bool SR865::setFilter(const int &new_filter) const
{
    if (!isValidNumber(this->filterList, new_filter))
        return false;

    QString command = "OFSL " + QString::number(new_filter);
    return sendCommand(command);
}
Esempio n. 17
0
bool SR865::setReferenceTriggerOutputZ(const int &new_mode) const
{
    if (!isValidNumber(this->referenceTriggerOutputZList, new_mode))
        return false;

    QString command = "REFZ " + QString::number(new_mode);
    return sendCommand(command);
}
Esempio n. 18
0
bool SR865::setVoltageInputShields(const int &new_voltageInputShields) const
{
    if (!isValidNumber(this->voltageInputShieldsList, new_voltageInputShields))
        return false;

    QString command = "IGND " + QString::number(new_voltageInputShields);
    return sendCommand(command);
}
Esempio n. 19
0
//質問する数字を選ぶ
int Human::SendQuery(){
	ShowQueryHistory();	//質問履歴の表示
	int test;
	do{
		cout << name << " >> I guess your number is..";
		cin >> test;
	} while (isValidNumber(test) == false);
	return test;
}
Esempio n. 20
0
    /*!
        \fn bool QDBusUtil::isValidMemberName(const QString &memberName)
        Returns true if \a memberName is a valid member name. A valid member name does not exceed
        255 characters in length, is not empty, is composed only of ASCII letters, digits and
        underscores, but does not start with a digit.
    */
    bool isValidMemberName(const QString &memberName)
    {
        if (memberName.isEmpty() || memberName.length() > DBUS_MAXIMUM_NAME_LENGTH)
            return false;

        const QChar* c = memberName.unicode();
        if (isValidNumber(c[0]))
            return false;
        for (int j = 0; j < memberName.length(); ++j)
            if (!isValidCharacterNoDash(c[j]))
                return false;
        return true;
    }
Esempio n. 21
0
int main(void)
{
	char naturalInput[256];
	int naturalLength;
		
		while(1)
		{
			printf("Input a natural number in decimal representation.\n");
			printf(">");
			
			fgets(naturalInput, 256, stdin);
			
			removeNewline(naturalInput);	//Remove newline character from array.
			
			naturalLength = strlen(naturalInput);
			
			if(isValidNumber(naturalInput, naturalLength) == 1)	//Check if array contains non-digits.
				outputBinary(naturalInput);
			else
				printf("\nPlease input a natural number in decimal representation.\n");
		}
		
	return 0;
}
Esempio n. 22
0
/*This function is used to validate the commands in the text file and returns wheter a move is valid or not (true/ false)*/
int isValidMove(char line[], FILE* inputFile)
{
    /*Instance variables used in tokenization*/
    char *token, tokens[2][20];

    /*Array of all valid keywords (excluding comments)*/
    char keywords[10][14] = {"forward", "reverse", "turnright", "turnleft", "pause", "loop", "light", "reset", "on", "off"};

    /*Counter variable*/
    int counter;

    /*Creates token*/
    token = removeWhiteSpace(strtok( line, " \t\n" ));

    /*If token is empty or begins with a '#', the move is valid (must be a comment or empty line)*/
    if (token == NULL || strncmp(token, "#", 1) == 0)
        return true;

    /*Store the token*/
    else
        strcpy(tokens[0], token);

    /*Create another token*/
    token = removeWhiteSpace(strtok( NULL , " \t\n" ));

    /*If this token is empty and the command was reset*/
    if (token == NULL && strcmp(tokens[0], keywords[7]) == 0)
        return true;

    /*If this token is empty (reset is the only keyword not followed by a word or number)*/
    else if (token == NULL)
        return false;

    else

        /*Store the second token */
        strcpy(tokens[1], token);

    /*Makes sure there is not a third keyword in the line (not a valid command)*/
    if (strtok( NULL, " \t\n" ) == NULL)
    {
        /*Checks to see if the command (first token stored is one of the commands that require a number)*/
        /*Forward, reverse, turnleft, turnrignt, pause, loop*/
        for (counter = 0; counter  < 6; counter++)
        {
            /*If the first token was one of the commands and the second one was a valid number*/
            if (strcmp(tokens[0], keywords[counter]) == 0 && isValidNumber(tokens[1]) == true)
            {
                /*Checks to see if the keyword was a loop (loops require special validation)*/
                if (counter == 5)
                    /*Will either be true or false*/
                    return isValidLoop(inputFile);

                return true;
            }
        }

        /*If the command was light and the second keyword was valid (on/off)*/
        if ((strcmp(tokens[0], keywords[6]) == 0) && (strcmp(tokens[1], keywords[8]) == 0 || strcmp(tokens[1], keywords[9]) == 0))
        {
            return true;
        }
    }

    /*If nothing is true then move must be invalid*/
    return false;
}