Middle Europe Productions Library  alpha 1.3.3
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
MEP::Object Class Reference

MEP::Object is a container of a sf::Texture it also have built in memory management. More...

#include <Object.h>

Inheritance diagram for MEP::Object:
MEP::Drawable MEP::AnimationObject MEP::TextureObject MEP::Button

Public Types

enum  ObjectType { ObjectType::NotInit, ObjectType::Single, ObjectType::Multi }
 

Public Member Functions

 Object ()=delete
 
 Object (const Object &x)
 
 Object (const U_int32 ID, const std::string &path, const std::string &filename, bool transparencyM=false)
 
 Object (const U_int32 ID, const std::string &path, const std::string &filename, unsigned int frames, bool transparencyM=false)
 
 Object (const U_int32 ID, std::list< sf::Image > &images, const std::string &filename, bool transparencyM=false)
 
virtual const sf::Vector2u & getSize () const
 
unsigned long getNufTextures () const
 
bool draw (sf::RenderWindow &window) override
 
void update (sf::Time &) override
 
void entryUpdate (sf::Time &currentTime, bool low=false) override
 
void exitUpdate (sf::Time &currentTime, bool low=false) override
 
ObjectgetObjectPoint ()
 
ObjectgetObjectRef ()
 
const U_int32getID () const
 
const std::string & getName () const
 
virtual bool isTansparent (unsigned int x, unsigned int y)
 
bool isActive () const
 
const ObjectTypegetType () const
 
unsigned int nufC () const
 
bool operator== (const std::string &x) const
 
bool operator== (const Object &x) const
 
virtual void debugOutput (std::ostream &out) const
 
 ~Object () override
 
- Public Member Functions inherited from MEP::Drawable
void _link (std::shared_ptr< bool > _li)
 
std::shared_ptr< bool > _linkAddr ()
 
const std::shared_ptr< bool > _linkAddr () const
 
bool _isLinked () const
 
U_int32 getDrawTag () const
 
void setDrawTag (const U_int32 tag)
 
bool addDrawTag (const U_int32 tag)
 
bool removeDrawTag (const U_int32 tag)
 
virtual void onResize ()
 
 Drawable ()=default
 
virtual ~Drawable ()
 

Protected Member Functions

void deleteObject ()
 
- Protected Member Functions inherited from MEP::Drawable
void notify ()
 
void drawTagDebug (std::ostream &out) const
 

Protected Attributes

bool transparency = false
 
bool ** table = nullptr
 
sf::Vector2u m_size = {0, 0}
 
std::list< sf::Texture * > * texture
 
ObjectType m_type = Object::ObjectType::NotInit
 

Friends

std::ostream & operator<< (std::ostream &out, const Object &x)
 

Detailed Description

MEP::Object is a container of a sf::Texture it also have built in memory management.

MEP::Object keeps a track of all of the shared instances of itself. In will only be possible to delete a MEP::Object when all of the instances are deleted and MEP::Resources deleteObject() method is called.

Member Enumeration Documentation

◆ ObjectType

Enumerator
NotInit 

Object not initialized.

Single 

Object is a single texture.

Multi 

Object is a list of textures.

Constructor & Destructor Documentation

◆ Object() [1/5]

MEP::Object::Object ( )
delete

Default constructor.

◆ Object() [2/5]

MEP::Object::Object ( const Object x)
inline

Copy constructor.

◆ Object() [3/5]

MEP::Object::Object ( const U_int32  ID,
const std::string &  path,
const std::string &  filename,
bool  transparencyM = false 
)
inline

Constructor of an object.

Parameters
[in]path: Path to the resources.
[in]name: Name of a resource.
[in]transparencyM: Transparency of a resource.

◆ Object() [4/5]

MEP::Object::Object ( const U_int32  ID,
const std::string &  path,
const std::string &  filename,
unsigned int  frames,
bool  transparencyM = false 
)
inline

Constructor of an object.

Parameters
[in]path: Path to the resources.
[in]name: Name of a resource.
[in]frames: Number of textures. Loading starts from the texture name0 to nameN where N is a number of frames - 1.
[in]transparencyM: Transparency of a resource.

◆ Object() [5/5]

MEP::Object::Object ( const U_int32  ID,
std::list< sf::Image > &  images,
const std::string &  filename,
bool  transparencyM = false 
)
inline

Constructor of an object.

Parameters
[in]path: Path to the resources.
[in]name: Name of a resource.
[in]frames: Number of textures. Loading starts from the texture name0 to nameN where N is a number of frames - 1.
[in]transparencyM: Transparency of a resource.

◆ ~Object()

MEP::Object::~Object ( )
inlineoverride

Member Function Documentation

◆ debugOutput()

virtual void MEP::Object::debugOutput ( std::ostream &  out) const
inlinevirtual

Debug output of the class.

Reimplemented from MEP::Drawable.

Reimplemented in MEP::TextureObject, and MEP::AnimationObject.

◆ deleteObject()

void MEP::Object::deleteObject ( )
inlineprotected

◆ draw()

bool MEP::Object::draw ( sf::RenderWindow &  window)
inlineoverridevirtual

Override of a MEP::Drawable draw.

Reimplemented from MEP::Drawable.

Reimplemented in MEP::TextureObject.

◆ entryUpdate()

void MEP::Object::entryUpdate ( sf::Time &  currentTime,
bool  low = false 
)
inlineoverridevirtual

Override of a MEP::Drawable entryUpdate.

Reimplemented from MEP::Drawable.

◆ exitUpdate()

void MEP::Object::exitUpdate ( sf::Time &  currentTime,
bool  low = false 
)
inlineoverridevirtual

Override of a MEP::Drawable exitUpdate.

Reimplemented from MEP::Drawable.

◆ getID()

const U_int32& MEP::Object::getID ( ) const
inline

Outputs the ID of the MEP::Object

Returns
MEP::Object

◆ getName()

const std::string& MEP::Object::getName ( ) const
inline

Outputs the name of the MEP::Object

Returns
MEP::Object

◆ getNufTextures()

unsigned long MEP::Object::getNufTextures ( ) const
inline

Outputs the number of frames of a MEP::Object

Returns
sf:Vector2u size.

◆ getObjectPoint()

Object* MEP::Object::getObjectPoint ( )
inline

Outputs the pointer to the MEP::Object

Returns
MEP::Object

◆ getObjectRef()

Object& MEP::Object::getObjectRef ( )
inline

Outputs the reference to the MEP::Object

Returns
MEP::Object

◆ getSize()

virtual const sf::Vector2u& MEP::Object::getSize ( ) const
inlinevirtual

Outputs the size of a master MEP::Object

Returns
sf:Vector2u size.

Reimplemented in MEP::AnimationObject.

◆ getType()

const ObjectType& MEP::Object::getType ( ) const
inline

Outputs the type of an MEP::Object

Returns
MEP::Object::ObjectType

◆ isActive()

bool MEP::Object::isActive ( ) const
inlinevirtual

Checks the activity of an object it is mainly related to the associated animations

Reimplemented from MEP::Drawable.

Reimplemented in MEP::TextureObject.

◆ isTansparent()

bool MEP::Object::isTansparent ( unsigned int  x,
unsigned int  y 
)
inlinevirtual

Checks the transparency of an object for the default SDL_Rect

Returns
true - position has an alpha channel > 100, false - position has an alpha chanel < 100

Reimplemented in MEP::Button, and MEP::AnimationObject.

◆ nufC()

unsigned int MEP::Object::nufC ( ) const
inline

Outputs the number of copies of the MEP::Object

Returns
Number of copies.

◆ operator==() [1/2]

bool MEP::Object::operator== ( const Object x) const
inline

Operator == operates on MEP::Object name.

◆ operator==() [2/2]

bool MEP::Object::operator== ( const std::string &  x) const
inline

Operator == operates on MEP::Object name.

◆ update()

void MEP::Object::update ( sf::Time &  )
inlineoverridevirtual

Override of a MEP::Drawable update.

Reimplemented from MEP::Drawable.

Reimplemented in MEP::TextureObject.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const Object x 
)
friend

Overrdie of the << operator for diagnostic purposes.

Member Data Documentation

◆ m_size

sf::Vector2u MEP::Object::m_size = {0, 0}
protected

◆ m_type

ObjectType MEP::Object::m_type = Object::ObjectType::NotInit
protected

◆ table

bool** MEP::Object::table = nullptr
protected

◆ texture

std::list<sf::Texture*>* MEP::Object::texture
protected

◆ transparency

bool MEP::Object::transparency = false
protected