Fusion360-Addons/usr/autodesk/CPP/include/CAM/Machine/Machine.h
2021-10-31 19:11:02 +01:00

209 lines
6.3 KiB
C++

//////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "../../Core/Base.h"
#include "../CAMTypeDefs.h"
#include <string>
// THIS CLASS WILL BE VISIBLE TO AN API CLIENT.
// THIS HEADER FILE WILL BE GENERATED FROM NIDL.
#include "../../Core/OSMacros.h"
#ifdef CAMXINTERFACE_EXPORTS
# ifdef __COMPILING_ADSK_CAM_MACHINE_CPP__
# define ADSK_CAM_MACHINE_API XI_EXPORT
# else
# define ADSK_CAM_MACHINE_API
# endif
#else
# define ADSK_CAM_MACHINE_API XI_IMPORT
#endif
namespace adsk { namespace cam {
class MachineCapabilities;
class MachineKinematics;
}}
namespace adsk { namespace cam {
/// Object that represents a machine.
class Machine : public core::Base {
public:
/// Gets and sets the vendor name of the machine.
std::string vendor() const;
bool vendor(const std::string& value);
/// Gets and sets the model name of the machine.
std::string model() const;
bool model(const std::string& value);
/// Gets and sets the description of the machine.
std::string description() const;
bool description(const std::string& value);
/// Gets the unique identifier of the machine.
/// Can be used for comparing machines within the document.
std::string id() const;
/// Gets the capabilities of the machine.
core::Ptr<MachineCapabilities> capabilities() const;
/// Gets the kinematics tree of the machine.
core::Ptr<MachineKinematics> kinematics() const;
/// Creates a Machine from a template.
/// machineTemplate : The template to act as a base for creating a machine from.
/// Returns the newly created machine with a valid kinematics tree.
static core::Ptr<Machine> createFromTemplate(MachineTemplate machineTemplate);
/// Creates a Machine from a file.
/// location : The location in the machine library.
/// filePath : The path to a file to act as a base for creating a machine from.
/// The path is relative to the library location given, unless library location is External,
/// then the filePath is expected to be an absolute path.
/// Returns the newly created machine with a valid kinematics tree.
static core::Ptr<Machine> createFromFile(LibraryLocation location, const std::string& filePath);
/// Save the Machine to a file.
/// Any subsequent edits will need to be saved again.
/// location : The location in the machine library to save the machine to.
/// filePath : The path of the file to save the machine as.
/// The path is relative to the library location given, unless library location is External,
/// then the filePath is expected to be an absolute path.
/// .machine will be appended if no extension is given.
/// Returns true if the machine was saved successfully, false otherwise.
bool save(LibraryLocation location, const std::string& filePath) const;
ADSK_CAM_MACHINE_API static const char* classType();
ADSK_CAM_MACHINE_API const char* objectType() const override;
ADSK_CAM_MACHINE_API void* queryInterface(const char* id) const override;
ADSK_CAM_MACHINE_API static const char* interfaceId() { return classType(); }
private:
// Raw interface
virtual char* vendor_raw() const = 0;
virtual bool vendor_raw(const char * value) = 0;
virtual char* model_raw() const = 0;
virtual bool model_raw(const char * value) = 0;
virtual char* description_raw() const = 0;
virtual bool description_raw(const char * value) = 0;
virtual char* id_raw() const = 0;
virtual MachineCapabilities* capabilities_raw() const = 0;
virtual MachineKinematics* kinematics_raw() const = 0;
ADSK_CAM_MACHINE_API static Machine* createFromTemplate_raw(MachineTemplate machineTemplate);
ADSK_CAM_MACHINE_API static Machine* createFromFile_raw(LibraryLocation location, const char * filePath);
virtual bool save_raw(LibraryLocation location, const char * filePath) const = 0;
};
// Inline wrappers
inline std::string Machine::vendor() const
{
std::string res;
char* p= vendor_raw();
if (p)
{
res = p;
core::DeallocateArray(p);
}
return res;
}
inline bool Machine::vendor(const std::string& value)
{
return vendor_raw(value.c_str());
}
inline std::string Machine::model() const
{
std::string res;
char* p= model_raw();
if (p)
{
res = p;
core::DeallocateArray(p);
}
return res;
}
inline bool Machine::model(const std::string& value)
{
return model_raw(value.c_str());
}
inline std::string Machine::description() const
{
std::string res;
char* p= description_raw();
if (p)
{
res = p;
core::DeallocateArray(p);
}
return res;
}
inline bool Machine::description(const std::string& value)
{
return description_raw(value.c_str());
}
inline std::string Machine::id() const
{
std::string res;
char* p= id_raw();
if (p)
{
res = p;
core::DeallocateArray(p);
}
return res;
}
inline core::Ptr<MachineCapabilities> Machine::capabilities() const
{
core::Ptr<MachineCapabilities> res = capabilities_raw();
return res;
}
inline core::Ptr<MachineKinematics> Machine::kinematics() const
{
core::Ptr<MachineKinematics> res = kinematics_raw();
return res;
}
inline core::Ptr<Machine> Machine::createFromTemplate(MachineTemplate machineTemplate)
{
core::Ptr<Machine> res = createFromTemplate_raw(machineTemplate);
return res;
}
inline core::Ptr<Machine> Machine::createFromFile(LibraryLocation location, const std::string& filePath)
{
core::Ptr<Machine> res = createFromFile_raw(location, filePath.c_str());
return res;
}
inline bool Machine::save(LibraryLocation location, const std::string& filePath) const
{
bool res = save_raw(location, filePath.c_str());
return res;
}
}// namespace cam
}// namespace adsk
#undef ADSK_CAM_MACHINE_API