FData optimization

This commit is contained in:
Markus Gans 2020-09-18 22:40:51 +02:00
parent 5092244b81
commit ff2e29b246
4 changed files with 54 additions and 75 deletions

View File

@ -51,7 +51,7 @@ void doubleToItem ( FListBoxItem& item
, std::size_t index )
{
typedef std::list<double> DblList;
DblList& dbl_list = FListBoxHelper::getContainer<DblList>(container);
DblList& dbl_list = flistboxhelper::getContainer<DblList>(container);
std::list<double>::iterator iter = dbl_list.begin();
std::advance (iter, index);
item.setText (FString() << *iter);

View File

@ -834,7 +834,7 @@ void FListBox::drawList()
const bool lineHasBrackets = hasBrackets(iter);
// Import data via lazy conversion
lazyConvert (iter, int(y));
lazyConvert (iter, y);
// Set screen position and attributes
setLineAttributes ( int(y), isSelected(iter), lineHasBrackets

View File

@ -51,13 +51,11 @@ namespace finalcut
//----------------------------------------------------------------------
template <typename T>
struct FData; // Class forward declaration
class FData; // Class forward declaration
struct FDataAccess
class FDataAccess
{
public:
virtual ~FDataAccess();
template <typename T>
const T& get() const
{
@ -72,94 +70,75 @@ struct FDataAccess
}
};
//----------------------------------------------------------------------
inline FDataAccess::~FDataAccess()
{ }
//----------------------------------------------------------------------
// struct FData
//----------------------------------------------------------------------
template <typename T>
struct FData : public FDataAccess
class FData : public FDataAccess
{
explicit FData (T& v) // constructor
: value_ref{v}
{ }
public:
explicit FData (T& v) // constructor
: value_ref{v}
{ }
explicit FData (T&& v) // constructor
: value{v}
, value_ref{value}
{ }
explicit FData (T&& v) // constructor
: value{std::move(v)}
, value_ref{value}
{ }
~FData() // destructor
{ }
T operator () () const
{
return value_ref;
}
FData (const FData& d) // Copy constructor
: value{d.value}
, value_ref{d.value_ref}
{ }
template <typename... Args>
T operator () (Args... args) const
{
return value_ref(args...);
}
FData& operator = (const FData& d) // Copy assignment operator (=)
{
value = d.value;
value_ref = d.value_ref;
return *this;
}
explicit operator T () const
{
return value_ref;
}
T operator () () const
{
return value_ref;
}
T& get()
{
return value_ref;
}
template <typename... Args>
T operator () (Args... args) const
{
return value_ref(args...);
}
void set (const T& v)
{
value_ref = v;
}
explicit operator T () const
{
return value_ref;
}
bool isInitializedCopy()
{
return bool(value);
}
T& get()
{
return value_ref;
}
bool isInitializedReference()
{
return ! isInitializedCopy();
}
void set (const T& v)
{
value_ref = v;
}
FData& operator << (const T& v)
{
value_ref = v;
return *this;
}
bool isInitializedCopy()
{
return bool(value);
}
bool isInitializedReference()
{
return ! isInitializedCopy();
}
FData& operator << (const T& v)
{
value_ref = v;
return *this;
}
friend std::ostream& operator << (std::ostream &os, const FData& data)
{
os << data.value_ref;
return os;
}
friend std::ostream& operator << (std::ostream &os, const FData& data)
{
os << data.value_ref;
return os;
}
private:
// Data members
T value{};
public:
T& value_ref;
};

View File

@ -371,7 +371,7 @@ class FListBox : public FWidget
// non-member function
//----------------------------------------------------------------------
namespace FListBoxHelper
namespace flistboxhelper
{
template <typename Container>