Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <stdexcept>
- class Iterable{
- public:
- Iterable();
- class Slice{
- private:
- signed long int mStart,mEnd;
- public:
- Slice(signed long int aStart,signed long int aEnd);
- Slice(const Slice& );
- unsigned int start(unsigned int) const throw(std::range_error);
- unsigned int end(unsigned int) const throw(std::range_error);
- };
- class UnneededAllocation{
- private:
- unsigned int mNumRemaining;
- public:
- UnneededAllocation(unsigned int) throw(UnneededAllocation);
- unsigned int remaining();
- };
- protected:
- unsigned int mAlloc,mUsed;
- static unsigned int gBufferSize;
- virtual void Allocate(unsigned int) throw(UnneededAllocation) = 0;
- virtual unsigned int newSize(unsigned int) throw(UnneededAllocation);
- };
- class SmartArray:public Iterable
- {
- protected:
- void Allocate(unsigned int) throw(Iterable::UnneededAllocation);
- public:
- class SmartObject{
- protected:
- virtual void destroy() = 0;
- unsigned int mRefCount;
- private:
- SmartObject* createReference();
- public:
- SmartObject();
- class Reference{
- private:
- SmartObject* referenceTo;
- protected:
- void Log( const char* );
- public:
- Reference( SmartObject* );
- Reference( Reference& );
- Reference( void );
- Reference& operator = ( SmartObject* );
- Reference& operator = ( Reference& );
- ~Reference();
- SmartObject& operator () ();
- };
- };
- class Callback
- {
- public:
- virtual SmartObject& operator ()(SmartObject::Reference&,unsigned int ID) const = 0;
- };
- SmartArray(void);
- SmartArray( const SmartArray& );
- ~SmartArray(void);
- SmartArray& ForEach( const Callback& );
- SmartArray& Append( SmartObject* );
- SmartArray& Append( SmartObject::Reference& );
- SmartArray& Insert( SmartObject*, int );
- SmartArray& Prepend( SmartObject* );
- const SmartArray operator [] ( const Slice& );
- private:
- SmartObject::Reference* mItems;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement