refactoring: wrapped boost::optional in OPT<> class for the purpose of easier transition to C++17 in the future

This commit is contained in:
Tomasz Włostowski 2017-11-01 12:14:16 +01:00
parent 3292d622c1
commit 9932ff32ae
65 changed files with 187 additions and 190 deletions

View File

@ -23,6 +23,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <algorithm>
#include <commit.h>
#include <base_struct.h>

View File

@ -22,11 +22,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <algorithm>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_circle.h>
using boost::optional;
bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const
{
// fixme: ugly!
@ -366,7 +366,7 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const
}
const optional<SHAPE_LINE_CHAIN::INTERSECTION> SHAPE_LINE_CHAIN::SelfIntersecting() const
const OPT<SHAPE_LINE_CHAIN::INTERSECTION> SHAPE_LINE_CHAIN::SelfIntersecting() const
{
for( int s1 = 0; s1 < SegmentCount(); s1++ )
{
@ -410,7 +410,7 @@ const optional<SHAPE_LINE_CHAIN::INTERSECTION> SHAPE_LINE_CHAIN::SelfIntersectin
}
}
return optional<INTERSECTION>();
return OPT<SHAPE_LINE_CHAIN::INTERSECTION>();
}

View File

@ -25,6 +25,8 @@
#include <tool/tool_action.h>
#include <tool/action_manager.h>
#include <algorithm>
TOOL_ACTION::TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope,
int aDefaultHotKey, const wxString aMenuItem, const wxString& aMenuDesc,
const BITMAP_OPAQUE* aIcon, TOOL_ACTION_FLAGS aFlags, void* aParam ) :

View File

@ -35,7 +35,7 @@
#include <class_draw_panel_gal.h>
#include <pcbnew_id.h>
#include <boost/optional.hpp>
#include <core/optional.h>
///> Stores information about a mouse button state
struct TOOL_DISPATCHER::BUTTON_STATE
@ -154,7 +154,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
{
BUTTON_STATE* st = m_buttons[aIndex];
wxEventType type = aEvent.GetEventType();
boost::optional<TOOL_EVENT> evt;
OPT<TOOL_EVENT> evt;
bool isClick = false;
// bool up = type == st->upEvent;
@ -307,7 +307,7 @@ int translateSpecialCode( int aKeyCode )
void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
{
bool motion = false, buttonEvents = false;
boost::optional<TOOL_EVENT> evt;
OPT<TOOL_EVENT> evt;
int key = 0; // key = 0 if the event is not a key event
bool keyIsSpecial = false; // True if the key is a special key code
@ -436,7 +436,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent& aEvent )
{
boost::optional<TOOL_EVENT> evt = m_actions->TranslateLegacyId( aEvent.GetId() );
OPT<TOOL_EVENT> evt = m_actions->TranslateLegacyId( aEvent.GetId() );
if( evt )
m_toolMgr->ProcessEvent( *evt );

View File

@ -27,7 +27,7 @@
#include <stack>
#include <algorithm>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <wx/event.h>
#include <wx/clipbrd.h>
@ -44,8 +44,6 @@
#include <wxPcbStruct.h>
#include <class_draw_panel_gal.h>
using boost::optional;
/// Struct describing the current execution state of a TOOL
struct TOOL_MANAGER::TOOL_STATE
{
@ -494,7 +492,7 @@ void TOOL_MANAGER::RunMainStack( TOOL_BASE* aTool, std::function<void()> aFunc )
}
optional<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool,
OPT<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool,
const TOOL_EVENT_LIST& aConditions )
{
TOOL_STATE* st = m_toolState[aTool];
@ -632,7 +630,6 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
return false;
}
void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
{
// Store the current tool ID to decide whether to restore the cursor position
@ -703,10 +700,10 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
if( activeTool == GetCurrentToolId() )
{
m_viewControls->ForceCursorPosition( (bool) m_origCursor,
m_origCursor.get_value_or( VECTOR2D( 0, 0 ) ) );
m_origCursor.value_or( VECTOR2D( 0, 0 ) ) );
}
m_origCursor = boost::none;
m_origCursor = NULLOPT;
break;
}
}

View File

@ -29,8 +29,6 @@
#include <base_units.h>
#include <wx/valnum.h>
#include <boost/optional.hpp>
#include "wx_unit_binder.h"
WX_UNIT_BINDER::WX_UNIT_BINDER( wxWindow* aParent, wxTextEntry* aTextInput,

View File

@ -29,7 +29,7 @@
#include <limits>
#include <base_units.h>
#include <wx/valnum.h>
#include <boost/optional.hpp>
#include <core/optional.h>
WX_UNIT_TEXT::WX_UNIT_TEXT( wxWindow* aParent, const wxString& aLabel, double aValue, double aStep ) :
wxPanel( aParent, wxID_ANY ),
@ -109,18 +109,18 @@ void WX_UNIT_TEXT::SetValue( double aValue )
}
boost::optional<double> WX_UNIT_TEXT::GetValue() const
OPT<double> WX_UNIT_TEXT::GetValue() const
{
wxString text = m_inputValue->GetValue();
double value;
if( text == DEFAULT_VALUE )
return boost::optional<double>( -1.0 );
return OPT<double>( -1.0 );
if( !text.ToDouble( &value ) )
return boost::optional<double>();
return OPT<double>();
return boost::optional<double>( value );
return OPT<double>( value );
}

View File

@ -36,7 +36,7 @@ void GERBVIEW_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
aToolManager->RegisterTool( new ZOOM_TOOL );
}
boost::optional<TOOL_EVENT> GERBVIEW_ACTIONS::TranslateLegacyId( int aId )
OPT<TOOL_EVENT> GERBVIEW_ACTIONS::TranslateLegacyId( int aId )
{
switch( aId )
{
@ -72,5 +72,5 @@ boost::optional<TOOL_EVENT> GERBVIEW_ACTIONS::TranslateLegacyId( int aId )
break;
}
return boost::optional<TOOL_EVENT>();
return OPT<TOOL_EVENT>();
}

View File

@ -23,7 +23,7 @@
#include <tool/tool_action.h>
#include <tool/actions.h>
#include <boost/optional.hpp>
#include <core/optional.h>
class TOOL_EVENT;
class TOOL_MANAGER;
@ -130,7 +130,7 @@ public:
static TOOL_ACTION highlightAttribute;
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual boost::optional<TOOL_EVENT> TranslateLegacyId( int aId ) override;
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override;
///> @copydoc COMMON_ACTIONS::RegisterAllTools()
virtual void RegisterAllTools( TOOL_MANAGER* aToolManager ) override;

View File

@ -692,7 +692,7 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
}
else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
{
boost::optional<int> id = evt->GetCommandId();
OPT<int> id = evt->GetCommandId();
// User has selected an item, so this one will be returned
if( id && ( *id > 0 ) )

11
include/core/optional.h Normal file
View File

@ -0,0 +1,11 @@
# ifndef ___OPTIONAL_H___
# define ___OPTIONAL_H___
#include <boost/optional.hpp>
template<typename T>
using OPT = boost::optional<T>;
const auto NULLOPT = boost::none;
# endif //___OPTIONAL_HPP___

View File

@ -179,7 +179,7 @@ T Convert( const wxString& aValue )
/**
* Class OPTIONAL_XML_ATTRIBUTE
* models an optional XML attribute.
* This was implemented as an alternative to boost::optional. This class should be replaced with a
* This was implemented as an alternative to OPT. This class should be replaced with a
* simple typedef per type using std::optional when C++17 is published.
*/
template <class T>

View File

@ -30,6 +30,8 @@
#define STROKE_FONT_H_
#include <deque>
#include <algorithm>
#include <utf8.h>
#include <eda_text.h>

View File

@ -29,10 +29,9 @@
#include <climits>
#include <math/vector2d.h>
#include <core/optional.h>
#include <boost/optional/optional.hpp>
typedef boost::optional<VECTOR2I> OPT_VECTOR2I;
typedef OPT<VECTOR2I> OPT_VECTOR2I;
class SEG
{

View File

@ -25,8 +25,6 @@
#ifndef __SHAPE_INDEX_LIST_H
#define __SHAPE_INDEX_LIST_H
#include <boost/unordered_map.hpp>
template <class T>
const SHAPE* defaultShapeFunctor( const T aItem )
{

View File

@ -29,7 +29,7 @@
#include <vector>
#include <sstream>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <math/vector2d.h>
#include <geometry/shape.h>
@ -538,7 +538,7 @@ public:
* Checks if the line chain is self-intersecting.
* @return (optional) first found self-intersection point.
*/
const boost::optional<INTERSECTION> SelfIntersecting() const;
const OPT<INTERSECTION> SelfIntersecting() const;
/**
* Function Simplify()

View File

@ -30,7 +30,7 @@
#include <math/vector2d.h>
#include <limits>
#include <boost/optional.hpp>
#include <core/optional.h>
/**
* Class BOX2
@ -468,7 +468,7 @@ public:
typedef BOX2<VECTOR2I> BOX2I;
typedef BOX2<VECTOR2D> BOX2D;
typedef boost::optional<BOX2I> OPT_BOX2I;
typedef OPT<BOX2I> OPT_BOX2I;
// FIXME should be removed to avoid multiple typedefs for the same type
typedef BOX2D DBOX;

View File

@ -27,7 +27,7 @@
#define __ACTIONS_H
#include <tool/tool_action.h>
#include <boost/optional.hpp>
#include <core/optional.h>
class TOOL_EVENT;
class TOOL_MANAGER;
@ -73,7 +73,7 @@ public:
* @return std::string is name of the corresponding TOOL_ACTION. It may be empty, if there is
* no corresponding TOOL_ACTION.
*/
virtual boost::optional<TOOL_EVENT> TranslateLegacyId( int aId ) = 0;
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) = 0;
///> Registers all valid tools for an application with the tool manager
virtual void RegisterAllTools( TOOL_MANAGER* aToolManager ) = 0;

View File

@ -26,7 +26,6 @@
#define CONDITIONAL_MENU_H
#include "selection_conditions.h"
#include <boost/unordered_map.hpp>
#include <list>
#include <wx/wx.h>

View File

@ -172,7 +172,7 @@ public:
bool HasReferencePoint() const
{
return m_referencePoint != boost::none;
return m_referencePoint != NULLOPT;
}
VECTOR2I GetReferencePoint() const
@ -187,12 +187,12 @@ public:
void ClearReferencePoint()
{
m_referencePoint = boost::none;
m_referencePoint = NULLOPT;
}
private:
boost::optional<VECTOR2I> m_referencePoint;
OPT<VECTOR2I> m_referencePoint;
/// Set of selected items
std::set<EDA_ITEM*> m_items;

View File

@ -32,7 +32,7 @@
#include <math/vector2d.h>
#include <cassert>
#include <boost/optional.hpp>
#include <core/optional.h>
class TOOL_ACTION;
class TOOL_MANAGER;
@ -387,12 +387,12 @@ public:
m_param = (void*) aParam;
}
boost::optional<int> GetCommandId() const
OPT<int> GetCommandId() const
{
return m_commandId;
}
boost::optional<std::string> GetCommandStr() const
OPT<std::string> GetCommandStr() const
{
return m_commandStr;
}
@ -453,11 +453,11 @@ private:
///> Generic parameter used for passing non-standard data.
void* m_param;
boost::optional<int> m_commandId;
boost::optional<std::string> m_commandStr;
OPT<int> m_commandId;
OPT<std::string> m_commandStr;
};
typedef boost::optional<TOOL_EVENT> OPT_TOOL_EVENT;
typedef OPT<TOOL_EVENT> OPT_TOOL_EVENT;
/**
* Class TOOL_EVENT_LIST
@ -490,13 +490,13 @@ public:
*/
const std::string Format() const;
boost::optional<const TOOL_EVENT&> Matches( const TOOL_EVENT& aEvent ) const
OPT<const TOOL_EVENT&> Matches( const TOOL_EVENT& aEvent ) const
{
for( const_iterator i = m_events.begin(); i != m_events.end(); ++i )
if( i->Matches( aEvent ) )
return *i;
return boost::optional<const TOOL_EVENT&>();
return OPT<const TOOL_EVENT&>();
}
/**

View File

@ -329,7 +329,7 @@ public:
* The pause/resume operation is done through COROUTINE object.
* Called only from coroutines.
*/
boost::optional<TOOL_EVENT> ScheduleWait( TOOL_BASE* aTool,
OPT<TOOL_EVENT> ScheduleWait( TOOL_BASE* aTool,
const TOOL_EVENT_LIST& aConditions );
/**
@ -514,7 +514,7 @@ private:
ACTION_MANAGER* m_actionMgr;
/// Original cursor position, if overridden by the context menu handler
boost::optional<VECTOR2D> m_origCursor;
OPT<VECTOR2D> m_origCursor;
EDA_ITEM* m_model;
KIGFX::VIEW* m_view;

View File

@ -80,7 +80,7 @@ public:
* Function GetValue
* Returns the current value in currently used units.
*/
virtual boost::optional<double> GetValue() const;
virtual OPT<double> GetValue() const;
/**
* Function GetUnits

View File

@ -381,8 +381,7 @@ bool D_PAD::GetBestAnchorPosition( VECTOR2I& aPos )
minDistEdge = std::max( GetSize().x, GetSize().y );
}
boost::optional<VECTOR2I> bestAnchor( []()->
boost::optional<VECTOR2I>{ return boost::none; }() );
OPT<VECTOR2I> bestAnchor;
for ( int y = 0; y < stepsY ; y++ )
{

View File

@ -47,16 +47,16 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
wxASSERT( !m_items.Empty() );
// This is a way to trick gcc into considering these variables as initialized
boost::optional<int> trackStartX = boost::make_optional<int>( false, 0 );
boost::optional<int> trackStartY = boost::make_optional<int>( false, 0 );
boost::optional<int> trackEndX = boost::make_optional<int>( false, 0 );
boost::optional<int> trackEndY = boost::make_optional<int>( false, 0 );
boost::optional<int> trackWidth = boost::make_optional<int>( false, 0 );
boost::optional<PCB_LAYER_ID> trackLayer = boost::make_optional<PCB_LAYER_ID>( false, (PCB_LAYER_ID) 0 );
boost::optional<int> viaX = boost::make_optional<int>( false, 0 );
boost::optional<int> viaY = boost::make_optional<int>( false, 0 );
boost::optional<int> viaDiameter = boost::make_optional<int>( false, 0 );
boost::optional<int> viaDrill = boost::make_optional<int>( false, 0 );
OPT<int> trackStartX = NULLOPT;
OPT<int> trackStartY = NULLOPT;
OPT<int> trackEndX = NULLOPT;
OPT<int> trackEndY = NULLOPT;
OPT<int> trackWidth = NULLOPT;
OPT<PCB_LAYER_ID> trackLayer = NULLOPT;
OPT<int> viaX = NULLOPT;
OPT<int> viaY = NULLOPT;
OPT<int> viaDiameter = NULLOPT;
OPT<int> viaDrill = NULLOPT;
m_haveUniqueNet = true;
int prevNet = -1;
@ -112,22 +112,22 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
else // check if values are the same for every selected track
{
if( trackStartX && ( *trackStartX != t->GetStart().x ) )
trackStartX = boost::none;
trackStartX = NULLOPT;
if( trackStartY && ( *trackStartY != t->GetStart().y ) )
trackStartY = boost::none;
trackStartY = NULLOPT;
if( trackEndX && ( *trackEndX != t->GetEnd().x ) )
trackEndX = boost::none;
trackEndX = NULLOPT;
if( trackEndY && ( *trackEndY != t->GetEnd().y ) )
trackEndY = boost::none;
trackEndY = NULLOPT;
if( trackWidth && ( *trackWidth != t->GetWidth() ) )
trackWidth = boost::none;
trackWidth = NULLOPT;
if( trackLayer && ( *trackLayer != t->GetLayer() ) )
trackLayer = boost::none;
trackLayer = NULLOPT;
}
if( t->IsLocked() )
@ -153,16 +153,16 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
else // check if values are the same for every selected via
{
if( viaX && ( *viaX != v->GetPosition().x ) )
viaX = boost::none;
viaX = NULLOPT;
if( viaY && ( *viaY != v->GetPosition().y ) )
viaY = boost::none;
viaY = NULLOPT;
if( viaDiameter && ( *viaDiameter != v->GetWidth() ) )
viaDiameter = boost::none;
viaDiameter = NULLOPT;
if( viaDrill && ( *viaDrill != v->GetDrillValue() ) )
viaDrill = boost::none;
viaDrill = NULLOPT;
}
if( v->IsLocked() )

View File

@ -24,7 +24,7 @@
#include <dialogs/dialog_track_via_properties_base.h>
#include <wx_unit_binder.h>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <layers_id_colors_and_visibility.h>
class SELECTION;
@ -61,9 +61,9 @@ private:
///> Checks if the dialog values are correct.
bool check() const;
///> Sets wxTextEntry to the value stored in boost::optional<T> or "<...>" if it is not available.
///> Sets wxTextEntry to the value stored in OPT<T> or "<...>" if it is not available.
template<typename T>
void setCommonVal( const boost::optional<T>& aVal, wxTextEntry* aTxtEntry, WX_UNIT_BINDER& aBinder )
void setCommonVal( const OPT<T>& aVal, wxTextEntry* aTxtEntry, WX_UNIT_BINDER& aBinder )
{
if( aVal )
aBinder.SetValue( *aVal );

View File

@ -25,7 +25,7 @@
#include "dialog_track_via_size.h"
#include <base_units.h>
#include <confirm.h>
#include <boost/optional.hpp>
#include <core/optional.h>
#include "class_board_design_settings.h"

View File

@ -96,10 +96,10 @@ static wxString getFilterString()
// Tries to guess the plugin type basing on the path
static boost::optional<IO_MGR::PCB_FILE_T> getPluginType( const wxString& aPath )
static OPT<IO_MGR::PCB_FILE_T> getPluginType( const wxString& aPath )
{
if( ( aPath.StartsWith( "http://" ) || aPath.StartsWith( "https://" ) ) )
return boost::optional<IO_MGR::PCB_FILE_T>( IO_MGR::GITHUB );
return OPT<IO_MGR::PCB_FILE_T>( IO_MGR::GITHUB );
wxFileName path( aPath );
@ -127,10 +127,10 @@ static boost::optional<IO_MGR::PCB_FILE_T> getPluginType( const wxString& aPath
}
if( ok )
return boost::optional<IO_MGR::PCB_FILE_T>( fileFilters[i].m_Plugin );
return OPT<IO_MGR::PCB_FILE_T>( fileFilters[i].m_Plugin );
}
return boost::none;
return NULLOPT;
}
@ -139,7 +139,7 @@ static bool passesFilter( const wxString& aFileName, int aFilterIndex )
{
wxASSERT( aFilterIndex <= FILTER_COUNT );
wxFileName file( aFileName );
boost::optional<IO_MGR::PCB_FILE_T> result = getPluginType( aFileName );
OPT<IO_MGR::PCB_FILE_T> result = getPluginType( aFileName );
if( !result ) // does not match any supported plugin
return false;

View File

@ -26,7 +26,7 @@
#include <wizard_add_fplib_base.h>
#include <io_mgr.h>
#include <boost/optional.hpp>
#include <core/optional.h>
class KIWAY_PLAYER;
@ -115,9 +115,9 @@ public:
/**
* Function GetPluginType
* Returns the plugin type, autodetected basing on the path.
* @return Returns empty boost::optional if the type could not be autodetected.
* @return Returns empty OPT if the type could not be autodetected.
*/
inline boost::optional<IO_MGR::PCB_FILE_T> GetPluginType() const
inline OPT<IO_MGR::PCB_FILE_T> GetPluginType() const
{
return m_plugin;
}
@ -194,7 +194,7 @@ public:
wxString m_path;
wxString m_description;
boost::optional<IO_MGR::PCB_FILE_T> m_plugin;
OPT<IO_MGR::PCB_FILE_T> m_plugin;
STATUS m_status;
friend class WIZARD_FPLIB_TABLE;

View File

@ -1085,7 +1085,7 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e,
txt->SetText( FROM_UTF8( a.value->c_str() ) );
}
if( a.x && a.y ) // boost::optional
if( a.x && a.y ) // OPT
{
wxPoint pos( kicad_x( *a.x ), kicad_y( *a.y ) );
txt->SetTextPos( pos );

View File

@ -47,7 +47,7 @@ class FP_THREAD_IFACE
public:
/// Retrieve a cache entry by LIB_ID
boost::optional<CACHE_ENTRY> GetFromCache( LIB_ID const & aFPID )
OPT<CACHE_ENTRY> GetFromCache( LIB_ID const & aFPID )
{
MUTLOCK lock( m_lock );
auto it = m_cachedFootprints.find( aFPID );
@ -55,7 +55,7 @@ class FP_THREAD_IFACE
if( it != m_cachedFootprints.end() )
return it->second;
else
return boost::none;
return NULLOPT;
}
/**
@ -74,13 +74,13 @@ class FP_THREAD_IFACE
}
/// Pop an entry from the queue, or empty option if none is available.
boost::optional<CACHE_ENTRY> PopFromQueue()
OPT<CACHE_ENTRY> PopFromQueue()
{
MUTLOCK lock( m_lock );
if( m_loaderQueue.empty() )
{
return boost::none;
return NULLOPT;
}
else
{

View File

@ -32,7 +32,7 @@
#include <gal/gal_display_options.h>
#include <lib_id.h>
#include <kiway_player.h>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <widgets/footprint_preview_widget.h>

View File

@ -36,8 +36,7 @@
#include <common.h> // KiROUND
#include <convert_to_biu.h> // IU_PER_MM
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
#include <unordered_map>
class BOARD;
@ -65,8 +64,8 @@ struct LAYER;
*/
class PCB_PARSER : public PCB_LEXER
{
typedef boost::unordered_map< std::string, PCB_LAYER_ID > LAYER_ID_MAP;
typedef boost::unordered_map< std::string, LSET > LSET_MAP;
typedef std::unordered_map< std::string, PCB_LAYER_ID > LAYER_ID_MAP;
typedef std::unordered_map< std::string, LSET > LSET_MAP;
BOARD* m_board;
LAYER_ID_MAP m_layerIndices; ///< map layer name to it's index

View File

@ -19,7 +19,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/optional.hpp>
#include <core/optional.h>
#include "class_draw_panel_gal.h"
#include "class_board.h"
@ -43,7 +43,6 @@
#include "length_tuner_tool.h"
using namespace KIGFX;
using boost::optional;
static TOOL_ACTION ACT_StartTuning( "pcbnew.LengthTuner.StartTuning", AS_CONTEXT, 'X',
_( "New Track" ), _( "Starts laying a new track." ) );

View File

@ -690,9 +690,9 @@ void DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n, bool
ips[1] = st_p[i].IntersectLines( st_n[j] );
if( d_n[i].Collinear( d_p[j] ) )
ips[0] = boost::none;
ips[0] = OPT_VECTOR2I();
if( st_p[i].Collinear( st_p[j] ) )
ips[1] = boost::none;
ips[1] = OPT_VECTOR2I();
// diagonal-diagonal and straight-straight cases - the most typical case if the pads
// are on the same straight/diagonal line

View File

@ -247,7 +247,7 @@ private:
int m_netP, m_netN;
DP_PRIMITIVE_PAIR m_start;
boost::optional<DP_PRIMITIVE_PAIR> m_prevPair;
OPT<DP_PRIMITIVE_PAIR> m_prevPair;
///> current algorithm iteration
int m_iteration;

View File

@ -19,7 +19,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/optional.hpp>
#include <core/optional.h>
#include <base_units.h> // God forgive me doing this...
@ -33,8 +33,6 @@
namespace PNS {
using boost::optional;
DP_MEANDER_PLACER::DP_MEANDER_PLACER( ROUTER* aRouter ) :
MEANDER_PLACER_BASE( aRouter )
{

View File

@ -24,6 +24,7 @@
#include <layers_id_colors_and_visibility.h>
#include <map>
#include <unordered_set>
#include <boost/range/adaptor/map.hpp>
@ -47,7 +48,7 @@ class INDEX
public:
typedef std::list<ITEM*> NET_ITEMS_LIST;
typedef SHAPE_INDEX<ITEM*> ITEM_SHAPE_INDEX;
typedef boost::unordered_set<ITEM*> ITEM_SET;
typedef std::unordered_set<ITEM*> ITEM_SET;
INDEX();
~INDEX();

View File

@ -23,7 +23,6 @@
#define __PNS_JOINT_H
#include <vector>
#include <boost/functional/hash.hpp>
#include <math/vector2d.h>
@ -54,6 +53,20 @@ public:
int net;
};
struct JOINT_TAG_HASH
{
std::size_t operator()( const JOINT::HASH_TAG& aP ) const
{
using std::size_t;
using std::hash;
using std::string;
return ( (hash<int>()( aP.pos.x )
^ (hash<int>()( aP.pos.y ) << 1) ) >> 1 )
^ (hash<int>()( aP.net ) << 1);
}
};
JOINT() :
ITEM( JOINT_T ), m_locked( false ) {}
@ -249,16 +262,6 @@ inline bool operator==( JOINT::HASH_TAG const& aP1, JOINT::HASH_TAG const& aP2 )
return aP1.pos == aP2.pos && aP1.net == aP2.net;
}
inline std::size_t hash_value( JOINT::HASH_TAG const& aP )
{
std::size_t seed = 0;
boost::hash_combine( seed, aP.pos.x );
boost::hash_combine( seed, aP.pos.y );
boost::hash_combine( seed, aP.net );
return seed;
}
}
#endif // __PNS_JOINT_H

View File

@ -19,7 +19,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/optional.hpp>
#include <core/optional.h>
#include <math/vector2d.h>
@ -31,8 +31,6 @@
#include <geometry/shape_rect.h>
using boost::optional;
namespace PNS {
LINE::LINE( const LINE& aOther ) :
@ -338,7 +336,7 @@ void LINE::ShowLinks() const
SHAPE_LINE_CHAIN dragCornerInternal( const SHAPE_LINE_CHAIN& aOrigin, const VECTOR2I& aP )
{
optional<SHAPE_LINE_CHAIN> picked;
OPT<SHAPE_LINE_CHAIN> picked;
int i;
int d = 2;

View File

@ -19,7 +19,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/optional.hpp>
#include <core/optional.h>
#include "pns_node.h"
#include "pns_line_placer.h"
@ -32,8 +32,6 @@
#include <class_board_item.h>
using boost::optional;
namespace PNS {
LINE_PLACER::LINE_PLACER( ROUTER* aRouter ) :

View File

@ -38,13 +38,11 @@
#include "pns_index.h"
#include "pns_router.h"
using boost::unordered_set;
using boost::unordered_map;
namespace PNS {
#ifdef DEBUG
static boost::unordered_set<NODE*> allocNodes;
static std::unordered_set<NODE*> allocNodes;
#endif
NODE::NODE()
@ -1082,7 +1080,7 @@ void NODE::unlinkJoint( const VECTOR2I& aPos, const LAYER_RANGE& aLayers,
void NODE::Dump( bool aLong )
{
#if 0
boost::unordered_set<SEGMENT*> all_segs;
std::unordered_set<SEGMENT*> all_segs;
SHAPE_INDEX_LIST<ITEM*>::iterator i;
for( i = m_items.begin(); i != m_items.end(); i++ )

View File

@ -24,10 +24,10 @@
#include <vector>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <geometry/shape.h>
#include <geometry/shape_line_chain.h>
@ -137,7 +137,7 @@ protected:
class NODE
{
public:
typedef boost::optional<OBSTACLE> OPT_OBSTACLE;
typedef OPT<OBSTACLE> OPT_OBSTACLE;
typedef std::vector<ITEM*> ITEM_VECTOR;
typedef std::vector<OBSTACLE> OBSTACLES;
@ -420,7 +420,7 @@ public:
private:
struct DEFAULT_OBSTACLE_VISITOR;
typedef boost::unordered_multimap<JOINT::HASH_TAG, JOINT> JOINT_MAP;
typedef std::unordered_multimap<JOINT::HASH_TAG, JOINT, JOINT::JOINT_TAG_HASH> JOINT_MAP;
typedef JOINT_MAP::value_type TagJointPair;
/// nodes are not copyable
@ -486,7 +486,7 @@ private:
std::set<NODE*> m_children;
///> hash of root's items that have been changed in this node
boost::unordered_set<ITEM*> m_override;
std::unordered_set<ITEM*> m_override;
///> worst case item-item clearance
int m_maxClearance;
@ -500,7 +500,7 @@ private:
///> depth of the node (number of parent nodes in the inheritance chain)
int m_depth;
boost::unordered_set<ITEM*> m_garbageItems;
std::unordered_set<ITEM*> m_garbageItems;
};
}

View File

@ -22,7 +22,7 @@
#ifndef __PNS_OPTIMIZER_H
#define __PNS_OPTIMIZER_H
#include <boost/unordered_map.hpp>
#include <unordered_map>
#include <memory>
#include <geometry/shape_index_list.h>
@ -170,7 +170,7 @@ private:
SHAPE_INDEX_LIST<ITEM*> m_cache;
typedef boost::unordered_map<ITEM*, CACHED_ITEM> CachedItemTags;
typedef std::unordered_map<ITEM*, CACHED_ITEM> CachedItemTags;
CachedItemTags m_cacheTags;
NODE* m_world;
int m_collisionKindMask;

View File

@ -25,7 +25,7 @@
#include <list>
#include <memory>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <boost/unordered_set.hpp>
#include <geometry/shape_line_chain.h>

View File

@ -87,7 +87,7 @@ public:
private:
typedef std::vector<SHAPE_LINE_CHAIN> HULL_SET;
typedef boost::optional<LINE> OPT_LINE;
typedef OPT<LINE> OPT_LINE;
typedef std::pair<LINE, LINE> LINE_PAIR;
typedef std::vector<LINE_PAIR> LINE_PAIR_VEC;

View File

@ -23,7 +23,7 @@
#define __PNS_SIZES_SETTINGS_H
#include <map>
#include <boost/optional.hpp>
#include <core/optional.h>
#include "../class_track.h" // for VIATYPE_T
@ -82,10 +82,10 @@ public:
int ViaDrill() const { return m_viaDrill; }
void SetViaDrill( int aDrill ) { m_viaDrill = aDrill; }
boost::optional<int> PairedLayer( int aLayerId )
OPT<int> PairedLayer( int aLayerId )
{
if( m_layerPairs.find(aLayerId) == m_layerPairs.end() )
return boost::optional<int>();
return OPT<int>();
return m_layerPairs[aLayerId];
}

View File

@ -141,14 +141,14 @@ const SHAPE_LINE_CHAIN ConvexHull( const SHAPE_CONVEX& aConvex, int aClearance )
SHAPE_LINE_CHAIN octagon;
octagon.SetClosed( true );
octagon.Append( leftline.IntersectLines( bottomleftline ).get() );
octagon.Append( bottomline.IntersectLines( bottomleftline ).get() );
octagon.Append( bottomline.IntersectLines( bottomrightline ).get() );
octagon.Append( rightline.IntersectLines( bottomrightline ).get() );
octagon.Append( rightline.IntersectLines( toprightline ).get() );
octagon.Append( topline.IntersectLines( toprightline ).get() );
octagon.Append( topline.IntersectLines( topleftline ).get() );
octagon.Append( leftline.IntersectLines( topleftline ).get() );
octagon.Append( *leftline.IntersectLines( bottomleftline ) );
octagon.Append( *bottomline.IntersectLines( bottomleftline ) );
octagon.Append( *bottomline.IntersectLines( bottomrightline ) );
octagon.Append( *rightline.IntersectLines( bottomrightline ) );
octagon.Append( *rightline.IntersectLines( toprightline ) );
octagon.Append( *topline.IntersectLines( toprightline ) );
octagon.Append( *topline.IntersectLines( topleftline ) );
octagon.Append( *leftline.IntersectLines( topleftline ) );
return octagon;
}

View File

@ -19,7 +19,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/optional.hpp>
#include <core/optional.h>
#include <geometry/shape_line_chain.h>
@ -27,7 +27,6 @@
#include "pns_optimizer.h"
#include "pns_utils.h"
#include "pns_router.h"
using boost::optional;
namespace PNS {
@ -55,7 +54,7 @@ NODE::OPT_OBSTACLE WALKAROUND::nearestObstacle( const LINE& aPath )
WALKAROUND::WALKAROUND_STATUS WALKAROUND::singleStep( LINE& aPath,
bool aWindingDirection )
{
optional<OBSTACLE>& current_obs =
OPT<OBSTACLE>& current_obs =
aWindingDirection ? m_currentObstacle[0] : m_currentObstacle[1];
bool& prev_recursive = aWindingDirection ? m_recursiveCollision[0] : m_recursiveCollision[1];

View File

@ -21,7 +21,7 @@
#include <wx/numdlg.h>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <functional>
using namespace std::placeholders;
@ -60,8 +60,6 @@ using namespace std::placeholders;
#include "pns_router.h"
using namespace KIGFX;
using boost::optional;
/**
* Flags used by via tool actions
@ -460,7 +458,7 @@ void ROUTER_TOOL::switchLayerOnViaPlacement()
m_router->SwitchLayer( al );
}
optional<int> newLayer = m_router->Sizes().PairedLayer( cl );
OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
if( !newLayer )
newLayer = m_router->Sizes().GetLayerTop();

View File

@ -219,7 +219,7 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
boost::optional<VECTOR2D> startingPoint;
OPT<VECTOR2D> startingPoint;
BOARD_COMMIT commit( m_frame );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
@ -234,11 +234,11 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
{
commit.Add( line );
commit.Push( _( "Draw a line segment" ) );
startingPoint = line->GetEnd();
startingPoint = VECTOR2D( line->GetEnd() );
}
else
{
startingPoint = boost::none;
startingPoint = NULLOPT;
}
line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
@ -920,7 +920,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
boost::optional<VECTOR2D> aStartingPoint )
OPT<VECTOR2D> aStartingPoint )
{
// Only two shapes are currently supported
assert( aShape == S_SEGMENT || aShape == S_CIRCLE );

View File

@ -26,7 +26,7 @@
#define __DRAWING_TOOL_H
#include <tools/pcb_tool.h>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <tool/tool_menu.h>
@ -206,7 +206,7 @@ private:
///> @return False if the tool was cancelled before the origin was set or origin and end are
///> the same point.
bool drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
boost::optional<VECTOR2D> aStartingPoint = boost::none );
OPT<VECTOR2D> aStartingPoint = NULLOPT );
///> Starts drawing an arc.
///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to

View File

@ -108,7 +108,7 @@ void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin, bool aEnabl
}
else
{
m_auxAxis = boost::optional<VECTOR2I>();
m_auxAxis = OPT<VECTOR2I>();
view->SetVisible( &m_viewAxis, false );
}

View File

@ -28,7 +28,7 @@
#include <vector>
#include <math/vector2d.h>
#include <boost/optional.hpp>
#include <core/optional.h>
#include <origin_viewitem.h>
#include <layers_id_colors_and_visibility.h>
@ -102,7 +102,7 @@ private:
}
PCB_BASE_FRAME* m_frame;
boost::optional<VECTOR2I> m_auxAxis;
OPT<VECTOR2I> m_auxAxis;
bool m_diagonalAuxAxesEnable;
KIGFX::ORIGIN_VIEWITEM m_viewSnapPoint, m_viewAxis;
};

View File

@ -26,6 +26,9 @@
#include "kicad_clipboard.h"
#include "selection_tool.h"
#include "pcb_actions.h"
#include <core/optional.h>
#include <tool/tool_manager.h>
#include <class_draw_panel_gal.h>
@ -467,12 +470,12 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
pad->SetPrimitives( shapes );
pad->SetShape ( PAD_SHAPE_CUSTOM );
boost::optional<VECTOR2I> anchor;
OPT<VECTOR2I> anchor;
VECTOR2I tmp;
if( refPad )
{
anchor = pad->GetPosition();
anchor = VECTOR2I( pad->GetPosition() );
}
else if( pad->GetBestAnchorPosition( tmp ) )
{

View File

@ -27,7 +27,7 @@
#include <pcbnew_id.h>
boost::optional<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
{
switch( aId )
{
@ -199,5 +199,5 @@ boost::optional<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
return PCB_ACTIONS::pasteFromClipboard.MakeEvent();
}
return boost::optional<TOOL_EVENT>();
return OPT<TOOL_EVENT>();
}

View File

@ -28,7 +28,7 @@
#include <tool/tool_action.h>
#include <tool/actions.h>
#include <boost/optional.hpp>
#include <core/optional.h>
class TOOL_EVENT;
class TOOL_MANAGER;
@ -391,7 +391,7 @@ public:
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual boost::optional<TOOL_EVENT> TranslateLegacyId( int aId ) override;
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override;
///> @copydoc COMMON_ACTIONS::RegisterAllTools()
virtual void RegisterAllTools( TOOL_MANAGER* aToolManager ) override;

View File

@ -47,7 +47,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
assert( !m_picking );
m_picking = true;
m_picked = boost::none;
m_picked = NULLOPT;
setControls();
@ -62,7 +62,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
{
bool getNext = false;
m_picked = p;
m_picked = VECTOR2D( p );
if( m_clickHandler )
{
@ -112,7 +112,7 @@ void PICKER_TOOL::reset()
m_autoPanning = false;
m_picking = false;
m_clickHandler = boost::none;
m_clickHandler = NULLOPT;
}

View File

@ -74,7 +74,7 @@ public:
* Function GetPoint()
* Returns picked point.
*/
inline boost::optional<VECTOR2D> GetPoint() const
inline OPT<VECTOR2D> GetPoint() const
{
assert( !m_picking );
return m_picked;
@ -108,10 +108,10 @@ private:
bool m_autoPanning;
///> Optional mouse click event handler.
boost::optional<CLICK_HANDLER> m_clickHandler;
OPT<CLICK_HANDLER> m_clickHandler;
///> Picked point (if any).
boost::optional<VECTOR2D> m_picked;
OPT<VECTOR2D> m_picked;
///> Activity status.
bool m_picking;

View File

@ -1361,7 +1361,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
}
else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
{
boost::optional<int> id = evt->GetCommandId();
OPT<int> id = evt->GetCommandId();
// User has selected an item, so this one will be returned
if( id && ( *id > 0 ) )

View File

@ -28,10 +28,6 @@
* @brief Pcbnew main program.
*/
#ifdef KICAD_SCRIPTING
#include <python_scripting.h>
#include <pcbnew_scripting_helpers.h>
#endif
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
@ -51,7 +47,6 @@
#include <hotkeys.h>
#include <wildcards_and_files_ext.h>
#include <class_board.h>
#include <3d_viewer.h>
#include <fp_lib_table.h>
#include <module_editor_frame.h>
#include <modview_frame.h>

View File

@ -103,9 +103,9 @@ public:
virtual ~TEST_ACTIONS() {};
virtual boost::optional<TOOL_EVENT> TranslateLegacyId( int aId )
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId )
{
return boost::none;
return NULLOPT;
}
void RegisterAllTools( TOOL_MANAGER* aToolManager )

View File

@ -75,6 +75,7 @@ target_link_libraries( test_window
common
pcbcommon
bitmaps
gal
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}