Black Knight

Chameleon





C++/CLR Tutorial

To write a C++/CLR plug-in for Chameleon, simply complete the steps below:

1. Create a new C++/CLR project and reference Chameleon_Plugin.dll

2. Copy and paste the skeleton plug-in (below) into a new .h file


//must reference Chameleon_Plugin.dll
using namespace BKTech::Chameleon::Plugins;
using namespace System;
using namespace System::ComponentModel;

//namespace indicates placement in plug-in tree
namespace YourNamespaceGoesHere {

//must implement interface from BKTech::Chameleon::Plugins
public ref class YourPluginNameGoesHere : IChameleonPlugin
{
public:

    //Non-Browsable Public Properties

    //Returns author string for display in GUI
    //Browsable(false) prevents from showing up in custom property tab
    [Browsable(false)] virtual property String ^Author
    {
        String ^get()
        {
            return "";
        }
    };

    //Returns category string for display in GUI
    //no effect on plug-in placement in tree
    [Browsable(false)] virtual property String ^Category
    {
        String ^get()
        {
            return "";
        }
    };

    //Returns description string for display in GUI
    [Browsable(false)] virtual property String ^Description
    {
        String ^get()
        {
            return "";
        }
    };

    //Returns expected input string for display in GUI
    [Browsable(false)] virtual property String ^ExpectedInput
    {
        String ^get()
        {
            return "";
        }
    };

    //Returns output string for display in GUI
    [Browsable(false)] virtual property String ^Output
    {
        String ^get()
        {
            return "";
        }
    };

    //Public Functions (implemented in .cpp file)
    virtual bool Initialize(array<string^>^, FeedBack::sendFeedBack^);
    virtual bool Execute();
    virtual bool Clean();
    virtual String ^Save();
    virtual bool Load(String ^loadValue);

private:
    //stores the data files that this plug-in should operate on
    array<String^,1>^ myDataFiles;

    //reports feedback back to the client
    FeedBack::sendFeedBack^ myReporter;
};
}

            

3. Populate .h skeleton with string values for custom properties

4. Copy and paste the skeleton plug-in (below) into a new .cpp file


//include the header file you just created
#include "YourDotHFileHere.h"

using namespace System;
using namespace BKTech::Chameleon::Plugins;

namespace YourNamespaceGoesHere {

//Any custom properties (set with Browsable(true) in .h)
//should be converted to string and returned here
String ^YourClassNameGoesHere::Save()
{
	return "";
}

//This function should accept a string
//in the same format returned by your Save function
//and populate your variables accordingly
bool YourClassNameGoesHere::Load(String ^loadValue)
{
	return true;
}

//Validates input and prepares for execution
bool YourClassNameGoesHere::Initialize(array<String^,1>^ infiles,
                                      FeedBack::sendFeedBack ^reporter)
{
    //Save parameters to private members
    myDataFiles = infiles;
    myReporter = reporter;

    //Provide feedback to the user
    myReporter("YourClassNameGoesHere initialized with " +
                            myDataFiles->Length.ToString() + " file(s)",
                                FeedBack::ReturnCode::Success);

    //Everything checks out, so we are ready for Execute()
    return true;
}

//This function implements plug-in core logic
bool YourClassNameGoesHere::Execute()
{

    //Return a boolean to let the client know your status
    return true;
}

//If any memory was dynamically allocated, free it
bool IABMToTextpadSyn::Clean()
{
    return true;
}
}

5. Add implementation for desired logic to Initialize, Execute, Save, Load, Clean

6. Build

7. Store in plugins directory

8. Run Chameleon