summaryrefslogtreecommitdiffstats
path: root/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util
diff options
context:
space:
mode:
Diffstat (limited to 'tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util')
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp45
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h48
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp213
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Exceptions.h190
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/File.cpp224
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/File.h135
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp51
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.h55
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Library.cpp160
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Library.h99
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp34
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/LogWriter.h49
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logger.cpp109
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logger.h91
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logging.h67
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Utils.cpp562
-rw-r--r--tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Utils.h69
17 files changed, 0 insertions, 2201 deletions
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp
deleted file mode 100644
index 7b0b535523..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#include "tuscany/sca/util/DefaultLogWriter.h"
-#include <iostream>
-using namespace std;
-
-namespace tuscany
-{
- namespace sca
- {
- DefaultLogWriter::~DefaultLogWriter()
- {
- }
-
- void DefaultLogWriter::log(int level, const char* msg)
- {
- for (int i=0; i < level; i++)
- {
- cout << " ";
- }
- cout << msg <<endl;
- }
-
- } // End namespace sca
-} // End namespace tuscany
-
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h
deleted file mode 100644
index 2c797010d0..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_defaultlogwriter_h
-#define tuscany_sca_util_defaultlogwriter_h
-
-#include "tuscany/sca/util/LogWriter.h"
-
-namespace tuscany
-{
- namespace sca
- {
- /**
- * Log writer to write out to standard out.
- */
- class DefaultLogWriter : public LogWriter
- {
- public:
- virtual ~DefaultLogWriter();
-
- /**
- * Will write to the console.
- * See LogWriter#log.
- */
- virtual void log(int level, const char* msg);
- };
-
- } // End namespace sca
-} // End namespace tuscany
-#endif // tuscany_sca_util_defaultlogwriter_h
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp
deleted file mode 100644
index d8f86e0147..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#include "tuscany/sca/util/Exceptions.h"
-#include "tuscany/sca/util/Logging.h"
-using namespace std;
-
-namespace tuscany
-{
- namespace sca
- {
-
- // ========================================================================
- // Constructor
- // ========================================================================
- TuscanyRuntimeException :: TuscanyRuntimeException(const char* name,
- severity_level sev,
- const char* msg_text)
- : severity(sev), location_set(0)
- {
- class_name = new char[strlen(name) + 1];
- strcpy(class_name,name);
- message_text = new char[strlen(msg_text)+1];
- strcpy(message_text,msg_text);
- LOGERROR_2(1, "%s raised: %s", class_name, message_text);
-
- } // end TuscanyRuntimeException constuctor
-
- // ========================================================================
- // Constructor
- // ========================================================================
- TuscanyRuntimeException :: TuscanyRuntimeException(const TuscanyRuntimeException& c)
- :
- severity(c.getSeverity()), location_set(c.location_set)
-
- {
- class_name = new char[strlen(c.getEClassName()) + 1];
- strcpy(class_name, c.getEClassName());
- message_text = new char[strlen(c.getMessageText())+1];
- strcpy(message_text,c.getMessageText());
- for (int i=0;i<c.location_set;i++)
- {
- locations[i].file = new char[strlen(c.locations[i].file) + 1];
- strcpy(locations[i].file,c.locations[i].file);
- locations[i].line = c.locations[i].line;
- locations[i].function = new char[strlen(c.locations[i].function) + 1];
- strcpy(locations[i].function, c.locations[i].function);
- }
- LOGERROR_2(1, "%s raised: %s", class_name, message_text);
- }
-
- // ========================================================================
- // Destructor
- // ========================================================================
- TuscanyRuntimeException :: ~TuscanyRuntimeException()
- {
- if (class_name) delete class_name;
- if (message_text) delete message_text;
- for (int i=0;i<location_set;i++)
- {
- if (locations[i].file) delete locations[i].file;
- if (locations[i].function) delete locations[i].function;
- }
-
- } // end TuscanyRuntimeException destructor
-
- // ========================================================================
- // Return class name of this exception
- // ========================================================================
- const char* TuscanyRuntimeException :: getEClassName() const
- {
- return class_name;
- } // end getClassName()
-
- // ========================================================================
- // Return severity
- // ========================================================================
- TuscanyRuntimeException::severity_level TuscanyRuntimeException :: getSeverity() const
- {
- return severity;
- } // end getSeverity()
-
- // ========================================================================
- // Return message text associated with exception
- // ========================================================================
- const char* TuscanyRuntimeException :: getMessageText() const
- {
- return message_text;
- } // end getMessageText()
-
- // ========================================================================
- // Return file name where exception was raised
- // ========================================================================
- const char* TuscanyRuntimeException :: getFileName() const
- {
- return locations[0].file;
- } // end getFileName()
-
- // ========================================================================
- // Return line number where exception was raised
- // ========================================================================
- unsigned long TuscanyRuntimeException :: getLineNumber() const
- {
- return locations[0].line;
- } // end getLineNumber()
-
- // ========================================================================
- // Return function name where exception was raised
- // ========================================================================
- const char* TuscanyRuntimeException :: getFunctionName() const
- {
- return locations[0].function;
- } // end getFunctionName()
-
-
- // ========================================================================
- // set severity of exception
- // ========================================================================
- void TuscanyRuntimeException :: setSeverity(severity_level sev)
- {
- severity = sev;
- } // end setSeverity(severity_level sev) const
-
- // ========================================================================
- // set message text associated with exception
- // ========================================================================
- void TuscanyRuntimeException :: setMessageText(const char* msg_text)
- {
- if (message_text != 0) delete message_text;
- message_text = new char[strlen(msg_text) + 1];
- strcpy(message_text,msg_text);
- } // end setMessageText(const string &msg_text) const
-
- // ========================================================================
- // set location of most recent throw/handling of the exception
- // ========================================================================
- void TuscanyRuntimeException :: setLocation(const char* file,
- unsigned long line,
- const char* function)
- {
- if (location_set < num_locations)
- {
- locations[location_set].file = new char[strlen(file) + 1];
- strcpy(locations[location_set].file,file);
- locations[location_set].line = line;
- locations[location_set].function = new char[strlen(function) + 1];
- strcpy(locations[location_set].function,function);
-
- location_set++;
- }
- } // end setLocation()
-
-
- // ========================================================================
- // print self
- // ========================================================================
- ostream& TuscanyRuntimeException :: PrintSelf(ostream &os) const
- {
-
- os << "Exception object :" << endl;
- os << " class: " << class_name << endl;
- os << " description: " << message_text << endl;
- if (location_set != 0)
- {
- os << " file name: " << locations[0].file << endl;
- char lineNumber[100];
- sprintf(lineNumber, "%lu",locations[0].line);
- os << " line number: " << lineNumber << endl;
- os << " function: " << locations[0].function << endl;
- os << " location history:" << endl;
-
- int i=1;
- while (i < location_set)
- {
- os << " " << i << ")" << endl;
- os << " file: " << locations[i].file << endl;
- os << " line: " << locations[i].line << endl;
- os << " function: " << locations[i].function << endl;
- i++;
- }
- }
- return os;
- } // end ostream operator <<
-
- // ========================================================================
- // ostream operator <<
- // ========================================================================
- SCA_API ostream& operator<< (ostream &os, const TuscanyRuntimeException &except)
- {
- return except.PrintSelf(os);
- } // end ostream operator <<
-
-
- } // End namespace sca
-} // End namespace tuscany
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Exceptions.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Exceptions.h
deleted file mode 100644
index 16188ed550..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Exceptions.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_exceptions_h
-#define tuscany_sca_util_exceptions_h
-
-
-#include "tuscany/sca/export.h"
-
-#include <ostream>
-
-
-namespace tuscany
-{
- namespace sca
- {
- /**
- * Top level exception to represent all the exceptions that may be
- * thrown by an SCA runtime implementation.
- */
- class SCA_API TuscanyRuntimeException
- {
- public:
- /**
- * Represents the possible severity levels for an exception.
- */
- enum severity_level
- {
- Normal,
- Warning,
- Error,
- Severe
- };
-
- /**
- * Constructor.
- * @param name Class name of the exception.
- * @param sev Severity level.
- * @param msg_text Detailed description of the exception.
- */
- TuscanyRuntimeException(
- const char *name="TuscanyRuntimeException",
- severity_level sev=Severe,
- const char* msg_text="");
-
- TuscanyRuntimeException(const TuscanyRuntimeException& c);
-
- // Destructor
- virtual ~TuscanyRuntimeException();
-
- /**
- * Return class name of this exception.
- */
- const char* getEClassName() const;
-
- /**
- * Return severity.
- */
- severity_level getSeverity() const;
-
- /**
- * Return message text associated with exception.
- */
- const char* getMessageText() const;
-
- /*
- * Return file name where the exception was raised.
- */
- const char* getFileName() const;
-
- /**
- * Return line number where the exception was raised.
- */
- unsigned long getLineNumber() const;
-
- /**
- * Return function name where the exception was raised.
- */
- const char* getFunctionName() const;
-
- /**
- * Set the exception severity.
- */
- void setSeverity(severity_level sev);
-
- /**
- * Set the message text associated with exception.
- */
- void setMessageText(const char* msg_text);
-
- /**
- * Set the location where the exception was raised.
- * @param file Name of the file.
- * @param line Line number in the file.
- * @param function Name of the function.
- */
- void setLocation(const char* file,
- unsigned long line,
- const char* function="");
-
- /**
- * Append exception details to ostream.
- */
- virtual std::ostream& PrintSelf(std::ostream &os) const;
-
- /**
- * Operator to send exceptions details to a stream.
- */
- SCA_API friend std::ostream& operator<< (std::ostream &os, const TuscanyRuntimeException &except);
- protected:
-
- private:
- /**
- * Class name of the exception.
- */
- char* class_name;
-
- /**
- * Severity level of the exception.
- */
- severity_level severity;
-
- /**
- * Description of the exception.
- */
- char* message_text; // Description of exception
-
- /**
- * Location where the exception was thrown or handled and thrown.
- */
- class location
- {
- public:
- char* file; // File name (from __FILE__)
- unsigned long line; // Line number (from __LINE__)
- char* function; // Function name
- };
-
-
- enum {num_locations=5};
- /**
- * Array of locations where the exception has been handled and thrown.
- */
- location locations[num_locations];
-
- /**
- * The current location (index into TuscanyRuntimeException#location).
- */
- int location_set;
-
-
- }; // End TuscanyRuntimeException class definition
-
-
- /**
- * Indicates a problem in the consistency of the SCA model provided to the
- * Tuscany runtime.
- */
- class SCA_API SystemConfigurationException: public TuscanyRuntimeException
- {
- public:
- SystemConfigurationException(const char* msg)
- : TuscanyRuntimeException("SystemConfigurationException", Severe,
- msg)
- {
- }
- private:
- };
-
- } // End namespace sca
-} // End namespace tuscany
-#endif // tuscany_sca_util_exceptions_h
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/File.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/File.cpp
deleted file mode 100644
index 20066a09e0..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/File.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#if defined(WIN32) || defined (_WINDOWS)
-#pragma warning(disable: 4786)
-#endif
-
-#include "tuscany/sca/util/File.h"
-#include "tuscany/sca/util/Utils.h"
-#include "tuscany/sca/util/Exceptions.h"
-#include <iostream>
-
-#include <string>
-#include <iostream>
-using namespace std;
-
-#if defined(WIN32) || defined (_WINDOWS)
-#include <windows.h>
-#else
-#include <unistd.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#endif
-
-namespace tuscany
-{
- namespace sca
- {
- File::File(const string& dir, const string& file)
- : directory(dir), fileName(file)
- {
- }
- File::~File()
- {
- }
-
-
- Files::Files(const string& rootDir, const string& pattern, bool subdirectories)
- : rootDirectory(rootDir)
- {
- findFiles(rootDirectory, pattern, subdirectories);
- }
-
- Files::~Files()
- {
- }
-
- unsigned int Files::size()
- {
- return files.size();
- }
-
- const File& Files::operator[] (unsigned int index)
- {
- if (size() <= index)
- {
- throw SystemConfigurationException("Files::operator[] index out of bounds");
- }
-
- FILES::iterator iter = files.begin();
- for (unsigned int i=0; i<index; i++)
- {
- iter++;
- }
-
- return *iter;
- }
-
-
- void Files::findFiles(const string& rootDir, const string& pattern, bool subdirectories)
- {
-
-#if defined(WIN32) || defined (_WINDOWS)
- char currentDir[ _MAX_FNAME];
-
-
- GetCurrentDirectory(_MAX_FNAME, currentDir);
-
- // Set current directory, from which to search.
- if (!SetCurrentDirectory(rootDir.c_str()))
- {
- cout << "Unable to set current directory to: " << rootDir.c_str() << endl;
- return;
- }
- char fullDirname[ _MAX_FNAME];
- GetCurrentDirectory(_MAX_FNAME, fullDirname);
-
- // First, look for all files in this directory that meet the pattern
- char search[ _MAX_FNAME];
- strcpy(search, pattern.c_str());
-
- // Find the first file in the directory
- WIN32_FIND_DATA data;
- HANDLE searchHandle = FindFirstFile(search, &data);
-
- int more = TRUE;
- if (searchHandle != INVALID_HANDLE_VALUE)
- {
- // Found some matching files, so call the function with the details of each one
- while (more)
- {
- // Skip over directories
- if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- // Add the file to our list
- files.push_back(File(fullDirname, data.cFileName));
- }
-
- more = FindNextFile(searchHandle, &data);
- }
- }
-
-
- if (!subdirectories)
- return;
-
- // Now recurse down all the directories
- // Find the first file in the directory
- searchHandle = FindFirstFile( "*.*", &data);
- more = TRUE;
-
- if (searchHandle != INVALID_HANDLE_VALUE)
- {
- // Found some files in the directory.
- while (more)
- {
- // If directory
- if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- // Skip over '.' and '..'
- if ((strcmp(data.cFileName, ".")) && (strcmp("..", data.cFileName)))
- {
- // Recurse
- findFiles(data.cFileName, pattern, subdirectories);
- }
- }
-
- more = FindNextFile(searchHandle, &data);
- }
- }
- SetCurrentDirectory(currentDir);
-#else
- // Linux
- //char fullDirname[MAX_PATH];
- //getcwd(fullDirname, MAX_PATH);
-
- DIR* root = opendir(rootDir.c_str());
- if (!root)
- {
- cout << "Unable to open directory: " << rootDir.c_str() << endl;
- return;
- }
-
- bool exactMatch = true;
- string token1, token2;
- if (pattern.find('*') != string::npos)
- {
- exactMatch = false;
- Utils::tokeniseString("*", pattern, token1, token2);
- }
-
- struct dirent *entry=0;
- while ((entry = readdir(root)))
- {
- string entryName = rootDir + "/" + entry->d_name;
- struct stat statbuf;
- if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
- continue;
- if (stat(entryName.c_str(), &statbuf) != 0)
- {
- perror("stat");
- }
- else
- {
- if (S_ISDIR(statbuf.st_mode))
- {
- if (subdirectories)
- {
- findFiles(entryName, pattern, subdirectories);
- }
- }
- else if (S_ISREG(statbuf.st_mode))
- {
- string filename = entry->d_name;
-
- if ((exactMatch && filename == pattern) ||
- (!exactMatch &&
- ((filename.find(token1) == 0)
- && (filename.length() >= token2.length())
- && (filename.rfind(token2) == (filename.length() - token2.length())) )))
- {
- // Add the file to our list
- files.push_back(File(rootDir, filename));
- }
- }
- }
- }
- closedir(root);
-#endif
- }
-
-
- } // End namespace sca
-} // End namespace tuscany
-
-
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/File.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/File.h
deleted file mode 100644
index a0aef07cf3..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/File.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_file_h
-#define tuscany_sca_util_file_h
-
-#include <string>
-using std::string;
-#include <vector>
-using std::vector;
-
-namespace tuscany
-{
- namespace sca
- {
- /**
- * File access methods. Provides platform independent
- * access to files.
- */
- class File
- {
- public:
- /**
- * Constructor.
- * @param directory Name of the directory in which this file is located.
- * Either / or \ can be used interchangeably for separating directory elements.
- * @param fileName Name of the file in the dirctory.
- */
- File(const string& directory, const string& fileName);
-
- /**
- * Destructor.
- */
- virtual ~File();
-
- /**
- * Return the directory in which this file is located.
- * @return Name of the directory.
- */
- const string& getDirectory() const {return directory;}
-
- /**
- * Name of the file.
- * @return Name of the file.
- */
- const string& getFileName() const {return fileName;}
- private:
- /**
- * Name of the directory.
- */
- string directory;
-
- /**
- * Name of the file.
- */
- string fileName;
- };
-
- /**
- * Collection of File to provide platform independent access
- * to files and directories.
- */
- class Files
- {
- public:
- /**
- * Constructor which will search a given directory with a pattern and return a
- * new instance of this collection class.
- * @param rootDirectory The directory in which to search.
- * @param pattern A pattern for matching file names. Can include * and ?.
- * @param subdirectories Whether subdirectories should be searched too.
- */
- Files(const string& rootDirectory, const string& pattern, bool subdirectories = false);
-
- /**
- * Destructor.
- */
- virtual ~Files();
-
- /**
- * Return the number of files found.
- * @return The number of files found.
- */
- unsigned int size();
-
- /**
- * Return a File at this position in the collection.
- * @param index The index into the collection.
- * @return The File at this index in the collection.
- */
- const File& operator[] (unsigned int index);
-
- private:
- /**
- * Search the given directory and pattern for matching files.
- * @param rootDirectory The directory in which to search.
- * @param pattern A pattern for matching file names. Can include * and ?.
- * @param subdirectories Whether subdirectories should be searched too.
- */
- void findFiles(const string& rootDirectory, const string& pattern, bool subdirectories);
-
- /**
- * The top level directory to search.
- */
- string rootDirectory;
-
- typedef vector<File> FILES;
-
- /**
- * Vector of File.
- */
- FILES files;
- };
-
- } // End namespace sca
-} // End namespace tuscany
-#endif // tuscany_sca_util_file_h
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp
deleted file mode 100644
index 109d398e1a..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#include "tuscany/sca/util/FileLogWriter.h"
-#include <iostream>
-using namespace std;
-
-namespace tuscany
-{
- namespace sca
- {
- FileLogWriter::FileLogWriter(const char* logfile)
- {
- logFile.open(logfile, ios_base::app);
- }
-
- FileLogWriter::~FileLogWriter()
- {
- logFile.close();
- }
-
- void FileLogWriter::log(int level, const char* msg)
- {
- for (int i=0; i < level; i++)
- {
- logFile << " ";
- }
- logFile << msg <<endl;
- }
-
- } // End namespace sca
-} // End namespace tuscany
-
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.h
deleted file mode 100644
index 50d25ee932..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_filelogwriter_h
-#define tuscany_sca_util_filelogwriter_h
-
-#include "tuscany/sca/util/LogWriter.h"
-#include <iostream>
-#include <fstream>
-using std::ofstream;
-
-namespace tuscany
-{
- namespace sca
- {
- /**
- * Log writer to write out to standard out.
- */
- class FileLogWriter : public LogWriter
- {
- public:
- FileLogWriter(const char* logfile);
-
- virtual ~FileLogWriter();
-
- /**
- * Will write to the console.
- * See LogWriter#log.
- */
- virtual void log(int level, const char* msg);
- private:
- ofstream logFile;
- };
-
- } // End namespace sca
-} // End namespace tuscany
-#endif // tuscany_sca_util_defaultlogwriter_h
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Library.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Library.cpp
deleted file mode 100644
index a9ff01b293..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Library.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#if defined(WIN32) || defined (_WINDOWS)
-#pragma warning(disable: 4786)
-#endif
-
-#include "tuscany/sca/util/Library.h"
-#include "tuscany/sca/util/Utils.h"
-#include "tuscany/sca/util/Exceptions.h"
-#include "tuscany/sca/util/Logging.h"
-
-namespace tuscany
-{
- namespace sca
- {
- Library::Library()
- : hDLL(NULL)
- {
- }
-
- Library::Library(const string& libraryName)
- : name(libraryName), hDLL(NULL)
- {
- LOGINFO_1(3, "Library::construcor : %s", name.c_str());
- load();
- }
-
- Library::Library(const Library& lib)
- : name(lib.name), hDLL(NULL)
- {
- LOGINFO_1(3, "Library::copy constructor : %s", name.c_str());
- if (lib.hDLL)
- {
- load();
- }
- }
-
- Library& Library::operator=(const Library& lib)
- {
- LOGINFO_1(3, "Library::operator= : %s", name.c_str());
- if (&lib != this)
- {
- unload();
- name = lib.name;
- load();
- }
- return *this;
- }
-
- Library::~Library()
- {
- LOGINFO_1(3, "Library::destructor: %s", name.c_str());
- unload();
- }
-
-
- void Library::load()
- {
- LOGINFO_1(3, "Library::load : %s", name.c_str());
- string msg;
-#if defined(WIN32) || defined (_WINDOWS)
- int l = name.length();
- string dllName;
- if (l>=4 && name.substr(l-4, 4)==".dll")
- {
- dllName = name;
- }
- else
- {
- dllName = name+".dll";
- }
- hDLL = LoadLibrary(dllName.c_str());
- if (hDLL == NULL)
- {
- msg = "Unable to load library: " + dllName;
- }
-#else
- int l = name.length();
- string soName;
- if (l>=3 && name.substr(l-3, 3)==".so")
- {
- soName = name;
- }
- else
- {
- int s = name.rfind("/");
- if (s == name.length())
- {
- soName = name + ".so";
- }
- else
- {
- s++;
- soName = name.substr(0, s) + "lib" + name.substr(s, name.length()-s) + ".so";
- }
- }
- hDLL = dlopen(soName.c_str(), RTLD_NOW);
- if (hDLL == NULL)
- {
- msg = "Unable to load library: " + soName + ": " + dlerror();
- }
-#endif
- if (hDLL == NULL)
- {
- LOGERROR(1, msg.c_str());
- throw SystemConfigurationException(msg.c_str());
- }
- }
-
- void Library::unload()
- {
- if (hDLL != NULL)
- {
- LOGINFO_1(3, "Library::unload : %s", name.c_str());
-#if defined(WIN32) || defined (_WINDOWS)
- FreeLibrary(hDLL);
-#else
- dlclose(hDLL);
-#endif
- hDLL = NULL;
- }
- }
-
- void* Library::getSymbol(const string& symbol)
- {
- LOGINFO_1(3, "Library::getSymbol : %s", symbol.c_str());
- if (!hDLL)
- {
- return 0;
- }
-#if defined(WIN32) || defined (_WINDOWS)
- return GetProcAddress(hDLL, symbol.c_str());
-#else
- return dlsym(hDLL, symbol.c_str());
-#endif
- }
-
- } // End namespace sca
-} // End namespace tuscany
-
-
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Library.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Library.h
deleted file mode 100644
index 48b2ad4430..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Library.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_library_h
-#define tuscany_sca_util_library_h
-#include "tuscany/sca/export.h"
-
-#if defined(WIN32) || defined (_WINDOWS)
-#include <windows.h>
-#else
-#include <unistd.h>
-#include <dlfcn.h>
-#endif
-
-#include <string>
-using std::string;
-
-namespace tuscany
-{
- namespace sca
- {
- /**
- * Information about shared libraries and methods to
- * access these shared libraries.
- */
- class SCA_API Library
- {
- public:
- Library();
-
- /**
- * Constructor. Will load the library.
- * @param libraryName Fully qualified name of the library.
- */
- Library(const string& libraryName);
-
- /**
- * Destructor. Will unload the library.
- */
- virtual ~Library();
-
- Library(const Library& lib);
- Library& operator=(const Library& lib);
-
- /**
- * Find an externalized symbol in the library.
- * @param symbol The name of the symbol to be found.
- * @return The pointer to the symbol if found, otherwise 0.
- */
- void* getSymbol(const string& symbol);
- private:
- /**
- * Name of the library.
- */
- string name;
-
- /**
- * Handle to the loaded library.
- */
-#if defined(WIN32) || defined (_WINDOWS)
- HINSTANCE hDLL;
-#else
- void* hDLL;
-#endif
-
- /**
- * Load the library.
- */
- void load();
-
- /**
- * Unload the library, if successfully loaded.
- */
- void unload();
-
- };
-
- } // End namespace sca
-} // End namespace tuscany
-
-#endif // tuscany_sca_util_library_h
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp
deleted file mode 100644
index 7613e14c4a..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#include "tuscany/sca/util/LogWriter.h"
-
-namespace tuscany
-{
- namespace sca
- {
- LogWriter::~LogWriter()
- {
- }
-
- } // End namespace sca
-} // End namespace tuscany
-
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/LogWriter.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/LogWriter.h
deleted file mode 100644
index 430ce1a785..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/LogWriter.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_logwriter_h
-#define tuscany_sca_util_logwriter_h
-
-#include "tuscany/sca/export.h"
-
-namespace tuscany
-{
- namespace sca
- {
- /**
- * Abstract class for extending logging to other destinations.
- */
- class SCA_API LogWriter
- {
- public:
- virtual ~LogWriter();
-
- /**
- * Log a message.
- * @param level The level of logging for this message.
- * @param msg The message to log.
- */
- virtual void log(int level, const char* msg) = 0;
- };
-
- } // End namespace sca
-} // End namespace tuscany
-#endif // tuscany_sca_util_logwriter_h
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logger.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logger.cpp
deleted file mode 100644
index cdaa3e562b..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logger.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#include <iostream>
-#include <stdarg.h>
-
-#include "tuscany/sca/util/Logger.h"
-#include "tuscany/sca/util/DefaultLogWriter.h"
-#include "tuscany/sca/util/FileLogWriter.h"
-
-using namespace std;
-
-namespace tuscany
-{
- namespace sca
- {
- LogWriter* Logger::logWriter = getLogWriter();
-
- LogWriter* Logger::getLogWriter()
- {
- if (logWriter == 0)
- {
- setLogWriter(0);
- }
- return logWriter;
- }
-
- void Logger::setLogWriter(LogWriter* writer)
- {
- if (logWriter != writer
- && logWriter != 0)
- {
- delete logWriter;
- }
-
- if (writer == 0)
- {
- char* loggingVar = 0;
- loggingVar = getenv("TUSCANY_SCACPP_LOG");
- if (loggingVar == 0)
- logWriter = new DefaultLogWriter;
- else
- logWriter = new FileLogWriter(loggingVar);
- }
- else
- {
- logWriter = writer;
- }
- }
-
- int Logger::loggingLevel = setLogging();
-
- int Logger::setLogging()
- {
- char* loggingVar = 0;
- loggingVar = getenv("TUSCANY_SCACPP_LOGGING");
- if (loggingVar == 0)
- return 0;
- else
- return atoi(loggingVar);
- }
-
- void Logger::setLogging(int level)
- {
- loggingLevel = level;
- }
-
- void Logger::log(int level, const char* msg)
- {
- if (level <= loggingLevel)
- {
- logWriter->log(level, msg);
- }
- }
-
- void Logger::logArgs(int level, const char* msg, ...)
- {
- if (level <= loggingLevel)
- {
- va_list variableArguments;
- va_start(variableArguments, msg);
- char messageBuffer[1024];
- vsprintf(messageBuffer, msg, variableArguments);
- logWriter->log(level, messageBuffer);
- va_end(variableArguments);
- }
- }
-
- } // End namespace sca
-} // End namespace tuscany
-
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logger.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logger.h
deleted file mode 100644
index b0b09adc50..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logger.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_logger_h
-#define tuscany_sca_util_logger_h
-
-#include "tuscany/sca/export.h"
-#include "tuscany/sca/util/LogWriter.h"
-namespace tuscany
-{
- namespace sca
- {
- /**
- * Provide a logging interface.
- */
- class Logger {
-
- public:
- /**
- * Set the log writer to use.
- * @param writer The writer to use for all subsequent logging.
- */
- SCA_API static void setLogWriter(LogWriter* writer);
-
- /**
- * Set or reset the logging level. Any message with a higher logging
- * level than this value will be filtered (i.e. not shown).
- * @param level The level of logging to use for all subsequent logging.
- */
- SCA_API static void setLogging(int level);
-
- /**
- * Log a message.
- * @param level The log level of this message.
- * @param msg The message to be logged.
- */
- SCA_API static void log(int level, const char* msg);
-
- /**
- * Log a message with variable arguments.
- * @param level The log level of this message.
- * @param msg The message to be logged. Must include template
- * characters as described in printf.
- * @param ... Variable arguments.
- */
- SCA_API static void logArgs(int level, const char* msg, ...);
-
- /**
- * The currently set logging level
- */
- SCA_API static int loggingLevel;
-
- private:
- /**
- * The current log writer.
- */
- static LogWriter* logWriter;
-
- /**
- * Get the current log writer.
- * @return The current log writer.
- */
- static LogWriter* getLogWriter();
-
- /**
- * Retrieves the logging level set as an environment variable.
- */
- static int setLogging();
- };
-
- } // End namespace sca
-} // End namespace tuscany
-#endif // tuscany_sca_util_logger_h
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logging.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logging.h
deleted file mode 100644
index 047c653229..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Logging.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_logging_h
-#define tuscany_sca_util_logging_h
-
-#include "tuscany/sca/util/Logger.h"
-
-#define LOGENTRY(level, methodName) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::log(level, "Entering: " methodName);
-
-#define LOGEXIT(level, methodName) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::log(level, "Exiting: " methodName);
-
-#define LOGINFO(level, message) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::log(level, message);
-
-#define LOGINFO_1(level, message, arg1) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::logArgs(level, message, arg1);
-
-#define LOGINFO_2(level, message, arg1, arg2) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::logArgs(level, message, arg1, arg2);
-
-#define LOGINFO_3(level, message, arg1, arg2, arg3) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::logArgs(level, message, arg1, arg2, arg3);
-
-#define LOGERROR(level, message) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::log(level, message);
-
-#define LOGERROR_1(level, message, arg1) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::logArgs(level, message, arg1);
-
-#define LOGERROR_2(level, message, arg1, arg2) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::logArgs(level, message, arg1, arg2);
-
-#define LOGERROR_3(level, message, arg1, arg2, arg3) \
-if (tuscany::sca::Logger::loggingLevel >= level) \
-tuscany::sca::Logger::logArgs(level, message, arg1, arg2, arg3);
-
-#endif // tuscany_sca_util_logging_h
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Utils.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Utils.cpp
deleted file mode 100644
index 447f498eff..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Utils.cpp
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#if defined(WIN32) || defined (_WINDOWS)
-#pragma warning(disable: 4786)
-#endif
-
-#include "tuscany/sca/util/Utils.h"
-
-using namespace std;
-using namespace commonj::sdo;
-namespace tuscany
-{
- namespace sca
- {
- void Utils::tokeniseUri(const string& uri, string& token1, string& token2)
- {
- tokeniseString("/", uri, token1, token2);
- }
-
- void Utils::tokeniseQName(const string& qname, string& uri, string& name)
- {
- tokeniseString("#", qname, uri, name);
- if (name == "")
- {
- name = uri;
- uri = "";
- }
- }
-
- void Utils::tokeniseString(
- const string& separator,
- const string& str,
- string& token1,
- string& token2)
- {
- string::size_type sep = str.find(separator);
- if (sep != string::npos)
- {
- token1 = str.substr(0, sep);
- if ( (sep+1) < str.length())
- {
- token2 = str.substr(sep+1);
- }
- else
- {
- token2 = "";
- }
- }
- else
- {
- token1 = str;
- token2 = "";
- }
- }
-
- void Utils::rTokeniseString(
- const string& separator,
- const string& str,
- string& token1,
- string& token2)
- {
- string::size_type sep = str.rfind(separator);
- if (sep != string::npos)
- {
- token1 = str.substr(0, sep);
- if ( (sep+1) < str.length())
- {
- token2 = str.substr(sep+1);
- }
- else
- {
- token2 = "";
- }
- }
- else
- {
- token1 = "";
- token2 = str;
- }
- }
-
- void Utils::breakpoint() {
- // dummy method used to set breakpoints
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Print a DatObject tree
- //////////////////////////////////////////////////////////////////////////
- void Utils::tabs(int inc)
- {
- for (int ind=0; ind <inc; ind++)
- {
- cout << " ";
- }
- }
-
- const bool Utils::compareProperties(DataObjectPtr dataObject1, const Property& prop1, DataObjectPtr dataObject2, const Property& prop2, string& diff)
- {
- if(strcmp(prop1.getName(),prop2.getName()) != 0)
- {
- diff.append("Differing names for Properties:\n");
- diff.append(prop1.getName());
- diff.append("\n");
- diff.append(prop2.getName());
- return false;
- }
-
- const Type& propertyType1 = prop1.getType();
- const Type& propertyType2 = prop2.getType();
-
- if(strcmp(propertyType1.getName(), propertyType2.getName()) != 0 ||
- strcmp(propertyType1.getURI(),propertyType2.getURI()) != 0 )
- {
- diff.append("Differing types for Properties:\n");
- diff.append(propertyType1.getName());
- diff.append("#");
- diff.append(propertyType1.getURI());
- diff.append("\n");
- diff.append(propertyType2.getName());
- diff.append("#");
- diff.append(propertyType2.getURI());
- return false;
- }
- if (dataObject1->isSet(prop1) != dataObject2->isSet(prop2))
- {
- diff.append("Property ");
- diff.append(prop1.getName());
- diff.append(" is set on one DataObject but not the other");
- return false;
- }
-
- if (dataObject1->isSet(prop1))
- {
-
- if (prop1.isMany() != prop2.isMany())
- {
- diff.append("Property ");
- diff.append(prop1.getName());
- diff.append(" is many on one DataObject but not the other");
- return false;
- }
- if (propertyType1.isDataType() != propertyType2.isDataType())
- {
- diff.append("Property ");
- diff.append(prop1.getName());
- diff.append(" is dataType on one DataObject but not the other");
- return false;
- }
-
- //////////////////////////////////////////////////////////////////////
- // For a many-valued property get the list of values
- //////////////////////////////////////////////////////////////////////
- if (prop1.isMany())
- {
- DataObjectList& dol1 = dataObject1->getList(prop1);
- DataObjectList& dol2 = dataObject2->getList(prop2);
- if (dol1.size() != dol2.size())
- {
- diff.append("Property ");
- diff.append(prop1.getName());
- diff.append(" is many but has differing number of elements");
- return false;
- }
-
- for (int j = 0; j <dol1.size(); j++)
- {
-
- if (propertyType1.isDataType())
- {
- if( strcmp(dol1.getCString(j), dol2.getCString(j)) != 0)
- {
- diff.append("Differing value for Property ");
- diff.append(prop1.getName());
- diff.append("[");
- diff += ((int)j);
- diff.append("]:\n");
- diff.append(dol1.getCString(j));
- diff.append("\n");
- diff.append(dol2.getCString(j));
- return false;
- }
- }
- else
- {
- if(!compareDataObjects(dol1[j], dol2[j], diff))
- {
- return false;
- }
- }
- }
- } // end IsMany
-
-
- //////////////////////////////////////////////////////////////////////
- // For a primitive data type compare the values
- //////////////////////////////////////////////////////////////////////
- else if (propertyType1.isDataType())
- {
- if( strcmp(dataObject1->getCString(prop1), dataObject2->getCString(prop2)) != 0)
- {
- diff.append("Differing value for Property ");
- diff.append(prop1.getName());
- diff.append(":\n");
- diff.append(dataObject1->getCString(prop1));
- diff.append("\n");
- diff.append(dataObject2->getCString(prop2));
- return false;
- }
- }
-
- //////////////////////////////////////////////////////////////////////
- // For a dataobject compare the DOs
- //////////////////////////////////////////////////////////////////////
- else
- {
- if(!compareDataObjects(dataObject1->getDataObject(prop1), dataObject2->getDataObject(prop2), diff))
- {
- return false;
- }
- }
- }
- return true;
- }
-
- const bool Utils::compareDataObjects(DataObjectPtr dataObject1, DataObjectPtr dataObject2, string& diff)
- {
- if (!dataObject1 || !dataObject2)
- {
- diff.append("Cannot compare null DataObjects");
- return false;
- }
-
- const Type& dataObject1Type = dataObject1->getType();
- const Type& dataObject2Type = dataObject2->getType();
-
- if( strcmp(dataObject1Type.getURI(), dataObject2Type.getURI()) != 0 ||
- strcmp(dataObject1Type.getName(), dataObject2Type.getName()) != 0 )
- {
- diff.append("DataObject Types differ:\n");
- diff.append(dataObject1Type.getURI());
- diff.append("#");
- diff.append(dataObject1Type.getName());
- diff.append("\n");
- diff.append(dataObject2Type.getURI());
- diff.append("#");
- diff.append(dataObject2Type.getName());
- return false;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Iterate over all the properties
- //////////////////////////////////////////////////////////////////////////
- PropertyList pl1 = dataObject1->getInstanceProperties();
- PropertyList pl2 = dataObject2->getInstanceProperties();
- if (pl1.size() != pl2.size())
- {
- diff.append("Differing number of properties");
- return false;
- }
-
- if (pl1.size() != 0)
- {
- for (int i = 0; i < pl1.size(); i++)
- {
- if(!compareProperties(dataObject1, pl1[i], dataObject2, pl2[i], diff))
- {
- return false;
- }
- }
- }
- else
- {
- if(dataObject1->getType().isOpenType() != dataObject2->getType().isOpenType() &&
- dataObject1->getType().isDataObjectType() != dataObject2->getType().isDataObjectType())
- {
- diff.append("DataObject is open & DO type on one but not the other");
- return false;
- }
-
- // Compare elements under an open DataObject
- if(dataObject1->getType().isOpenType() && dataObject1->getType().isDataObjectType())
- {
- SequencePtr sequence1 = dataObject1->getSequence();
- SequencePtr sequence2 = dataObject2->getSequence();
-
- if (sequence1 != NULL && sequence2 != NULL)
- {
- if (sequence1->size() != sequence1->size())
- {
- diff.append("Open DataObjects have differing number of elements");
- return false;
- }
-
- for (int i = 0; i < sequence1->size(); i++)
- {
- if (sequence1->isText(i) != sequence2->isText(i))
- {
- diff.append("Open DataObjects have differing element types at position ");
- diff += ((int) i);
- return false;
- }
- if (sequence1->isText(i))
- {
- if( strcmp(sequence1->getCStringValue(i), sequence2->getCStringValue(i)) != 0)
- {
- diff.append("Differing value for element at position ");
- diff += ((int) i);
- diff.append(":\n");
- diff.append(sequence1->getCStringValue(i));
- diff.append("\n");
- diff.append(sequence2->getCStringValue(i));
- return false;
- }
- }
- else
- {
- const Property& p1 = sequence1->getProperty(i);
- const Property& p2 = sequence2->getProperty(i);
-
- if(!compareProperties(dataObject1, p1, dataObject2, p2, diff))
- {
- return false;
- }
- }
- }
- }
- }
- }
-
- return true;
- }
-
- void Utils::printDO(DataObjectPtr dataObject, int increment)
- {
- int inc=increment;
- if (!dataObject)
- return;
- const Type& dataObjectType = dataObject->getType();
- tabs(inc);
- cout << "DataObject type: " << dataObjectType.getURI()<< "#" << dataObjectType.getName() << endl;
- inc++;
-
- //////////////////////////////////////////////////////////////////////////
- // Iterate over all the properties
- //////////////////////////////////////////////////////////////////////////
- PropertyList pl = dataObject->getInstanceProperties();
- if (pl.size() != 0)
- {
- for (int i = 0; i < pl.size(); i++)
- {
- tabs(inc);
- cout << "Property: " << pl[i].getName() << endl;
-
- const Type& propertyType = pl[i].getType();
-
- tabs(inc);
- cout << "Property Type: " << propertyType.getURI()<< "#" << propertyType.getName() << endl;
-
- if (dataObject->isSet(pl[i]))
- {
-
- //////////////////////////////////////////////////////////////////////
- // For a many-valued property get the list of values
- //////////////////////////////////////////////////////////////////////
- if (pl[i].isMany())
- {
- inc++;
- DataObjectList& dol = dataObject->getList(pl[i]);
- for (int j = 0; j <dol.size(); j++)
- {
- tabs(inc);
- cout << "Value " << j <<endl;
- inc++;
-
- if (propertyType.isDataType())
- {
- tabs(inc);
- cout<< "Property Value: " << dol.getCString(j) <<endl ;
- }
- else
- printDO(dol[j], inc);
- inc--;
- }
- inc--;
- } // end IsMany
-
-
- //////////////////////////////////////////////////////////////////////
- // For a primitive data type print the value
- //////////////////////////////////////////////////////////////////////
- else if (propertyType.isDataType())
- {
- tabs(inc);
- cout<< "Property Value: " << dataObject->getCString(pl[i]) <<endl ;
- }
-
- //////////////////////////////////////////////////////////////////////
- // For a dataobject print the do
- //////////////////////////////////////////////////////////////////////
- else
- {
- inc++;
- printDO(dataObject->getDataObject(pl[i]), inc);
- inc--;
- }
- }
- else
- {
- tabs(inc);
- cout<< "Property Value: not set" <<endl ;
- }
-
- }
- }
- else
- {
- // Print elements under an open DataObject
- if(dataObject->getType().isOpenType() && dataObject->getType().isDataObjectType())
- {
- SequencePtr sequence = dataObject->getSequence();
- if (sequence != NULL)
- {
- for (int i = 0; i < sequence->size(); i++)
- {
- if (sequence->isText(i))
- {
- tabs(inc);
- cout<< "Text Value: " << sequence->getCStringValue(i) <<endl ;
- }
- else {
- const Property& p = sequence->getProperty(i);
-
- tabs(inc);
- cout << "Property: " << p.getName() << endl;
-
- const Type& propertyType = p.getType();
-
- tabs(inc);
- cout << "Property Type: " << propertyType.getURI()<< "#" << propertyType.getName() << endl;
-
- if (dataObject->isSet(p))
- {
-
- //////////////////////////////////////////////////////////////////////
- // For a many-valued property get the list of values
- //////////////////////////////////////////////////////////////////////
- if (p.isMany())
- {
- inc++;
- DataObjectList& dol = dataObject->getList(p);
- for (int j = 0; j <dol.size(); j++)
- {
- tabs(inc);
- cout << "Value " << j <<endl;
- inc++;
-
- if (propertyType.isDataType())
- {
- tabs(inc);
- cout<< "Property Value: " << dol.getCString(j) <<endl ;
- }
- else
- printDO(dol[j], inc);
- inc--;
- }
- inc--;
- } // end IsMany
-
-
- //////////////////////////////////////////////////////////////////////
- // For a primitive data type print the value
- //////////////////////////////////////////////////////////////////////
- else if (propertyType.isDataType())
- {
- tabs(inc);
- cout<< "Property Value: " << dataObject->getCString(p) <<endl ;
- }
-
- //////////////////////////////////////////////////////////////////////
- // For a dataobject print the do
- //////////////////////////////////////////////////////////////////////
- else
- {
- inc++;
- printDO(dataObject->getDataObject(p), inc);
- inc--;
- }
- }
- else
- {
- tabs(inc);
- cout<< "Property Value: not set" <<endl ;
- }
- }
- }
- }
- }
- }
- inc--;
- }
-
- void Utils::printTypes(DataFactoryPtr df)
- {
- //////////////////////////////////////////////////////////////////////////
- // Retrieve the DataFactory from the mediator
- // get the list of Types in the DataFactory and list them
- //////////////////////////////////////////////////////////////////////////
- TypeList tl = df->getTypes();
- for (int i = 0; i < tl.size(); i++)
- {
- cout << "Type: " << tl[i].getURI()<< "#" << tl[i].getName() << endl;
- PropertyList pl = tl[i].getProperties();
- for (int j = 0; j < pl.size(); j++)
- {
- cout << "\tProperty: " << pl[j].getName()
- << " type: " <<pl[j].getType().getURI()<<"#"<<pl[j].getType().getName()<< endl;
-
- }
- }
-
- }
-
- void Utils::printType(const Type& type, int increment)
- {
- int inc = increment;
- tabs(inc);
- cout << "Type: " << type.getURI()<< "#" << type.getName() << endl;
- inc++;
- PropertyList pl = type.getProperties();
- for (int j = 0; j < pl.size(); j++)
- {
- tabs(inc);
- cout << "\tProperty: " << pl[j].getName()
- << " type: " <<pl[j].getType().getURI()<<"#"<<pl[j].getType().getName()<< endl;
- inc++;
- printType(pl[j].getType(), inc);
- inc--;
- }
- }
-
- } // End namespace sca
-} // End namespace tuscany
-
diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Utils.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Utils.h
deleted file mode 100644
index 4d20d952c8..0000000000
--- a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/core/src/tuscany/sca/util/Utils.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_sca_util_utils_h
-#define tuscany_sca_util_utils_h
-#include <string>
-using std::string;
-#include "commonj/sdo/SDO.h"
-
-#include "tuscany/sca/export.h"
-
-namespace tuscany
-{
- namespace sca
- {
- /**
- * Utility methods to parse strings and provide debugging information.
- */
- class SCA_API Utils {
-
- public:
- static void tokeniseUri(const string& uri, string& token1, string& token2);
- static void tokeniseQName(const string& sdoname, string& uri, string& name);
- static void tokeniseString(
- const string& separator,
- const string& str,
- string& token1,
- string& token2);
-
- static void rTokeniseString(
- const string& separator,
- const string& str,
- string& token1,
- string& token2);
-
- static void breakpoint();
-
- static void printDO(commonj::sdo::DataObjectPtr dataObject, int increment=0);
- static void printTypes(commonj::sdo::DataFactoryPtr df);
- static void printType(const commonj::sdo::Type& type, int increment=0);
-
- static const bool compareDataObjects(commonj::sdo::DataObjectPtr dataObject1, commonj::sdo::DataObjectPtr dataObject2, string& diff);
- static const bool compareProperties(commonj::sdo::DataObjectPtr dataObject1, const commonj::sdo::Property& prop1, commonj::sdo::DataObjectPtr dataObject2, const commonj::sdo::Property& prop2, string& diff);
-
- private:
- static void tabs(int increment=0);
- };
-
- } // End namespace sca
-} // End namespace tuscany
-#endif // tuscany_sca_util_utils_h