Leviathan  0.8.0.0
Leviathan game engine
Leviathan::ScriptSafeVariableBlock Class Reference

Reference counted version for scripts of VariableBlock. More...

#include <DataBlock.h>

+ Inheritance diagram for Leviathan::ScriptSafeVariableBlock:

Public Member Functions

template<class BlockBaseType >
 ScriptSafeVariableBlock (DataBlock< BlockBaseType > *block, const std::string &name)
 
DLLEXPORT ScriptSafeVariableBlock (VariableBlock *copyfrom, const std::string &name)
 
bool IsValidType ()
 
int ConvertAndReturnProxyInt ()
 
std::string ConvertAndReturnProxyString ()
 
- Public Member Functions inherited from Leviathan::NamedVariableBlock
template<class DBRType >
 NamedVariableBlock (DataBlock< DBRType > *block, const std::string &name)
 
 NamedVariableBlock (DataBlockAll *block, const std::string &name)
 
 NamedVariableBlock (const int &var, const std::string &name)
 
 NamedVariableBlock (const bool &var, bool isactuallybooltype, const std::string &name)
 
 NamedVariableBlock (const std::string &var, const std::string &name)
 
 NamedVariableBlock (const std::wstring &var, const std::string &name)
 
 NamedVariableBlock (const double &var, const std::string &name)
 
 NamedVariableBlock (const float &var, const std::string &name)
 
 NamedVariableBlock (const char &var, const std::string &name)
 
 NamedVariableBlock (void *var, const std::string &name)
 
std::string GetName () const
 
bool CompareName (const std::string &str) const
 
std::string & GetNameChangeable ()
 
- Public Member Functions inherited from Leviathan::VariableBlock
 VariableBlock ()
 Default empty constructor, block has no value of any kind. More...
 
template<class DBRType >
 VariableBlock (DataBlock< DBRType > *block)
 
 VariableBlock (const int &var)
 
 VariableBlock (const bool &var, bool isactuallybooltype)
 
 VariableBlock (const std::string &var)
 
 VariableBlock (const std::wstring &var)
 
 VariableBlock (const double &var)
 
 VariableBlock (const float &var)
 
 VariableBlock (const char &var)
 
 VariableBlock (void *var)
 
DLLEXPORT VariableBlock (sf::Packet &packet)
 Constructs from a packet. More...
 
DLLEXPORT void AddDataToPacket (sf::Packet &packet) const
 Stores data to a packet. More...
 
 VariableBlock (const VariableBlock &arg)
 
DLLEXPORT VariableBlock (const std::string &valuetoparse, std::map< std::string, std::shared_ptr< VariableBlock >> *predefined)
 
 VariableBlock (DataBlockAll *block)
 
virtual ~VariableBlock ()
 
DataBlockAllGetBlock ()
 
const DataBlockAllGetBlockConst () const
 
bool IsValid () const
 
VariableBlockoperator= (VariableBlock *arg)
 
template<class DBlockTP >
VariableBlockoperator= (DataBlock< DBlockTP > *arg)
 
VariableBlockoperator= (const VariableBlock &arg)
 
bool operator== (const VariableBlock &other) const
 comparison operator More...
 
bool operator!= (const VariableBlock &other) const
 Opposite of the comparison operator. More...
 
template<class ConvertT >
 operator ConvertT () const
 
template<class ConvertT >
 operator ConvertT * ()
 
template<class ConvertT >
bool IsConversionAllowedNonPtr () const
 
template<class ConvertT >
bool IsConversionAllowedPtr () const
 
template<class ConvertT >
bool ConvertAndAssingToVariable (ConvertT &var) const
 
template<class ConvertT >
ConvertT ConvertAndReturnVariable () const
 
- Public Member Functions inherited from Leviathan::ReferenceCounted
 ReferenceCounted (const ReferenceCounted &other)=delete
 
ReferenceCountedoperator= (const ReferenceCounted &other)=delete
 
FORCE_INLINE void AddRef () const
 
FORCE_INLINE void Release () const
 removes a reference and deletes the object if reference count reaches zero More...
 
FORCE_INLINE void AddRef ()
 
FORCE_INLINE void Release ()
 
int32_t GetRefCount () const
 Returns the reference count. More...
 

Protected Attributes

int ASTypeID
 
- Protected Attributes inherited from Leviathan::NamedVariableBlock
std::string Name
 
- Protected Attributes inherited from Leviathan::VariableBlock
DataBlockAllBlockData = nullptr
 

Additional Inherited Members

- Public Types inherited from Leviathan::ReferenceCounted
using basepointer = boost::intrusive_ptr< ReferenceCounted >
 
using refcountedpointer = boost::intrusive_ptr< ReferenceCounted >
 
- Static Public Member Functions inherited from Leviathan::ReferenceCounted
template<class ActualType >
static boost::intrusive_ptr< ActualType > WrapPtr (ActualType *ptr)
 Creates an intrusive_ptr from raw pointer. More...
 
template<class ActualType , class... Args>
static boost::intrusive_ptr< ActualType > MakeShared (Args &&... args)
 Constructs a new instance and wraps it. More...
 
- Protected Member Functions inherited from Leviathan::ReferenceCounted
DLLEXPORT ReferenceCounted ()
 
virtual DLLEXPORT ~ReferenceCounted ()
 

Detailed Description

Reference counted version for scripts of VariableBlock.

Also stores the AngelScript ID of the type

Note
Do NOT use smart pointers with this class
Todo:

Unify multiple values containing things and naming

This whole thing should be made again and the types should be integrated to a single VariableBlock class that has a void* and an angelscript type

Definition at line 840 of file DataBlock.h.

Constructor & Destructor Documentation

◆ ScriptSafeVariableBlock() [1/2]

template<class BlockBaseType >
Leviathan::ScriptSafeVariableBlock::ScriptSafeVariableBlock ( DataBlock< BlockBaseType > *  block,
const std::string &  name 
)
inline

Definition at line 844 of file DataBlock.h.

845  :
846  NamedVariableBlock(block, name)
847  {
848  // getting typeid //
850  }
NamedVariableBlock(DataBlock< DBRType > *block, const std::string &name)
Definition: DataBlock.h:766

◆ ScriptSafeVariableBlock() [2/2]

Leviathan::ScriptSafeVariableBlock::ScriptSafeVariableBlock ( VariableBlock copyfrom,
const std::string &  name 
)

Definition at line 104 of file DataBlock.cpp.

105  :
106  NamedVariableBlock(copyfrom->GetBlock()->AllocateNewFromThis(), name)
107 {
108  // we need to copy all settings from the block //
109  switch(copyfrom->GetBlock()->Type) {
110  case DATABLOCK_TYPE_INT:
112  break;
115  break;
116  case DATABLOCK_TYPE_BOOL:
118  break;
119  case DATABLOCK_TYPE_WSTRING: {
120  // we'll use automatic conversion here //
121  unique_ptr<DataBlockAll> tmp(new StringBlock(ConvertAndReturnVariable<std::string>()));
122 
124  BlockData = tmp.release();
125 
127  break;
128  } break;
131  break;
132  case DATABLOCK_TYPE_CHAR:
134  break;
137  break;
138 
139  default:
140  throw InvalidArgument("cannot convert non-named, generic type block to script "
141  "safe block");
142  }
143 }
static int Get(ScriptExecutor *resolver)
#define DATABLOCK_TYPE_INT
Definition: DataBlock.h:22
DataBlockAll * BlockData
Definition: DataBlock.h:756
static DLLEXPORT ScriptExecutor * Get()
#define DATABLOCK_TYPE_WSTRING
Definition: DataBlock.h:25
NamedVariableBlock(DataBlock< DBRType > *block, const std::string &name)
Definition: DataBlock.h:766
#define DATABLOCK_TYPE_FLOAT
Definition: DataBlock.h:23
#define DATABLOCK_TYPE_STRING
Definition: DataBlock.h:26
virtual DLLEXPORT DataBlockAll * AllocateNewFromThis() const =0
#define DATABLOCK_TYPE_DOUBLE
Definition: DataBlock.h:28
DataBlockAll * GetBlock()
Definition: DataBlock.h:499
#define DATABLOCK_TYPE_BOOL
Definition: DataBlock.h:24
DataBlock< std::string > StringBlock
Definition: DataBlock.h:386
#define SAFE_DELETE(x)
Definition: Define.h:151
#define DATABLOCK_TYPE_CHAR
Definition: DataBlock.h:27

Member Function Documentation

◆ ConvertAndReturnProxyInt()

int Leviathan::ScriptSafeVariableBlock::ConvertAndReturnProxyInt ( )
inline

Definition at line 860 of file DataBlock.h.

860  {
861  return ConvertAndReturnVariable<int>();
862  }

◆ ConvertAndReturnProxyString()

std::string Leviathan::ScriptSafeVariableBlock::ConvertAndReturnProxyString ( )
inline

Definition at line 863 of file DataBlock.h.

863  {
864 
865  return ConvertAndReturnVariable<std::string>();
866  }

◆ IsValidType()

bool Leviathan::ScriptSafeVariableBlock::IsValidType ( )
inline

Definition at line 855 of file DataBlock.h.

855  {
856  return ASTypeID > 0 ? true: false;
857  }

Member Data Documentation

◆ ASTypeID

int Leviathan::ScriptSafeVariableBlock::ASTypeID
protected

Definition at line 870 of file DataBlock.h.


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