示例#1
0
void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget)
{
    if (Q_GTK_IS_WIDGET(widget)) {
        gtk_widget_realize(widget);
        QHashableLatin1Literal widgetPath = classPath(widget);

        removeWidgetFromMap(widgetPath);
        gtkWidgetMap()->insert(widgetPath, widget);
#ifdef DUMP_GTK_WIDGET_TREE
        qWarning("Inserted Gtk Widget: %s", widgetPath.data());
#endif
    }
 }
示例#2
0
string MRJSession::getClassPath()
{
    // to work around problem in Mac OS X 10.2 (Jaguar) (bugzilla #164712),
    // put our classes in the boot class path.
    string classPath("-Xbootclasspath/p:");
    
    // keep appending paths make from FSSpecs.
    MRJClassPath::const_iterator i = mClassPath.begin();
    if (i != mClassPath.end()) {
        char path[1024];
        if (ref2path(*i, path, sizeof(path)) == noErr)
            classPath += path;
        ++i;
        while (i != mClassPath.end()) {
            if (ref2path(*i, path, sizeof(path)) == noErr) {
                classPath += ":";
                classPath += path;
            }    
            ++i;
        }
    }

    return classPath;
}
示例#3
0
int main(int argc, char** argv)
{
    CIMClient               client;
    Boolean                 verbose = false;
    Uint32                  numObjects;
    Array<CIMObjectPath>    resultObjectPaths;
    Array<CIMObject>        resultObjects;
    CIMName                 assocClass;
    CIMName                 resultClass;
    String                  role;
    String                  resultRole;

    //
    // Check command line option
    //
    if (argc > 2)
    {
        cerr << "Usage: AssociationClient [-v]" << endl;
        return 1;
    }

    if (argc == 2)
    {
        const char *opt = argv[1];
        if (strcmp(opt, "-v") == 0)
        {
            verbose = true;
        }
        else
        {
            cerr << "Usage: AssociationClient [-v]" << endl;
            return 1;
        }
    }

    try
    {
        // ===================================================================
        // connectLocal
        //
        // The connectLocal Client API creates a connection to the server for
        // a local client.  The connection is automatically authenticated
        // for the current user.  (The connect Client API can be used to create
        // an HTTP connection with the server defined by the URL in address.
        // User name and Password information can be passed using the connect
        // Client API.)
        // ===================================================================

        client.connectLocal();

        // ===================================================================
        // associators
        //
        // Get the CIM instances (Sample_Student instances) that are associated
        // to the source CIM instance (Sample_Teacher.Name = "Teacher1") via an
        // instance of the Sample_TeacherStudent association class.
        // ===================================================================

        assocClass = SAMPLE_TEACHERSTUDENT;
        CIMObjectPath instancePath("Sample_Teacher.Name=\"Teacher1\"");

        resultObjects = client.associators(
                                NAMESPACE,
                                instancePath,
                                assocClass,
                                resultClass,
                                role,
                                resultRole);

        // verify result
        numObjects  = resultObjects.size();
        if (_verifyResult(numObjects, 3) != 0)
            return -1;

        // display result
        // cout << "Number of associator objects = " << numObjects << endl;
        _displayResult(resultObjects, verbose);

        // ===================================================================
        // associators
        //
        // Validate role and resultRole parameters syntax.
        // ===================================================================

        // invalid role parameter syntax
        String invalidRole = "Teaches_*student";

        Boolean gotException = false;
        try
        {
            resultObjects = client.associators(
                                    NAMESPACE,
                                    instancePath,
                                    assocClass,
                                    resultClass,
                                    invalidRole,
                                    resultRole);

        }
        catch (CIMException& e)
        {
            if (e.getCode() == CIM_ERR_INVALID_PARAMETER)
            {
                gotException = true;
                if (verbose)
                {
                    cout << "Test role parameter syntax: " <<
                        e.getMessage() << endl;
                }
            }
            else
            {
                throw;
            }
        }
        PEGASUS_TEST_ASSERT(gotException);

        // invalid resultRole parameter syntax
        String invalidResultRole = "3Taught_By";
        gotException = false;
        try
        {
            resultObjects = client.associators(
                                    NAMESPACE,
                                    instancePath,
                                    assocClass,
                                    resultClass,
                                    role,
                                    invalidResultRole);

        }
        catch (CIMException& e)
        {
            if (e.getCode() == CIM_ERR_INVALID_PARAMETER)
            {
                gotException = true;
                if (verbose)
                {
                    cout << "Test resultRole parameter syntax: " <<
                        e.getMessage() << endl;
                }
            }
            else
            {
                throw;
            }
        }
        PEGASUS_TEST_ASSERT(gotException);

        // ===================================================================
        // associatorNames
        //
        // Get the names of the CIM instances (Sample_Student instances) that
        // are associated to the source CIM instance (Sample_Teacher.Name =
        // "Teacher1") via an instance of the Sample_TeacherStudent association
        // class.
        // ===================================================================

        resultObjectPaths = client.associatorNames(
                                NAMESPACE,
                                instancePath,
                                assocClass,
                                resultClass,
                                role,
                                resultRole);

        // verify result
        numObjects = resultObjectPaths.size();
        if (_verifyResult(numObjects, 3) != 0)
            return -1;

        // display result
        // cout << "Number of associator name objects = " << numObjects << endl;
        _displayResult(resultObjectPaths, verbose);

        // ===================================================================
        // associatorNames
        //
        // Validate role and resultRole parameters syntax.
        // ===================================================================

        // invalid role parameter syntax
        gotException = false;
        try
        {
            resultObjectPaths = client.associatorNames(
                                    NAMESPACE,
                                    instancePath,
                                    assocClass,
                                    resultClass,
                                    invalidRole,
                                    resultRole);
        }
        catch (CIMException& e)
        {
            if (e.getCode() == CIM_ERR_INVALID_PARAMETER)
            {
                gotException = true;
                if (verbose)
                {
                    cout << "Test role parameter syntax: " <<
                        e.getMessage() << endl;
                }
            }
            else
            {
                throw;
            }
        }
        PEGASUS_TEST_ASSERT(gotException);

        // invalid resultRole parameter syntax
        gotException = false;
        try
        {
            resultObjectPaths = client.associatorNames(
                                    NAMESPACE,
                                    instancePath,
                                    assocClass,
                                    resultClass,
                                    role,
                                    invalidResultRole);
        }
        catch (CIMException& e)
        {
            if (e.getCode() == CIM_ERR_INVALID_PARAMETER)
            {
                gotException = true;
                if (verbose)
                {
                    cout << "Test resultRole parameter syntax: " <<
                        e.getMessage() << endl;
                }
            }
            else
            {
                throw;
            }
        }
        PEGASUS_TEST_ASSERT(gotException);

        // ===================================================================
        // references
        //
        // Get the association instances (Sample_TeacherStudent instances) that
        // refer to the specified target CIM instance (Sample_Teacher.Name =
        // "Teacher1").
        // ===================================================================

        resultObjects = client.references(
                                NAMESPACE,
                                instancePath,
                                resultClass,
                                role);

        // verify result
        numObjects = resultObjects.size();
        if (_verifyResult(numObjects, 5) != 0)
            return -1;

        // display result
        // cout << "Number of reference objects = " << numObjects << endl;
        _displayResult(resultObjects, verbose);

        // ===================================================================
        // references
        //
        // Validate role parameter syntax.
        // ===================================================================

        // invalid role parameter syntax
        gotException = false;
        try
        {
            resultObjects = client.references(
                                    NAMESPACE,
                                    instancePath,
                                    resultClass,
                                    invalidRole);
        }
        catch (CIMException& e)
        {
            if (e.getCode() == CIM_ERR_INVALID_PARAMETER)
            {
                gotException = true;
                if (verbose)
                {
                    cout << "Test role parameter syntax: " <<
                        e.getMessage() << endl;
                }
            }
            else
            {
                throw;
            }
        }
        PEGASUS_TEST_ASSERT(gotException);

        // ===================================================================
        // referenceNames
        //
        // Get the names of the association instances (Sample_TeacherStudent
        // instances) that refer to the specified target CIM instance
        // (Sample_Teacher.Name = "Teacher1").
        // ===================================================================

        resultObjectPaths = client.referenceNames(
                                NAMESPACE,
                                instancePath,
                                resultClass,
                                role);

        // verify result
        numObjects = resultObjectPaths.size();
        if (_verifyResult(numObjects, 5) != 0)
            return -1;

        // display result
        // cout << "Number of reference name objects = " << numObjects << endl;
        _displayResult(resultObjectPaths, verbose);

        // ===================================================================
        // referenceNames
        //
        // Validate role parameter syntax.
        // ===================================================================

        // invalid role parameter syntax
        gotException = false;
        try
        {
            resultObjectPaths = client.referenceNames(
                                        NAMESPACE,
                                        instancePath,
                                        resultClass,
                                        invalidRole);
        }
        catch (CIMException& e)
        {
            if (e.getCode() == CIM_ERR_INVALID_PARAMETER)
            {
                gotException = true;
                if (verbose)
                {
                    cout << "Test role parameter syntax: " <<
                        e.getMessage() << endl;
                }
            }
            else
            {
                throw;
            }
        }
        PEGASUS_TEST_ASSERT(gotException);

        // ===================================================================
        // Call the association methods with different filters specified.
        // Filters used are: role, resultClass, resultRole, assocClass.
        // ===================================================================

        //
        // get all the students who are taught by 'Teacher1'
        //
        role = "Teaches";
        resultRole = "TaughtBy";
        resultClass = CIMName("Sample_Student");
        assocClass = SAMPLE_TEACHERSTUDENT;

        resultObjects = client.associators(
                                NAMESPACE,
                                instancePath,
                                assocClass,
                                resultClass,
                                role,
                                resultRole);
        // verify result
        numObjects = resultObjects.size();
        if (_verifyResult(numObjects, 3) != 0)
            return -1;

        // display result
        // cout << "Number of associator objects = " << numObjects << endl;
        _displayResult(resultObjects, verbose);

        //
        // get all the students who have 'Teacher1' as an advisor
        //
        role = "Advises";
        resultRole = "AdvisedBy";
        resultClass = CIMName("Sample_Student");
        assocClass = SAMPLE_ADVISORSTUDENT;

        resultObjectPaths = client.associatorNames(
                                NAMESPACE,
                                instancePath,
                                assocClass,
                                resultClass,
                                role,
                                resultRole);

        // verify result
        numObjects = resultObjectPaths.size();
        if (_verifyResult(numObjects, 2) != 0)
            return -1;

        // display result
        // cout << "Number of associator name objects = " << numObjects << endl;
        _displayResult(resultObjectPaths, verbose);

        //
        // get all the TeacherStudent association instances in which 'Teacher1'
        // plays the role of a teacher.
        //
        role = "Teaches";
        resultClass = CIMName("Sample_TeacherStudent");

        resultObjects = client.references(
                                NAMESPACE,
                                instancePath,
                                resultClass,
                                role);

        // verify result
        numObjects = resultObjects.size();
        if (_verifyResult(numObjects, 3) != 0)
            return -1;

        // display result
        // cout << "Number of reference objects = " << numObjects << endl;
        _displayResult(resultObjects, verbose);

        //
        // get all the AdvisorStudent association instances in which 'Teacher1'
        // plays the role of an advisor.
        //
        role = "Advises";
        resultClass = CIMName("Sample_AdvisorStudent");

        resultObjectPaths = client.referenceNames(
                                NAMESPACE,
                                instancePath,
                                resultClass,
                                role);

        // verify result
        numObjects = resultObjectPaths.size();
        if (_verifyResult(numObjects, 2) != 0)
            return -1;

        // display result
        // cout << "Number of reference objects = " << numObjects << endl;
        _displayResult(resultObjectPaths, verbose);

        // ===================================================================
        // Pass Class object to the Association Methods
        // ===================================================================

        //
        // get the CIM classes that are associated with the Sample_Teacher class
        //
        CIMObjectPath classPath("Sample_Teacher");
        assocClass = CIMName();
        resultClass = CIMName();
        role = String::EMPTY;
        resultRole = String::EMPTY;

        resultObjects = client.associators(
                                NAMESPACE,
                                classPath,
                                assocClass,
                                resultClass,
                                role,
                                resultRole);

        // verify result
        numObjects  = resultObjects.size();
        if (_verifyResult(numObjects, 1) != 0)
            return -1;

        // display result
        // cout << "Number of associated class objects = " <<
        //     numObjects << endl;
        _displayResult(resultObjects, verbose);

        //
        // get the association classes that refer to the Sample_Teacher class
        //
        resultObjects = client.references(
                                NAMESPACE,
                                classPath,
                                resultClass,
                                role);

        // verify result
        numObjects  = resultObjects.size();
        if (_verifyResult(numObjects, 2) != 0)
            return -1;

        // display result
        // cout << "Number of association class objects = " <<
        //     numObjects << endl;
        _displayResult(resultObjects, verbose);
    }
    catch (Exception& e)
    {
        cerr << "Error: " << e.getMessage() << endl;
        return -1;
    }

    cout << "AssociationClient +++++ passed all tests" << endl;

    return 0;
}