Exemplo n.º 1
0
/**
 * Overwridden add member to attach the name to the workspace when a workspace
 * object is added to the service
 * If the name already exists then this throws a std::runtime_error. If a
 * workspace group is added adds the
 * members which are not in the ADS yet.
 * @param name The name of the object
 * @param workspace The shared pointer to the workspace to store
 */
void AnalysisDataServiceImpl::add(
    const std::string &name,
    const boost::shared_ptr<API::Workspace> &workspace) {
  verifyName(name);
  // Attach the name to the workspace
  if (workspace)
    workspace->setName(name);
  Kernel::DataService<API::Workspace>::add(name, workspace);

  // if a group is added add its members as well
  auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(workspace);
  if (!group)
    return;
  group->observeADSNotifications(true);
  for (size_t i = 0; i < group->size(); ++i) {
    auto ws = group->getItem(i);
    std::string wsName = ws->name();
    // if anonymous make up a name and add
    if (wsName.empty()) {
      wsName = name + "_" + boost::lexical_cast<std::string>(i + 1);
    } else if (doesExist(wsName)) { // if ws is already there do nothing
      wsName.clear();
    }
    // add member workspace if needed
    if (!wsName.empty()) {
      add(wsName, ws);
    }
  }
}
Exemplo n.º 2
0
void Space::verifySpace( char* n, Verifier* aVerifier ) {
  verifyName      (n, aVerifier);
  verifyBoundaries(   aVerifier);
  verifyBytes     (   aVerifier);
  verifyObjs      (   aVerifier);
  verifySentinel  (   aVerifier);
}
Exemplo n.º 3
0
HActionInfo::HActionInfo(
    const QString& name, const HActionArguments& inputArguments,
    const HActionArguments& outputArguments, bool hasRetVal,
    HInclusionRequirement ireq, QString* err) :
        h_ptr(new HActionInfoPrivate())
{
    if (!verifyName(name, err))
    {
        return;
    }

    if (!outputArguments.size() && hasRetVal)
    {
        if (err)
        {
            *err = "Cannot contain a return value when no output arguments "
                   "are specified";
        }
        return;
    }

    h_ptr->m_name = name;

    h_ptr->m_inputArguments = inputArguments;
    h_ptr->m_outputArguments = outputArguments;

    h_ptr->m_hasRetValArg = hasRetVal;
    h_ptr->m_inclusionRequirement = ireq;
}
Exemplo n.º 4
0
bool HActionSetup::setName(const QString& name, QString* err)
{
    if (verifyName(name, err))
    {
        h_ptr->m_name = name;
        return true;
    }

    return false;
}
Exemplo n.º 5
0
bool HStateVariableInfoPrivate::setName(const QString& name, QString* err)
{
    if (verifyName(name, err))
    {
        m_name = name;
        return true;
    }

    return false;
}
Exemplo n.º 6
0
HActionInfo::HActionInfo(
    const QString& name, HInclusionRequirement ireq, QString* err) :
        h_ptr(new HActionInfoPrivate())
{
    if (!verifyName(name, err))
    {
        return;
    }

    h_ptr->m_name = name;
    h_ptr->m_inclusionRequirement = ireq;
}
Exemplo n.º 7
0
Variable::Variable(String const &name, Value *initial, Flags const &m)
    : d(new Instance)
{
    d->name = name;
    d->mode = m;

    std::auto_ptr<Value> v(initial);
    if(!initial)
    {
        v.reset(new NoneValue);
    }
    verifyName(d->name);
    verifyValid(*v);
    d->value = v.release();
}
Exemplo n.º 8
0
void Java_java_lang_Class_forName(void)
{
    START_TEMPORARY_ROOTS
        DECLARE_TEMPORARY_ROOT(STRING_INSTANCE, string, 
                               topStackAsType(STRING_INSTANCE));
    
        if (string == NULL) {
            raiseException(NullPointerException);
        } else {
            long length = string->length;
            CLASS thisClass = NULL;
            DECLARE_TEMPORARY_ROOT(char*, className, mallocBytes(length + 1));
            getStringContentsSafely(string, className, length + 1);
            if (strchr(className, '/') == NULL) {
                replaceLetters(className,'.','/');
                if (verifyName(className, LegalClass, FALSE)) {
                    thisClass = 
                        getClassX((CONST_CHAR_HANDLE)&className, 0, length);
                    /* The specification does not require that the current
                     * class have "access" to thisClass */
                }
            }
            if (thisClass != NULL) {
                topStackAsType(CLASS) = thisClass;
                if (!IS_ARRAY_CLASS(thisClass)) {
                    if (!CLASS_INITIALIZED((INSTANCE_CLASS)thisClass)) {
                        initializeClass((INSTANCE_CLASS)thisClass);
                    }
                }
            } else { 
                raiseExceptionMsg("java/lang/ClassNotFoundException", 
                                  string);
            }
        }
    END_TEMPORARY_ROOTS
}
Exemplo n.º 9
0
void GpxFileParser::parse(const QString &name) {
    qDebug() << __FUNCTION__ << name;

    m_cacheList.clear();

    // check for file type
    QFileInfo info(name);
    if(!info.suffix().compare("zip", Qt::CaseInsensitive)) {
        qDebug() << __FUNCTION__ << "ZIP file detected";

        QuaZip zip(name);
        if(!zip.open(QuaZip::mdUnzip)) {
            emit failed(QObject::tr("Cannot open file %1: Code %2")
                        .arg(zip.getZipName()).arg(zip.getZipError()));

            return;
        }

        qDebug() << __FUNCTION__ << "ZIP file opened";

        for(bool m=zip.goToFirstFile(); m; m=zip.goToNextFile()) {
            QString gpxName = zip.getCurrentFileName();

            // check if filename is not a waypoint file name
            if(!filenameIsWaypoint(gpxName)) {
                qDebug() << __FUNCTION__ << "found" << gpxName;

                QuaZipFile file(&zip);
                if(!file.open(QIODevice::ReadOnly)) {
                    QString errorStr = QObject::tr("Cannot open file %1 for reading:\n%2")
                                       .arg(gpxName).arg(file.errorString());

                    zip.close();
                    emit failed(errorStr);
                    return;
                }

                // parse file
                QString errorStr = parseGpxFile(file);
                file.close();

                // try to also load waypoints from zip file
                if(!errorStr.isEmpty()) {
                    emit failed(errorStr);
                    return;
                }

                QString wptName = gpxName.insert(gpxName.length()-4,"-wpts");

                if(zip.setCurrentFile(wptName, QuaZip::csInsensitive)) {

                    QuaZipFile file(&zip);
                    if(file.open(QIODevice::ReadOnly)) {
                        qDebug() << __FUNCTION__ << "found matching" << wptName;

                        parseGpxWptFile(file);

                        file.close();
                    }
                }

                // don't try to process another file from the zip
                break;
            }
        }

        if(zip.getZipError() != UNZ_OK) {
            QString errorStr = QObject::tr("Zip error in %1: Code %2")
                               .arg(zip.getCurrentFileName()).arg(zip.getZipError());
            zip.close();
            emit failed(errorStr);
            return;
        }

        zip.close();

        qDebug() << __FUNCTION__ << "ZIP done";
    } else if(!info.suffix().compare("gpx", Qt::CaseInsensitive) ||
              !info.suffix().compare("loc", Qt::CaseInsensitive)) {

        // check if user requests to load a waypoint file
        if(filenameIsWaypoint(name)) {
            emit failed(QObject::tr("File is a waypoint file"));
            return;
        }

        QFile file( name );
        if (!file.open(QFile::ReadOnly | QFile::Text)) {
            emit failed(QObject::tr("Cannot open file %1 for reading:\n%2")
                        .arg(file.fileName()).arg(file.errorString()));
            return;
        }

        QString errorStr = parseGpxFile(file);
        file.close();

        if(!errorStr.isEmpty()) {
            emit failed(errorStr);
            return;
        }

        QString wptName(name);
        wptName.insert(wptName.length()-4,"-wpts");
        qDebug() << __FUNCTION__ << "trying to open " << wptName;
        QFile wptFile( wptName );
        if (wptFile.open(QFile::ReadOnly | QFile::Text)) {
            qDebug() << __FUNCTION__ << "found matching" << wptName;

            parseGpxWptFile(wptFile);

            file.close();
        }

    } else {
        emit failed(QObject::tr("Unsupported file type: %1").arg(info.suffix()));
        return;
    }

    if(!m_name.isEmpty())
        verifyName(m_cacheList, m_name);

    emit succeeded(m_cacheList);
}