BinaryListComponent

Search for usage in LXR

BinaryListComponent< T, Component > Class Template Referenceabstract

#include <binarylistcomponent.h>

Inheritance diagram for BinaryListComponent< T, Component >:

Public Member Functions

 BinaryListComponent (Component *parent, QString basename)
 
 BinaryListComponent (Component *parent, QString basename, QString txtExt, QString binExt)
 

Protected Member Functions

virtual void clearData ()
 
virtual bool dropBinary ()
 
virtual bool dropText ()
 
virtual void loadData ()
 
virtual void loadData (bool dropBinaryFile)
 
virtual void loadDataFromBinary ()
 
virtual void loadDataFromBinary (QFile &binfile)
 
virtual void loadDataFromText ()=0
 
virtual void writeBinary ()
 
virtual void writeBinary (QFile &binfile)
 

Protected Attributes

QString filepath_bin
 
QString filepath_txt
 

Detailed Description

template<class T, typename Component>
class BinaryListComponent< T, Component >

provides functionality for loading the component data from Binary

Author
Valentin Boettcher
Version
1.0

This class is an abstract Template which requires that the type T is some child of SkyObject and the type Component is some child of ListComponent. The class T must provide a static TYPE property of the type SkyObject::TYPE. This is required because access to the type() method is inconvenient here!

The derived class must provide a void loadFromText() method, which loads the component via addListObject or similar. (This method implements parsing etc, and cannot be abstracted by this class.)

Finally, one has to add this template as a friend class upon deriving it. This is a concession to the already present architecture.

File paths are determent by the means of KSPaths::writableLocation.

Definition at line 39 of file binarylistcomponent.h.

Constructor & Destructor Documentation

◆ BinaryListComponent() [1/2]

BinaryListComponent.

Parameters
parenta reference to the inheriting child
basenamethe base filename for the binary

Sets the file extensions to dat for text and bin for binary.

Definition at line 147 of file binarylistcomponent.h.

◆ BinaryListComponent() [2/2]

template<class T , typename Component >
BinaryListComponent< T, Component >::BinaryListComponent ( Component * parent,
QString basename,
QString txtExt,
QString binExt )

BinaryListComponent.

Parameters
parenta reference to the inheriting child
basenamethe base filename for the binary
txtExttext data file extension
binExtbinary data file extension

Definition at line 150 of file binarylistcomponent.h.

Member Function Documentation

◆ clearData()

template<class T , typename Component >
void BinaryListComponent< T, Component >::clearData ( )
protectedvirtual

clearData

Removes the current component data where necessary.

Definition at line 252 of file binarylistcomponent.h.

◆ dropBinary()

template<class T , typename Component >
bool BinaryListComponent< T, Component >::dropBinary ( )
protectedvirtual

dropBinary

Removes the binary file.

Returns
True if operation succeeds

Definition at line 240 of file binarylistcomponent.h.

◆ dropText()

template<class T , typename Component >
bool BinaryListComponent< T, Component >::dropText ( )
protectedvirtual

dropText

Removes the text file.

Returns
True if operation succeeds

Definition at line 246 of file binarylistcomponent.h.

◆ loadData() [1/2]

template<class T , typename Component >
void BinaryListComponent< T, Component >::loadData ( )
protectedvirtual

loadData

Calls loadData(false)

Definition at line 157 of file binarylistcomponent.h.

◆ loadData() [2/2]

template<class T , typename Component >
void BinaryListComponent< T, Component >::loadData ( bool dropBinaryFile)
protectedvirtual

loadData

Load the component data from binary (if available) or from text

Parameters
dropBinaryFilewhether to drop the current binary (and to recreate it)

Tip: If you want to reload the data and recreate the binfile, just call loadData(true).

Definition at line 163 of file binarylistcomponent.h.

◆ loadDataFromBinary() [1/2]

template<class T , typename Component >
void BinaryListComponent< T, Component >::loadDataFromBinary ( )
protectedvirtual

loadDataFromBinary

Opens the default binfile and calls loadDataFromBinary([FILE])

Definition at line 182 of file binarylistcomponent.h.

◆ loadDataFromBinary() [2/2]

template<class T , typename Component >
void BinaryListComponent< T, Component >::loadDataFromBinary ( QFile & binfile)
protectedvirtual

loadDataFromBinary

Parameters
binfilethe binary file

Loads the component data from the given binary.

Definition at line 189 of file binarylistcomponent.h.

◆ loadDataFromText()

template<class T , typename Component >
virtual void BinaryListComponent< T, Component >::loadDataFromText ( )
protectedpure virtual

loadDataFromText

Load the component data from text.

This method shall be implemented by those who derive this class.

This method should load the component data from text by the use of addListObject or similar.

◆ writeBinary() [1/2]

template<class T , typename Component >
void BinaryListComponent< T, Component >::writeBinary ( )
protectedvirtual

writeBinary

Opens the default binfile and calls writeBinary([FILE])

Definition at line 216 of file binarylistcomponent.h.

◆ writeBinary() [2/2]

template<class T , typename Component >
void BinaryListComponent< T, Component >::writeBinary ( QFile & binfile)
protectedvirtual

writeBinary

Parameters
binfile

Writes the component data to the specified binary. (Destructive)

Definition at line 223 of file binarylistcomponent.h.

Member Data Documentation

◆ filepath_bin

template<class T , typename Component >
QString BinaryListComponent< T, Component >::filepath_bin
protected

Definition at line 138 of file binarylistcomponent.h.

◆ filepath_txt

template<class T , typename Component >
QString BinaryListComponent< T, Component >::filepath_txt
protected

Definition at line 137 of file binarylistcomponent.h.


The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.