comparison OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 4961:1b76853e1797 more-tags

DbOptimizer plugin
author Alain Mazy <am@osimis.io>
date Wed, 23 Mar 2022 11:56:28 +0100
parents 8785d8442f90
children 501411a67f10
comparison
equal deleted inserted replaced
4960:c68265bf1f94 4961:1b76853e1797
1544 boost::lexical_cast<std::string>(minor) + "." + 1544 boost::lexical_cast<std::string>(minor) + "." +
1545 boost::lexical_cast<std::string>(revision) + 1545 boost::lexical_cast<std::string>(revision) +
1546 " is required)"); 1546 " is required)");
1547 } 1547 }
1548 1548
1549 1549 bool CheckMinimalVersion(const char* version,
1550 bool CheckMinimalOrthancVersion(unsigned int major, 1550 unsigned int major,
1551 unsigned int minor, 1551 unsigned int minor,
1552 unsigned int revision) 1552 unsigned int revision)
1553 { 1553 {
1554 if (!HasGlobalContext()) 1554 if (!strcmp(version, "mainline"))
1555 {
1556 LogError("Bad Orthanc context in the plugin");
1557 return false;
1558 }
1559
1560 if (!strcmp(GetGlobalContext()->orthancVersion, "mainline"))
1561 { 1555 {
1562 // Assume compatibility with the mainline 1556 // Assume compatibility with the mainline
1563 return true; 1557 return true;
1564 } 1558 }
1565 1559
1566 // Parse the version of the Orthanc core 1560 // Parse the version
1567 int aa, bb, cc; 1561 int aa, bb, cc;
1568 if ( 1562 if (
1569 #ifdef _MSC_VER 1563 #ifdef _MSC_VER
1570 sscanf_s 1564 sscanf_s
1571 #else 1565 #else
1572 sscanf 1566 sscanf
1573 #endif 1567 #endif
1574 (GetGlobalContext()->orthancVersion, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 || 1568 (version, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 ||
1575 aa < 0 || 1569 aa < 0 ||
1576 bb < 0 || 1570 bb < 0 ||
1577 cc < 0) 1571 cc < 0)
1578 { 1572 {
1579 return false; 1573 return false;
1593 if (a < major) 1587 if (a < major)
1594 { 1588 {
1595 return false; 1589 return false;
1596 } 1590 }
1597 1591
1598
1599 // Check the minor version number 1592 // Check the minor version number
1600 assert(a == major); 1593 assert(a == major);
1601 1594
1602 if (b > minor) 1595 if (b > minor)
1603 { 1596 {
1618 } 1611 }
1619 else 1612 else
1620 { 1613 {
1621 return false; 1614 return false;
1622 } 1615 }
1616 }
1617
1618
1619 bool CheckMinimalOrthancVersion(unsigned int major,
1620 unsigned int minor,
1621 unsigned int revision)
1622 {
1623 if (!HasGlobalContext())
1624 {
1625 LogError("Bad Orthanc context in the plugin");
1626 return false;
1627 }
1628
1629 return CheckMinimalVersion(GetGlobalContext()->orthancVersion,
1630 major, minor, revision);
1623 } 1631 }
1624 1632
1625 1633
1626 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0) 1634 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0)
1627 const char* AutodetectMimeType(const std::string& path) 1635 const char* AutodetectMimeType(const std::string& path)