Actin  Version 5.5.5
Software for Robotics Simulation and Control
ecXmlMain.cpp

An example to demonstrate usage of the EcXmlObject class.
The header file for the EcXmlExample class

#ifndef ecXmlExample_H_
#define ecXmlExample_H_
//------------------------------------------------------------------------------
// Copyright (c) 2018 Energid Technologies. All rights reserved.
//
//
//------------------------------------------------------------------------------
{
public:
(
);
virtual ~EcXmlExample
(
);
(
const EcXmlExample& orig
);
EcXmlExample& operator=
(
const EcXmlExample& orig
);
EcBoolean operator==
(
const EcXmlExample& orig
) const;
(
virtual EcXmlObject* clone
(
) const EC_OVERRIDE;
virtual void registerComponents
(
(
const EcXmlObject* other
) const EC_OVERRIDE;
(
) const EC_OVERRIDE;
(
) const;
virtual void setExampleVariable
(
EcU32 exampleVariable
);
virtual EcBoolean read
(
EcXmlReader& stream
virtual EcBoolean write
(
EcXmlWriter& stream
) const EC_OVERRIDE;
(
);
virtual const EcToken& token
(
) const EC_OVERRIDE;
protected:
};
#endif // ecXmlExample_H_


The implementation file for the EcXmlExample class

//------------------------------------------------------------------------------
// Copyright (c) 2018 Energid Technologies. All rights reserved.
//
//
//------------------------------------------------------------------------------
#include "ecXmlExample.h"
// create xml tokens
namespace EcXmlExampleTokens
{
const EcString ns("http://www.energid.com/namespace/xmlExample#");
EcToken EcXmlExampleToken(ns + EcString("xmlExampleVariable"));
}
// Functions: Big four and other header functions
// Description: Common functions
// constructor
(
):
m_ExampleVariable(0)
{
}
// destructor
(
)
{
}
// copy constructor. Also copies the parent link pointer.
(
const EcXmlExample& orig
):
m_ExampleVariable(orig.m_ExampleVariable)
{
}
// assignment operator
EcXmlExample& EcXmlExample::operator=
(
const EcXmlExample& orig
)
{
// self assignment.
if (this==&orig)
{
return *this;
}
// call parent
EcXmlCompoundType::operator=(orig);
m_ExampleVariable =orig.m_ExampleVariable;
return *this;
}
// equality operator
EcBoolean EcXmlExample::operator==
(
const EcXmlExample& orig
) const
{
if(retVal)
{
if(!(m_ExampleVariable ==orig.m_ExampleVariable))
{
retVal=EcFalse;
}
}
return retVal;
}
//End of header functions.
// Functions: xmlInit()
// Description: XML-initializes the class and all parent classes.
// I/O: Return error status
(
)
{
{
return EcTrue;
}
else
{
return EcFalse;
}
}
// Function: clone()
// Description: A virtual constructor that returns an EcXmlObject.
// I/O: Return XML object
(
) const
{
return new EcXmlExample(*this);
}
// Function: registerComponents()
// read from and written to xml streams.
(
)
{
registerComponent(EcXmlExampleTokens::EcXmlExampleToken,&m_ExampleVariable);
}
// Function: equality
// Description: equality - virtual equality to an EcXmlObject pointer
// I/O: Input XML object, Return status
(
const EcXmlObject* other
) const
{
EcBoolean retVal=EcTrue;
const EcXmlExample* cast=
dynamic_cast<const EcXmlExample*>(other);
if(!cast || !(*this==*cast))
{
retVal=EcFalse;
}
return retVal;
}
// Function: newObject
// Description: A virtual new that returns an EcXmlObject.
// I/O: Return XML object
(
) const
{
return new EcXmlExample();
}
// Function: get/set members
// Description: Accessors and mutators for member variables.
// gets the example variable
(
) const
{
return m_ExampleVariable;
}
// sets the example variable
(
EcU32 exampleVariable
)
{
m_ExampleVariable = exampleVariable;
}
//End of get/set
// Function: read()
// Description: Reads class data from an XML stream.
// I/O: Input stream, Output: true for success.
(
EcXmlReader& stream
)
{
return retVal;
}
// Function: write()
// Description: Writes class data to an XML stream.
// I/O: Input stream, Output: true for success.
(
EcXmlWriter& stream
) const
{
return retVal;
}
// Function: nullObject()
// Description: Returns a null object of this class.
// I/O: Return null object
(
)
{
return EcXmlExample();
}
const EcToken&
(
) const
{
return EcXmlExampleTokens::EcXmlExampleToken;
}


main() for the Actin XML example

//------------------------------------------------------------------------------
// Copyright (c) 2004-2013 Energid Technologies. All rights reserved.
//
//
//------------------------------------------------------------------------------
#include "ecXmlExample.h"
int main
(
int argc,
char* argv[]
)
{
// set the MCML lanauge.
// create and run the example
EcXmlExample example;
example.run();
return 0;
}
// Create VxWorks DKM entry point