Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::ConfigOptionEnumGeneric Class Reference

#include <src/libslic3r/Config.hpp>

+ Inheritance diagram for Slic3r::ConfigOptionEnumGeneric:
+ Collaboration diagram for Slic3r::ConfigOptionEnumGeneric:

Public Member Functions

 ConfigOptionEnumGeneric (const t_config_enum_values *keys_map=nullptr)
 
 ConfigOptionEnumGeneric (const t_config_enum_values *keys_map, int value)
 
ConfigOptionType type () const override
 
ConfigOptionclone () const override
 
ConfigOptionEnumGenericoperator= (const ConfigOption *opt)
 
bool operator== (const ConfigOptionEnumGeneric &rhs) const throw ()
 
bool operator< (const ConfigOptionEnumGeneric &rhs) const throw ()
 
bool operator== (const ConfigOption &rhs) const override
 
void set (const ConfigOption *rhs) override
 
std::string serialize () const override
 
bool deserialize (const std::string &str, bool append=false) override
 
int getInt () const override
 
void setInt (int val) override
 
bool operator== (const ConfigOptionInt &rhs) const throw ()
 
bool operator== (const int &rhs) const throw ()
 
 operator int () const
 
bool operator!= (const int &rhs) const throw ()
 
bool operator!= (const ConfigOption &rhs) const
 
bool operator< (const int &rhs) const throw ()
 
size_t hash () const override throw ()
 
virtual double getFloat () const
 
virtual bool getBool () const
 
bool is_scalar () const
 
bool is_vector () const
 
virtual bool nullable () const
 
virtual bool is_nil () const
 
virtual bool overriden_by (const ConfigOption *rhs) const
 
virtual bool apply_override (const ConfigOption *rhs)
 

Static Public Member Functions

static ConfigOptionType static_type ()
 

Public Attributes

const t_config_enum_valueskeys_map
 
int value
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar)
 

Friends

class cereal::access
 

Detailed Description

Constructor & Destructor Documentation

◆ ConfigOptionEnumGeneric() [1/2]

Slic3r::ConfigOptionEnumGeneric::ConfigOptionEnumGeneric ( const t_config_enum_values keys_map = nullptr)
inline
1574: keys_map(keys_map) {}
const t_config_enum_values * keys_map
Definition Config.hpp:1577

◆ ConfigOptionEnumGeneric() [2/2]

Slic3r::ConfigOptionEnumGeneric::ConfigOptionEnumGeneric ( const t_config_enum_values keys_map,
int  value 
)
inlineexplicit
ConfigOptionInt()
Definition Config.hpp:722
int value
Definition Config.hpp:305

Member Function Documentation

◆ apply_override()

virtual bool Slic3r::ConfigOption::apply_override ( const ConfigOption rhs)
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionVector< T >, Slic3r::ConfigOptionVector< double >, Slic3r::ConfigOptionVector< FloatOrPercent >, Slic3r::ConfigOptionVector< int >, Slic3r::ConfigOptionVector< std::string >, Slic3r::ConfigOptionVector< unsigned char >, and Slic3r::ConfigOptionVector< Vec2d >.

290 {
291 if (*this == *rhs)
292 return false;
293 *this = *rhs;
294 return true;
295 }

Referenced by Slic3r::print_config_diffs().

+ Here is the caller graph for this function:

◆ clone()

ConfigOption * Slic3r::ConfigOptionEnumGeneric::clone ( ) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1581{ return new ConfigOptionEnumGeneric(*this); }
ConfigOptionEnumGeneric(const t_config_enum_values *keys_map=nullptr)
Definition Config.hpp:1574

◆ deserialize()

bool Slic3r::ConfigOptionEnumGeneric::deserialize ( const std::string &  str,
bool  append = false 
)
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1610 {
1611 UNUSED(append);
1612 auto it = this->keys_map->find(str);
1613 if (it == this->keys_map->end())
1614 return false;
1615 this->value = it->second;
1616 return true;
1617 }
#define UNUSED(x)
Definition libslic3r.h:74
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:110

References Slic3r::append(), and UNUSED.

+ Here is the call graph for this function:

◆ getBool()

virtual bool Slic3r::ConfigOption::getBool ( ) const
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionBool.

272{ throw BadOptionTypeException("Calling ConfigOption::getBool on a non-boolean ConfigOption"); }

Referenced by Slic3r::client::MyContext::scalar_variable_to_expr().

+ Here is the caller graph for this function:

◆ getFloat()

virtual double Slic3r::ConfigOption::getFloat ( ) const
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionFloat.

271{ throw BadOptionTypeException("Calling ConfigOption::getFloat on a non-float ConfigOption"); }

Referenced by Slic3r::GUI::TabSLAMaterial::build(), Slic3r::GUI::get_string_value(), Slic3r::client::MyContext::scalar_variable_to_expr(), and Slic3r::GUI::Sidebar::update_sliced_info_sizer().

+ Here is the caller graph for this function:

◆ getInt()

int Slic3r::ConfigOptionInt::getInt ( ) const
inlineoverridevirtualinherited

Reimplemented from Slic3r::ConfigOption.

728{ return this->value; }

References Slic3r::ConfigOptionSingle< int >::value.

◆ hash()

size_t Slic3r::ConfigOptionSingle< int >::hash ( ) const
throw (
)
inlineoverridevirtualinherited

Implements Slic3r::ConfigOption.

329{ return std::hash<T>{}(this->value); }

◆ is_nil()

◆ is_scalar()

bool Slic3r::ConfigOption::is_scalar ( ) const
inlineinherited
277{ return (int(this->type()) & int(coVectorType)) == 0; }
virtual ConfigOptionType type() const =0
@ coVectorType
Definition Config.hpp:161

References Slic3r::coVectorType, and Slic3r::ConfigOption::type().

Referenced by Slic3r::PresetBundle::full_fff_config(), Slic3r::client::MyContext::is_nil_test(), Slic3r::ConfigOption::is_vector(), Slic3r::client::MyContext::legacy_variable_expansion(), Slic3r::PresetBundle::load_config_file_config(), Slic3r::client::MyContext::scalar_variable_assign_scalar(), Slic3r::client::MyContext::scalar_variable_to_expr(), Slic3r::client::MyContext::vector_variable_assign_array(), Slic3r::client::MyContext::vector_variable_assign_initializer_list(), and Slic3r::client::MyContext::vector_variable_new_from_array().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_vector()

◆ nullable()

virtual bool Slic3r::ConfigOption::nullable ( ) const
inlinevirtualinherited

◆ operator int()

Slic3r::ConfigOptionSingle< int >::operator int ( ) const
inlineinherited
307{ return this->value; }

◆ operator!=() [1/2]

bool Slic3r::ConfigOption::operator!= ( const ConfigOption rhs) const
inlineinherited
275{ return ! (*this == rhs); }

◆ operator!=() [2/2]

bool Slic3r::ConfigOptionSingle< int >::operator!= ( const int &  rhs) const
throw (
)
inlineinherited
326{ return this->value != rhs; }

◆ operator<() [1/2]

bool Slic3r::ConfigOptionEnumGeneric::operator< ( const ConfigOptionEnumGeneric rhs) const
throw (
)
inline
1584{ return this->value < rhs.value; }

◆ operator<() [2/2]

bool Slic3r::ConfigOptionSingle< int >::operator< ( const int &  rhs) const
throw (
)
inlineinherited
327{ return this->value < rhs; }

◆ operator=()

ConfigOptionEnumGeneric & Slic3r::ConfigOptionEnumGeneric::operator= ( const ConfigOption opt)
inline
1582{ this->set(opt); return *this; }
void set(const ConfigOption *rhs) override
Definition Config.hpp:1594

References set().

+ Here is the call graph for this function:

◆ operator==() [1/4]

bool Slic3r::ConfigOptionEnumGeneric::operator== ( const ConfigOption rhs) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1587 {
1588 if (rhs.type() != this->type())
1589 throw ConfigurationError("ConfigOptionEnumGeneric: Comparing incompatible types");
1590 // rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum<T>
1591 return this->value == rhs.getInt();
1592 }

References Slic3r::ConfigOption::getInt(), and Slic3r::ConfigOption::type().

+ Here is the call graph for this function:

◆ operator==() [2/4]

bool Slic3r::ConfigOptionEnumGeneric::operator== ( const ConfigOptionEnumGeneric rhs) const
throw (
)
inline
1583{ return this->value == rhs.value; }

◆ operator==() [3/4]

bool Slic3r::ConfigOptionInt::operator== ( const ConfigOptionInt rhs) const
throw (
)
inlineinherited
731{ return this->value == rhs.value; }

◆ operator==() [4/4]

bool Slic3r::ConfigOptionSingle< int >::operator== ( const int &  rhs) const
throw (
)
inlineinherited
325{ return this->value == rhs; }

◆ overriden_by()

virtual bool Slic3r::ConfigOption::overriden_by ( const ConfigOption rhs) const
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionVector< T >, Slic3r::ConfigOptionVector< double >, Slic3r::ConfigOptionVector< FloatOrPercent >, Slic3r::ConfigOptionVector< int >, Slic3r::ConfigOptionVector< std::string >, Slic3r::ConfigOptionVector< unsigned char >, and Slic3r::ConfigOptionVector< Vec2d >.

285 {
286 assert(! this->nullable() && ! rhs->nullable());
287 return *this != *rhs;
288 }
virtual bool nullable() const
Definition Config.hpp:280

References Slic3r::ConfigOption::nullable().

Referenced by Slic3r::print_config_diffs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize() [1/2]

std::string Slic3r::ConfigOptionEnumGeneric::serialize ( ) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1602 {
1603 for (const auto &kvp : *this->keys_map)
1604 if (kvp.second == this->value)
1605 return kvp.first;
1606 return std::string();
1607 }
if(!(yy_init))
Definition lexer.c:1190

References keys_map.

◆ serialize() [2/2]

template<class Archive >
void Slic3r::ConfigOptionEnumGeneric::serialize ( Archive &  ar)
inlineprivate
1621{ ar(cereal::base_class<ConfigOptionInt>(this)); }

◆ set()

void Slic3r::ConfigOptionEnumGeneric::set ( const ConfigOption rhs)
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1594 {
1595 if (rhs->type() != this->type())
1596 throw ConfigurationError("ConfigOptionEnumGeneric: Assigning an incompatible type");
1597 // rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum<T>
1598 this->value = rhs->getInt();
1599 }

References Slic3r::ConfigOption::getInt(), and Slic3r::ConfigOption::type().

Referenced by operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setInt()

void Slic3r::ConfigOptionInt::setInt ( int  val)
inlineoverridevirtualinherited

Reimplemented from Slic3r::ConfigOption.

729{ this->value = val; }

Referenced by Slic3r::apply_to_print_region_config().

+ Here is the caller graph for this function:

◆ static_type()

static ConfigOptionType Slic3r::ConfigOptionEnumGeneric::static_type ( )
inlinestatic
1579{ return coEnum; }
@ coEnum
Definition Config.hpp:194

References Slic3r::coEnum.

Referenced by type().

+ Here is the caller graph for this function:

◆ type()

ConfigOptionType Slic3r::ConfigOptionEnumGeneric::type ( ) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1580{ return static_type(); }
static ConfigOptionType static_type()
Definition Config.hpp:1579

References static_type().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ cereal::access

friend class cereal::access
friend

Member Data Documentation

◆ keys_map

const t_config_enum_values* Slic3r::ConfigOptionEnumGeneric::keys_map

Referenced by serialize().

◆ value

int Slic3r::ConfigOptionSingle< int >::value
inherited

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