Exemplo n.º 1
0
/**
 * Copy the internal presentation of this object into the new
 * object.
 */
void UMLEntityConstraintList::copyInto(UMLEntityConstraintList* rhs) const
{
    // Don't copy yourself.
    if (rhs == this) return;

    rhs->clear();

    // Suffering from const; we shall not modify our object.
    UMLEntityConstraintList* tmp = new UMLEntityConstraintList(*this);

    UMLEntityConstraint* item;
    for (UMLEntityConstraintListIt ecit(*tmp); ecit.hasNext() ;) {
        item = ecit.next();
        rhs->append((UMLEntityConstraint*)item->clone());
    }
    delete tmp;
}
Exemplo n.º 2
0
int
main(int argc, char* argv[])
{
	int result = AAFRESULT_SUCCESS;
	int osReturn = EXIT_SUCCESS;
	testMode_t testMode = kAAFUnitTestReadWrite;
	bool help = false;
	bool list = false;
	bool filter = false;
	bool terse = false;
	bool isEncodingNameSpecified = false;
	std::wstring encodingName;

	wchar_t** wargv=new wchar_t*[argc+1];
	wargv[argc]=0;
	for (int i=0; i<argc; ++i) {
		size_t argSize=strlen(argv[i])+1;
		wargv[i]=new wchar_t[argSize];
		if (mbstowcs(wargv[i], argv[i], argSize)==static_cast<size_t>(-1)) {
			std::wcerr << L"ERROR: Cannot convert arguments to wide characters." << std::endl;
			return EXIT_FAILURE;
		}
	}

	// Create the module test object.
	CAAFModuleTest AAFModuleTest;
	try
	{
		HRESULT hr = S_OK;

		int startArg=1;
		for ( ; startArg<argc && wargv[startArg][0]==L'-'; ++startArg) {
			std::wstring options(wargv[startArg]+1);
			if (options==L"--") {
				break;
			}
			if (options.empty()) {
				std::wcerr << L"ERROR: The - option specifier has no option" << std::endl;
				osReturn=EXIT_FAILURE;
				continue;
			} else if (options==L"--help") {
				options='h';
			} else if (options==L"--list") {
				options='l';
			} else if (options==L"--read") {
				options='r';
			} else if (options==L"--skip") {
				options='s';
			} else if (options==L"--terse") {
				options='s';
			} else if (options==L"--encoding") {
				options='e';
			}
			for (std::wstring::const_iterator cit(options.begin()), ecit(options.end())
				; cit<ecit
				; ++cit)
			{
				switch (*cit) {
					case L'h':
						help = true;
						break;
					case L'l':
						// List the AAF class names, one per line, in the order that the tests will be run.
						// This can be used for more selective automated testing...
						list = true;
						break;
					case L'r':
						testMode = kAAFUnitTestReadOnly;
						break;
					case L's':
						filter = true;
						break;
					case L't':
						terse = true;
						break;
					case L'e':
						if (startArg < (argc-1)) {
							encodingName=wargv[++startArg];
							isEncodingNameSpecified = true;
						} else {
							std::wcerr << L"ERROR: The -e option requires an option argument" << std::endl;
							osReturn=EXIT_FAILURE;
						}
						break;
					default:
						std::wcerr << L"ERROR: The -" << *cit << L" option is not valid" << std::endl;
						osReturn=EXIT_FAILURE;
				}
			}
		}
		if (filter && startArg>=argc) {
			std::wcerr << L"ERROR: The -s (skip tests) option requires one or more tests to be specified" << std::endl;
			osReturn=EXIT_FAILURE;
		}
		if (terse && startArg>=argc) {
			std::wcerr << L"ERROR: The -t (terse) option requires one or more tests to be specified" << std::endl;
			osReturn=EXIT_FAILURE;
		}
		if (help || osReturn!=EXIT_SUCCESS) {
			std::wcout << std::endl
				<< L"ComModTestAAF [-hlrs] [-e file_encoding] [test1 test2 ...]" << std::endl
				<< L" No arguments --> To run all tests" << std::endl
				<< L" Otherwise any AAF object class name can be typed" << std::endl
				<< L" and that objects test method will be executed." << std::endl
				<< L" example: AAFSegment AAFTransition etc" << std::endl << std::endl
				<< L" -h : Produce this help" << std::endl
				<< L" -l : Print list of all tests and available encodings" << std::endl
				<< L" -r : Run read/only tests for regression and cross-platform testing" << std::endl
				<< L" -s : Skip specified test(s) - use with -r for tests not supported in earlier releases" << std::endl
				<< L" -t : Terse output for specified test(s)" << std::endl
				<< L" -e : Use to test with file encoding other than the default Structured Storage encoding" << std::endl;
			listFileEncodings();
			std::wcout << std::endl
				<< L" --help, --list, --read, --skip, --terse, and --encoding are also supported" << std::endl
				<< std::endl;
			return osReturn;
		}
		if (list) {
			AAFModuleTest.ListObjectMap();
			AAFRESULT ar=AAFModuleTest.ListEncodings();
			if (ar!=AAFRESULT_SUCCESS) {
				throw ar;
			}
			return EXIT_SUCCESS;
		}

		// Make sure the dll can be loaded and initialized.
		CAAFInitialize aafInit;

		// Make sure the shared plugins can be loaded and registered.
		CAAFInitializePlugins aafInitPlugins;

		// If encoding name is specified change the
		// default value of file encoding to be used
		// by module tests.
		aafUID_t fileKind = testFileKindDefault;
		testRawStorageType_t rawStorageType = kAAFNamedFile;
		if (!encodingName.empty()) {
			if (FindFileEncodingByName(encodingName.c_str(), &fileKind)!= AAFRESULT_SUCCESS)
			{
				std::wcerr << L"ERROR: Failed to find the specified file encoding -- " << encodingName << std::endl;
				return EXIT_FAILURE;
			}
            if (fileKind != aafFileKindAafXmlText)
            {
                // Always use disk raw storage if file encoding is specified and is 
                // not the XML file encoding
                // The XML file encoding is a multi-file format and does not support the
                // "single file" raw storage type
                rawStorageType = kAAFDiskRawStorage;
            }
		}

		if (startArg >= argc)
		{
			// Call all Module tests...
			hr = AAFModuleTest.Test(testMode
				, fileKind
				, rawStorageType
			);
		}
		else
		{
			// Call only the modules that are named in the command line.
			hr = AAFModuleTest.Test(testMode
				, fileKind
				, rawStorageType
				, argc-startArg
				, &wargv[startArg]
				, filter
				, terse
			);
		}
		result = (int)hr;
	}
	catch (HRESULT& rhr)
	{
		result = rhr;
	}
	catch (...)
	{
		result = AAFRESULT_TEST_FAILED;
	}

	for (int k=0; k<argc; ++k) {
	  delete [] wargv[k];
	}
	delete [] wargv;

	// Translate AAFRESULTs into an exit status.
	// Only the 8 least significant bits are available to a waiting parent
	// (see IEEE Std 1003.1) and by convention the 8th bit (values over 127)
	// is reserved to indicate core dumped (GNU C Library manual 25.6.2).

	if (result == AAFRESULT_SUCCESS)
		return EXIT_SUCCESS;
	else
		return EXIT_FAILURE;		// Test failed or test could not run
}