4 digit library version numeration implemented in OpenCV Manager

Code refactoring done.
OpenCV library version type changed to int.
Some UI labels updated.
OpenCV Manager verison incremented.
This commit is contained in:
Alexander Smorkalov
2013-01-16 16:47:06 +04:00
parent 101e9bd456
commit 4feae810fa
10 changed files with 102 additions and 113 deletions

View File

@@ -124,14 +124,19 @@ inline int SplitIntelFeatures(const vector<string>& features)
return result;
}
inline string SplitVersion(const vector<string>& features, const string& package_version)
inline int SplitVersion(const vector<string>& features, const string& package_version)
{
string result;
int result = 0;
if ((features.size() > 1) && ('v' == features[1][0]))
{
result = features[1].substr(1);
result += SplitStringVector(package_version, '.')[0];
// Taking major and minor mart of library version from package name
string tmp1 = features[1].substr(1);
result += atoi(tmp1.substr(0,1).c_str())*1000000 + atoi(tmp1.substr(1,1).c_str())*10000;
// Taking release and build number from package revision
vector<string> tmp2 = SplitStringVector(package_version, '.');
result += atoi(tmp2[0].c_str())*100 + atoi(tmp2[1].c_str());
}
else
{
@@ -186,9 +191,9 @@ inline int SplitPlatfrom(const vector<string>& features)
* Second part is version. Version starts from "v" symbol. After "v" symbol version nomber without dot symbol added.
* If platform is known third part is platform name
* If platform is unknown it is defined by hardware capabilities using pattern: <arch>_<floating point and vectorization features>_<other features>
* Example: armv7_neon, armv5_vfpv3
* Example: armv7_neon
*/
PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::string install_path):
PackageInfo::PackageInfo(int version, int platform, int cpu_id, std::string install_path):
Version(version),
Platform(platform),
CpuID(cpu_id),
@@ -198,7 +203,14 @@ InstallPath("")
Platform = PLATFORM_UNKNOWN;
#endif
FullName = BasePackageName + "_v" + Version.substr(0, Version.size()-1);
int major_version = version/1000000;
int minor_version = version/10000 - major_version*100;
char tmp[32];
sprintf(tmp, "%d%d", major_version, minor_version);
FullName = BasePackageName + std::string("_v") + std::string(tmp);
if (PLATFORM_UNKNOWN != Platform)
{
FullName += string("_") + JoinPlatform(platform);
@@ -296,7 +308,7 @@ InstallPath("")
else
{
LOGD("PackageInfo::PackageInfo: package arch unknown");
Version.clear();
Version = 0;
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
}
@@ -304,7 +316,7 @@ InstallPath("")
else
{
LOGD("PackageInfo::PackageInfo: package arch unknown");
Version.clear();
Version = 0;
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
}
@@ -371,7 +383,7 @@ InstallPath(install_path)
{
LOGI("Info library not found in package");
LOGI("OpenCV Manager package does not contain any verison of OpenCV library");
Version.clear();
Version = 0;
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
@@ -383,7 +395,7 @@ InstallPath(install_path)
if (!features.empty() && (BasePackageName == features[0]))
{
Version = SplitVersion(features, package_version);
if (Version.empty())
if (0 == Version)
{
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
@@ -410,7 +422,7 @@ InstallPath(install_path)
if (features.size() < 3)
{
LOGD("It is not OpenCV library package for this platform");
Version.clear();
Version = 0;
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
@@ -444,7 +456,7 @@ InstallPath(install_path)
else
{
LOGD("It is not OpenCV library package for this platform");
Version.clear();
Version = 0;
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
@@ -454,7 +466,7 @@ InstallPath(install_path)
else
{
LOGD("It is not OpenCV library package for this platform");
Version.clear();
Version = 0;
CpuID = ARCH_UNKNOWN;
Platform = PLATFORM_UNKNOWN;
return;
@@ -463,7 +475,7 @@ InstallPath(install_path)
bool PackageInfo::IsValid() const
{
return !(Version.empty() && (PLATFORM_UNKNOWN == Platform) && (ARCH_UNKNOWN == CpuID));
return !((0 == Version) && (PLATFORM_UNKNOWN == Platform) && (ARCH_UNKNOWN == CpuID));
}
int PackageInfo::GetPlatform() const
@@ -481,7 +493,7 @@ string PackageInfo::GetFullName() const
return FullName;
}
string PackageInfo::GetVersion() const
int PackageInfo::GetVersion() const
{
return Version;
}
@@ -494,4 +506,4 @@ string PackageInfo::GetInstalationPath() const
bool PackageInfo::operator==(const PackageInfo& package) const
{
return (package.FullName == FullName);
}
}