JX Application Framework
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
JFileArrayIndex Class Reference

#include <JFileArrayIndex.h>

Inheritance diagram for JFileArrayIndex:
[legend]

Public Types

enum  ItemType {
  kData = 0 ,
  kEmbeddedFile = 1
}
 

Public Member Functions

 JFileArrayIndex ()
 
 ~JFileArrayIndex () override
 
void InsertItemAtIndex (const JFAIndex &index, const JUnsignedOffset offset, const JFAID &id)
 
void RemoveItem (const JFAIndex &index, const JSize itemSize)
 
void MoveItemToIndex (const JFAIndex &currentIndex, const JFAIndex &newIndex)
 
void SwapItems (const JFAIndex &index1, const JFAIndex &index2)
 
JUnsignedOffset GetItemOffset (const JFAIndex &index) const
 
void ItemSizeChanged (const JFAIndex &index, const JInteger changeInItemSize)
 
JFAID GetItemID (const JFAIndex &index) const
 
void SetItemID (const JFAIndex &index, const JFAID &id)
 
bool GetItemIndexFromID (const JFAID &id, JFAIndex *index) const
 
JFAID GetUniqueID () const
 
void SetToEmbeddedFile (const JFAIndex &index)
 
bool IsEmbeddedFile (const JFAIndex &index) const
 
void EmbeddedFileOpened (const JFAIndex &index, JFileArray *theEmbeddedFile)
 
void EmbeddedFileClosed (const JFAIndex &index)
 
bool EmbeddedFileIsClosed (const JFAIndex &index) const
 
bool AllEmbeddedFilesAreClosed () const
 
void ReplaceEmbeddedFileStreams (std::fstream *newStream)
 
void ReadIndex (const JSize itemCount, std::istream &input)
 
void WriteIndex (std::ostream &output)
 
JSize GetIndexLength () const
 
- Public Member Functions inherited from JContainer
 JContainer ()
 
 JContainer (const JContainer &source)
 
JContaineroperator= (const JContainer &source)
 
- Public Member Functions inherited from JCollection
 JCollection ()
 
 JCollection (const JCollection &source)
 
 ~JCollection () override
 
JCollectionoperator= (const JCollection &source)
 
JSize GetItemCount () const
 
bool IsEmpty () const
 
bool IndexValid (const JIndex index) const
 
JIndex GetIndexFromEnd (const JIndex index) const
 
JString ToString () const override
 
- Public Member Functions inherited from JBroadcaster
 JBroadcaster ()
 
virtual ~JBroadcaster ()
 
JBroadcasteroperator= (const JBroadcaster &source)
 
bool HasSenders () const
 
JSize GetSenderCount () const
 
bool HasRecipients () const
 
JSize GetRecipientCount () const
 
template<class T >
void ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f)
 

Additional Inherited Members

- Protected Member Functions inherited from JContainer
void InstallCollection (JCollection *list)
 
const JCollectionGetList () const
 
void Receive (JBroadcaster *sender, const Message &message) override
 
- Protected Member Functions inherited from JCollection
void ItemAdded ()
 
void ItemRemoved ()
 
void SetItemCount (const JSize newItemCount)
 
- Protected Member Functions inherited from JBroadcaster
 JBroadcaster (const JBroadcaster &source)
 
void ListenTo (const JBroadcaster *sender)
 
void StopListening (const JBroadcaster *sender)
 
void ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember)
 
void StopListening (const JBroadcaster *sender, const std::type_info &messageType)
 
template<class T >
void Send (JBroadcaster *recipient, const T &message)
 
template<class T >
void Broadcast (const T &message)
 
void SendWithFeedback (JBroadcaster *recipient, Message *message)
 
void BroadcastWithFeedback (Message *message)
 
virtual void ReceiveWithFeedback (JBroadcaster *sender, Message *message)
 
virtual void ReceiveGoingAway (JBroadcaster *sender)
 

Detailed Description

            The Index-of-Items for a JFileArray Class

This class stores and index of the items in a JFileArray.

Member Enumeration Documentation

◆ ItemType

Enumerator
kData 
kEmbeddedFile 

Constructor & Destructor Documentation

◆ JFileArrayIndex()

JFileArrayIndex::JFileArrayIndex ( )

◆ ~JFileArrayIndex()

JFileArrayIndex::~JFileArrayIndex ( )
override

Member Function Documentation

◆ AllEmbeddedFilesAreClosed()

bool JFileArrayIndex::AllEmbeddedFilesAreClosed ( ) const

Returns true if all embedded files are closed.

◆ EmbeddedFileClosed()

void JFileArrayIndex::EmbeddedFileClosed ( const JFAIndex index)

Tell us that the specified item (an embedded file) has been closed. We scream if the item isn't an embedded file or if the item isn't open.

◆ EmbeddedFileIsClosed()

bool JFileArrayIndex::EmbeddedFileIsClosed ( const JFAIndex index) const

Returns TRUE if the specified item is not an embedded file or if it is a closed embedded file.

◆ EmbeddedFileOpened()

void JFileArrayIndex::EmbeddedFileOpened ( const JFAIndex index,
JFileArray theEmbeddedFile 
)

Notify us that an embedded file has been opened. We scream if the item isn't an embedded file or if the item is already open.

◆ GetIndexLength()

JSize JFileArrayIndex::GetIndexLength ( ) const

Return the amount of space required to store the index. Not inline because constants shouldn't be part of class declaration.

◆ GetItemID()

JFAID JFileArrayIndex::GetItemID ( const JFAIndex index) const

◆ GetItemIndexFromID()

bool JFileArrayIndex::GetItemIndexFromID ( const JFAID id,
JFAIndex index 
) const

Return the index of the item with the specified ID. Returns false if there is no item with the specified ID.

◆ GetItemOffset()

JUnsignedOffset JFileArrayIndex::GetItemOffset ( const JFAIndex index) const

◆ GetUniqueID()

JFAID JFileArrayIndex::GetUniqueID ( ) const

Return an unused ID. Return zero if all ID's have been used.

◆ InsertItemAtIndex()

void JFileArrayIndex::InsertItemAtIndex ( const JFAIndex index,
const JUnsignedOffset  offset,
const JFAID id 
)

Insert a new item into the index. Since the storage is appended to the file, we don't have to adjust any item offsets.

If the item will be an embedded file, the caller must set it separately.

◆ IsEmbeddedFile()

bool JFileArrayIndex::IsEmbeddedFile ( const JFAIndex index) const

Returns TRUE if the specified item contains an embedded file.

◆ ItemSizeChanged()

void JFileArrayIndex::ItemSizeChanged ( const JFAIndex index,
const JInteger  changeInItemSize 
)

Adjust the offsets of the other items. This is the only way item offsets change.

◆ MoveItemToIndex()

void JFileArrayIndex::MoveItemToIndex ( const JFAIndex currentIndex,
const JFAIndex newIndex 
)
inline

◆ ReadIndex()

void JFileArrayIndex::ReadIndex ( const JSize  itemCount,
std::istream &  input 
)

Read the file's index.

Caller must position read mark before calling.

◆ RemoveItem()

void JFileArrayIndex::RemoveItem ( const JFAIndex index,
const JSize  itemSize 
)

Remove the specified item and adjust the offsets of the other items.

◆ ReplaceEmbeddedFileStreams()

void JFileArrayIndex::ReplaceEmbeddedFileStreams ( std::fstream *  newStream)

Notify all embedded files that their enclosing file has a new std::fstream.

◆ SetItemID()

void JFileArrayIndex::SetItemID ( const JFAIndex index,
const JFAID newID 
)

Set the id of the specified item. We scream if the id has already been used.

◆ SetToEmbeddedFile()

void JFileArrayIndex::SetToEmbeddedFile ( const JFAIndex index)

Specify that the specified item contains an embedded file. This is irreversible because the data (an entire JFileArray) is not usable by anyone else. They should remove the item instead.

◆ SwapItems()

void JFileArrayIndex::SwapItems ( const JFAIndex index1,
const JFAIndex index2 
)
inline

◆ WriteIndex()

void JFileArrayIndex::WriteIndex ( std::ostream &  output)

Write the file's index.

Caller must position write mark before calling.

The documentation for this class was generated from the following files: