initial commit for github
This commit is contained in:
commit
60968612de
370 changed files with 68427 additions and 0 deletions
70
ddlrepresentation/ddl_common.h
Normal file
70
ddlrepresentation/ddl_common.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_COMMON_HEADER
|
||||
#define DDL_COMMON_HEADER
|
||||
|
||||
|
||||
// Disables VS warnings about unsafe C functions
|
||||
#ifdef WIN32
|
||||
#define _SCL_SECURE_NO_WARNINGS // NOLINT
|
||||
#endif
|
||||
|
||||
// Determine whether move semantics are available
|
||||
#ifdef _MSC_VER
|
||||
// On Windows, make the decision using the VS version
|
||||
#if _MSC_VER >= 1800 // VS 2013 (needs default-generation)
|
||||
#define DDL_HAS_MOVE 1
|
||||
#else
|
||||
#define DDL_HAS_MOVE 0
|
||||
#endif
|
||||
#else
|
||||
// Otherwise use the standard version macro
|
||||
#if __cplusplus >= 201103L
|
||||
#define DDL_HAS_MOVE 1
|
||||
#else
|
||||
#define DDL_HAS_MOVE 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Include utils
|
||||
#include <a_util/base.h>
|
||||
#include <a_util/filesystem.h>
|
||||
#include <a_util/xml.h>
|
||||
#include <a_util/memory.h>
|
||||
#include <a_util/regex.h>
|
||||
#include <a_util/strings.h>
|
||||
#include <a_util/variant.h>
|
||||
#include <a_util/datetime.h>
|
||||
#include <a_util/system.h>
|
||||
#include <a_util/concurrency.h>
|
||||
#include <a_util/logging.h>
|
||||
#include <a_util/result.h>
|
||||
|
||||
// Include standard headers
|
||||
#include <stack>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#endif // DDL_COMMON_HEADER
|
||||
|
50
ddlrepresentation/ddl_error.cpp
Normal file
50
ddlrepresentation/ddl_error.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddl_error.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
static DDLError s_last_error;
|
||||
|
||||
a_util::result::Result DDLError::setLastDDLError(a_util::result::Result result,
|
||||
const std::string& error)
|
||||
{
|
||||
s_last_error._last_error_code = result;
|
||||
if (!error.empty())
|
||||
{
|
||||
s_last_error._last_error_description = error;
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLError::getLastDDLErrorCode()
|
||||
{
|
||||
return s_last_error._last_error_code;
|
||||
}
|
||||
|
||||
const char* DDLError::getLastDDLErrorDescription()
|
||||
{
|
||||
return s_last_error._last_error_description.c_str();
|
||||
}
|
||||
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
|
77
ddlrepresentation/ddl_error.h
Normal file
77
ddlrepresentation/ddl_error.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLERROR_H_INCLUDED
|
||||
#define DDLERROR_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Static DDL Error Handling class.
|
||||
*
|
||||
* The parser will use this static Error handling to inform about validation errors.
|
||||
*/
|
||||
class DDLError
|
||||
{
|
||||
std::string _last_error_description;
|
||||
a_util::result::Result _last_error_code;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gets the last DDL Error Code occured.
|
||||
* @return the DDL Error.
|
||||
*/
|
||||
static a_util::result::Result getLastDDLErrorCode();
|
||||
/**
|
||||
* Gets the last DDL Error description occured.
|
||||
* @return the last DDL Error description.
|
||||
* @remark not thread safe!
|
||||
*/
|
||||
static const char* getLastDDLErrorDescription();
|
||||
/**
|
||||
* Sets the last DDL Error and error description.
|
||||
* @return the last DDL Error description.
|
||||
* @remark not thread safe!
|
||||
*/
|
||||
static a_util::result::Result setLastDDLError(a_util::result::Result result,
|
||||
const std::string& error);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to set an error description to the DDL error handling and return a DDL Error.
|
||||
* @param [in] \_\_errCode\_\_ the error code to return
|
||||
* @param [in] \_\_desc\_\_ the description to set
|
||||
*/
|
||||
#define RETURN_DDLERROR_DESC(__errCode__, __desc__) { ddl::DDLError::setLastDDLError(__errCode__, __desc__); return __errCode__; }
|
||||
/**
|
||||
* Helper to set an error description to the DDL error handling and return a DDL Error if failed.
|
||||
* @param [in] \_\_callterm\_\_ statement to execute to.
|
||||
*/
|
||||
#define RETURN_DDLERROR_IF_FAILED(__callterm__) { a_util::result::Result ntmpRes = __callterm__; if (isFailed(ntmpRes)) { RETURN_DDLERROR_DESC(ntmpRes, ""); } }
|
||||
/**
|
||||
* Helper to set an error description to the DDL error handling and return a DDL Error if failed.
|
||||
* @param [in] \_\_callterm\_\_ statement to execute to.
|
||||
* @param [in] \_\_desc\_\_ additional error description to set.
|
||||
*/
|
||||
#define RETURN_DDLERROR_IF_FAILED_DESC(__callterm__, __desc__) { a_util::result::Result ntmpRes = __callterm__; if (isFailed(ntmpRes)) { RETURN_DDLERROR_DESC(ntmpRes, __desc__); } }
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDLERROR_H_INCLUDED
|
118
ddlrepresentation/ddl_intf.h
Normal file
118
ddlrepresentation/ddl_intf.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_INTF_H_INCLUDED
|
||||
#define DDL_INTF_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
class IDDLVisitor;
|
||||
class IDDLChangeVisitor;
|
||||
|
||||
/**
|
||||
* Interface class for object representation of DDL descriptions.
|
||||
* E.g. it provides the accept() method for the Visitor design-pattern.
|
||||
*/
|
||||
class IDDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Virtual DTOR
|
||||
*/
|
||||
virtual ~IDDL(){}
|
||||
|
||||
/**
|
||||
* Acceptance method for Visitor design-pattern.
|
||||
* @param[in] visitor - Pointer to Visitor instance
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
* @retval ERR_NOT_INITIALIZED The object was not or not correctly
|
||||
* initialized
|
||||
*/
|
||||
virtual a_util::result::Result accept (IDDLVisitor * visitor) const = 0;
|
||||
|
||||
/**
|
||||
* Acceptance method for Visitor and Change design-pattern.
|
||||
* @param[in] visitor - Pointer to Visitor instance
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
* @retval ERR_NOT_INITIALIZED The object was not or not correctly
|
||||
* initialized
|
||||
*/
|
||||
virtual a_util::result::Result accept(IDDLChangeVisitor * visitor) = 0;
|
||||
|
||||
/**
|
||||
* Getter for the initialization flag.
|
||||
* @retval true The object was initialized correctly
|
||||
* @retval false The object was not or not correctly initialized
|
||||
*/
|
||||
virtual bool isInitialized() const = 0;
|
||||
|
||||
/**
|
||||
* Getter for the name of the representation object.
|
||||
* @return the name
|
||||
*/
|
||||
virtual const std::string& getName() const = 0;
|
||||
|
||||
/**
|
||||
* Getter for the predefinition flag.
|
||||
* @retval true The object was predefined
|
||||
* @retval false The object was defined later
|
||||
*/
|
||||
virtual bool isPredefined() const = 0;
|
||||
|
||||
/**
|
||||
* Getter for the predefinition flag.
|
||||
* @retval true The object was predefined
|
||||
* @retval false The object was defined later
|
||||
*/
|
||||
virtual bool isOverwriteable() const = 0;
|
||||
|
||||
/**
|
||||
* Getter for the creation level.
|
||||
* @return the level at creation time of this representation object
|
||||
*/
|
||||
virtual int getCreationLevel() const = 0;
|
||||
|
||||
/**
|
||||
* Getter for complex data type flag.
|
||||
* @retval true This is a complex data type
|
||||
*/
|
||||
virtual bool isComplex() const
|
||||
{
|
||||
// default is not complex
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags for Merging
|
||||
*
|
||||
*/
|
||||
enum TagMergeFlags
|
||||
{
|
||||
ddl_merge_force_overwrite = 0x01
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_INTF_H_INCLUDED
|
72
ddlrepresentation/ddl_type.cpp
Normal file
72
ddlrepresentation/ddl_type.cpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddl_type.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
bool DDL::isEqual(IDDL *lhs, IDDL *rhs)
|
||||
{
|
||||
if (NULL == lhs ||
|
||||
NULL == rhs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return a_util::strings::isEqualNoCase(lhs->getName().c_str(), rhs->getName().c_str());
|
||||
}
|
||||
|
||||
bool DDL::isSorted(IDDL *lhs, IDDL *rhs)
|
||||
{
|
||||
if (NULL == lhs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (NULL == rhs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return lhs->getName() < rhs->getName();
|
||||
}
|
||||
|
||||
bool DDL::isInitialized() const
|
||||
{
|
||||
// default case
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DDL::isPredefined() const
|
||||
{
|
||||
// default case
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DDL::isOverwriteable() const
|
||||
{
|
||||
return getCreationLevel() > 0; // cMediaManager::DL_AlwaysThere
|
||||
}
|
||||
|
||||
int DDL::getCreationLevel() const
|
||||
{
|
||||
// default case
|
||||
// cMediaManager::DL_AlwaysThere
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace ddl
|
203
ddlrepresentation/ddl_type.h
Normal file
203
ddlrepresentation/ddl_type.h
Normal file
|
@ -0,0 +1,203 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_TYPE_H_INCLUDED
|
||||
#define DDL_TYPE_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-49, ERR_OUT_OF_RANGE)
|
||||
|
||||
/**
|
||||
* The abstract helper class for representation classes for DDL descriptions.
|
||||
*/
|
||||
class DDL : public IDDL
|
||||
{
|
||||
public:
|
||||
|
||||
virtual bool isInitialized() const;
|
||||
|
||||
virtual bool isPredefined() const;
|
||||
|
||||
virtual bool isOverwriteable() const;
|
||||
|
||||
virtual int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Functor for use with \c std::transform() to delete all objects
|
||||
* where the elements of a vector point at.
|
||||
* @param[in] obj - Pointer to the object to delete
|
||||
* @return Pointer to the predefined object that was not deleted (see remarks).
|
||||
* @remarks Objects which are declarated as predefined are not deleted.
|
||||
*/
|
||||
template<typename T>
|
||||
static T* deleteChild(T *obj)
|
||||
{
|
||||
if (NULL != obj)
|
||||
{
|
||||
if (obj->isPredefined())
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete obj;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method moves element within the list.
|
||||
* @param[in] obj - Pointer to the list object
|
||||
* @param[in] from - Position of element in the list
|
||||
* @param[in] to - New position of element in the list
|
||||
* @return ERR_OUT_OF_RANGE - from and to parameters are out of range.
|
||||
* @return a_util::result::SUCCESS
|
||||
*/
|
||||
template<typename T>
|
||||
static a_util::result::Result moveChild(T *obj, const int from, const int to)
|
||||
{
|
||||
if (NULL == obj) { return a_util::result::Result(-4); } //ERR_POINTER for hackers...
|
||||
|
||||
if (-1 == from || -1 == to ||
|
||||
(int)obj->size() < from || (int)obj->size() < to)
|
||||
{
|
||||
return ERR_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
if (from != to)
|
||||
{
|
||||
if (from < to)
|
||||
{
|
||||
std::rotate(obj->begin() + from,
|
||||
obj->begin() + from + 1,
|
||||
obj->begin() + to + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::rotate(obj->begin() + to,
|
||||
obj->begin() + from,
|
||||
obj->begin() + from + 1);
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functor for use with \c std::transform() to clone the objects
|
||||
* where the elements of a vector point at.
|
||||
* @tparam T - Representation object type (e.g. \c Prefix)
|
||||
* @param[in] obj - Pointer to the object to clone
|
||||
* @return Pointer to cloned instance of T or \c NULL if there was
|
||||
* no original instance (obj == NULL).
|
||||
*/
|
||||
template<typename T>
|
||||
static T* clone(T* obj)
|
||||
{
|
||||
if (NULL != obj)
|
||||
{
|
||||
if (obj->isPredefined())
|
||||
{
|
||||
return ref<T>(obj);
|
||||
}
|
||||
return new T(*obj);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functor for use with \c std::transform() to ref the objects
|
||||
* where the elements of a vector point at, this is for the Always_there.
|
||||
* @tparam T - Representation object type (e.g. \c Prefix)
|
||||
* @param[in] obj - Pointer to the object to clone
|
||||
* @return Pointer to ref instance of T or \c NULL if there was
|
||||
* no original instance (obj == NULL).
|
||||
*/
|
||||
template<typename T>
|
||||
static T* ref(T* obj)
|
||||
{
|
||||
if (NULL != obj)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predicate to compare 2 DDL representation objects (for use with
|
||||
* \c std::unique()).
|
||||
* @param[in] lhs - Pointer to the object on left-hand side
|
||||
* @param[in] rhs - Pointer to the object on right-hand side
|
||||
* @retval true if the objects have the same name
|
||||
* @retval false else
|
||||
*/
|
||||
static bool isEqual(IDDL* lhs, IDDL* rhs);
|
||||
|
||||
/**
|
||||
* sort predicate to compare to 2 DDL representation objects (for use
|
||||
* with \c std::sort()).
|
||||
* @param[in] lhs - Pointer to the object on left-hand side
|
||||
* @param[in] rhs - Pointer to the object on right-hand side
|
||||
* @retval true if the left argument goes before the right one.
|
||||
* @retval false else
|
||||
*/
|
||||
static bool isSorted(IDDL* lhs, IDDL* rhs);
|
||||
};
|
||||
|
||||
/// functional pattern to use std find algorithms
|
||||
template<typename T = IDDL>
|
||||
struct DDLCompareFunctor
|
||||
{
|
||||
/// the name of the pattern
|
||||
const std::string& pattern;
|
||||
|
||||
/**
|
||||
* CTR
|
||||
*
|
||||
* @param [in] pattern the name of the pattern
|
||||
*/
|
||||
DDLCompareFunctor(const std::string& pattern): pattern(pattern)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* compare function for pattern
|
||||
*
|
||||
* @param [in] entry pointer to the DDL object
|
||||
*
|
||||
* @return true if equal, false otherwise
|
||||
*/
|
||||
bool operator()(const T* entry)
|
||||
{
|
||||
if (NULL == entry)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return pattern == entry->getName();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_TYPE_H_INCLUDED
|
87
ddlrepresentation/ddlalignment.cpp
Normal file
87
ddlrepresentation/ddlalignment.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlalignment.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
std::string DDLAlignment::toString(AlignmentType const alignment)
|
||||
{
|
||||
if (alignment != e_invalid)
|
||||
{
|
||||
return a_util::strings::toString((int32_t)alignment);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
DDLAlignment::AlignmentType DDLAlignment::fromString(const std::string &alignment)
|
||||
{
|
||||
if (!a_util::strings::isInt32(alignment))
|
||||
{
|
||||
// fallback to default
|
||||
return e_invalid;
|
||||
}
|
||||
int alignment_int = a_util::strings::toInt32(alignment);
|
||||
if (alignment_int <= 0)
|
||||
{
|
||||
return e1;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(alignment_int)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
return e1;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
return e2;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
return e4;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
return e8;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
return e16;
|
||||
}
|
||||
case 32:
|
||||
{
|
||||
return e32;
|
||||
}
|
||||
case 64:
|
||||
{
|
||||
return e64;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return e_invalid;
|
||||
}
|
||||
} // namespace ddl
|
69
ddlrepresentation/ddlalignment.h
Normal file
69
ddlrepresentation/ddlalignment.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLALIGNMENT_H_INCLUDED
|
||||
#define DDLALIGNMENT_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
|
||||
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Abstract wrapper class for the alignment enumeration
|
||||
*/
|
||||
class DDLAlignment
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Representation of the alignment enumeration
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
e0 = 1, /**< for backward compatibility */
|
||||
e1 = 1, /**< Default alignment */
|
||||
e2 = 2,
|
||||
e4 = 4,
|
||||
e8 = 8,
|
||||
e16 = 16,
|
||||
e32 = 32,
|
||||
e64 = 64,
|
||||
e_invalid = 255
|
||||
} AlignmentType;
|
||||
|
||||
/**
|
||||
* Converts the given alignment to a string.
|
||||
* @param[in] alignment - The alignment to convert
|
||||
* @return the alignment as string
|
||||
*/
|
||||
static std::string toString(AlignmentType const alignment);
|
||||
|
||||
/**
|
||||
* Extracts the alignment out of a given string.
|
||||
* @param[in] alignment - String containing the alignment
|
||||
* @return the extracted alignment
|
||||
*/
|
||||
static AlignmentType fromString(const std::string& alignment);
|
||||
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDLALIGNMENT_H_INCLUDED
|
136
ddlrepresentation/ddlbaseunit.cpp
Normal file
136
ddlrepresentation/ddlbaseunit.cpp
Normal file
|
@ -0,0 +1,136 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlbaseunit.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-5, ERR_INVALID_ARG)
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLBaseunit::DDLBaseunit() :
|
||||
_name{},
|
||||
_symbol{},
|
||||
_description{},
|
||||
_init_flag{},
|
||||
_level{1}
|
||||
{
|
||||
}
|
||||
|
||||
DDLBaseunit::DDLBaseunit(const std::string& name,
|
||||
const std::string& symbol,
|
||||
const std::string& description,
|
||||
int const creation_level) :
|
||||
_name(name),
|
||||
_symbol(symbol),
|
||||
_description(description),
|
||||
_init_flag(true),
|
||||
_level(creation_level)
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLBaseunit::create(const std::string& name,
|
||||
const std::string& symbol,
|
||||
const std::string& description,
|
||||
int const creation_level)
|
||||
{
|
||||
if (name.empty())
|
||||
{
|
||||
return ERR_INVALID_ARG;
|
||||
}
|
||||
_name = name;
|
||||
_symbol = symbol;
|
||||
_description = description;
|
||||
_init_flag = true;
|
||||
_level = creation_level;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLBaseunit::accept(IDDLVisitor *visitor) const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLBaseunit::accept(IDDLChangeVisitor *visitor)
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
bool DDLBaseunit::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
const std::string& DDLBaseunit::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLBaseunit::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
const std::string& DDLBaseunit::getSymbol() const
|
||||
{
|
||||
return _symbol;
|
||||
}
|
||||
|
||||
void DDLBaseunit::setSymbol(const std::string& symbol)
|
||||
{
|
||||
_symbol = symbol;
|
||||
}
|
||||
|
||||
|
||||
const std::string& DDLBaseunit::getDescription() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
void DDLBaseunit::setDescription(const std::string& description)
|
||||
{
|
||||
_description = description;
|
||||
}
|
||||
|
||||
|
||||
bool DDLBaseunit::isPredefined() const
|
||||
{
|
||||
return _level == -1; // cMediaManager::DL_AlwaysThere
|
||||
}
|
||||
|
||||
bool DDLBaseunit::isOverwriteable() const
|
||||
{
|
||||
return _level> 0;
|
||||
}
|
||||
|
||||
int DDLBaseunit::getCreationLevel() const
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
} // namespace ddl
|
118
ddlrepresentation/ddlbaseunit.h
Normal file
118
ddlrepresentation/ddlbaseunit.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLBASE_UNIT_H_INCLUDED
|
||||
#define DDLBASE_UNIT_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlunit_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Representation of a base unit inside a DDL description.
|
||||
*/
|
||||
class DDLBaseunit : public IDDLUnit
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLBaseunit();
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] name - Name of the base unit (e.g. "metre")
|
||||
* @param[in] symbol - Symbol of the base unit (e.g. "m")
|
||||
* @param[in] description - Description of the represented base unit
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
*/
|
||||
DDLBaseunit(const std::string& name,
|
||||
const std::string& symbol,
|
||||
const std::string& description,
|
||||
int const creation_level = 1);
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] name - Name of the base unit (e.g. "metre")
|
||||
* @param[in] symbol - Symbol of the base unit (e.g. "m")
|
||||
* @param[in] description - Description of the represented base unit
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
* @retval ERR_INVALID_ARG Empty name committed
|
||||
*/
|
||||
a_util::result::Result create(const std::string& name,
|
||||
const std::string& symbol,
|
||||
const std::string& description,
|
||||
int const creation_level = 1);
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isPredefined() const;
|
||||
bool isOverwriteable() const;
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Getter for the name.
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the name.
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
|
||||
/**
|
||||
* Getter for the symbol.
|
||||
* @return the symbol
|
||||
*/
|
||||
const std::string& getSymbol() const;
|
||||
/**
|
||||
* Setter for the description.
|
||||
*/
|
||||
void setSymbol(const std::string& symbol);
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the description.
|
||||
* @return the description
|
||||
*/
|
||||
const std::string& getDescription() const;
|
||||
|
||||
/**
|
||||
* Setter for the description.
|
||||
*/
|
||||
void setDescription(const std::string& desc);
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
std::string _symbol;
|
||||
std::string _description;
|
||||
|
||||
bool _init_flag;
|
||||
int _level;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDLBASE_UNIT_H_INCLUDED
|
65
ddlrepresentation/ddlbyteorder.cpp
Normal file
65
ddlrepresentation/ddlbyteorder.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlbyteorder.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
std::string DDLByteorder::toString(DDLByteorder::Byteorder const byteorder)
|
||||
{
|
||||
switch(byteorder)
|
||||
{
|
||||
case e_le:
|
||||
{
|
||||
return std::string("LE");
|
||||
}
|
||||
case e_be:
|
||||
{
|
||||
return std::string("BE");
|
||||
}
|
||||
default:
|
||||
{
|
||||
// error case
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DDLByteorder::Byteorder DDLByteorder::fromString(const std::string& byteorder)
|
||||
{
|
||||
if (byteorder == "LE")
|
||||
{
|
||||
return e_le;
|
||||
}
|
||||
if (byteorder == "BE")
|
||||
{
|
||||
return e_be;
|
||||
}
|
||||
if (byteorder == "Motorola")
|
||||
{
|
||||
return e_be;
|
||||
}
|
||||
if (byteorder == "Intel")
|
||||
{
|
||||
return e_le;
|
||||
}
|
||||
// fallback to default
|
||||
return e_le;
|
||||
}
|
||||
} // namespace ddl
|
64
ddlrepresentation/ddlbyteorder.h
Normal file
64
ddlrepresentation/ddlbyteorder.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef BYTEORDER_H_INCLUDED
|
||||
#define BYTEORDER_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_type.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Abstract wrapper class for the byteorder enumeration.
|
||||
*/
|
||||
class DDLByteorder : public DDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Representation of the byteorder enumeration
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
platform_not_supported = 0x00,
|
||||
plattform_little_endian_8 = 0x01,
|
||||
platform_big_endian_8 = 0x02,
|
||||
e_noe = platform_not_supported,
|
||||
e_le = plattform_little_endian_8,
|
||||
e_be = platform_big_endian_8
|
||||
} Byteorder;
|
||||
|
||||
/**
|
||||
* Converts the given byteorder enumeration to a string.
|
||||
* @param[in] byteorder - Byteorder value to convert
|
||||
* @return the byteorder as string
|
||||
*/
|
||||
static std::string toString(Byteorder const byteorder);
|
||||
|
||||
/**
|
||||
* Extracts the byteorder out of the given string.
|
||||
* @param[in] byteorder - String containing the byteorder
|
||||
* @return the extracted byteorder
|
||||
*/
|
||||
static Byteorder fromString(const std::string& byteorder);
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // BYTEORDER_H_INCLUDED
|
625
ddlrepresentation/ddlcloner.cpp
Normal file
625
ddlrepresentation/ddlcloner.cpp
Normal file
|
@ -0,0 +1,625 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlcloner.h"
|
||||
#include "a_util/result/error_def.h"
|
||||
#include "legacy_error_macros.h"
|
||||
|
||||
#include "ddldescription.h"
|
||||
#include "ddlunit.h"
|
||||
#include "ddlbaseunit.h"
|
||||
#include "ddlprefix.h"
|
||||
#include "ddldatatype.h"
|
||||
#include "ddlenum.h"
|
||||
#include "ddlcomplex.h"
|
||||
#include "ddlstream.h"
|
||||
#include "ddlstreammetatype.h"
|
||||
#include "ddlheader.h"
|
||||
#include "ddlextdeclaration.h"
|
||||
#include "ddlrefunit.h"
|
||||
#include "ddlelement.h"
|
||||
#include "ddlstreamstruct.h"
|
||||
|
||||
#include "ddlimporter.h"
|
||||
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-16, ERR_NOT_IMPL)
|
||||
_MAKE_RESULT(-18, ERR_NO_CLASS)
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLDescription * DDLCloner::getDDL() const
|
||||
{
|
||||
return _ddl_desc;
|
||||
}
|
||||
|
||||
void DDLCloner::destroyDDL()
|
||||
{
|
||||
DDLImporter::destroyDDL(_ddl_desc);
|
||||
_ddl_desc = NULL;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLCloner::createNew(const DDLVersion& version /* = 0 */)
|
||||
{
|
||||
if (NULL == _original_desc)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
// The DDL object does not get deleted because the caller/user of this
|
||||
// object is responsible for it.
|
||||
_ddl_desc = NULL;
|
||||
// clone original DDL
|
||||
RETURN_IF_FAILED(buildHeader());
|
||||
RETURN_IF_FAILED(buildUnits());
|
||||
RETURN_IF_FAILED(buildDatatypes());
|
||||
RETURN_IF_FAILED(buildEnums());
|
||||
RETURN_IF_FAILED(buildStructs());
|
||||
RETURN_IF_FAILED(buildStreams());
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLCloner::buildHeader()
|
||||
{
|
||||
if (NULL == _original_desc)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
// copy header object
|
||||
DDLHeader *header = new DDLHeader(*_original_desc->getHeader());
|
||||
// external declarations have to be cloned separately
|
||||
DDLExtDeclarationVec ext_declarations = header->getExtDeclarations();
|
||||
std::transform(ext_declarations.begin(), ext_declarations.end(),
|
||||
ext_declarations.begin(), DDL::clone<DDLExtDeclaration>);
|
||||
_ddl_desc = new DDLDescription(header);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLCloner::buildUnits()
|
||||
{
|
||||
if (NULL == _original_desc)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
// clone baseunit objects
|
||||
DDLBaseunitVec baseunits = _original_desc->getBaseunits();
|
||||
std::transform(baseunits.begin(), baseunits.end(), baseunits.begin(),
|
||||
DDL::clone<DDLBaseunit>);
|
||||
_ddl_desc->refBaseunits(baseunits);
|
||||
|
||||
// clone prefix objects
|
||||
DDLPrefixVec ddlprefixes = _original_desc->getPrefixes();
|
||||
std::transform(ddlprefixes.begin(), ddlprefixes.end(),
|
||||
ddlprefixes.begin(), DDL::clone<DDLPrefix>);
|
||||
_ddl_desc->refPrefixes(ddlprefixes);
|
||||
|
||||
// clone unit objects
|
||||
DDLUnitVec units = _original_desc->getUnits();
|
||||
std::transform(units.begin(), units.end(),
|
||||
units.begin(), DDL::clone<DDLUnit>);
|
||||
// refunit objects have to be cloned separately
|
||||
for (DDLUnitIt it_unit = units.begin(); units.end() != it_unit;
|
||||
++it_unit)
|
||||
{
|
||||
DDLRefUnitVec refunits = (*it_unit)->getRefUnits();
|
||||
for (DDLRefUnitIt it_ru = refunits.begin(); refunits.end() != it_ru;
|
||||
++it_ru)
|
||||
{
|
||||
// find prefix object
|
||||
DDLPrefixIt it_prefix = std::find_if(ddlprefixes.begin(),
|
||||
ddlprefixes.end(), DDLCompareFunctor<DDLPrefix>((*it_ru)->getPrefix()));
|
||||
if (ddlprefixes.end() == it_prefix)
|
||||
{
|
||||
return ERR_NO_CLASS;
|
||||
}
|
||||
// find unit and create refunit object with appropriate CTOR
|
||||
DDLBaseunitIt it_bu_found = std::find_if(baseunits.begin(),
|
||||
baseunits.end(), DDLCompareFunctor<DDLBaseunit>((*it_ru)->getName()));
|
||||
if (baseunits.end() == it_bu_found)
|
||||
{
|
||||
// not found in baseunit vector
|
||||
DDLUnitIt it_u_found = std::find_if(units.begin(),
|
||||
units.end(), DDLCompareFunctor<DDLUnit>((*it_ru)->getName()));
|
||||
if (units.end() == it_u_found)
|
||||
{
|
||||
// not found in unit vector
|
||||
// => not defined at all
|
||||
return ERR_NO_CLASS;
|
||||
}
|
||||
*it_ru = new DDLRefUnit(*it_u_found, (*it_ru)->getPower(),
|
||||
*it_prefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
*it_ru = new DDLRefUnit(*it_bu_found, (*it_ru)->getPower(),
|
||||
*it_prefix);
|
||||
}
|
||||
}
|
||||
(*it_unit)->setRefUnits(refunits);
|
||||
}
|
||||
_ddl_desc->refUnits(units);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLCloner::buildDatatypes()
|
||||
{
|
||||
if (NULL == _original_desc)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
DDLDTVec datatypes = _original_desc->getDatatypes();
|
||||
for (DDLDTIt it_dt = datatypes.begin(); datatypes.end() != it_dt; ++it_dt)
|
||||
{
|
||||
DDLVersion version = (*it_dt)->getDDLVersion();
|
||||
if ((*it_dt)->getUnit().empty())
|
||||
{
|
||||
// datatype without defined unit
|
||||
(*it_dt) = new DDLDataType((*it_dt)->getName(),
|
||||
(*it_dt)->getNumBits(),
|
||||
NULL,
|
||||
(*it_dt)->getDescription(),
|
||||
(*it_dt)->getAlignment(),
|
||||
(*it_dt)->getArraysize(),
|
||||
(*it_dt)->getCreationLevel(),
|
||||
(*it_dt)->getArraySizeSource(),
|
||||
(*it_dt)->isMinValid(),
|
||||
(*it_dt)->getMinValue(),
|
||||
(*it_dt)->isMaxValid(),
|
||||
(*it_dt)->getMaxValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
// find unit and clone datatype object with appropriate CTOR
|
||||
DDLBaseunitVec baseunits = _ddl_desc->getBaseunits();
|
||||
DDLBaseunitIt it_bu_found = std::find_if(baseunits.begin(),
|
||||
baseunits.end(), DDLCompareFunctor<DDLBaseunit>((*it_dt)->getUnit()));
|
||||
if (baseunits.end() == it_bu_found)
|
||||
{
|
||||
// not found in baseunit vector
|
||||
DDLUnitVec units = _ddl_desc->getUnits();
|
||||
DDLUnitIt it_u_found = std::find_if(units.begin(),
|
||||
units.end(), DDLCompareFunctor<DDLUnit>((*it_dt)->getUnit()));
|
||||
if (units.end() == it_u_found)
|
||||
{
|
||||
// not found in unit vector
|
||||
// => not defined at all
|
||||
return ERR_NO_CLASS;
|
||||
}
|
||||
(*it_dt) = new DDLDataType((*it_dt)->getName(),
|
||||
(*it_dt)->getNumBits(),
|
||||
*it_u_found,
|
||||
(*it_dt)->getDescription(),
|
||||
(*it_dt)->getAlignment(),
|
||||
(*it_dt)->getArraysize(),
|
||||
(*it_dt)->getCreationLevel(),
|
||||
(*it_dt)->getArraySizeSource(),
|
||||
(*it_dt)->isMinValid(),
|
||||
(*it_dt)->getMinValue(),
|
||||
(*it_dt)->isMaxValid(),
|
||||
(*it_dt)->getMaxValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
(*it_dt) = new DDLDataType((*it_dt)->getName(),
|
||||
(*it_dt)->getNumBits(),
|
||||
*it_bu_found,
|
||||
(*it_dt)->getDescription(),
|
||||
(*it_dt)->getAlignment(),
|
||||
(*it_dt)->getArraysize(),
|
||||
(*it_dt)->getCreationLevel(),
|
||||
(*it_dt)->getArraySizeSource(),
|
||||
(*it_dt)->isMinValid(),
|
||||
(*it_dt)->getMinValue(),
|
||||
(*it_dt)->isMaxValid(),
|
||||
(*it_dt)->getMaxValue());
|
||||
}
|
||||
}
|
||||
(*it_dt)->setDDLVersion(version);
|
||||
}
|
||||
_ddl_desc->refDatatypes(datatypes);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLCloner::buildEnums()
|
||||
{
|
||||
if (NULL == _original_desc)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
DDLEnumVec enums = _original_desc->getEnums();
|
||||
// clone enums
|
||||
std::transform(enums.begin(), enums.end(),
|
||||
enums.begin(), DDL::clone<DDLEnum>);
|
||||
_ddl_desc->refEnums(enums);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLCloner::buildStructs()
|
||||
{
|
||||
if (NULL == _original_desc)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
// clone structs
|
||||
DDLComplexVec structs;
|
||||
structs.cloneFrom(_original_desc->getStructs());
|
||||
|
||||
// elements have to be cloned seperately
|
||||
DDLDTVec datatypes = _ddl_desc->getDatatypes();
|
||||
DDLUnitVec units = _ddl_desc->getUnits();
|
||||
DDLBaseunitVec baseunits = _ddl_desc->getBaseunits();
|
||||
DDLEnumVec ddl_enums = _ddl_desc->getEnums();
|
||||
for (DDLComplexVec::iterator it_struct = structs.begin();
|
||||
structs.end() != it_struct; ++it_struct)
|
||||
{
|
||||
DDLElementVec elements = (*it_struct)->getElements();
|
||||
for (DDLElementIt it_element = elements.begin();
|
||||
elements.end() != it_element; ++it_element)
|
||||
{
|
||||
DDLComplex* ddl_struct = NULL;
|
||||
DDLEnum* ddl_enum = NULL;
|
||||
DDLDataType* type = datatypes.find((*it_element)->getType());
|
||||
if (!type)
|
||||
{
|
||||
// not found in datatypes vector
|
||||
ddl_struct = structs.find((*it_element)->getType());
|
||||
if (!ddl_struct)
|
||||
{
|
||||
// not found in structs vector
|
||||
ddl_enum = ddl_enums.find((*it_element)->getType());
|
||||
if (!ddl_enum)
|
||||
{
|
||||
// not found in enums vector
|
||||
// => not defined at all
|
||||
return ERR_NO_CLASS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((*it_element)->getUnit().empty())
|
||||
{
|
||||
// no unit defined
|
||||
if (ddl_enum)
|
||||
{
|
||||
*it_element = new DDLElement(ddl_enum,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
NULL,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
else if(ddl_struct)
|
||||
{
|
||||
*it_element = new DDLElement(ddl_struct,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
NULL,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
*it_element = new DDLElement(type,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
NULL,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// find unit
|
||||
DDLBaseunitIt it_bu_found = std::find_if(baseunits.begin(),
|
||||
baseunits.end(), DDLCompareFunctor<DDLBaseunit>((*it_element)->getUnit()));
|
||||
if (baseunits.end() == it_bu_found)
|
||||
{
|
||||
// not found in baseunit vector
|
||||
DDLUnitIt it_u_found = std::find_if(units.begin(),
|
||||
units.end(), DDLCompareFunctor<DDLUnit>((*it_element)->getUnit()));
|
||||
if (units.end() == it_u_found)
|
||||
{
|
||||
// not found in units vector
|
||||
// => not defined at all
|
||||
return ERR_NO_CLASS;
|
||||
}
|
||||
if (ddl_enum)
|
||||
{
|
||||
*it_element = new DDLElement(ddl_enum,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
*it_u_found,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
else if (ddl_struct)
|
||||
{
|
||||
*it_element = new DDLElement(ddl_struct,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
*it_u_found,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
*it_element = new DDLElement(type,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
*it_u_found,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ddl_enum)
|
||||
{
|
||||
*it_element = new DDLElement(ddl_enum,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
*it_bu_found,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
else if (ddl_struct)
|
||||
{
|
||||
*it_element = new DDLElement(ddl_struct,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
*it_bu_found,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
*it_element = new DDLElement(type,
|
||||
(*it_element)->getName(),
|
||||
(*it_element)->getBytepos(),
|
||||
(*it_element)->getArraysize(),
|
||||
(*it_element)->getByteorder(),
|
||||
(*it_element)->getAlignment(),
|
||||
*it_bu_found,
|
||||
(*it_element)->getBitpos(),
|
||||
(*it_element)->getNumBits(),
|
||||
(*it_element)->getDescription(),
|
||||
(*it_element)->getComment(),
|
||||
(*it_element)->getArraySizeSource(),
|
||||
(*it_element)->getConstantValue(),
|
||||
(*it_element)->isMinValid(),
|
||||
(*it_element)->getMinValue(),
|
||||
(*it_element)->isMaxValid(),
|
||||
(*it_element)->getMaxValue(),
|
||||
(*it_element)->isDefaultValid(),
|
||||
(*it_element)->getDefaultValue(),
|
||||
(*it_element)->isScaleValid(),
|
||||
(*it_element)->getScaleValue(),
|
||||
(*it_element)->isOffsetValid(),
|
||||
(*it_element)->getOffsetValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(*it_struct)->setElements(elements);
|
||||
}
|
||||
_ddl_desc->refStructs(structs);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLCloner::buildStreams()
|
||||
{
|
||||
if (NULL == _original_desc)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
// clone the streams
|
||||
DDLStreamVec streams = _original_desc->getStreams();
|
||||
DDLComplexVec structs = _ddl_desc->getStructs();
|
||||
for (DDLStreamIt it_stream = streams.begin();
|
||||
streams.end() != it_stream; ++it_stream)
|
||||
{
|
||||
// find type
|
||||
DDLComplexIt it_found = std::find_if(structs.begin(),
|
||||
structs.end(), DDLCompareFunctor<DDLComplex>((*it_stream)->getType()));
|
||||
if (structs.end() == it_found)
|
||||
{
|
||||
// type not found
|
||||
return ERR_NO_CLASS;
|
||||
}
|
||||
|
||||
// clone the contained stream structs
|
||||
DDLStreamStructVec strm_structs = (*it_stream)->getStructs();
|
||||
DDLVersion version = (*it_stream)->getDDLVersion();
|
||||
*it_stream = new DDLStream(*it_found, (*it_stream)->getName(),
|
||||
(*it_stream)->getDescription(), strm_structs,
|
||||
(*it_stream)->getCreationLevel());
|
||||
(*it_stream)->setDDLVersion(version);
|
||||
|
||||
for (DDLStreamStructIt it_struct = strm_structs.begin();
|
||||
strm_structs.end() != it_struct; ++it_struct)
|
||||
{
|
||||
// find type
|
||||
it_found = std::find_if(structs.begin(), structs.end(),
|
||||
DDLCompareFunctor<DDLComplex>((*it_struct)->getType()));
|
||||
if (structs.end() == it_found)
|
||||
{
|
||||
// type not found
|
||||
return ERR_NO_CLASS;
|
||||
}
|
||||
*it_struct = new DDLStreamStruct(*it_found,
|
||||
(*it_struct)->getBytepos(), (*it_struct)->getName());
|
||||
}
|
||||
(*it_stream)->refStructs(strm_structs);
|
||||
}
|
||||
_ddl_desc->refStreams(streams);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLCloner::setOriginal(const DDLDescription* original)
|
||||
{
|
||||
if (!original) { return ERR_POINTER; }
|
||||
_original_desc = original;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result ddl::DDLCloner::buildStreamMetaTypes()
|
||||
{
|
||||
return ERR_NOT_IMPL; ///@todo
|
||||
}
|
||||
|
||||
} // namespace ddl
|
69
ddlrepresentation/ddlcloner.h
Normal file
69
ddlrepresentation/ddlcloner.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_CLONER_H_INCLUDED
|
||||
#define DDL_CLONER_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlfactorymethod_intf.h"
|
||||
#include "ddldescription.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Implementation of IDDLFactorMethod for cloning of DDL representations.
|
||||
*/
|
||||
class DDLCloner : public IDDLFactoryMethod
|
||||
{
|
||||
public: // implements IDDLFactoryMethod
|
||||
|
||||
DDLDescription * getDDL() const;
|
||||
|
||||
a_util::result::Result createNew(const DDLVersion& version = DDLVersion::ddl_version_invalid);
|
||||
|
||||
void destroyDDL();
|
||||
|
||||
a_util::result::Result buildHeader();
|
||||
|
||||
a_util::result::Result buildUnits();
|
||||
|
||||
a_util::result::Result buildDatatypes();
|
||||
|
||||
a_util::result::Result buildEnums();
|
||||
|
||||
a_util::result::Result buildStructs();
|
||||
|
||||
a_util::result::Result buildStreams();
|
||||
|
||||
a_util::result::Result buildStreamMetaTypes();
|
||||
public:
|
||||
/**
|
||||
* Setter method for the original DDL object.
|
||||
* @param[in] original - Pointer to the DDL object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
*/
|
||||
a_util::result::Result setOriginal(const DDLDescription* original);
|
||||
|
||||
private: // members
|
||||
DDLDescription* _ddl_desc;
|
||||
const DDLDescription* _original_desc;
|
||||
};
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_CLONER_H_INCLUDED
|
1263
ddlrepresentation/ddlcompare.cpp
Normal file
1263
ddlrepresentation/ddlcompare.cpp
Normal file
File diff suppressed because it is too large
Load diff
309
ddlrepresentation/ddlcompare.h
Normal file
309
ddlrepresentation/ddlcompare.h
Normal file
|
@ -0,0 +1,309 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLCOMPARE_H_INCLUDED
|
||||
#define DDLCOMPARE_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddldescription.h"
|
||||
#include "ddlunit_intf.h"
|
||||
#include "ddlelement.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
/**
|
||||
* Utility class to compare media descriptions
|
||||
*/
|
||||
class DDLCompare
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Flags for the description based isEqual methods
|
||||
*/
|
||||
enum DescriptionCheckFlags
|
||||
{
|
||||
dcf_data_types = 0x01, ///< Compare datatypes
|
||||
dcf_units = 0x02, ///< Compare units
|
||||
dcf_enums = 0x04, ///< Compare enums
|
||||
dcf_structs = 0x08, ///< Compare structs
|
||||
dcf_streams = 0x10, ///< Compare streams
|
||||
dcf_base_units = 0x20, ///< Compare baseunits
|
||||
dcf_prefixes = 0x40, ///< Compare prefixes
|
||||
dcf_all = 0xFF, ///< Compare all elements (see above)
|
||||
dcf_subset = 0x0100, ///< Checks whether the first description is a subset of the second
|
||||
dcf_versions = 0x0200, ///< Compares the version attributes as well
|
||||
dcf_comments = 0x0400, ///< Compares the comment attributes as well
|
||||
dcf_descriptions = 0x0800, ///< Compares the description attributes as well
|
||||
dcf_header = 0x1000, ///< Compare the header as well
|
||||
dcf_visualization_attributes = 0x2000, ///< Check attributes relevant for visualization (min/max/default/scale/offset)
|
||||
dcf_no_enum_values_check = 0x010000, ///< Do not compare enum values.
|
||||
dcf_no_recursion = 0x020000, ///< Do not compare sub-entities (elements, ref units, stream structs, ...)
|
||||
dcf_no_header_dates = 0x040000, ///< Do not compare header dates (date_creation, date_change)
|
||||
|
||||
dcf_everything = 0xFFFF ///< Check everything (all flags except the "No" variants)
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags for the item based isEqual methods
|
||||
*/
|
||||
enum ItemCheckFlags
|
||||
{
|
||||
icf_none = 0x00,
|
||||
icf_memory = 0x01, ///< Compare the in-memory representation
|
||||
icf_serialized = 0x02, ///< Compare the serialized representation
|
||||
icf_names = 0x04, ///< Compare the names of structs and their elements
|
||||
icf_versions = 0x08, ///< Compare the versions of all elements and structs
|
||||
icf_units = 0x10, ///< Compare the units as well
|
||||
icf_comments = 0x20, ///< Compare the comments as well
|
||||
icf_descriptions = 0x40, ///< Compare the comments as well
|
||||
icf_subset = 0x80, ///< Check if the first item is a subset of the second.
|
||||
icf_visualizations_attributes = 0x0100, ///< Check attributes relevant for visualization (min/max/default/scale/offset)
|
||||
icf_no_enum_values_check = 0x0200, ///< Do not compare enum values.
|
||||
icf_no_recursion = 0x0400 ///< Do not compare sub-entities (elements, ref units, stream structs, ...)
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief isBinaryEqual checks whether two type descriptions describe the same binary data layout
|
||||
* @param [in] type1 The name of the first type.
|
||||
* @param [in] desc1 The description that has type1.
|
||||
* @param [in] type2 The name of the second type.
|
||||
* @param [in] desc2 The description that has type2.
|
||||
* @param [in] is_subset If true then the method checks if the first type is a subset of the second (starting at offset 0, possibly with smaller size).
|
||||
* @retval a_util::result::SUCCESS The description describe the same layout
|
||||
* @retval ERR_FAILED The description do NOT describe the same layout
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isBinaryEqual(const std::string& type1, const std::string& desc1,
|
||||
const std::string& type2, const std::string& desc2,
|
||||
bool is_subset = true);
|
||||
|
||||
/**
|
||||
* @brief isBinaryEqual checks whether two type descriptions describe the same binary data layout
|
||||
* @param [in] type1 The name of the first type.
|
||||
* @param [in] desc1 The description that has type1.
|
||||
* @param [in] type2 The name of the second type.
|
||||
* @param [in] desc2 The description that has type2.
|
||||
* @param [in] is_subset If true then the method checks if the first type is a subset of the second (starting at offset 0, possibly with smaller size).
|
||||
* @retval a_util::result::SUCCESS The description describe the same layout
|
||||
* @retval ERR_FAILED The description do NOT describe the same layout
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isBinaryEqual(const std::string& type1, const DDLDescription* desc1,
|
||||
const std::string& type2, const DDLDescription* desc2,
|
||||
bool is_subset = true);
|
||||
|
||||
// main ddl entities comparisons
|
||||
|
||||
/**
|
||||
* @brief isEqualPrefix checks whether two prefix descriptions are equal.
|
||||
* @param [in] prefix1 The name of the first prefix.
|
||||
* @param [in] desc1 The description that has prefix1.
|
||||
* @param [in] prefix2 The name of the second prefix.
|
||||
* @param [in] desc2 The description that has prefix2.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqualPrefix(const std::string& prefix1, const std::string& desc1,
|
||||
const std::string& prefix2, const std::string& desc2,
|
||||
uint32_t flags = icf_none);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two prefix descriptions are equal.
|
||||
* @param [in] prefix1 The first prefix.
|
||||
* @param [in] prefix2 The second prefix.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const DDLPrefix* prefix1, const DDLPrefix* prefix2,
|
||||
uint32_t flags = icf_none);
|
||||
|
||||
/**
|
||||
* @brief isEqualUnit checks whether two unit descriptions are equal.
|
||||
* @param [in] unit1 The name of the first type.
|
||||
* @param [in] desc1 The description that has unit1.
|
||||
* @param [in] unit2 The name of the second type.
|
||||
* @param [in] desc2 The description that has unit2.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqualUnit(const std::string& unit1, const std::string& desc1,
|
||||
const std::string& unit2, const std::string& desc2,
|
||||
uint32_t flags = icf_none);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two unit descriptions are equal.
|
||||
* @param [in] unit1 The first unit.
|
||||
* @param [in] unit2 The second unit.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const IDDLUnit* unit1, const IDDLUnit* unit2,
|
||||
uint32_t flags = icf_none);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two type (POD/enum/struct) descriptions are equal.
|
||||
* When this is true for a struct then it also implies @ref isBinaryEqual is true
|
||||
* @param [in] type1 The name of the first type.
|
||||
* @param [in] desc1 The description that has type1.
|
||||
* @param [in] type2 The name of the second type.
|
||||
* @param [in] desc2 The description that has type2.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqualType(const std::string& type1, const std::string& desc1,
|
||||
const std::string& type2, const std::string& desc2,
|
||||
uint32_t flags = icf_memory);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two type (POD/enum/struct) descriptions are equal
|
||||
* When this is true for a struct then it also implies @ref isBinaryEqual is true
|
||||
* @param [in] type1 The first type.
|
||||
* @param [in] type2 The second type.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const IDDLDataType* type1, const IDDLDataType* type2,
|
||||
uint32_t flags = icf_memory);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two stream descriptions are equal.
|
||||
* @param [in] stream1 The name of the first stream.
|
||||
* @param [in] desc1 The description that has stream1.
|
||||
* @param [in] stream2 The name of the second stream.
|
||||
* @param [in] desc2 The description that has stream2.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqualStream(const std::string& stream1, const std::string& desc1,
|
||||
const std::string& stream2, const std::string& desc2,
|
||||
uint32_t flags = icf_memory);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two stream descriptions are equal.
|
||||
* @param [in] stream1 The first stream.
|
||||
* @param [in] stream2 The second stream.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const DDLStream* stream1, const DDLStream* stream2,
|
||||
uint32_t flags = icf_memory);
|
||||
|
||||
// sub-item comparison
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two external declarations are equal.
|
||||
* @param [in] ext1 The first declaration.
|
||||
* @param [in] ext2 The second declaration.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const DDLExtDeclaration* ext1, const DDLExtDeclaration* ext2,
|
||||
uint32_t flags = icf_none);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two reference units are equal.
|
||||
* @param [in] ref_unit1 The first unit.
|
||||
* @param [in] ref_unit2 The second unit.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const DDLRefUnit* ref_unit1, const DDLRefUnit* ref_unit2,
|
||||
uint32_t flags = icf_none);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two struct elements are equal.
|
||||
* Note that in case of dynamic elements only the name of the array size specifier can be checked.
|
||||
* Compare the whole struct if you need a more tourough comparison.
|
||||
* @param [in] elem1 The first element.
|
||||
* @param [in] elem2 The second element.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const DDLElement* elem1, const DDLElement* elem2,
|
||||
uint32_t flags = icf_none);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two stream structs equal.
|
||||
* @param [in] stream_struct1 The first struct.
|
||||
* @param [in] stream_struct2 The second struct.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref ItemCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const DDLStreamStruct* stream_struct1, const DDLStreamStruct* stream_struct2,
|
||||
uint32_t flags = icf_none);
|
||||
|
||||
// description based methods
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two descriptions are equal.
|
||||
* @param [in] desc1 The first description.
|
||||
* @param [in] desc2 The second description.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref DescriptionCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const std::string& desc1,
|
||||
const std::string& desc2,
|
||||
uint32_t flags = dcf_all | dcf_subset);
|
||||
|
||||
/**
|
||||
* @brief isEqual checks whether two descriptions are equal.
|
||||
* @param [in] desc1 The first description.
|
||||
* @param [in] desc2 The second description.
|
||||
* @param [in] flags Flags that specifiy what should be checked, see @ref DescriptionCheckFlags.
|
||||
* @retval a_util::result::SUCCESS The descriptions are equal.
|
||||
* @retval ERR_FAILED The description are not equal.
|
||||
* @retval Standard result (other DDL parsing errors etc.)
|
||||
*/
|
||||
static a_util::result::Result isEqual(const DDLDescription* desc1,
|
||||
const DDLDescription* desc2,
|
||||
uint32_t flags = dcf_all | dcf_subset);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
303
ddlrepresentation/ddlcomplex.cpp
Normal file
303
ddlrepresentation/ddlcomplex.cpp
Normal file
|
@ -0,0 +1,303 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include <utility> //std::swap
|
||||
|
||||
#include "ddlcomplex.h"
|
||||
#include "ddlalignment.h"
|
||||
#include "ddldescription.h"
|
||||
#include "ddlelement.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-5, ERR_INVALID_ARG);
|
||||
_MAKE_RESULT(-20, ERR_NOT_FOUND);
|
||||
|
||||
DDLComplex::DDLComplex() :
|
||||
_language_version(DDLVersion::getDefaultVersion()), _init_flag(false), _level(1), _dynamic_elements(false)
|
||||
{
|
||||
}
|
||||
|
||||
DDLComplex::DDLComplex(const std::string& name,
|
||||
unsigned int const version,
|
||||
const std::string& comment,
|
||||
DDLAlignment::AlignmentType const alignment,
|
||||
DDLElementVec ddl_elements,
|
||||
int const creation_level,
|
||||
DDLVersion language_version) :
|
||||
_language_version(language_version),
|
||||
_name(name),
|
||||
_version(version),
|
||||
_comment(comment),
|
||||
_alignment(alignment),
|
||||
_ddl_elements(),
|
||||
_init_flag(true),
|
||||
_level(creation_level),
|
||||
_dynamic_elements(false)
|
||||
{
|
||||
cloneElements(ddl_elements);
|
||||
}
|
||||
|
||||
DDLComplex::DDLComplex(const DDLComplex &other) :
|
||||
_language_version(other.getDDLVersion()),
|
||||
_name(other.getName()),
|
||||
_version(other.getVersion()),
|
||||
_comment(other.getComment()),
|
||||
_alignment(other.getAlignment()),
|
||||
_init_flag(true),
|
||||
_level(other.getCreationLevel())
|
||||
{
|
||||
cloneElements(other.getElements());
|
||||
}
|
||||
|
||||
DDLComplex& DDLComplex::operator=(DDLComplex other)
|
||||
{
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
DDLComplex::DDLComplex(DDLComplex&& other) : DDLComplex()
|
||||
{
|
||||
swap(*this, other);
|
||||
}
|
||||
|
||||
DDLComplex::~DDLComplex()
|
||||
{
|
||||
std::transform(_ddl_elements.begin(), _ddl_elements.end(),
|
||||
_ddl_elements.begin(), DDL::deleteChild<DDLElement>);
|
||||
_ddl_elements.clear();
|
||||
}
|
||||
|
||||
a_util::result::Result DDLComplex::create(const std::string& name,
|
||||
unsigned int const version,
|
||||
const std::string& comment,
|
||||
DDLAlignment::AlignmentType const alignment,
|
||||
DDLElementVec ddl_elements,
|
||||
int const creation_level)
|
||||
{
|
||||
if (name.empty())
|
||||
{
|
||||
return ERR_INVALID_ARG;
|
||||
}
|
||||
_name = name;
|
||||
_version = version;
|
||||
_comment = comment;
|
||||
_alignment = alignment;
|
||||
cloneElements(ddl_elements);
|
||||
_init_flag = true;
|
||||
_level = creation_level;
|
||||
_language_version = DDLVersion::getDefaultVersion();
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLComplex::accept(IDDLVisitor *visitor) const
|
||||
{
|
||||
return visitor->visit(this);
|
||||
}
|
||||
a_util::result::Result DDLComplex::accept(IDDLChangeVisitor *visitor)
|
||||
{
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLComplex::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLComplex::setName(const std::string& name )
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
bool DDLComplex::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
bool DDLComplex::isPredefined() const
|
||||
{
|
||||
return _level == -1; // cMediaManager::DL_Internal
|
||||
}
|
||||
|
||||
bool DDLComplex::isOverwriteable() const
|
||||
{
|
||||
return _level > 0; // cMediaManager::DL_AlwaysThere
|
||||
}
|
||||
|
||||
int DDLComplex::getCreationLevel() const
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
unsigned int DDLComplex::getVersion() const
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
void DDLComplex::setVersion(unsigned int const version)
|
||||
{
|
||||
_version = version;
|
||||
}
|
||||
|
||||
DDLVersion DDLComplex::getDDLVersion() const
|
||||
{
|
||||
return _language_version;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLComplex::setDDLVersion(const DDLVersion& language_version)
|
||||
{
|
||||
_language_version = language_version;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
void DDLComplex::setComment(const std::string& comment)
|
||||
{
|
||||
_comment = comment;
|
||||
}
|
||||
|
||||
std::string DDLComplex::getComment() const
|
||||
{
|
||||
return _comment;
|
||||
}
|
||||
|
||||
void DDLComplex::setAlignment(DDLAlignment::AlignmentType const alignment)
|
||||
{
|
||||
_alignment = alignment;
|
||||
}
|
||||
|
||||
DDLAlignment::AlignmentType DDLComplex::getAlignment() const
|
||||
{
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
void DDLComplex::cloneElements(DDLElementVec ddl_elements)
|
||||
{
|
||||
std::transform(_ddl_elements.begin(), _ddl_elements.end(), _ddl_elements.begin(), DDLDescription::deleteChild<DDLElement>);
|
||||
_ddl_elements.clear();
|
||||
|
||||
_ddl_elements = ddl_elements;
|
||||
std::transform(_ddl_elements.begin(), _ddl_elements.end(), _ddl_elements.begin(), DDLDescription::clone<DDLElement>);
|
||||
_dynamic_elements = false;
|
||||
for (DDLElementIt itEl = _ddl_elements.begin(); itEl != _ddl_elements.end(); itEl++)
|
||||
{
|
||||
if ((*itEl)->isDynamic())
|
||||
{
|
||||
_dynamic_elements = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DDLComplex::setElements(DDLElementVec ddl_elements)
|
||||
{
|
||||
std::transform(_ddl_elements.begin(), _ddl_elements.end(), _ddl_elements.begin(), DDLDescription::deleteChild<DDLElement>);
|
||||
_ddl_elements.clear();
|
||||
|
||||
_ddl_elements = ddl_elements;
|
||||
_dynamic_elements = false;
|
||||
for (DDLElementIt itEl = _ddl_elements.begin(); itEl != _ddl_elements.end(); itEl++)
|
||||
{
|
||||
if ((*itEl)->isDynamic())
|
||||
{
|
||||
_dynamic_elements = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DDLComplex::addElement(DDLElement* element, int pos)
|
||||
{
|
||||
if (NULL != element)
|
||||
{
|
||||
const DDLElementVec::size_type size_pos = static_cast<DDLElementVec::size_type>(pos);
|
||||
if (0 <= size_pos && size_pos < _ddl_elements.size())
|
||||
{
|
||||
_ddl_elements.insert(_ddl_elements.begin() + size_pos, element);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ddl_elements.push_back(element);
|
||||
}
|
||||
if (!_dynamic_elements)
|
||||
{
|
||||
_dynamic_elements = element->isDynamic();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a_util::result::Result DDLComplex::removeElement(const std::string& element_name)
|
||||
{
|
||||
DDLElementIt it = _ddl_elements.begin();
|
||||
while (_ddl_elements.end() != it)
|
||||
{
|
||||
if ((*it)->getName() == element_name)
|
||||
{
|
||||
bool itHasDynArr = (*it)->isDynamic();
|
||||
DDLDescription::deleteChild(*it);
|
||||
_ddl_elements.erase(it);
|
||||
if (_dynamic_elements && itHasDynArr)
|
||||
{
|
||||
// We have to verify if the structure was dynamic only because of this element
|
||||
_dynamic_elements = false;
|
||||
for (DDLElementIt itEl = _ddl_elements.begin(); itEl != _ddl_elements.end(); itEl++)
|
||||
{
|
||||
if ((*itEl)->isDynamic())
|
||||
{
|
||||
_dynamic_elements = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
const DDLElementVec& DDLComplex::getElements() const
|
||||
{
|
||||
return _ddl_elements;
|
||||
}
|
||||
|
||||
DDLElementVec& DDLComplex::getElements()
|
||||
{
|
||||
return _ddl_elements;
|
||||
}
|
||||
|
||||
bool DDLComplex::hasDynamicElements()
|
||||
{
|
||||
return _dynamic_elements;
|
||||
}
|
||||
|
||||
void swap(DDLComplex& lhs, DDLComplex& rhs) noexcept
|
||||
{
|
||||
using std::swap; // ADL
|
||||
swap(lhs._language_version, rhs._language_version);
|
||||
swap(lhs._name, rhs._name);
|
||||
swap(lhs._version, rhs._version);
|
||||
swap(lhs._comment, rhs._comment);
|
||||
swap(lhs._alignment, rhs._alignment);
|
||||
swap(lhs._ddl_elements, rhs._ddl_elements);
|
||||
swap(lhs._init_flag, rhs._init_flag);
|
||||
swap(lhs._level, rhs._level);
|
||||
swap(lhs._dynamic_elements, rhs._dynamic_elements);
|
||||
}
|
||||
} // namespace ddl
|
275
ddlrepresentation/ddlcomplex.h
Normal file
275
ddlrepresentation/ddlcomplex.h
Normal file
|
@ -0,0 +1,275 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLCOMPLEX_H_INCLUDED
|
||||
#define DDLCOMPLEX_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddldatatype_intf.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlalignment.h"
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
class DDLElement;
|
||||
class DDLAlignment;
|
||||
|
||||
/**
|
||||
* Container type of DDLElement objects
|
||||
*/
|
||||
typedef std::vector<DDLElement*> DDLElementVec;
|
||||
/**
|
||||
* Iterator type for DDLElementVec
|
||||
*/
|
||||
typedef DDLElementVec::iterator DDLElementIt;
|
||||
/**
|
||||
* Constant-iterator type for DDLElementVec
|
||||
*/
|
||||
typedef DDLElementVec::const_iterator DDLElementItConst;
|
||||
|
||||
/**
|
||||
* Representation for a complex datatype inside a DDL specification.
|
||||
*/
|
||||
class DDLComplex : public IDDLDataType
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLComplex();
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] name - Name of the data type
|
||||
* @param[in] version - Version number of the specified data type
|
||||
* @param[in] comment - Additional comments (optional)
|
||||
* @param[in] alignment - Alignment value (optional)
|
||||
* @param[in] ddl_elements - Vector of sub elements (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
*/
|
||||
DDLComplex(const std::string& name,
|
||||
unsigned int const version,
|
||||
const std::string& comment = a_util::strings::empty_string,
|
||||
DDLAlignment::AlignmentType const alignment = DDLAlignment::e1,
|
||||
DDLElementVec ddl_elements = DDLElementVec(),
|
||||
int const creation_level = 1,
|
||||
DDLVersion language_version = DDLVersion::getDefaultVersion());
|
||||
|
||||
/**
|
||||
* Copy CTOR
|
||||
* @param[in] other - Reference to complex datatype object to copy
|
||||
*/
|
||||
DDLComplex(const DDLComplex &other);
|
||||
|
||||
/**
|
||||
* Assignment operator (either copies or moves)
|
||||
* @param[in] other Complex DDL type to copy from
|
||||
* @return @c *this
|
||||
*/
|
||||
DDLComplex& operator=(DDLComplex other);
|
||||
|
||||
/**
|
||||
* Move CTOR
|
||||
* @param[in,out] other Complex DDL type to move from - empty but valid when finished
|
||||
*/
|
||||
DDLComplex(DDLComplex&& other);
|
||||
|
||||
/**
|
||||
* DTOR
|
||||
*/
|
||||
virtual ~DDLComplex();
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the name of the complex datatype.
|
||||
* @param [in] name - Name of the complex datatype
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setName(const std::string& name );
|
||||
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
bool isPredefined() const;
|
||||
bool isOverwriteable() const;
|
||||
|
||||
int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] name - Name of the data type
|
||||
* @param[in] version - Version number of the specified data type
|
||||
* @param[in] comment - Additional comments (optional)
|
||||
* @param[in] alignment - Alignment value (optional)
|
||||
* @param[in] ddl_elements - Vector of sub elements (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
* @retval ERR_INVALID_ARG Empty name committed
|
||||
*/
|
||||
a_util::result::Result create(const std::string& name,
|
||||
unsigned int const version,
|
||||
const std::string& comment = a_util::strings::empty_string,
|
||||
DDLAlignment::AlignmentType const alignment = DDLAlignment::e1,
|
||||
DDLElementVec ddl_elements = DDLElementVec(),
|
||||
int const creation_level = 1);
|
||||
|
||||
/**
|
||||
* Getter for the version.
|
||||
* @return the version
|
||||
*/
|
||||
unsigned int getVersion() const;
|
||||
|
||||
/**
|
||||
* Setter for the version.
|
||||
* @param version the version to set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setVersion(unsigned int const version);
|
||||
|
||||
/**
|
||||
* Getter for the DDL version.
|
||||
* @return the DDL version
|
||||
*/
|
||||
DDLVersion getDDLVersion() const;
|
||||
|
||||
/**
|
||||
* Setter for the DDL version.
|
||||
* @param language_version the DDL version to set
|
||||
* @return Standard result code.
|
||||
* @retval a_util::result::SUCCESS
|
||||
*/
|
||||
a_util::result::Result setDDLVersion(const DDLVersion& language_version);
|
||||
|
||||
/**
|
||||
* Setter for the comment.
|
||||
* @param[in] comment - Additional comments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setComment(const std::string& comment);
|
||||
|
||||
/**
|
||||
* Getter for the comment.
|
||||
* @return the comment
|
||||
*/
|
||||
std::string getComment() const;
|
||||
|
||||
/**
|
||||
* Setter for the alignment.
|
||||
* @param[in] alignment - Alignment value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setAlignment(DDLAlignment::AlignmentType const alignment);
|
||||
|
||||
/**
|
||||
* Setter for the element vector.
|
||||
* @param[in] ddl_elements - Vector of elements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void cloneElements(DDLElementVec ddl_elements);
|
||||
|
||||
/**
|
||||
* Setter for the element vector.
|
||||
* @param[in] ddl_elements - Vector of elements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setElements(DDLElementVec ddl_elements);
|
||||
|
||||
/**
|
||||
* Adder for an element.
|
||||
* @param[in] element - Pointer to the element to add
|
||||
* @param[in] pos - Position to add the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void addElement(DDLElement* element, int pos = -1);
|
||||
|
||||
/**
|
||||
* removal for an element.
|
||||
* @param[in] element_name - name of the element to remove
|
||||
* @retval ERR_NOT_FOUND if not found
|
||||
*/
|
||||
a_util::result::Result removeElement(const std::string& element_name);
|
||||
|
||||
/**
|
||||
* Getter for the elements.
|
||||
* @return vector of the elements
|
||||
*/
|
||||
const DDLElementVec& getElements() const;
|
||||
|
||||
/**
|
||||
* Getter for the elements.
|
||||
* @return vector of the elements
|
||||
*/
|
||||
DDLElementVec& getElements();
|
||||
|
||||
/**
|
||||
* Getter for the boolean identifying dynamic elements.
|
||||
* *Note*: this function is not recursive, so to identify structures containing
|
||||
* structures with dynamic elements, you have to do the recursion yourself.
|
||||
* @return true if dynamic elements were found
|
||||
*/
|
||||
bool hasDynamicElements();
|
||||
|
||||
/**
|
||||
* Getter for the alignment of the complex datatype.
|
||||
* @return the alignment
|
||||
*/
|
||||
DDLAlignment::AlignmentType getAlignment() const;
|
||||
|
||||
bool isComplex() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add swap functionality, also enabling the copy-swap-idiom
|
||||
* @param[in,out] lhs Left-hand side ddl type
|
||||
* @param[in,out] rhs Right-hand side ddl type
|
||||
*/
|
||||
friend void swap(DDLComplex& lhs, DDLComplex& rhs) noexcept;
|
||||
|
||||
private:
|
||||
/// The DDL Version this structure was created in
|
||||
DDLVersion _language_version;
|
||||
std::string _name;
|
||||
unsigned int _version;
|
||||
std::string _comment;
|
||||
DDLAlignment::AlignmentType _alignment;
|
||||
DDLElementVec _ddl_elements;
|
||||
|
||||
bool _init_flag;
|
||||
int _level;
|
||||
bool _dynamic_elements;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // _COMPLEX_H_INCLUDED_
|
445
ddlrepresentation/ddlcontainer.cpp
Normal file
445
ddlrepresentation/ddlcontainer.cpp
Normal file
|
@ -0,0 +1,445 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlcontainer.h"
|
||||
#include "ddl_type.h"
|
||||
|
||||
#include "ddlunit.h"
|
||||
#include "ddlbaseunit.h"
|
||||
#include "ddlprefix.h"
|
||||
#include "ddldatatype.h"
|
||||
#include "ddlenum.h"
|
||||
#include "ddlcomplex.h"
|
||||
#include "ddlstream.h"
|
||||
#include "ddlstreammetatype.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct LessCompare
|
||||
{
|
||||
bool operator()(const T* obj1, const T* obj2)
|
||||
{
|
||||
return obj1->getName() < obj2->getName();
|
||||
}
|
||||
|
||||
bool operator()(const T* obj, const std::string& name)
|
||||
{
|
||||
return obj->getName() < name;
|
||||
}
|
||||
|
||||
bool operator()(const std::string& name, const T* obj)
|
||||
{
|
||||
return name < obj->getName();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
DDLContainerNoClone<T>::DDLContainerNoClone(bool sorted): _sorted(sorted)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DDLContainerNoClone<T>::insert(T* elem, int pos)
|
||||
{
|
||||
if (_sorted)
|
||||
{
|
||||
_pointers.insert(std::lower_bound(_pointers.begin(), _pointers.end(), elem, LessCompare<T>()), elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
const typename std::vector<T*>::size_type sz_pos =
|
||||
static_cast<typename std::vector<T*>::size_type>(pos);
|
||||
if (0 <= sz_pos && sz_pos < _pointers.size())
|
||||
{
|
||||
_pointers.insert(_pointers.begin() + sz_pos, elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pointers.push_back(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename DDLContainerNoClone<T>::iterator DDLContainerNoClone<T>::findIt(const std::string& name)
|
||||
{
|
||||
if (_sorted)
|
||||
{
|
||||
iterator it = std::lower_bound(this->begin(), this->end(), name, LessCompare<T>());
|
||||
if (this->end() == it || name != (*it)->getName())
|
||||
{
|
||||
// not found
|
||||
return this->end();
|
||||
}
|
||||
return it;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator it = std::find_if(this->begin(), this->end(), DDLCompareFunctor<>(name));
|
||||
if (this->end() == it)
|
||||
{
|
||||
// not found
|
||||
return this->end();
|
||||
}
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* DDLContainerNoClone<T>::find(const std::string& name) const
|
||||
{
|
||||
if (_sorted)
|
||||
{
|
||||
return find_sorted(name);
|
||||
}
|
||||
return find_unsorted(name);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* DDLContainerNoClone<T>::find(const std::string& name)
|
||||
{
|
||||
if (_sorted)
|
||||
{
|
||||
return find_sorted(name);
|
||||
}
|
||||
return find_unsorted(name);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* DDLContainerNoClone<T>::find_unsorted(const std::string& name) const
|
||||
{
|
||||
|
||||
const_iterator it = std::find_if(this->begin(), this->end(), DDLCompareFunctor<>(name));
|
||||
if (this->end() == it)
|
||||
{
|
||||
// not found
|
||||
return NULL;
|
||||
}
|
||||
return *it;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* DDLContainerNoClone<T>::find_sorted(const std::string& name) const
|
||||
{
|
||||
|
||||
const_iterator it = std::lower_bound(this->begin(), this->end(), name, LessCompare<T>());
|
||||
if (this->end() == it || name != (*it)->getName())
|
||||
{
|
||||
// not found
|
||||
return find_unsorted(name);
|
||||
}
|
||||
return *it;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* DDLContainerNoClone<T>::find_unsorted(const std::string& name)
|
||||
{
|
||||
|
||||
iterator it = std::find_if(this->begin(), this->end(), DDLCompareFunctor<>(name));
|
||||
if (end() == it)
|
||||
{
|
||||
// not found
|
||||
return NULL;
|
||||
}
|
||||
return *it;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* DDLContainerNoClone<T>::find_sorted(const std::string& name)
|
||||
{
|
||||
iterator it = std::lower_bound(this->begin(), this->end(), name, LessCompare<T>());
|
||||
if (end() == it || name != (*it)->getName())
|
||||
{
|
||||
// not found
|
||||
auto obj = find_unsorted(name);
|
||||
if (obj != nullptr)
|
||||
{
|
||||
sort();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
return *it;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DDLContainerNoClone<T>::copyFromRef(DDLContainerNoClone& other)
|
||||
{
|
||||
_pointers.resize(other.size());
|
||||
std::copy(other.begin(), other.end(), _pointers.begin());
|
||||
if (_sorted && !other._sorted)
|
||||
{
|
||||
sort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
void DDLContainerNoClone<T>::deleteAll()
|
||||
{
|
||||
for (iterator it = begin(); it != end(); ++it)
|
||||
{
|
||||
DDL::deleteChild<T>(*it);
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DDLContainerNoClone<T>::sort()
|
||||
{
|
||||
std::sort(_pointers.begin(), _pointers.end(), LessCompare<T>());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool DDLContainerNoClone<T>::isSorted() const
|
||||
{
|
||||
return _sorted;
|
||||
}
|
||||
|
||||
// Note on our iterators:
|
||||
// we do not want to expose the std::vector and std::vector::iterator implementation to the user
|
||||
// so we use the simplest kind of iterator, a pointer.
|
||||
template <typename T>
|
||||
typename DDLContainerNoClone<T>::iterator DDLContainerNoClone<T>::begin()
|
||||
{
|
||||
#if defined(WIN32) && ((_MSC_VER < 1600) || defined(_DEBUG))
|
||||
// have a look at http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#464 and
|
||||
// http://stackoverflow.com/questions/3829788/using-operator-on-empty-stdvector
|
||||
// to find out the reason for this special implementation (VS2008 and lower)
|
||||
if (_pointers.empty())
|
||||
{
|
||||
return &_empty_dummy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &*_pointers.begin();
|
||||
}
|
||||
#else
|
||||
return &*_pointers.begin();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename DDLContainerNoClone<T>::const_iterator DDLContainerNoClone<T>::begin() const
|
||||
{
|
||||
#if defined(WIN32) && ((_MSC_VER < 1600) || defined(_DEBUG))
|
||||
// have a look at http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#464 and
|
||||
// http://stackoverflow.com/questions/3829788/using-operator-on-empty-stdvector
|
||||
// to find out the reason for this special implementation (VS2008 and lower)
|
||||
if (_pointers.empty())
|
||||
{
|
||||
return &_empty_dummy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &*_pointers.begin();
|
||||
}
|
||||
#else
|
||||
return &*_pointers.begin();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename DDLContainerNoClone<T>::iterator DDLContainerNoClone<T>::end()
|
||||
{
|
||||
#if defined(WIN32) && ((_MSC_VER < 1600) || defined(_DEBUG))
|
||||
// have a look at http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#464 and
|
||||
// http://stackoverflow.com/questions/3829788/using-operator-on-empty-stdvector
|
||||
// to find out the reason for this special implementation (VS2008 and lower)
|
||||
if (_pointers.empty())
|
||||
{
|
||||
return &_empty_dummy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &*_pointers.begin() + _pointers.size();
|
||||
}
|
||||
#else
|
||||
return &*_pointers.end();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename DDLContainerNoClone<T>::const_iterator DDLContainerNoClone<T>::end() const
|
||||
{
|
||||
#if defined(WIN32) && ((_MSC_VER < 1600) || defined(_DEBUG))
|
||||
// have a look at http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#464 and
|
||||
// http://stackoverflow.com/questions/3829788/using-operator-on-empty-stdvector
|
||||
// to find out the reason for this special implementation (VS2008 and lower)
|
||||
if (_pointers.empty())
|
||||
{
|
||||
return &_empty_dummy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &*_pointers.begin() + _pointers.size();
|
||||
}
|
||||
#else
|
||||
return &*_pointers.end();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DDLContainerNoClone<T>::clear()
|
||||
{
|
||||
_pointers.clear();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename DDLContainerNoClone<T>::iterator DDLContainerNoClone<T>::erase(iterator it)
|
||||
{
|
||||
typename std::vector<T*>::iterator it_helper = _pointers.erase(_pointers.begin() + (it - begin()));
|
||||
#if defined(WIN32) && ((_MSC_VER < 1600) || defined(_DEBUG))
|
||||
// have a look at http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#464 and
|
||||
// http://stackoverflow.com/questions/3829788/using-operator-on-empty-stdvector
|
||||
// to find out the reason for this special implementation (VS2008 and lower)
|
||||
if (it_helper == _pointers.end())
|
||||
{
|
||||
return &_empty_dummy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &*it_helper;
|
||||
}
|
||||
#else
|
||||
return &*it_helper;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename DDLContainerNoClone<T>::iterator DDLContainerNoClone<T>::erase(iterator pos_first, iterator pos_last)
|
||||
{
|
||||
if (pos_first == pos_last)
|
||||
{
|
||||
return end();
|
||||
}
|
||||
|
||||
#if defined(WIN32) && ((_MSC_VER < 1600) || defined(_DEBUG))
|
||||
// have a look at http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#464 and
|
||||
// http://stackoverflow.com/questions/3829788/using-operator-on-empty-stdvector
|
||||
// to find out the reason for this special implementation (VS2008 and lower)
|
||||
|
||||
// another bug in MSVS Debug http://connect.microsoft.com/VisualStudio/feedback/details/557029/visual-c-iterator-debugging-incorrectly-raises-assertion-on-correct-use-of-return-value-of-std-vector-erase
|
||||
// prevents us from using the erase(start, end) version.
|
||||
typename std::vector<T*>::iterator it_helper = _pointers.begin() + (pos_first - begin());
|
||||
for (uint64_t nCount = pos_last - pos_first; nCount > 0; --nCount)
|
||||
{
|
||||
it_helper = _pointers.erase(it_helper);
|
||||
}
|
||||
|
||||
if (it_helper == _pointers.end())
|
||||
{
|
||||
return &_empty_dummy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &*it_helper;
|
||||
}
|
||||
#else
|
||||
typename std::vector<T*>::iterator it_helper = _pointers.erase(_pointers.begin() + (pos_first - begin()),
|
||||
_pointers.begin() + (pos_last - begin()));
|
||||
return &*it_helper;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool DDLContainerNoClone<T>::empty() const
|
||||
{
|
||||
return _pointers.empty();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
unsigned int DDLContainerNoClone<T>::size() const
|
||||
{
|
||||
return static_cast<unsigned int>(_pointers.size());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T*& DDLContainerNoClone<T>::operator[] (unsigned int pos)
|
||||
{
|
||||
return _pointers[pos];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* const& DDLContainerNoClone<T>::operator[] (unsigned int pos) const
|
||||
{
|
||||
return _pointers[pos];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T*& DDLContainerNoClone<T>::at(unsigned int pos)
|
||||
{
|
||||
return _pointers.at(pos);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* const& DDLContainerNoClone<T>::at(unsigned int pos) const
|
||||
{
|
||||
return _pointers.at(pos);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DDLContainer<T>::DDLContainer(bool sorted): DDLContainerNoClone<T>(sorted)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DDLContainer<T>::cloneFrom(const DDLContainer& other)
|
||||
{
|
||||
this->clear();
|
||||
for (typename DDLContainer::const_iterator it = other.begin(); it != other.end(); ++it)
|
||||
{
|
||||
this->insert(DDL::clone<T>(*it));
|
||||
}
|
||||
}
|
||||
|
||||
template class DDLContainerNoClone<IDDL>;
|
||||
template class DDLContainerNoClone<DDLUnit>;
|
||||
template class DDLContainerNoClone<DDLBaseunit>;
|
||||
template class DDLContainerNoClone<DDLPrefix>;
|
||||
template class DDLContainerNoClone<DDLDataType>;
|
||||
template class DDLContainerNoClone<DDLEnum>;
|
||||
template class DDLContainerNoClone<DDLComplex>;
|
||||
template class DDLContainerNoClone<DDLStream>;
|
||||
template class DDLContainerNoClone<DDLStreamMetaType>;
|
||||
|
||||
#if defined(WIN32) && ((_MSC_VER < 1600) || defined(_DEBUG))
|
||||
IDDL* DDLContainerNoClone<IDDL>::_empty_dummy = NULL;
|
||||
DDLUnit* DDLContainerNoClone<DDLUnit>::_empty_dummy = NULL;
|
||||
DDLBaseunit* DDLContainerNoClone<DDLBaseunit>::_empty_dummy = NULL;
|
||||
DDLPrefix* DDLContainerNoClone<DDLPrefix>::_empty_dummy = NULL;
|
||||
DDLDataType* DDLContainerNoClone<DDLDataType>::_empty_dummy = NULL;
|
||||
DDLEnum* DDLContainerNoClone<DDLEnum>::_empty_dummy = NULL;
|
||||
DDLComplex* DDLContainerNoClone<DDLComplex>::_empty_dummy = NULL;
|
||||
DDLStream* DDLContainerNoClone<DDLStream>::_empty_dummy = NULL;
|
||||
DDLStreamMetaType* DDLContainerNoClone<DDLStreamMetaType>::_empty_dummy = NULL;
|
||||
#endif
|
||||
|
||||
template class DDLContainer<DDLUnit>;
|
||||
template class DDLContainer<DDLBaseunit>;
|
||||
template class DDLContainer<DDLPrefix>;
|
||||
template class DDLContainer<DDLDataType>;
|
||||
template class DDLContainer<DDLEnum>;
|
||||
template class DDLContainer<DDLComplex>;
|
||||
template class DDLContainer<DDLStream>;
|
||||
template class DDLContainer<DDLStreamMetaType>;
|
||||
|
||||
}
|
335
ddlrepresentation/ddlcontainer.h
Normal file
335
ddlrepresentation/ddlcontainer.h
Normal file
|
@ -0,0 +1,335 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_CONTAINER_H_INCLUDED
|
||||
#define DDL_CONTAINER_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
class DDLUnit;
|
||||
class DDLBaseunit;
|
||||
class DDLPrefix;
|
||||
class DDLDataType;
|
||||
class DDLEnum;
|
||||
class DDLComplex;
|
||||
class DDLStream;
|
||||
class DDLStreamMetaType;
|
||||
|
||||
/**
|
||||
* Utility class that stores DDL entities
|
||||
*/
|
||||
template <typename T>
|
||||
class DDLContainerNoClone
|
||||
{
|
||||
private:
|
||||
std::vector<T*> _pointers;
|
||||
bool _sorted;
|
||||
|
||||
#if defined(WIN32) && ((_MSC_VER < 1600) || defined(_DEBUG))
|
||||
static T* _empty_dummy;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
///iterator for DDL container
|
||||
typedef T** iterator; // NOLINT
|
||||
|
||||
///const iterator for DDL container
|
||||
typedef T* const * const_iterator; // NOLINT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param [in] sorted whether the items should be sorted by name (this improves access times)
|
||||
*/
|
||||
DDLContainerNoClone(bool sorted = true);
|
||||
|
||||
/**
|
||||
* @brief insert
|
||||
* @param [in] elem The element to insert.
|
||||
* @param [in] pos Position to add the element
|
||||
* @return void
|
||||
*/
|
||||
void insert(T* elem, int pos = -1);
|
||||
|
||||
/**
|
||||
* Finds an element by name
|
||||
* @param [in] name
|
||||
* @return pointer to the element or NULL
|
||||
*/
|
||||
T* find(const std::string& name);
|
||||
|
||||
/**
|
||||
* Finds an element by name
|
||||
* @param [in] name
|
||||
* @return iterator to the element or end()
|
||||
*/
|
||||
iterator findIt(const std::string& name);
|
||||
|
||||
/**
|
||||
* Finds an element by name
|
||||
* @param [in] name
|
||||
* @return pointer to the element or NULL
|
||||
*/
|
||||
const T* find(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Copies the pointers from the other container.
|
||||
* @param [in] other Thge other container
|
||||
* @return void
|
||||
*/
|
||||
void copyFromRef(DDLContainerNoClone &other);
|
||||
|
||||
/**
|
||||
* Deletes all stored items (by calling delete on the pointers)
|
||||
*/
|
||||
void deleteAll();
|
||||
|
||||
/**
|
||||
* sort the items by name.
|
||||
*/
|
||||
void sort();
|
||||
|
||||
/**
|
||||
* Returns Whether or not the container is sorted by name or not.
|
||||
* @return whether or not the container is sorted by name or not.
|
||||
*/
|
||||
bool isSorted() const;
|
||||
|
||||
/**
|
||||
* Returns an iterator to the first element.
|
||||
* @return an iterator to the first element.
|
||||
*/
|
||||
iterator begin();
|
||||
|
||||
/**
|
||||
* Returns an iterator to the first element.
|
||||
* @return an iterator to the first element.
|
||||
*/
|
||||
const_iterator begin() const;
|
||||
|
||||
/**
|
||||
* Returns an iterator to the element after the last element.
|
||||
* @return an iterator to the element after the last element.
|
||||
*/
|
||||
iterator end();
|
||||
|
||||
/**
|
||||
* Returns an iterator to the element after the last element.
|
||||
* @return an iterator to the element after the last element.
|
||||
*/
|
||||
const_iterator end() const;
|
||||
|
||||
/**
|
||||
* clears the container (does not destroy the elements)
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* removes an element from the container
|
||||
* @param [in] pos The element which should be removed.
|
||||
* @return iterator to the element after the erased element.
|
||||
*/
|
||||
iterator erase(iterator pos);
|
||||
|
||||
/**
|
||||
* @brief removes a sequence of elements from the container
|
||||
* @param pos_first the first element to erase.
|
||||
* @param pos_last the first one that should not be erased.
|
||||
* @return iterator to the element after the erased elements.
|
||||
*/
|
||||
iterator erase(iterator pos_first, iterator pos_last);
|
||||
|
||||
/**
|
||||
* Returns whether the container is empty or not.
|
||||
* @return whether the container is empty or not.
|
||||
*/
|
||||
bool empty() const;
|
||||
|
||||
/**
|
||||
* Returns the size of the container.
|
||||
* @return the size of the container.
|
||||
*/
|
||||
unsigned int size() const; // for compatibility reasons
|
||||
|
||||
/**
|
||||
* random access operator.
|
||||
* @param [in] pos The index of the element.
|
||||
* @return The element.
|
||||
*/
|
||||
T*& operator[] (unsigned int pos);
|
||||
|
||||
/**
|
||||
* random access operator.
|
||||
* @param [in] pos The index of the element.
|
||||
* @return The element.
|
||||
*/
|
||||
T* const& operator[] (unsigned int pos) const;
|
||||
|
||||
/**
|
||||
* random access method.
|
||||
* @param [in] pos The index of the element.
|
||||
* @return The element.
|
||||
*/
|
||||
T*& at(unsigned int pos);
|
||||
|
||||
/**
|
||||
* random access method.
|
||||
* @param [in] pos The index of the element.
|
||||
* @return The element.
|
||||
*/
|
||||
T* const& at(unsigned int pos) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Finds an sorted element by name
|
||||
* @param [in] name
|
||||
* @return pointer to the element or NULL
|
||||
*/
|
||||
T* find_sorted(const std::string& name);
|
||||
|
||||
/**
|
||||
* Finds an sorted element by name
|
||||
* @param [in] name
|
||||
* @return pointer to the element or NULL
|
||||
*/
|
||||
const T* find_sorted(const std::string& name) const;
|
||||
|
||||
|
||||
/**
|
||||
* Finds an unsorted element by name
|
||||
* @param [in] name
|
||||
* @return pointer to the element or NULL
|
||||
*/
|
||||
T* find_unsorted(const std::string& name);
|
||||
|
||||
/**
|
||||
* Finds an unsorted element by name
|
||||
* @param [in] name
|
||||
* @return pointer to the element or NULL
|
||||
*/
|
||||
const T* find_unsorted(const std::string& name) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility class to store DDL elements that can be cloned.
|
||||
*/
|
||||
template <typename T>
|
||||
class DDLContainer: public DDLContainerNoClone<T>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param [in] sorted Whether the container shall be sorted by name or not.
|
||||
*/
|
||||
DDLContainer(bool sorted = true);
|
||||
|
||||
/**
|
||||
* Clones all elements of a given container.
|
||||
* @param [in] other the container that should be cloned.
|
||||
* @return void
|
||||
*/
|
||||
void cloneFrom(const DDLContainer& other);
|
||||
};
|
||||
|
||||
/**
|
||||
* Container type of basic DDL objects
|
||||
*/
|
||||
typedef DDLContainerNoClone<IDDL> DDLVec;
|
||||
|
||||
/**
|
||||
* Container type of DDLUnit objects
|
||||
*/
|
||||
typedef DDLContainer<DDLUnit> DDLUnitVec;
|
||||
/**
|
||||
* Container type of DDLBaseunit objects
|
||||
*/
|
||||
typedef DDLContainer<DDLBaseunit> DDLBaseunitVec;
|
||||
/**
|
||||
* Container type of DDLPrefix objects
|
||||
*/
|
||||
typedef DDLContainer<DDLPrefix> DDLPrefixVec;
|
||||
/**
|
||||
* Container type of DDLDataType objects
|
||||
*/
|
||||
typedef DDLContainer<DDLDataType> DDLDTVec;
|
||||
/**
|
||||
* Container type of DDLEnum objects
|
||||
*/
|
||||
typedef DDLContainer<DDLEnum> DDLEnumVec;
|
||||
/**
|
||||
* Container type of DDLComplex objects
|
||||
*/
|
||||
typedef DDLContainer<DDLComplex> DDLComplexVec;
|
||||
/**
|
||||
* Container type of DDLStream objects
|
||||
*/
|
||||
typedef DDLContainer<DDLStream> DDLStreamVec;
|
||||
/**
|
||||
* Container type of DDLStreamMetaType objects
|
||||
*/
|
||||
typedef DDLContainer<DDLStreamMetaType> DDLStreamMetaTypeVec;
|
||||
|
||||
/**
|
||||
* Iterator type for DDLUnitVec
|
||||
*/
|
||||
typedef DDLUnitVec::iterator DDLUnitIt;
|
||||
/**
|
||||
* Iterator type for DDLBaseunitVec
|
||||
*/
|
||||
typedef DDLBaseunitVec::iterator DDLBaseunitIt;
|
||||
/**
|
||||
* Iterator type for DDLPrefixVec
|
||||
*/
|
||||
typedef DDLPrefixVec::iterator DDLPrefixIt;
|
||||
/**
|
||||
* Iterator type for DDLDTVec
|
||||
*/
|
||||
typedef DDLDTVec::iterator DDLDTIt;
|
||||
/**
|
||||
* Iterator type for tDDLConstVec
|
||||
*/
|
||||
typedef DDLEnumVec::iterator DDLEnumIt;
|
||||
/**
|
||||
* Iterator type for DDLComplexVec
|
||||
*/
|
||||
typedef DDLComplexVec::iterator DDLComplexIt;
|
||||
/**
|
||||
* Iterator type for DDLStreamVec
|
||||
*/
|
||||
typedef DDLStreamVec::iterator DDLStreamIt;
|
||||
|
||||
/**
|
||||
* Associative container type for DDLStream objects
|
||||
*/
|
||||
typedef std::map<std::string, DDLStream*> DDLStreamMap;
|
||||
|
||||
/**
|
||||
* Iterator type for DDLStreamMap
|
||||
*/
|
||||
typedef DDLStreamMap::iterator DDLStreamMapIt;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
300
ddlrepresentation/ddldatatype.cpp
Normal file
300
ddlrepresentation/ddldatatype.cpp
Normal file
|
@ -0,0 +1,300 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddldatatype.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
|
||||
DDLDataType::DDLDataType() :
|
||||
_language_version{DDLVersion::ddl_version_invalid},
|
||||
_name{},
|
||||
_num_bits{},
|
||||
_byte_size{},
|
||||
_aligned_size{},
|
||||
_unit{},
|
||||
_description{},
|
||||
_array_size{},
|
||||
_array_size_source{},
|
||||
_alignment{},
|
||||
_init_flag{},
|
||||
_level{1},
|
||||
_min_valid{},
|
||||
_min_val{},
|
||||
_max_valid{},
|
||||
_max_val{},
|
||||
_default_valid{},
|
||||
_default_val{}
|
||||
{
|
||||
}
|
||||
|
||||
DDLDataType::DDLDataType(const std::string& name,
|
||||
unsigned int const num_bits,
|
||||
IDDLUnit* unit,
|
||||
const std::string& description,
|
||||
DDLAlignment::AlignmentType const alignment,
|
||||
unsigned int const array_size,
|
||||
int const creation_level,
|
||||
const std::string& array_size_source,
|
||||
bool const min_valid,
|
||||
const std::string& min_value,
|
||||
bool const max_valid,
|
||||
const std::string& max_value) :
|
||||
_language_version(DDLVersion::ddl_version_invalid),
|
||||
_name(name),
|
||||
_num_bits(num_bits),
|
||||
_unit(unit),
|
||||
_description(description),
|
||||
_array_size(array_size),
|
||||
_array_size_source(array_size_source),
|
||||
_alignment(alignment),
|
||||
_init_flag(true),
|
||||
_level(creation_level),
|
||||
_min_valid(min_valid),
|
||||
_min_val(min_value),
|
||||
_max_valid(max_valid),
|
||||
_max_val(max_value)
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLDataType::accept(IDDLVisitor *visitor) const
|
||||
{
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLDataType::accept(IDDLChangeVisitor *visitor)
|
||||
{
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLDataType::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLDataType::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
bool DDLDataType::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
int DDLDataType::getCreationLevel() const
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLDataType::create(const std::string& name,
|
||||
unsigned int const num_bits,
|
||||
IDDLUnit* unit,
|
||||
const std::string& description,
|
||||
DDLAlignment::AlignmentType const alignment,
|
||||
unsigned int const array_size,
|
||||
int const creation_level,
|
||||
const std::string& array_size_source,
|
||||
bool const min_valid,
|
||||
const std::string& min_value,
|
||||
bool const max_valid,
|
||||
const std::string& max_value)
|
||||
{
|
||||
if (!unit) { return ERR_POINTER; }
|
||||
_name = name;
|
||||
_num_bits = num_bits;
|
||||
_unit = unit;
|
||||
_description = description;
|
||||
_array_size = array_size;
|
||||
_init_flag = true;
|
||||
_level = creation_level;
|
||||
_alignment = alignment;
|
||||
_array_size_source = array_size_source;
|
||||
_language_version = DDLVersion::ddl_version_invalid;
|
||||
_min_valid = min_valid;
|
||||
_min_val = min_value;
|
||||
_max_valid = max_valid;
|
||||
_max_val = max_value;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
unsigned int DDLDataType::getNumBits() const
|
||||
{
|
||||
return _num_bits;
|
||||
}
|
||||
|
||||
void DDLDataType::setNumBits(unsigned int const num_bits)
|
||||
{
|
||||
_num_bits = num_bits;
|
||||
}
|
||||
|
||||
void DDLDataType::setDescription(const std::string& description)
|
||||
{
|
||||
_description = description;
|
||||
}
|
||||
|
||||
std::string DDLDataType::getDescription() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
void DDLDataType::setArraysize(unsigned int const array_size)
|
||||
{
|
||||
if (array_size > 0)
|
||||
{
|
||||
_array_size = array_size;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int DDLDataType::getArraysize() const
|
||||
{
|
||||
return _array_size;
|
||||
}
|
||||
|
||||
void DDLDataType::setUnit(IDDLUnit* unit)
|
||||
{
|
||||
_unit = unit;
|
||||
}
|
||||
|
||||
std::string DDLDataType::getUnit() const
|
||||
{
|
||||
if (NULL == _unit)
|
||||
{
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return _unit->getName();
|
||||
}
|
||||
|
||||
const IDDLUnit* DDLDataType::getUnitObject() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _unit;
|
||||
}
|
||||
|
||||
IDDLUnit* DDLDataType::getUnitObject()
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _unit;
|
||||
}
|
||||
|
||||
bool DDLDataType::isPredefined() const
|
||||
{
|
||||
return _level == -1; // cMediaManager::DL_AlwaysThere
|
||||
}
|
||||
|
||||
bool DDLDataType::isOverwriteable() const
|
||||
{
|
||||
return _level > 0;
|
||||
}
|
||||
|
||||
void DDLDataType::setAlignment(DDLAlignment::AlignmentType const alignment)
|
||||
{
|
||||
_alignment = alignment;
|
||||
}
|
||||
|
||||
DDLAlignment::AlignmentType DDLDataType::getAlignment() const
|
||||
{
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
std::string DDLDataType::getArraySizeSource() const
|
||||
{
|
||||
return _array_size_source;
|
||||
}
|
||||
|
||||
void DDLDataType::setArraySizeSource( const std::string& array_size_source )
|
||||
{
|
||||
_array_size_source = array_size_source;
|
||||
}
|
||||
|
||||
bool DDLDataType::isDynamic() const
|
||||
{
|
||||
if (getArraysize() == 0 ||
|
||||
(!getArraySizeSource().empty() && !a_util::strings::isInt64(getArraySizeSource())))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DDLVersion DDLDataType::getDDLVersion() const
|
||||
{
|
||||
return _language_version;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLDataType::setDDLVersion(DDLVersion& language_version)
|
||||
{
|
||||
_language_version = language_version;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
const std::string & DDLDataType::getMinValue () const
|
||||
{
|
||||
return _min_val;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLDataType::setMinValue (const std::string& min_value)
|
||||
{
|
||||
// TODO validate new min value
|
||||
_min_val = min_value;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
const std::string & DDLDataType::getMaxValue () const
|
||||
{
|
||||
return _max_val;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLDataType::setMaxValue (const std::string& max_value)
|
||||
{
|
||||
// TODO validate new max value
|
||||
_max_val = max_value;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
void DDLDataType::setMinValidity (bool const min_valid)
|
||||
{
|
||||
_min_valid = min_valid;
|
||||
}
|
||||
|
||||
bool DDLDataType::isMinValid () const
|
||||
{
|
||||
return _min_valid;
|
||||
}
|
||||
|
||||
void DDLDataType::setMaxValidity (bool const max_valid)
|
||||
{
|
||||
_max_valid = max_valid;
|
||||
}
|
||||
|
||||
bool DDLDataType::isMaxValid () const
|
||||
{
|
||||
return _max_valid;
|
||||
}
|
||||
|
||||
} // namespace ddl
|
330
ddlrepresentation/ddldatatype.h
Normal file
330
ddlrepresentation/ddldatatype.h
Normal file
|
@ -0,0 +1,330 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLDATATYPE_H_INCLUDED
|
||||
#define DDLDATATYPE_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddldatatype_intf.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddlunit_intf.h"
|
||||
#include "ddlalignment.h"
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
/**
|
||||
* Representation for a (simple) data type inside a DDL description.
|
||||
*/
|
||||
class DDLDataType : public IDDLDataType
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLDataType();
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] name - Name of the primitive data type
|
||||
* @param[in] size - Size in bit
|
||||
* @param[in] unit - Pointer to the unit of the data type (optional)
|
||||
* @param[in] description - Description of the primitive data type (optional)
|
||||
* @param[in] alignment - Alignment of the primitive data type (optional)
|
||||
* @param[in] array_size - Array size of the primitive data type (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
* @param[in] array_size_source - Name of the element that represents
|
||||
* the arrays size (optional)
|
||||
* @param [in] min_valid - Validity flag for the minimum value (optional)
|
||||
* @param[in] min_val - Minimum value of the data type (optional)
|
||||
* @param [in] max_valid - Validity flag for the maximum value (optional)
|
||||
* @param[in] max_val - Maximum value of the data type (optional)
|
||||
*/
|
||||
DDLDataType(const std::string& name,
|
||||
unsigned int const size,
|
||||
IDDLUnit* unit = NULL,
|
||||
const std::string& description = a_util::strings::empty_string,
|
||||
DDLAlignment::AlignmentType const alignment = DDLAlignment::e1,
|
||||
unsigned int const array_size = 1,
|
||||
int const creation_level = 1,
|
||||
const std::string& array_size_source = a_util::strings::empty_string,
|
||||
bool const min_valid = false,
|
||||
const std::string& min_val = a_util::strings::empty_string,
|
||||
bool const max_valid = false,
|
||||
const std::string& max_val = a_util::strings::empty_string);
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isPredefined() const;
|
||||
bool isOverwriteable() const;
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the name of the data type.
|
||||
* @param [in] name Name of the data type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
int getCreationLevel() const;
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] name - Name of the primitive data type
|
||||
* @param[in] size - Size in bit
|
||||
* @param[in] unit - Pointer to the unit of the data type
|
||||
* @param[in] description - Description of the primitive data type (optional)
|
||||
* @param[in] alignment - Alignment of the primitive data type (optional)
|
||||
* @param[in] array_size - Array size of the primitive data type (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
* @param[in] array_size_source - Name of the element that represents the arrays size
|
||||
* @param [in] min_valid - Validity flag for the minimum value (optional)
|
||||
* @param[in] min_val - Minimum value of the data type (optional)
|
||||
* @param [in] max_valid - Validity flag for the maximum value (optional)
|
||||
* @param[in] max_val - Maximum value of the data type (optional)
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
*/
|
||||
a_util::result::Result create(const std::string& name,
|
||||
unsigned int const size,
|
||||
IDDLUnit* unit = NULL,
|
||||
const std::string& description = a_util::strings::empty_string,
|
||||
DDLAlignment::AlignmentType const alignment = DDLAlignment::e1,
|
||||
unsigned int const array_size = 1,
|
||||
int const creation_level = 1,
|
||||
const std::string& array_size_source = a_util::strings::empty_string,
|
||||
bool const min_valid = false,
|
||||
const std::string& min_val = a_util::strings::empty_string,
|
||||
bool const max_valid = false,
|
||||
const std::string& max_val = a_util::strings::empty_string);
|
||||
|
||||
|
||||
/**
|
||||
* Setter for the description.
|
||||
* @param[in] description - Description of the primitive data type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setDescription(const std::string& description);
|
||||
|
||||
/**
|
||||
* Getter for the description.
|
||||
* @return the description
|
||||
*/
|
||||
std::string getDescription() const;
|
||||
|
||||
/**
|
||||
* Setter for the array size.
|
||||
* @param[in] array_size - Array size of the data type<br>
|
||||
* = 1 -> primitve presentation<br>\> 1 -> array with the amount of elements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setArraysize(unsigned int const array_size);
|
||||
|
||||
/**
|
||||
* Getter for the array size.
|
||||
* @return the array size
|
||||
*/
|
||||
unsigned int getArraysize() const;
|
||||
|
||||
/**
|
||||
* Setter for the unit.
|
||||
* @param[in] unit - Pointer to the unit object of the data type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setUnit(IDDLUnit* unit);
|
||||
|
||||
/**
|
||||
* Getter for the unit name.
|
||||
* @return name of the referenced unit (\c a_util::strings::empty_string if there is none)
|
||||
*/
|
||||
std::string getUnit() const;
|
||||
|
||||
/**
|
||||
* Getter for the unit object.
|
||||
* @return pointer to the unit object (\c NULL if there is none)
|
||||
*/
|
||||
const IDDLUnit * getUnitObject() const;
|
||||
|
||||
/**
|
||||
* Getter for the unit object.
|
||||
* @return pointer to the unit object (\c NULL if there is none)
|
||||
*/
|
||||
IDDLUnit * getUnitObject();
|
||||
|
||||
/**
|
||||
* Setter for the alignment.
|
||||
* @param[in] alignment - Alignment value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setAlignment(DDLAlignment::AlignmentType const alignment);
|
||||
|
||||
/**
|
||||
* Getter for the alignment of the primitive data type.
|
||||
* @return the alignment
|
||||
*/
|
||||
DDLAlignment::AlignmentType getAlignment() const;
|
||||
|
||||
/**
|
||||
* Getter for the size of the primitive data type.
|
||||
* @return the size in [bit]
|
||||
*/
|
||||
unsigned int getNumBits() const;
|
||||
|
||||
/**
|
||||
* Setter for the size of the primitive data type.
|
||||
* @param [in] num_bits - Size in [bit]
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setNumBits(unsigned int const num_bits);
|
||||
|
||||
/**
|
||||
* Getter for the array size source.
|
||||
* @return the array size source
|
||||
*/
|
||||
std::string getArraySizeSource() const;
|
||||
|
||||
/**
|
||||
* Setter for the array size source.
|
||||
* @param[in] array_size_source - the array size source element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setArraySizeSource(const std::string& array_size_source);
|
||||
|
||||
/**
|
||||
* Checks if element is dynamic
|
||||
* @return true if it is a dynamic array
|
||||
*/
|
||||
bool isDynamic() const;
|
||||
|
||||
/**
|
||||
* Getter for the DDL version.
|
||||
* @return the DDL version
|
||||
*/
|
||||
DDLVersion getDDLVersion() const;
|
||||
|
||||
/**
|
||||
* Setter for the DDL version.
|
||||
* @param language_version the DDL version to set
|
||||
* @return Standard result code.
|
||||
* @retval a_util::result::SUCCESS Everything is fine.
|
||||
*/
|
||||
a_util::result::Result setDDLVersion(DDLVersion& language_version);
|
||||
|
||||
/**
|
||||
* Setter for the validity flag for the minimum value.
|
||||
*
|
||||
* @param [in] min_valid Validity flag for the minimum value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setMinValidity (bool const min_valid);
|
||||
|
||||
/**
|
||||
* Getter for the validity flag for the minimum value.
|
||||
*
|
||||
* @return the validity flag for the minimum value
|
||||
*/
|
||||
bool isMinValid () const;
|
||||
|
||||
/**
|
||||
* Getter for the minimum value of the data type.
|
||||
*
|
||||
* @return the minimum value
|
||||
*/
|
||||
const std::string &getMinValue () const;
|
||||
|
||||
/**
|
||||
* Setter for the minimum value of the data type.
|
||||
*
|
||||
* @param [in] min_val The new minimum value
|
||||
*
|
||||
* @retval a_util::result::SUCCESS Everything went fine.
|
||||
*/
|
||||
a_util::result::Result setMinValue (const std::string& min_val);
|
||||
|
||||
/**
|
||||
* Setter for the validity flag for the maximum value.
|
||||
*
|
||||
* @param [in] max_valid Validity flag for the maximum value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setMaxValidity (bool const max_valid);
|
||||
|
||||
/**
|
||||
* Getter for the validity flag for the maximum value.
|
||||
*
|
||||
* @return the validity flag for the maximum value
|
||||
*/
|
||||
bool isMaxValid () const;
|
||||
|
||||
/**
|
||||
* Getter for the maximum value of the data type.
|
||||
*
|
||||
* @return the maximum value
|
||||
*/
|
||||
const std::string &getMaxValue () const;
|
||||
|
||||
/**
|
||||
* Setter for the maximum value of the data type.
|
||||
*
|
||||
* @param [in] max_val The new maximum value
|
||||
*
|
||||
* @retval a_util::result::SUCCESS Everything went fine.
|
||||
*/
|
||||
a_util::result::Result setMaxValue (const std::string& max_val);
|
||||
|
||||
|
||||
private: // members
|
||||
/// The DDL Version this structure was created in
|
||||
DDLVersion _language_version;
|
||||
std::string _name;
|
||||
unsigned int _num_bits;
|
||||
size_t _byte_size;
|
||||
size_t _aligned_size;
|
||||
IDDLUnit* _unit;
|
||||
std::string _description;
|
||||
unsigned int _array_size;
|
||||
std::string _array_size_source;
|
||||
DDLAlignment::AlignmentType _alignment;
|
||||
|
||||
bool _init_flag;
|
||||
int _level;
|
||||
|
||||
bool _min_valid;
|
||||
std::string _min_val;
|
||||
bool _max_valid;
|
||||
std::string _max_val;
|
||||
bool _default_valid;
|
||||
std::string _default_val;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDLDATATYPE_H_INCLUDED
|
45
ddlrepresentation/ddldatatype_intf.h
Normal file
45
ddlrepresentation/ddldatatype_intf.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLDATATYPE_INTF_H_INCLUDED
|
||||
#define DDLDATATYPE_INTF_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
class DDLAlignment;
|
||||
|
||||
/**
|
||||
* Common interface for DDL datatypes.
|
||||
*/
|
||||
class IDDLDataType : public IDDL
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Virtual DTOR
|
||||
*/
|
||||
virtual ~IDDLDataType(){}
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // _DATATYPE_INTF_H_INCLUDED_
|
1613
ddlrepresentation/ddldescription.cpp
Normal file
1613
ddlrepresentation/ddldescription.cpp
Normal file
File diff suppressed because it is too large
Load diff
1007
ddlrepresentation/ddldescription.h
Normal file
1007
ddlrepresentation/ddldescription.h
Normal file
File diff suppressed because it is too large
Load diff
475
ddlrepresentation/ddlelement.cpp
Normal file
475
ddlrepresentation/ddlelement.cpp
Normal file
|
@ -0,0 +1,475 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlelement.h"
|
||||
#include <ddl.h>
|
||||
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLElement::DDLElement(IDDLDataType* poType,
|
||||
const std::string& name,
|
||||
unsigned int const uiBytepos,
|
||||
unsigned int const uiArraysize,
|
||||
DDLByteorder::Byteorder const eByteorder,
|
||||
DDLAlignment::AlignmentType const eAlignment,
|
||||
IDDLUnit* poUnit,
|
||||
unsigned int const uiBitpos,
|
||||
unsigned int const uiNumBits,
|
||||
const std::string& strDescription,
|
||||
const std::string& strComment,
|
||||
const std::string& strArraySizeSource,
|
||||
const std::string& strValue,
|
||||
bool const bMinValid,
|
||||
const std::string& strMinValue,
|
||||
bool const bMaxValid,
|
||||
const std::string& strMaxValue,
|
||||
bool const bDefaultValid,
|
||||
const std::string& strDefaultValue,
|
||||
bool const bScaleValid,
|
||||
const std::string& strScaleValue,
|
||||
bool const bOffsetValid,
|
||||
const std::string& strOffsetValue) :
|
||||
_type(poType),
|
||||
_name(name),
|
||||
_bytes_pos(uiBytepos),
|
||||
_bit_pos(uiBitpos),
|
||||
_num_bits(uiNumBits),
|
||||
_description(strDescription),
|
||||
_array_size(uiArraysize),
|
||||
_array_size_source(strArraySizeSource),
|
||||
_constant_value(strValue),
|
||||
_unit(poUnit),
|
||||
_byteorder(eByteorder),
|
||||
_alignment(eAlignment),
|
||||
_comment(strComment),
|
||||
_init_flag(NULL != _type),
|
||||
_min_valid(bMinValid),
|
||||
_min_value(strMinValue),
|
||||
_max_valid(bMaxValid),
|
||||
_max_value(strMaxValue),
|
||||
_default_valid(bDefaultValid),
|
||||
_default_value(strDefaultValue),
|
||||
_scale_valid(bScaleValid),
|
||||
_scale_value(strScaleValue),
|
||||
_offset_valid(bOffsetValid),
|
||||
_offset_value(strOffsetValue)
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLElement::accept(IDDLVisitor *poVisitor) const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLElement::accept(IDDLChangeVisitor *poVisitor)
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLElement::create(IDDLDataType* poType,
|
||||
const std::string& name,
|
||||
unsigned int const uiBytepos,
|
||||
unsigned int const uiArraysize,
|
||||
DDLByteorder::Byteorder const eByteorder,
|
||||
DDLAlignment::AlignmentType const eAlignment,
|
||||
IDDLUnit* poUnit,
|
||||
unsigned int const uiBitpos,
|
||||
unsigned int const uiNumBits,
|
||||
const std::string& strDescription,
|
||||
const std::string& strComment,
|
||||
const std::string& strArraySizeSource,
|
||||
const std::string& strValue,
|
||||
bool const bMinValid,
|
||||
const std::string& strMinValue,
|
||||
bool const bMaxValid,
|
||||
const std::string& strMaxValue,
|
||||
bool const bDefaultValid,
|
||||
const std::string& strDefaultValue,
|
||||
bool const bScaleValid,
|
||||
const std::string& strScaleValue,
|
||||
bool const bOffsetValid,
|
||||
const std::string& strOffsetValue)
|
||||
{
|
||||
if (!poType) { return ERR_POINTER; }
|
||||
_type = poType;
|
||||
_name = name;
|
||||
_bytes_pos = uiBytepos;
|
||||
_array_size = uiArraysize;
|
||||
_byteorder = eByteorder;
|
||||
_alignment = eAlignment;
|
||||
_unit = poUnit;
|
||||
_bit_pos = uiBitpos;
|
||||
_num_bits = uiNumBits;
|
||||
_description = strDescription;
|
||||
_comment = strComment;
|
||||
_array_size_source = strArraySizeSource;
|
||||
_init_flag = true;
|
||||
_constant_value = strValue;
|
||||
_min_valid = bMinValid;
|
||||
_min_value = strMinValue;
|
||||
_max_valid = bMaxValid;
|
||||
_max_value = strMaxValue;
|
||||
_default_valid = bDefaultValid;
|
||||
_default_value = strDefaultValue;
|
||||
_scale_valid = bScaleValid;
|
||||
_scale_value = strScaleValue;
|
||||
_offset_valid = bOffsetValid;
|
||||
_offset_value = strOffsetValue;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
bool DDLElement::isPredefined() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int DDLElement::getCreationLevel() const
|
||||
{
|
||||
return 99; // cMediaManager::DL_Internal => error
|
||||
}
|
||||
|
||||
const std::string& DDLElement::getType() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return _type->getName();
|
||||
}
|
||||
|
||||
void DDLElement::setType(IDDLDataType* const pType)
|
||||
{
|
||||
_type = pType;
|
||||
_init_flag = (_type != NULL);
|
||||
}
|
||||
|
||||
|
||||
IDDLDataType * DDLElement::getTypeObject() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _type;
|
||||
}
|
||||
|
||||
const std::string& DDLElement::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLElement::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
unsigned int DDLElement::getBytepos() const
|
||||
{
|
||||
return _bytes_pos;
|
||||
}
|
||||
|
||||
void DDLElement::setBytepos(unsigned int const uiBytePos)
|
||||
{
|
||||
_bytes_pos = uiBytePos;
|
||||
}
|
||||
|
||||
unsigned int DDLElement::getArraysize() const
|
||||
{
|
||||
return _array_size;
|
||||
}
|
||||
|
||||
void DDLElement::setArraysize(unsigned int const uiArraySize )
|
||||
{
|
||||
_array_size = uiArraySize;
|
||||
}
|
||||
|
||||
|
||||
DDLByteorder::Byteorder DDLElement::getByteorder() const
|
||||
{
|
||||
return _byteorder;
|
||||
}
|
||||
|
||||
void DDLElement::setByteorder(DDLByteorder::Byteorder const eByteOrder)
|
||||
{
|
||||
_byteorder = eByteOrder;
|
||||
}
|
||||
|
||||
DDLAlignment::AlignmentType DDLElement::getAlignment() const
|
||||
{
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
void DDLElement::setAlignment(DDLAlignment::AlignmentType const eAlign)
|
||||
{
|
||||
_alignment = eAlign;
|
||||
}
|
||||
|
||||
void DDLElement::setBitpos(unsigned int const uiBitpos)
|
||||
{
|
||||
if (uiBitpos >= 0 && uiBitpos <= 7)
|
||||
{
|
||||
_bit_pos = uiBitpos;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int DDLElement::getBitpos() const
|
||||
{
|
||||
return _bit_pos;
|
||||
}
|
||||
|
||||
void DDLElement::setNumBits(unsigned int const uiNumBits)
|
||||
{
|
||||
_num_bits = uiNumBits;
|
||||
}
|
||||
|
||||
unsigned int DDLElement::getNumBits() const
|
||||
{
|
||||
return _num_bits;
|
||||
}
|
||||
|
||||
void DDLElement::setDescription(const std::string& strDescription)
|
||||
{
|
||||
_description = strDescription;
|
||||
}
|
||||
|
||||
const std::string& DDLElement::getDescription() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
void DDLElement::setUnit(IDDLUnit* poUnit)
|
||||
{
|
||||
_unit = poUnit;
|
||||
}
|
||||
|
||||
const std::string& DDLElement::getUnit() const
|
||||
{
|
||||
if (NULL == _unit)
|
||||
{
|
||||
// no unit reference defined
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return _unit->getName();
|
||||
}
|
||||
|
||||
IDDLUnit * DDLElement::getUnitObject() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _unit;
|
||||
}
|
||||
|
||||
void DDLElement::setComment(const std::string& strComment)
|
||||
{
|
||||
_comment = strComment;
|
||||
}
|
||||
|
||||
const std::string& DDLElement::getComment() const
|
||||
{
|
||||
return _comment;
|
||||
}
|
||||
|
||||
bool DDLElement::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
const std::string& DDLElement::getArraySizeSource() const
|
||||
{
|
||||
return _array_size_source;
|
||||
}
|
||||
|
||||
void DDLElement::setArraySizeSource( const std::string& strArraySizeSource )
|
||||
{
|
||||
_array_size_source = strArraySizeSource;
|
||||
}
|
||||
|
||||
const std::string& DDLElement::getConstantValue() const
|
||||
{
|
||||
return _constant_value;
|
||||
}
|
||||
|
||||
void DDLElement::setConstantValue( const std::string& strConstantValue )
|
||||
{
|
||||
_constant_value = strConstantValue;
|
||||
}
|
||||
|
||||
bool DDLElement::isDynamic() const
|
||||
{
|
||||
if (!getArraySizeSource().empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void DDLElement::setMinValidity (bool const bMinValid)
|
||||
{
|
||||
_min_valid = bMinValid;
|
||||
}
|
||||
|
||||
bool DDLElement::isMinValid () const
|
||||
{
|
||||
return _min_valid;
|
||||
}
|
||||
|
||||
const std::string & DDLElement::getMinValue () const
|
||||
{
|
||||
if (_min_valid)
|
||||
{
|
||||
return _min_value;
|
||||
}
|
||||
else if (_init_flag)
|
||||
{
|
||||
DDLDataType *poDT = dynamic_cast<DDLDataType*>(_type);
|
||||
if (NULL != poDT && poDT->isMinValid())
|
||||
{
|
||||
// inherit minimum value from primitive data type
|
||||
return poDT->getMinValue();
|
||||
}
|
||||
}
|
||||
// no type information available or complex type or no min value valid
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLElement::setMinValue (const std::string& strMinVal)
|
||||
{
|
||||
// TODO validate new minimum value
|
||||
_min_value = strMinVal;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
void DDLElement::setMaxValidity (bool const bMaxValid)
|
||||
{
|
||||
_max_valid = bMaxValid;
|
||||
}
|
||||
|
||||
bool DDLElement::isMaxValid () const
|
||||
{
|
||||
return _max_valid;
|
||||
}
|
||||
|
||||
const std::string & DDLElement::getMaxValue () const
|
||||
{
|
||||
if (_max_valid)
|
||||
{
|
||||
return _max_value;
|
||||
}
|
||||
else if (_init_flag)
|
||||
{
|
||||
DDLDataType *poDT = dynamic_cast<DDLDataType*>(_type);
|
||||
if (NULL != poDT && poDT->isMaxValid())
|
||||
{
|
||||
// inherit maximum value from primitive type
|
||||
return poDT->getMaxValue();
|
||||
}
|
||||
}
|
||||
// no type information available or complex type or no min value valid
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLElement::setMaxValue (const std::string& strMaxVal)
|
||||
{
|
||||
// TODO validate new maximum value
|
||||
_max_value = strMaxVal;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
void DDLElement::setDefaultValidity (bool const bDefaultValid)
|
||||
{
|
||||
_default_valid = bDefaultValid;
|
||||
}
|
||||
|
||||
bool DDLElement::isDefaultValid () const
|
||||
{
|
||||
return _default_valid;
|
||||
}
|
||||
|
||||
const std::string & DDLElement::getDefaultValue () const
|
||||
{
|
||||
return _default_value;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLElement::setDefaultValue (const std::string& strDefaultVal)
|
||||
{
|
||||
// TODO validate new default value
|
||||
_default_value = strDefaultVal;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
void DDLElement::setScaleValidity (bool const bScaleValid)
|
||||
{
|
||||
_scale_valid = bScaleValid;
|
||||
}
|
||||
|
||||
bool DDLElement::isScaleValid () const
|
||||
{
|
||||
return _scale_valid;
|
||||
}
|
||||
|
||||
const std::string & DDLElement::getScaleValue () const
|
||||
{
|
||||
return _scale_value;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLElement::setScaleValue (const std::string& strScaleValue)
|
||||
{
|
||||
// TODO validate new scaling value
|
||||
_scale_value = strScaleValue;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
void DDLElement::setOffsetValidity (bool const bOffsetValid)
|
||||
{
|
||||
_offset_valid = bOffsetValid;
|
||||
}
|
||||
|
||||
bool DDLElement::isOffsetValid () const
|
||||
{
|
||||
return _offset_valid;
|
||||
}
|
||||
|
||||
const std::string & DDLElement::getOffsetValue () const
|
||||
{
|
||||
return _offset_value;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLElement::setOffsetValue (const std::string& strOffsetValue)
|
||||
{
|
||||
// TODO validate new offset value
|
||||
_offset_value = strOffsetValue;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
} // namespace ddl
|
572
ddlrepresentation/ddlelement.h
Normal file
572
ddlrepresentation/ddlelement.h
Normal file
|
@ -0,0 +1,572 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLELEMENT_H_INCLUDED
|
||||
#define DDLELEMENT_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddldatatype_intf.h"
|
||||
#include "ddlbyteorder.h"
|
||||
#include "ddlalignment.h"
|
||||
#include "ddlunit_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
/**
|
||||
* Representation of an element inside a struct in DDL a description.
|
||||
*/
|
||||
class DDLElement
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLElement() = default;
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] type - Pointer to the data-type object
|
||||
* @param[in] name - Name of the created element
|
||||
* @param[in] byte_pos - Byte position of the referenced data type
|
||||
* @param[in] array_size - Array size of the element
|
||||
* @param[in] byte_order - Byte order of the related data type
|
||||
* @param[in] alignment - Alignment of the related data type
|
||||
* @param[in] unit - Pointer to unit object
|
||||
* @param[in] bit_pos - Bit position of the referenced data type (optional)
|
||||
* @param[in] num_bits - The amount of bits used for the representation (optional)
|
||||
* @param[in] description - Description of the created data type (optional)
|
||||
* @param[in] comment - Additional comments (optional)
|
||||
* @param[in] array_size_source - The name of the source element for the size of a dynamic array (optional)
|
||||
* @param[in] value - The value of a constant element (optional)
|
||||
* @param[in] min_valid - Validity flag for the minimum value (optional)
|
||||
* @param[in] min_value - Minimum value of the element (optional)
|
||||
* @param[in] max_valid - Validity flag for the maximum value (optional)
|
||||
* @param[in] max_value - Maximum value of the element (optional)
|
||||
* @param[in] default_valid - Validity flag for the default value (optional)
|
||||
* @param[in] default_value - Default value of the element (optional)
|
||||
* @param[in] scale_valid - Validity flag for the scaling value (optional)
|
||||
* @param[in] scale_value - Scaling value of the element (optional)
|
||||
* @param[in] offset_valid - Validity flag for the offset value (optional)
|
||||
* @param[in] offset_value - Offset value of the element (optional)
|
||||
*/
|
||||
DDLElement(IDDLDataType* type,
|
||||
const std::string& name,
|
||||
unsigned int const byte_pos,
|
||||
unsigned int const array_size,
|
||||
DDLByteorder::Byteorder const byte_order,
|
||||
DDLAlignment::AlignmentType const alignment,
|
||||
IDDLUnit* unit = NULL,
|
||||
unsigned int const bit_pos = 0,
|
||||
unsigned int const num_bits = 0,
|
||||
const std::string& description = a_util::strings::empty_string,
|
||||
const std::string& comment = a_util::strings::empty_string,
|
||||
const std::string& array_size_source = a_util::strings::empty_string,
|
||||
const std::string& value = a_util::strings::empty_string,
|
||||
bool const min_valid = false,
|
||||
const std::string& min_value = a_util::strings::empty_string,
|
||||
bool const max_valid = false,
|
||||
const std::string& max_value = a_util::strings::empty_string,
|
||||
bool const default_valid = false,
|
||||
const std::string& default_value = a_util::strings::empty_string,
|
||||
bool const scale_valid = false,
|
||||
const std::string& scale_value = a_util::strings::empty_string,
|
||||
bool const offset_valid = false,
|
||||
const std::string& offset_value = a_util::strings::empty_string);
|
||||
|
||||
/**
|
||||
* @copydoc IDDL::accept()
|
||||
*/
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
/**
|
||||
* @copydoc IDDL::isInitialized()
|
||||
*/
|
||||
bool isInitialized() const;
|
||||
|
||||
/* a_util::result::Result Serialize(void const *pvDeSerData,
|
||||
size_t const &szSizeDeSerInByte,
|
||||
size_t const &szAlignedOffsetInByte,
|
||||
void *pvSerData,
|
||||
size_t const &szSizeSerInByte,
|
||||
size_t const &szOffsetInBit);
|
||||
|
||||
a_util::result::Result Deserialize(void *pvDeSerData,
|
||||
size_t const &szSizeDeSerInByte,
|
||||
size_t const &szAlignedOffsetInByte,
|
||||
void const *pvSerData,
|
||||
size_t const &szSizeSerInByte,
|
||||
size_t const &szOffsetInBit);
|
||||
|
||||
size_t getSize() const;*/
|
||||
|
||||
/**
|
||||
* @copydoc IDDL::isPredefined()
|
||||
*/
|
||||
bool isPredefined() const;
|
||||
|
||||
/**
|
||||
* @copydoc IDDL::getCreationLevel()
|
||||
*/
|
||||
int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the obejct with data.
|
||||
* @param[in] type - Pointer to the datatype object
|
||||
* @param[in] name - Name of the created element
|
||||
* @param[in] byte_pos - Byte position of the referenced data type
|
||||
* @param[in] array_size - Arraysize of the element
|
||||
* @param[in] byte_order - Byteorder of the related data type
|
||||
* @param[in] alignment - Alignment of the related data type
|
||||
* @param[in] unit - Pointer to unit object
|
||||
* @param[in] bit_pos - Bit position of the referenced data type (optional)
|
||||
* @param[in] num_bits - The amount of bits used for the representation (optional)
|
||||
* @param[in] description - Description of the created data type (optional)
|
||||
* @param[in] comment - Additional comments (optional)
|
||||
* @param[in] array_size_source - The name of the source element for the size of a dynamic array
|
||||
* @param[in] value - The value of a constant element (optional)
|
||||
* @param[in] min_valid - Validity flag for the minimum value (optional)
|
||||
* @param[in] min_value - Minimum value of the element (optional)
|
||||
* @param[in] max_valid - Validity flag for the maximum value (optional)
|
||||
* @param[in] max_value - Maximum value of the element (optional)
|
||||
* @param[in] default_valid - Validity flag for the default value (optional)
|
||||
* @param[in] default_value - Default value of the element (optional)
|
||||
* @param[in] scale_valid - Validity flag for the scaling value (optional)
|
||||
* @param[in] scale_value - Scaling value of the element (optional)
|
||||
* @param[in] offset_valid - Validity flag for the offset value (optional)
|
||||
* @param[in] offset_value - Offset value of the element (optional)
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
*/
|
||||
a_util::result::Result create(IDDLDataType* type,
|
||||
const std::string& name,
|
||||
unsigned int const byte_pos,
|
||||
unsigned int const array_size,
|
||||
DDLByteorder::Byteorder const byte_order,
|
||||
DDLAlignment::AlignmentType const alignment,
|
||||
IDDLUnit* unit = NULL,
|
||||
unsigned int const bit_pos = 0,
|
||||
unsigned int const num_bits = 0,
|
||||
const std::string& description = a_util::strings::empty_string,
|
||||
const std::string& comment = a_util::strings::empty_string,
|
||||
const std::string& array_size_source = a_util::strings::empty_string,
|
||||
const std::string& value = a_util::strings::empty_string,
|
||||
bool const min_valid = false,
|
||||
const std::string& min_value = a_util::strings::empty_string,
|
||||
bool const max_valid = false,
|
||||
const std::string& max_value = a_util::strings::empty_string,
|
||||
bool const default_valid = false,
|
||||
const std::string& default_value = a_util::strings::empty_string,
|
||||
bool const scale_valid = false,
|
||||
const std::string& scale_value = a_util::strings::empty_string,
|
||||
bool const offset_valid = false,
|
||||
const std::string& offset_value = a_util::strings::empty_string);
|
||||
|
||||
/**
|
||||
* Getter for the data-type name.
|
||||
* @return name of the data type
|
||||
*/
|
||||
const std::string& getType() const;
|
||||
|
||||
/**
|
||||
* Setter for the type of the element.
|
||||
* @param [in] type Pointer to the type object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setType(IDDLDataType* const type);
|
||||
|
||||
/**
|
||||
* Getter for the data-type object.
|
||||
* @return pointer to the data-type object
|
||||
*/
|
||||
IDDLDataType * getTypeObject() const;
|
||||
|
||||
/**
|
||||
* Getter for the name.
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the name of the element.
|
||||
* @param [in] name Name of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
|
||||
/**
|
||||
* Getter for the b byte position.
|
||||
* @return the byte position
|
||||
*/
|
||||
unsigned int getBytepos() const;
|
||||
|
||||
/**
|
||||
* Setter for the byte position of the element.
|
||||
* @param [in] byte_pos Byte position of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setBytepos(unsigned int const byte_pos);
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the array size.
|
||||
* @return the array size
|
||||
*/
|
||||
unsigned int getArraysize() const;
|
||||
|
||||
/**
|
||||
* Setter for the array size of the element.
|
||||
* @param [in] array_size Array size of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setArraysize(unsigned int const array_size);
|
||||
|
||||
/**
|
||||
* Getter for the byteorder.
|
||||
* @return the byteorder
|
||||
*/
|
||||
DDLByteorder::Byteorder getByteorder() const;
|
||||
|
||||
/**
|
||||
* Setter for the byte order of the element.
|
||||
* @param [in] byte_order Byte order of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setByteorder(DDLByteorder::Byteorder const byte_order);
|
||||
|
||||
/**
|
||||
* Getter for the alignment.
|
||||
* @return the alignment
|
||||
*/
|
||||
DDLAlignment::AlignmentType getAlignment() const;
|
||||
|
||||
/**
|
||||
* Setter for the alignment of the element.
|
||||
* @param [in] alignment Alignment of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setAlignment(DDLAlignment::AlignmentType const alignment);
|
||||
|
||||
/**
|
||||
* Setter for the bit position.
|
||||
* @param[in] bit_pos - Bit position of the referenced data type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setBitpos(unsigned int const bit_pos);
|
||||
|
||||
/**
|
||||
* Getter for the bit position.
|
||||
* @return the bit position
|
||||
*/
|
||||
unsigned int getBitpos() const;
|
||||
|
||||
/**
|
||||
* Setter for the amount of bits.
|
||||
* @param[in] num_bits - Amount of bits used for the representation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setNumBits(unsigned int const num_bits);
|
||||
|
||||
/**
|
||||
* Getter for the amount of bits.
|
||||
* @return the amount of bits
|
||||
*/
|
||||
unsigned int getNumBits() const;
|
||||
|
||||
/**
|
||||
* Setter for the description.
|
||||
* @param[in] description - the description
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setDescription(const std::string& description);
|
||||
|
||||
/**
|
||||
* Getter for the description.
|
||||
* @return the description
|
||||
*/
|
||||
const std::string& getDescription() const;
|
||||
|
||||
/**
|
||||
* Setter for the unit reference.
|
||||
* @param[in] unit - Pointer to the unit object of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setUnit(IDDLUnit* unit);
|
||||
|
||||
/**
|
||||
* Getter for the unit name.
|
||||
* @return the unit name
|
||||
*/
|
||||
const std::string& getUnit() const;
|
||||
|
||||
/**
|
||||
* Getter for the unit object.
|
||||
* @return pointer to the unit object
|
||||
*/
|
||||
IDDLUnit * getUnitObject() const;
|
||||
|
||||
/**
|
||||
* Setter for the comment.
|
||||
* @param[in] comment - Additional comments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setComment(const std::string& comment);
|
||||
|
||||
/**
|
||||
* Getter for the comment.
|
||||
* @return the comment
|
||||
*/
|
||||
const std::string& getComment() const;
|
||||
|
||||
/**
|
||||
* Getter for the array size source.
|
||||
* @return the array size source
|
||||
*/
|
||||
const std::string& getArraySizeSource() const;
|
||||
|
||||
/**
|
||||
* Setter for the array size source.
|
||||
* @param[in] array_size_source - the array size source element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setArraySizeSource(const std::string& array_size_source);
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the value of a constant element.
|
||||
* @return the value of a constant element
|
||||
*/
|
||||
const std::string& getConstantValue() const;
|
||||
|
||||
/**
|
||||
* Setter value of a constant element.
|
||||
* @param[in] constant_value - constant value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setConstantValue(const std::string& constant_value);
|
||||
|
||||
/**
|
||||
* Checks if element is dynamic
|
||||
* @return true if it is a dynamic array
|
||||
*/
|
||||
bool isDynamic() const;
|
||||
|
||||
/**
|
||||
* Setter for the validity flag for the minimum value.
|
||||
*
|
||||
* @param [in] min_valid Validity flag for the minimum value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setMinValidity (bool const min_valid);
|
||||
|
||||
/**
|
||||
* Getter for the validity flag for the minimum value.
|
||||
*
|
||||
* @return the validity flag for the minimum value
|
||||
*/
|
||||
bool isMinValid () const;
|
||||
|
||||
/**
|
||||
* Getter for the minimum value of the data type.
|
||||
*
|
||||
* @return the minimum value
|
||||
*/
|
||||
const std::string& getMinValue() const;
|
||||
|
||||
/**
|
||||
* Setter for the minimum value of the data type.
|
||||
*
|
||||
* @param [in] min_value The new minimum value
|
||||
*
|
||||
* @retval a_util::result::SUCCESS Everything went fine.
|
||||
*/
|
||||
a_util::result::Result setMinValue (const std::string& min_value);
|
||||
|
||||
/**
|
||||
* Setter for the validity flag for the maximum value.
|
||||
*
|
||||
* @param [in] max_valid Validity flag for the maximum value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setMaxValidity (bool const max_valid);
|
||||
|
||||
/**
|
||||
* Getter for the validity flag for the maximum value.
|
||||
*
|
||||
* @return the validity flag for the maximum value
|
||||
*/
|
||||
bool isMaxValid () const;
|
||||
|
||||
/**
|
||||
* Getter for the maximum value of the data type.
|
||||
*
|
||||
* @return the maximum value
|
||||
*/
|
||||
const std::string& getMaxValue () const;
|
||||
|
||||
/**
|
||||
* Setter for the maximum value of the data type.
|
||||
*
|
||||
* @param [in] max_value The new maximum value
|
||||
*
|
||||
* @retval a_util::result::SUCCESS Everything went fine.
|
||||
*/
|
||||
a_util::result::Result setMaxValue (const std::string& max_value);
|
||||
|
||||
/**
|
||||
* Setter for the validity flag for the default value.
|
||||
*
|
||||
* @param [in] default_valid Validity flag for the default value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setDefaultValidity (bool const default_valid);
|
||||
|
||||
/**
|
||||
* Getter for the validity flag for the default value.
|
||||
*
|
||||
* @return the validity flag for the default value
|
||||
*/
|
||||
bool isDefaultValid () const;
|
||||
|
||||
/**
|
||||
* Getter for the default value.
|
||||
*
|
||||
* @return the default value
|
||||
*/
|
||||
const std::string& getDefaultValue () const;
|
||||
|
||||
/**
|
||||
* Setter for the default value.
|
||||
*
|
||||
* @param [in] default_value The new default value
|
||||
*
|
||||
* @retval a_util::result::SUCCESS Everything went fine.
|
||||
*/
|
||||
a_util::result::Result setDefaultValue (const std::string& default_value);
|
||||
|
||||
/**
|
||||
* Setter for the validity flag for the scaling value.
|
||||
*
|
||||
* @param [in] scale_valid Validity flag for the scaling value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setScaleValidity (bool const scale_valid);
|
||||
|
||||
/**
|
||||
* Getter for the validity flag for the scaling value.
|
||||
*
|
||||
* @return the validity flag for the scaling value.
|
||||
*/
|
||||
bool isScaleValid () const;
|
||||
|
||||
/**
|
||||
* Getter for the scaling value.
|
||||
*
|
||||
* @return the scaling value
|
||||
*/
|
||||
const std::string& getScaleValue () const;
|
||||
|
||||
/**
|
||||
* Setter for the scaling value.
|
||||
*
|
||||
* @param [in] scale_value The new scaling value
|
||||
*
|
||||
* @retval a_util::result::SUCCESS Everything went fine.
|
||||
*/
|
||||
a_util::result::Result setScaleValue (const std::string& scale_value);
|
||||
|
||||
/**
|
||||
* Setter for the validity flag for the offset value.
|
||||
*
|
||||
* @param [in] offset_valid Validity flag for the offset value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setOffsetValidity (bool const offset_valid);
|
||||
|
||||
/**
|
||||
* Getter for the validity flag for the offset value.
|
||||
*
|
||||
* @return the validity flag for the offset value.
|
||||
*/
|
||||
bool isOffsetValid () const;
|
||||
|
||||
/**
|
||||
* Getter for the offset value.
|
||||
*
|
||||
* @return the offset value.
|
||||
*/
|
||||
const std::string& getOffsetValue () const;
|
||||
|
||||
/**
|
||||
* Setter for the offset value.
|
||||
*
|
||||
* @param [in] offset_value The new offset value
|
||||
*
|
||||
* @retval a_util::result::SUCCESS Everything went fine.
|
||||
*/
|
||||
a_util::result::Result setOffsetValue (const std::string& offset_value);
|
||||
|
||||
private:
|
||||
IDDLDataType * _type;
|
||||
std::string _name;
|
||||
unsigned int _bytes_pos;
|
||||
unsigned int _bit_pos;
|
||||
unsigned int _num_bits;
|
||||
std::string _description;
|
||||
unsigned int _array_size;
|
||||
std::string _array_size_source;
|
||||
std::string _constant_value;
|
||||
IDDLUnit * _unit;
|
||||
DDLByteorder::Byteorder _byteorder;
|
||||
DDLAlignment::AlignmentType _alignment;
|
||||
std::string _comment;
|
||||
bool _init_flag;
|
||||
|
||||
bool _min_valid;
|
||||
std::string _min_value;
|
||||
bool _max_valid;
|
||||
std::string _max_value;
|
||||
bool _default_valid;
|
||||
std::string _default_value;
|
||||
bool _scale_valid;
|
||||
std::string _scale_value;
|
||||
bool _offset_valid;
|
||||
std::string _offset_value;
|
||||
};
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDLELEMENT_H_INCLUDED
|
230
ddlrepresentation/ddlenum.cpp
Normal file
230
ddlrepresentation/ddlenum.cpp
Normal file
|
@ -0,0 +1,230 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlenum.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-20, ERR_NOT_FOUND)
|
||||
|
||||
struct tEnumName
|
||||
{
|
||||
tEnumName(std::string const& strEnumName) : m_strEnumName(strEnumName) { }
|
||||
|
||||
bool operator () (std::pair<std::string, std::string> const& oPair)
|
||||
{
|
||||
return (oPair.first == m_strEnumName);
|
||||
}
|
||||
|
||||
std::string m_strEnumName;
|
||||
};
|
||||
|
||||
DDLEnum::DDLEnum() :
|
||||
_name{},
|
||||
_name_values{},
|
||||
_unit{},
|
||||
_type{},
|
||||
_init_flag{},
|
||||
_level{1}
|
||||
{
|
||||
}
|
||||
|
||||
DDLEnum::DDLEnum(IDDLDataType* poType,
|
||||
const std::string& name,
|
||||
const EnumNameValueVec& vecNameValues,
|
||||
IDDLUnit* poUnit /*= NULL*/,
|
||||
int nCreationLevel /*= 1 */ ) :
|
||||
_name(name),
|
||||
_name_values(vecNameValues),
|
||||
_unit(poUnit),
|
||||
_type(poType),
|
||||
_init_flag(true),
|
||||
_level(nCreationLevel)
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLEnum::accept(IDDLVisitor *poVisitor) const
|
||||
{
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
a_util::result::Result DDLEnum::accept(IDDLChangeVisitor *poVisitor)
|
||||
{
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLEnum::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLEnum::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
const EnumNameValueVec& DDLEnum::getValues() const
|
||||
{
|
||||
return _name_values;
|
||||
}
|
||||
|
||||
void DDLEnum::setValues(const EnumNameValueVec& vecNameValues)
|
||||
{
|
||||
_name_values = vecNameValues;
|
||||
}
|
||||
|
||||
const std::string& DDLEnum::getType() const
|
||||
{
|
||||
if (_type != NULL)
|
||||
{
|
||||
return _type->getName();
|
||||
}
|
||||
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
|
||||
void DDLEnum::setType( IDDLDataType* const pType )
|
||||
{
|
||||
_type = pType;
|
||||
}
|
||||
|
||||
IDDLDataType * DDLEnum::getTypeObject() const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
bool DDLEnum::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
int DDLEnum::getCreationLevel() const
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
|
||||
a_util::result::Result DDLEnum::create(IDDLDataType* poType,
|
||||
const std::string& name,
|
||||
const EnumNameValueVec& vecNameValues,
|
||||
IDDLUnit* poUnit /*= NULL*/,
|
||||
int nCreationLevel /*= 1*/ )
|
||||
{
|
||||
if (!poUnit || !poType) { return ERR_POINTER; }
|
||||
_name = name;
|
||||
_unit = poUnit;
|
||||
_init_flag = true;
|
||||
_level = nCreationLevel;
|
||||
_name_values = vecNameValues;
|
||||
_type = poType;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
void DDLEnum::setUnit(IDDLUnit* poUnit)
|
||||
{
|
||||
_unit = poUnit;
|
||||
}
|
||||
|
||||
std::string DDLEnum::getUnit() const
|
||||
{
|
||||
if (NULL == _unit)
|
||||
{
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return _unit->getName();
|
||||
}
|
||||
|
||||
IDDLUnit * DDLEnum::getUnitObject() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _unit;
|
||||
}
|
||||
|
||||
bool DDLEnum::isPredefined() const
|
||||
{
|
||||
return _level == -1; // cMediaManager::DL_AlwaysThere
|
||||
}
|
||||
|
||||
bool DDLEnum::isOverwriteable() const
|
||||
{
|
||||
return _level > 0;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLEnum::removeElement(const std::string& strElement)
|
||||
{
|
||||
EnumNameValueVec::iterator itNameVal =
|
||||
find_if(_name_values.begin(), _name_values.end(), tEnumName(strElement));
|
||||
if (itNameVal != _name_values.end())
|
||||
{
|
||||
_name_values.erase(itNameVal);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLEnum::getValue(const std::string& strElement, std::string& strValue) const
|
||||
{
|
||||
EnumNameValueVec::const_iterator itNameVal =
|
||||
find_if(_name_values.begin(), _name_values.end(), tEnumName(strElement));
|
||||
|
||||
if (itNameVal != _name_values.end())
|
||||
{
|
||||
strValue = itNameVal->second;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLEnum::setValue(const std::string& strElement, const std::string& strValue)
|
||||
{
|
||||
EnumNameValueVec::iterator itNameVal =
|
||||
find_if(_name_values.begin(), _name_values.end(), tEnumName(strElement));
|
||||
|
||||
if (itNameVal != _name_values.end())
|
||||
{
|
||||
itNameVal->second = strValue;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLEnum::getNameForValue(const std::string& strValue, std::string& strElement)
|
||||
{
|
||||
for (EnumNameValueVec::iterator itNameVal = _name_values.begin();
|
||||
itNameVal != _name_values.end();
|
||||
++itNameVal)
|
||||
{
|
||||
if (itNameVal->second == strValue)
|
||||
{
|
||||
strElement = itNameVal->first;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
}
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
} // namespace ddl
|
206
ddlrepresentation/ddlenum.h
Normal file
206
ddlrepresentation/ddlenum.h
Normal file
|
@ -0,0 +1,206 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLCONSTANT_H_INCLUDED
|
||||
#define DDLCONSTANT_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddldatatype_intf.h"
|
||||
#include "ddlunit_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Container type of DDL enum elements
|
||||
*/
|
||||
typedef std::vector<std::pair<std::string, std::string> > EnumNameValueVec;
|
||||
/**
|
||||
* Representation for an enum inside a DDL description.
|
||||
*/
|
||||
class DDLEnum : public IDDLDataType
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLEnum();
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] type - Pointer to the data-type object
|
||||
* @param[in] name - Name of the created enum
|
||||
* @param[in] name_values - Values of the enum
|
||||
* @param[in] unit - Pointer to the unit of the datatype (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
*/
|
||||
DDLEnum(IDDLDataType* type,
|
||||
const std::string& name,
|
||||
const EnumNameValueVec& name_values,
|
||||
IDDLUnit* unit = NULL,
|
||||
int creation_level = 1);
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isPredefined() const;
|
||||
bool isOverwriteable() const;
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the name of the element.
|
||||
* @param [in] name Name of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
|
||||
/**
|
||||
* Getter for the Container type of DDL enum elements.
|
||||
*
|
||||
* @return Container type of DDL enum elements.
|
||||
*/
|
||||
const EnumNameValueVec& getValues() const;
|
||||
|
||||
/**
|
||||
* Setter for the DDL enum elements.
|
||||
*
|
||||
* @param [in] values Container type of DDL enum elements
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
void setValues(const EnumNameValueVec& values);
|
||||
|
||||
/**
|
||||
* Getter for the value of the element.
|
||||
*
|
||||
* @param [in] element Name of the element
|
||||
* @param [out] value Value of the element
|
||||
*
|
||||
* @return Standard result code.
|
||||
*/
|
||||
a_util::result::Result getValue(const std::string& element, std::string& value) const;
|
||||
|
||||
/**
|
||||
* Setter for the value of the element.
|
||||
*
|
||||
* @param [in] element Name of the element
|
||||
* @param [in] value Value of the element
|
||||
*
|
||||
* @return Standard result code.
|
||||
*/
|
||||
a_util::result::Result setValue(const std::string& element, const std::string& value);
|
||||
|
||||
/**
|
||||
* Getter for the name of the element.
|
||||
*
|
||||
* @param [in] value Value of the element
|
||||
* @param [out] element Name of the element
|
||||
*
|
||||
* @return Standard result code.
|
||||
*/
|
||||
a_util::result::Result getNameForValue(const std::string& value, std::string& element);
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the data-type name.
|
||||
* @return name of the data type
|
||||
*/
|
||||
const std::string& getType() const;
|
||||
|
||||
/**
|
||||
* Setter for the data-type object.
|
||||
*
|
||||
* @param [in] type pointer to the data-type object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setType(IDDLDataType* const type);
|
||||
|
||||
/**
|
||||
* Getter for the data-type object.
|
||||
* @return pointer to the data-type object
|
||||
*/
|
||||
IDDLDataType * getTypeObject() const;
|
||||
|
||||
int getCreationLevel() const;
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] type - Pointer to the data-type object
|
||||
* @param[in] name - Name of the created enum
|
||||
* @param[in] name_values - Values of the enum
|
||||
* @param[in] unit - Pointer to the unit of the datatype (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
* @return Standard result.
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
*/
|
||||
a_util::result::Result create(IDDLDataType* type,
|
||||
const std::string& name,
|
||||
const EnumNameValueVec& name_values,
|
||||
IDDLUnit* unit = NULL,
|
||||
int creation_level = 1);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Setter for the unit.
|
||||
* @param[in] unit - Pointer to the unit object of the data type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setUnit(IDDLUnit* unit);
|
||||
|
||||
/**
|
||||
* Getter for the unit name.
|
||||
* @return name of the referenced unit (\c a_util::strings::empty_string if there is none)
|
||||
*/
|
||||
std::string getUnit() const;
|
||||
|
||||
/**
|
||||
* Getter for the unit object.
|
||||
* @return pointer to the unit object (\c NULL if there is none)
|
||||
*/
|
||||
IDDLUnit * getUnitObject() const;
|
||||
|
||||
/**
|
||||
* Remove the element with the provided name.
|
||||
* @param[in] element - name of the element to be removed
|
||||
* @return Standard result.
|
||||
* @retval ERR_NOT_FOUND element not found
|
||||
*/
|
||||
a_util::result::Result removeElement(const std::string& element);
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
EnumNameValueVec _name_values;
|
||||
IDDLUnit *_unit;
|
||||
IDDLDataType * _type;
|
||||
|
||||
|
||||
bool _init_flag;
|
||||
int _level;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDLCONSTANT_H_INCLUDED
|
86
ddlrepresentation/ddlextdeclaration.cpp
Normal file
86
ddlrepresentation/ddlextdeclaration.cpp
Normal file
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlextdeclaration.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-5, ERR_INVALID_ARG)
|
||||
|
||||
DDLExtDeclaration::DDLExtDeclaration(const std::string& key,
|
||||
const std::string& value) :
|
||||
_key(key), _value(value), _init_flag(true)
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLExtDeclaration::accept(IDDLVisitor *visitor) const
|
||||
{
|
||||
return visitor->visit(this);
|
||||
}
|
||||
a_util::result::Result DDLExtDeclaration::accept(IDDLChangeVisitor *visitor)
|
||||
{
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLExtDeclaration::getName() const
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
bool DDLExtDeclaration::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLExtDeclaration::create(const std::string& key,
|
||||
const std::string& value)
|
||||
{
|
||||
if (key.empty())
|
||||
{
|
||||
return ERR_INVALID_ARG;
|
||||
}
|
||||
_key = key;
|
||||
_value = value;
|
||||
_init_flag = true;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
std::string DDLExtDeclaration::getKey() const
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
void DDLExtDeclaration::setKey(const std::string& key)
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
|
||||
std::string DDLExtDeclaration::getValue() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
void DDLExtDeclaration::setValue(const std::string& value)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
} // namespace ddl
|
93
ddlrepresentation/ddlextdeclaration.h
Normal file
93
ddlrepresentation/ddlextdeclaration.h
Normal file
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLEXT_DECLARATION_H_INCLUDED
|
||||
#define DDLEXT_DECLARATION_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
/**
|
||||
* Representation of an external declaration inside the header of a DDL
|
||||
* description.
|
||||
*/
|
||||
class DDLExtDeclaration : public DDL
|
||||
{
|
||||
public:
|
||||
/// Default CTOR
|
||||
DDLExtDeclaration() = default;
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] key - Name of the additional information
|
||||
* @param[in] value - Value of the additional information
|
||||
*/
|
||||
DDLExtDeclaration(const std::string& key, const std::string& value);
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] key - Name of the additional information
|
||||
* @param[in] value - Value of the additional information
|
||||
* @retval ERR_INVALID_ARG Empty key committed
|
||||
*/
|
||||
a_util::result::Result create(const std::string& key, const std::string& value);
|
||||
|
||||
/**
|
||||
* Getter for the key
|
||||
* @return the key
|
||||
*/
|
||||
std::string getKey() const;
|
||||
|
||||
/**
|
||||
* Setter for the key
|
||||
*/
|
||||
void setKey(const std::string& key);
|
||||
|
||||
/**
|
||||
* Getter for the value
|
||||
* @return the value
|
||||
*/
|
||||
std::string getValue() const;
|
||||
|
||||
/**
|
||||
* Setter for the Value
|
||||
*/
|
||||
void setValue(const std::string& value);
|
||||
|
||||
private:
|
||||
std::string _key;
|
||||
std::string _value;
|
||||
|
||||
bool _init_flag;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDLEXT_DECLARATION_H_INCLUDED
|
124
ddlrepresentation/ddlfactorymethod_intf.h
Normal file
124
ddlrepresentation/ddlfactorymethod_intf.h
Normal file
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_BUILDER_H_INCLUDED
|
||||
#define DDL_BUILDER_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
class DDLDescription;
|
||||
|
||||
/**
|
||||
* Abstract base class/interface for Factory Method design-pattern.
|
||||
*/
|
||||
class IDDLFactoryMethod
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Getter for the DDL object.
|
||||
* @return the DDL object
|
||||
* @attention The caller/user has the responsibility for the created
|
||||
* DDL object! Especially take this aspect into consideration in
|
||||
* matters of the deallocation of memory!
|
||||
*/
|
||||
virtual DDLDescription * getDDL() const = 0;
|
||||
|
||||
/**
|
||||
* Method to build up a new DDL hierarchy.
|
||||
* @param[in] version The version of the DDL hierarchy to be created. 0 Means newest version.
|
||||
* @retval ERR_NOT_INITIALIZED Not yet initialized (see setter methods
|
||||
* in concrete classes, e.g. \c DDLImporter::setFile())
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. refUnit)
|
||||
* @retval ERR_UNKNOWN Cross reference has not been resolved
|
||||
* @retval ERR_NOT_FOUND At least one mandatory element (e.g. header)
|
||||
* was not found.
|
||||
*/
|
||||
virtual a_util::result::Result createNew(const DDLVersion& version = DDLVersion::ddl_version_invalid) = 0;
|
||||
|
||||
/**
|
||||
* Method to destroy the DDL object and all contained objects.
|
||||
*/
|
||||
virtual void destroyDDL() = 0;
|
||||
|
||||
/**
|
||||
* Method to build a header object.
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
*/
|
||||
virtual a_util::result::Result buildHeader() = 0;
|
||||
|
||||
/**
|
||||
* Method to build a units object hierarchy.
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. refUnit)
|
||||
* @retval ERR_UNKNOWN Not all firstly unknown units have been resolved
|
||||
*/
|
||||
virtual a_util::result::Result buildUnits() = 0;
|
||||
|
||||
/**
|
||||
* Method to build a datatypes object hierarchy.
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. unit)
|
||||
*/
|
||||
virtual a_util::result::Result buildDatatypes() = 0;
|
||||
|
||||
/**
|
||||
* Method to build a enums object hierarchy.
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. refEnums)
|
||||
* @retval ERR_UNKNOWN Not all firstly unknown structs have been
|
||||
* resolved
|
||||
*/
|
||||
virtual a_util::result::Result buildEnums() = 0;
|
||||
|
||||
/**
|
||||
* Method to build a structs object hierarchy.
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. datatype)
|
||||
* @retval ERR_UNKNOWN Not all firstly unknown structs have been
|
||||
* resolved
|
||||
*/
|
||||
virtual a_util::result::Result buildStructs() = 0;
|
||||
|
||||
/**
|
||||
* Method to build a streams object hierarchy.
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. struct)
|
||||
*/
|
||||
virtual a_util::result::Result buildStreams() = 0;
|
||||
|
||||
/**
|
||||
* Method to build a streams object hierarchy.
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. struct)
|
||||
*/
|
||||
virtual a_util::result::Result buildStreamMetaTypes() = 0;
|
||||
|
||||
/**
|
||||
* DTOR
|
||||
*/
|
||||
virtual ~IDDLFactoryMethod(){}
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_BUILDER_H_INCLUDED
|
256
ddlrepresentation/ddlheader.cpp
Normal file
256
ddlrepresentation/ddlheader.cpp
Normal file
|
@ -0,0 +1,256 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlheader.h"
|
||||
|
||||
#include "ddlextdeclaration.h"
|
||||
#include "ddldescription.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-20, ERR_NOT_FOUND);
|
||||
|
||||
static const std::string strRegExDate [] = {
|
||||
std::string("^(\\d{4})(\\d{2})(\\d{2})$"),
|
||||
std::string("^(\\d{2})-(\\d{2})-(\\d{4})$"),
|
||||
std::string("^(\\d{4})-(\\d{2})-(\\d{2})$"),
|
||||
std::string("^(\\d{2})\\.(\\d{2})\\.(\\d{4})$")
|
||||
};
|
||||
|
||||
DDLHeader& DDLHeader::operator=(DDLHeader other)
|
||||
{
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
DDLHeader::DDLHeader(DDLHeader&& other)
|
||||
{
|
||||
swap(*this, other);
|
||||
}
|
||||
|
||||
DDLHeader::~DDLHeader()
|
||||
{
|
||||
std::transform(_ddl_ext_declarations.begin(),
|
||||
_ddl_ext_declarations.end(), _ddl_ext_declarations.begin(),
|
||||
deleteChild<DDLExtDeclaration>);
|
||||
}
|
||||
|
||||
DDLHeader::DDLHeader(const DDLVersion& language_version,
|
||||
const std::string& strAuthor, a_util::datetime::Date const sDateCreation,
|
||||
a_util::datetime::Date const sDateChange, const std::string& strDescription,
|
||||
DDLExtDeclarationVec vecExtDecls) :
|
||||
_language_version(language_version), _author(strAuthor),
|
||||
_date_creation(sDateCreation), _date_change(sDateChange),
|
||||
_description(strDescription), _ddl_ext_declarations(vecExtDecls),
|
||||
_init_flag(true)
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLHeader::create(DDLVersion& language_version,
|
||||
const std::string& strAuthor, a_util::datetime::Date const sDateCreation,
|
||||
a_util::datetime::Date const sDateChange, const std::string& strDescription,
|
||||
DDLExtDeclarationVec vecExtDecls)
|
||||
{
|
||||
_language_version = language_version;
|
||||
_author = strAuthor;
|
||||
_date_creation = sDateCreation;
|
||||
_date_change = sDateChange;
|
||||
_description = strDescription;
|
||||
_ddl_ext_declarations = vecExtDecls;
|
||||
_init_flag = true;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::datetime::Date DDLHeader::dateFromString(const std::string& strDate)
|
||||
{
|
||||
int32_t nDay = 0;
|
||||
int32_t nMonth = 0;
|
||||
int32_t nYear = 0;
|
||||
a_util::datetime::Date sDate(1900, 1, 1);
|
||||
|
||||
std::string arg1, arg2, arg3;
|
||||
a_util::regex::RegularExpression oRegExDate(strRegExDate[0]);
|
||||
if (oRegExDate.fullMatch(strDate, arg1, arg2, arg3))
|
||||
{
|
||||
nYear = a_util::strings::toInt32(arg1);
|
||||
nMonth = a_util::strings::toInt32(arg2);
|
||||
nDay = a_util::strings::toInt32(arg3);
|
||||
sDate = a_util::datetime::Date(nYear, nMonth, nDay);
|
||||
}
|
||||
oRegExDate.setPattern(strRegExDate[1]);
|
||||
if (oRegExDate.fullMatch(strDate, arg1, arg2, arg3))
|
||||
{
|
||||
nDay = a_util::strings::toInt32(arg1);
|
||||
nMonth = a_util::strings::toInt32(arg2);
|
||||
nYear = a_util::strings::toInt32(arg3);
|
||||
sDate = a_util::datetime::Date(nYear, nMonth, nDay);
|
||||
}
|
||||
oRegExDate.setPattern(strRegExDate[2]);
|
||||
if (oRegExDate.fullMatch(strDate, arg1, arg2, arg3))
|
||||
{
|
||||
nYear = a_util::strings::toInt32(arg1);
|
||||
nMonth = a_util::strings::toInt32(arg2);
|
||||
nDay = a_util::strings::toInt32(arg3);
|
||||
sDate = a_util::datetime::Date(nYear, nMonth, nDay);
|
||||
}
|
||||
oRegExDate.setPattern(strRegExDate[3]);
|
||||
if (oRegExDate.fullMatch(strDate, arg1, arg2, arg3))
|
||||
{
|
||||
nDay = a_util::strings::toInt32(arg1);
|
||||
nMonth = a_util::strings::toInt32(arg2);
|
||||
nYear = a_util::strings::toInt32(arg3);
|
||||
sDate = a_util::datetime::Date(nYear, nMonth, nDay);
|
||||
}
|
||||
|
||||
return sDate;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLHeader::accept(IDDLVisitor *poVisitor) const
|
||||
{
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
a_util::result::Result DDLHeader::accept(IDDLChangeVisitor *poVisitor)
|
||||
{
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLHeader::getName() const
|
||||
{
|
||||
static std::string s_Name("Header");
|
||||
return s_Name;
|
||||
}
|
||||
|
||||
bool DDLHeader::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
DDLVersion DDLHeader::getLanguageVersion() const
|
||||
{
|
||||
return _language_version;
|
||||
}
|
||||
|
||||
void DDLHeader::setLanguageVersion(const DDLVersion& language_version)
|
||||
{
|
||||
_language_version = language_version;
|
||||
}
|
||||
|
||||
std::string DDLHeader::getAuthor() const
|
||||
{
|
||||
return _author;
|
||||
}
|
||||
|
||||
void DDLHeader::setAuthor(const std::string& strAuthor)
|
||||
{
|
||||
_author = strAuthor;
|
||||
}
|
||||
|
||||
a_util::datetime::Date DDLHeader::getDateCreation() const
|
||||
{
|
||||
return _date_creation;
|
||||
}
|
||||
|
||||
a_util::datetime::Date DDLHeader::getDateChange() const
|
||||
{
|
||||
return _date_change;
|
||||
}
|
||||
|
||||
void DDLHeader::setDateChange(a_util::datetime::Date const sDateChange)
|
||||
{
|
||||
_date_change = sDateChange;
|
||||
}
|
||||
|
||||
void DDLHeader::setDateCreation(a_util::datetime::Date const sDateCreation)
|
||||
{
|
||||
_date_creation = sDateCreation;
|
||||
}
|
||||
|
||||
std::string DDLHeader::getDescription() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
void DDLHeader::setDescription(const std::string& strDescription)
|
||||
{
|
||||
_description = strDescription;
|
||||
}
|
||||
|
||||
void DDLHeader::setExtDeclarations(DDLExtDeclarationVec vecDDLExtDeclarations)
|
||||
{
|
||||
_ddl_ext_declarations = vecDDLExtDeclarations;
|
||||
}
|
||||
|
||||
void DDLHeader::addExtDeclaration(DDLExtDeclaration * poExtDeclaration, int nPos)
|
||||
{
|
||||
if (NULL != poExtDeclaration)
|
||||
{
|
||||
const DDLExtDeclarationVec::size_type szPos =
|
||||
static_cast<DDLExtDeclarationVec::size_type>(nPos);
|
||||
if (0 <= szPos && szPos < _ddl_ext_declarations.size())
|
||||
{
|
||||
_ddl_ext_declarations.insert(_ddl_ext_declarations.begin() + szPos,
|
||||
poExtDeclaration);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ddl_ext_declarations.push_back(poExtDeclaration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a_util::result::Result DDLHeader::removeExtDeclaration(const std::string& strKey)
|
||||
{
|
||||
DDLExtDeclarationIt oIt = _ddl_ext_declarations.begin();
|
||||
while (oIt != _ddl_ext_declarations.end())
|
||||
{
|
||||
if ((*oIt)->getKey() == strKey)
|
||||
{
|
||||
DDLDescription::deleteChild(*oIt);
|
||||
_ddl_ext_declarations.erase(oIt);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
oIt++;
|
||||
}
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
const DDLExtDeclarationVec& DDLHeader::getExtDeclarations() const
|
||||
{
|
||||
return _ddl_ext_declarations;
|
||||
}
|
||||
|
||||
DDLExtDeclarationVec& DDLHeader::getExtDeclarations()
|
||||
{
|
||||
return _ddl_ext_declarations;
|
||||
}
|
||||
|
||||
void swap(DDLHeader& lhs, DDLHeader& rhs) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(lhs._language_version, rhs._language_version);
|
||||
swap(lhs._author, rhs._author);
|
||||
swap(lhs._date_creation, rhs._date_creation);
|
||||
swap(lhs._date_change, rhs._date_change);
|
||||
swap(lhs._description, rhs._description);
|
||||
swap(lhs._ddl_ext_declarations, rhs._ddl_ext_declarations);
|
||||
swap(lhs._init_flag, rhs._init_flag);
|
||||
}
|
||||
|
||||
} // namespace ddl
|
253
ddlrepresentation/ddlheader.h
Normal file
253
ddlrepresentation/ddlheader.h
Normal file
|
@ -0,0 +1,253 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_HEADER_H_INCLUDED
|
||||
#define DDL_HEADER_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
class DDLExtDeclaration;
|
||||
|
||||
/**
|
||||
* Container type of DDLExtDeclaration objects
|
||||
*/
|
||||
typedef std::vector<DDLExtDeclaration*> DDLExtDeclarationVec;
|
||||
/**
|
||||
* Iterator type for DDLExtDeclarationVec
|
||||
*/
|
||||
typedef DDLExtDeclarationVec::iterator DDLExtDeclarationIt;
|
||||
|
||||
/**
|
||||
* Representation of the header of a DDL description.
|
||||
*/
|
||||
class DDLHeader : public DDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLHeader() = default;
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] language_version - Version number of the file where this description is based on
|
||||
* @param[in] author - Author
|
||||
* @param[in] date_creation - Creation date of file
|
||||
* @param[in] date_change - Date of last changes
|
||||
* @param[in] description - Short description of the file
|
||||
* @param[in] ext_decls - Vector of external declarations (optional)
|
||||
*/
|
||||
DDLHeader(const DDLVersion& language_version,
|
||||
const std::string& author,
|
||||
a_util::datetime::Date const date_creation,
|
||||
a_util::datetime::Date const date_change,
|
||||
const std::string& description,
|
||||
DDLExtDeclarationVec ext_decls = DDLExtDeclarationVec());
|
||||
|
||||
/**
|
||||
* Copy CTOR
|
||||
* @param[in] other - Reference to header object that should be copied
|
||||
*/
|
||||
DDLHeader(const DDLHeader&) = default;
|
||||
|
||||
/**
|
||||
* Assignment operator (either copies or moves)
|
||||
* @param[in] other DDL header type to copy from
|
||||
* @return @c *this
|
||||
*/
|
||||
DDLHeader& operator=(DDLHeader other);
|
||||
|
||||
/**
|
||||
* Move CTOR
|
||||
* @param[in,out] other DDL header type to move from - empty but valid when finished
|
||||
*/
|
||||
DDLHeader(DDLHeader&& other);
|
||||
|
||||
|
||||
/**
|
||||
* DTOR
|
||||
*/
|
||||
virtual ~DDLHeader();
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] language_version - Version number of the file where this description is based on
|
||||
* @param[in] author - Author
|
||||
* @param[in] date_creation - Creation date of file
|
||||
* @param[in] date_change - Date of last changes
|
||||
* @param[in] description - Short description of the file
|
||||
* @param[in] ext_decls - Vector of external declarations (optional)
|
||||
*
|
||||
* @return Standard result.
|
||||
*/
|
||||
a_util::result::Result create(DDLVersion& language_version, const std::string& author,
|
||||
a_util::datetime::Date const date_creation, a_util::datetime::Date const date_change,
|
||||
const std::string& description,
|
||||
DDLExtDeclarationVec ext_decls = DDLExtDeclarationVec());
|
||||
|
||||
/**
|
||||
* Getter for the language version.
|
||||
* @return the language version
|
||||
*/
|
||||
DDLVersion getLanguageVersion() const;
|
||||
|
||||
/**
|
||||
* Setter for the language version.
|
||||
* @param[in] language_version - the language version
|
||||
* @return void
|
||||
*/
|
||||
void setLanguageVersion(const DDLVersion& language_version);
|
||||
|
||||
/**
|
||||
* Getter for the author.
|
||||
* @return the author
|
||||
*/
|
||||
std::string getAuthor() const;
|
||||
|
||||
/**
|
||||
* Setter for the author.
|
||||
* @param[in] author - Author
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setAuthor(const std::string& author);
|
||||
|
||||
/**
|
||||
* Getter for the creation date.
|
||||
* @return the creation date
|
||||
*/
|
||||
a_util::datetime::Date getDateCreation() const;
|
||||
|
||||
/**
|
||||
* Setter for the creation date.
|
||||
* @param[in] date_creation - Creation date to set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setDateCreation(a_util::datetime::Date const date_creation);
|
||||
|
||||
/**
|
||||
* Getter for the change date.
|
||||
* @return the change date
|
||||
*/
|
||||
a_util::datetime::Date getDateChange() const;
|
||||
|
||||
/**
|
||||
* Setter for the change date.
|
||||
* @param[in] date_change - Change date to set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setDateChange(a_util::datetime::Date const date_change);
|
||||
|
||||
/**
|
||||
* Getter for the description.
|
||||
* @return the description
|
||||
*/
|
||||
std::string getDescription() const;
|
||||
|
||||
/**
|
||||
* Setter for the description.
|
||||
*/
|
||||
void setDescription(const std::string& description);
|
||||
|
||||
/**
|
||||
* Setter for the external declarations
|
||||
* @param[in] ext_declarations - Vector of external declarations
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setExtDeclarations(DDLExtDeclarationVec ext_declarations);
|
||||
|
||||
/**
|
||||
* Adder for an external declaration
|
||||
* @param[in] ext_declarations - Pointer to the external declaration
|
||||
* @param[in] pos - Position to add the external declaration
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void addExtDeclaration(DDLExtDeclaration * ext_declarations, int pos = -1);
|
||||
|
||||
/**
|
||||
* Removes the external declaration with the given key.
|
||||
* @param [in] key - Key of the external declaration which should be removed
|
||||
* @retval ERR_NOT_FOUND The specified key was not found
|
||||
*/
|
||||
a_util::result::Result removeExtDeclaration(const std::string& key);
|
||||
|
||||
/**
|
||||
* Getter for the external declarations
|
||||
* @return the external declarations
|
||||
*/
|
||||
const DDLExtDeclarationVec& getExtDeclarations() const;
|
||||
|
||||
/**
|
||||
* Getter for the external declarations
|
||||
* @return the external declarations
|
||||
*/
|
||||
DDLExtDeclarationVec& getExtDeclarations();
|
||||
|
||||
/**
|
||||
* Helper method to extract a date out of a string.
|
||||
* Following date formats are supported (complying with DDL spec):<br><ul>
|
||||
* <li> yyyymmdd </li>
|
||||
* <li> dd-mm-yyyy </li>
|
||||
* <li> yyyy-mm-dd </li>
|
||||
* <li> dd.mm.yyyy </li></ul>
|
||||
*
|
||||
* @param[in] date - String containing the date
|
||||
* @return the date structure
|
||||
*/
|
||||
static a_util::datetime::Date dateFromString(const std::string& date);
|
||||
|
||||
/**
|
||||
* Add swap functionality, also enabling the copy-swap-idiom
|
||||
* @param[in,out] lhs Left-hand side ddl header
|
||||
* @param[in,out] rhs Right-hand side ddl header
|
||||
*/
|
||||
friend void swap(DDLHeader& lhs, DDLHeader& rhs) noexcept;
|
||||
|
||||
|
||||
private:
|
||||
DDLVersion _language_version;
|
||||
std::string _author;
|
||||
a_util::datetime::Date _date_creation;
|
||||
a_util::datetime::Date _date_change;
|
||||
std::string _description;
|
||||
DDLExtDeclarationVec _ddl_ext_declarations;
|
||||
|
||||
bool _init_flag;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_HEADER_H_INCLUDED
|
2662
ddlrepresentation/ddlimporter.cpp
Normal file
2662
ddlrepresentation/ddlimporter.cpp
Normal file
File diff suppressed because it is too large
Load diff
394
ddlrepresentation/ddlimporter.h
Normal file
394
ddlrepresentation/ddlimporter.h
Normal file
|
@ -0,0 +1,394 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_IMPORTER_H_INCLUDED
|
||||
#define DDL_IMPORTER_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlfactorymethod_intf.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddlcontainer.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
class DDLDescription;
|
||||
|
||||
/**
|
||||
* \enum ImporterMsgSeverity
|
||||
* enumeration type for message severity
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
importer_info,
|
||||
importer_warning,
|
||||
importer_error
|
||||
} ImporterMsgSeverity;
|
||||
|
||||
/**
|
||||
* \struct ImporterMsg
|
||||
* error description structure type
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
std::string desc; //!< string of the message
|
||||
ImporterMsgSeverity severity; //!< enumeration type for message severity
|
||||
} ImporterMsg;
|
||||
|
||||
/**
|
||||
* Container for error descriptions
|
||||
*/
|
||||
typedef std::list<ImporterMsg> ImporterMsgList;
|
||||
|
||||
|
||||
/**
|
||||
* Concrete Factory Method for building up a DDL from a XML file.
|
||||
*/
|
||||
class DDLImporter : public IDDLFactoryMethod
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
* @param[in] basic_check Perform basic checks during Create* (unique element names etc.).
|
||||
* For a full check use DDLInspector.
|
||||
* @param[in] sorted Sorts all DDL items by name for better performance.
|
||||
*/
|
||||
DDLImporter(bool basic_check = true, bool sorted = true);
|
||||
|
||||
/**
|
||||
* CTOR with file name/path
|
||||
* @param[in] file - Path to file to use
|
||||
* @param[in] basic_check Perform basic checks during Create* (unique element names etc.).
|
||||
* For a full check use DDLInspector.
|
||||
* @param[in] sorted Sorts all DDL items by name for better performance.
|
||||
*/
|
||||
DDLImporter(const a_util::filesystem::Path& file,
|
||||
bool basic_check = true,
|
||||
bool sorted = true);
|
||||
|
||||
/**
|
||||
* CTOR with file name/path
|
||||
* @param[in] file - Path to file to use
|
||||
* @param[in] basic_check Perform basic checks during Create* (unique element names etc.).
|
||||
* For a full check use DDLInspector.
|
||||
* @param[in] sorted Sorts all DDL items by name for better performance.
|
||||
*/
|
||||
DDLImporter(const char* file, bool basic_check = true, bool sorted = true);
|
||||
|
||||
/**
|
||||
* CTOR with creation level.
|
||||
* @param[in] creation_level - Creation level
|
||||
* @param[in] basic_check Perform basic checks during Create* (unique element names etc.).
|
||||
* For a full check use DDLInspector.
|
||||
* @param[in] sorted Sorts all DDL items by name for better performance.
|
||||
*/
|
||||
DDLImporter(int creation_level, bool basic_check = true, bool sorted = true);
|
||||
|
||||
/// Default copy constructor
|
||||
DDLImporter(const DDLImporter&) = default;
|
||||
|
||||
/**
|
||||
* Assignment operator (either copies or moves)
|
||||
* @param[in] other DDLImporter object to copy from
|
||||
* @return @c *this
|
||||
*/
|
||||
DDLImporter& operator=(DDLImporter other);
|
||||
|
||||
/**
|
||||
* Move CTOR
|
||||
* @param[in,out] other DDLImporter object to move from - empty but valid when finished
|
||||
*/
|
||||
DDLImporter(DDLImporter&& other);
|
||||
|
||||
/**
|
||||
* Add swap functionality, also enabling the copy-swap-idiom
|
||||
* @param[in,out] lhs Left-hand side ddl type
|
||||
* @param[in,out] rhs Right-hand side ddl type
|
||||
*/
|
||||
friend void swap(DDLImporter& lhs, DDLImporter& rhs) noexcept;
|
||||
|
||||
|
||||
public: // implements IDDLFactoryMethod
|
||||
|
||||
virtual ~DDLImporter();
|
||||
|
||||
DDLDescription * getDDL() const;
|
||||
|
||||
/**
|
||||
* @copydoc IDDLFactoryMethod::createNew(double)
|
||||
* @remarks If an error occurs, a list of detailed error descriptions
|
||||
* can be obtained using \c GetAllErrors().
|
||||
*/
|
||||
a_util::result::Result createNew(const DDLVersion& version = DDLVersion::ddl_version_invalid);
|
||||
|
||||
void destroyDDL();
|
||||
|
||||
a_util::result::Result buildHeader();
|
||||
|
||||
a_util::result::Result buildUnits();
|
||||
|
||||
a_util::result::Result buildDatatypes();
|
||||
|
||||
a_util::result::Result buildStructs();
|
||||
|
||||
a_util::result::Result buildStreams();
|
||||
|
||||
a_util::result::Result buildEnums();
|
||||
|
||||
a_util::result::Result buildStreamMetaTypes();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Static method to destroy the given DDL hierarchy.
|
||||
* @param [in] ddl - Pointer to the DDL hierarchy which should be destroyed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static void destroyDDL(DDLDescription *ddl);
|
||||
|
||||
/**
|
||||
* Setter for the creation level.
|
||||
* @param[in] level - Creation level to use
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setCreationLevel(int const level = 1);
|
||||
|
||||
/**
|
||||
* Setter for the validation mode.
|
||||
* @param[in] full_check - Validation mode to use.
|
||||
* Set true for full description check.
|
||||
* Set false for description check until first error.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setFullCheckDescriptionMode(bool full_check = false);
|
||||
|
||||
/**
|
||||
* Setter to enable disable the merge of DDL defaults (units, datattypes, etc.)
|
||||
* @param [in] merge_defaults See description
|
||||
* @return void
|
||||
*/
|
||||
void setMergeDefaults(bool merge_defaults = true);
|
||||
|
||||
/**
|
||||
* Setter to switch from prefereing entities from the reference DDL, to using the reference
|
||||
* enties only when there is no "local" aquivalent.
|
||||
* Mind that reference entities are not cloned but only referenced.
|
||||
* They are also not included into the containers.
|
||||
* @param [in] prefere_reference See description
|
||||
* @return void
|
||||
*/
|
||||
void setPreferReferenceEntities(bool prefere_reference = true);
|
||||
|
||||
/**
|
||||
* Method to create a partial DDL (e.g. streams only).
|
||||
* @param[in] ref_ddl - Reference DDL object to be used for resolving
|
||||
* matters
|
||||
* @param[in] version The version the newly created description will have. Set 0 for
|
||||
* newst version.
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_INITIALIZED Not yet initialized (see setter methods
|
||||
* in concrete classes, e.g. \c DDLImporter::setFile())
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. refUnit)
|
||||
* @retval ERR_UNKNOWN Cross reference has not been resolved
|
||||
*/
|
||||
a_util::result::Result createPartial(const DDLDescription* ref_ddl, const DDLVersion& version);
|
||||
|
||||
/**
|
||||
* Setter for the source file.
|
||||
* @param[in] file - Path to file to use
|
||||
* @retval ERR_OPEN_FAILED Reading process failed
|
||||
* @retval ERR_UNEXPECTED Invalid XML tag
|
||||
*/
|
||||
a_util::result::Result setFile(const a_util::filesystem::Path& file);
|
||||
|
||||
/**
|
||||
* Setter for a XML string containing the DDL to import.
|
||||
* @param[in] xml - String containing the DDL
|
||||
* @retval ERR_UNEXPECTED Invalid XML tag
|
||||
*/
|
||||
a_util::result::Result setXML(const std::string& xml);
|
||||
|
||||
/**
|
||||
* Getter for the description of the last error.
|
||||
* @return the error description
|
||||
*/
|
||||
std::string getErrorDesc() const;
|
||||
|
||||
/**
|
||||
* Getter for the most recent error description.
|
||||
* @return The error description or \c a_util::strings::empty_string if there was none.
|
||||
* @remarks This method indeed returns the last \b error message
|
||||
* (message with severity \c importer_error).
|
||||
*/
|
||||
std::string getLastErrorDesc() const;
|
||||
|
||||
/**
|
||||
* Getter for all detected errors.
|
||||
* @return A list of all detected errors.
|
||||
*/
|
||||
ImporterMsgList getAllMessages() const;
|
||||
|
||||
/**
|
||||
* Method to log all messages which have at least the given severity
|
||||
* to console.
|
||||
* @param[in] least_severity - Minimum severity level (optional)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void printAllMessages(ImporterMsgSeverity least_severity = importer_info);
|
||||
|
||||
private: // methods
|
||||
/**
|
||||
* Creates a baseunit object from the given DOMElement.
|
||||
* @param[out] new_bu - Pointer to pointer to the newly created
|
||||
* baseunit object
|
||||
* @param[in] bu_element - The DOMElement with the information
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable
|
||||
*/
|
||||
a_util::result::Result buildSingleBaseunit(DDLBaseunit ** new_bu,
|
||||
const a_util::xml::DOMElement& bu_element);
|
||||
|
||||
/**
|
||||
* Creates a prefix object from the given DOMElement.
|
||||
* @param[out] new_prefix - Pointer to pointer to the newly created
|
||||
* prefix object
|
||||
* @param[in] prefix_element - The DOMElement with the information
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable
|
||||
*/
|
||||
a_util::result::Result buildSinglePrefix(DDLPrefix ** new_prefix,
|
||||
const a_util::xml::DOMElement& prefix_element);
|
||||
|
||||
/**
|
||||
* Creates a unit object from the given DOMElement.
|
||||
* @param[out] new_unit - Pointer to pointer to the newly created
|
||||
* unit object
|
||||
* @param[in] unit_element - The DOMElement with the information
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable
|
||||
*/
|
||||
a_util::result::Result buildSingleUnit(DDLUnit ** new_unit,
|
||||
const a_util::xml::DOMElement& unit_element);
|
||||
|
||||
/**
|
||||
* Creates a datatype object from the given DOMElement.
|
||||
* @param[out] new_datatype - Pointer to pointer to the newly
|
||||
* created datatype object
|
||||
* @param[in] dt_element -T he DOMElement with the information
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. unit)
|
||||
*/
|
||||
a_util::result::Result buildSingleDatatype(DDLDataType ** new_datatype,
|
||||
const a_util::xml::DOMElement& dt_element);
|
||||
|
||||
/**
|
||||
* Creates an enum object from the given DOMElement.
|
||||
* @param[out] new_enum - Pointer to pointer to the newly
|
||||
* created enum object
|
||||
* @param[in] oEnumElement - The DOMElement with the information
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. unit)
|
||||
*/
|
||||
a_util::result::Result buildSingleEnum(DDLEnum** new_enum,
|
||||
const a_util::xml::DOMElement& enum_element);
|
||||
|
||||
/**
|
||||
* Creates a struct object from the given DOMElement.
|
||||
* @param[out] new_struct - Pointer to pointer to the newly created
|
||||
* struct object
|
||||
* @param[in] struct_element - The DOMElement with the information
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. datatype)
|
||||
* @retval ERR_UNKNOWN Not all firstly unknown structs have been
|
||||
* resolved
|
||||
*/
|
||||
a_util::result::Result buildSingleStruct(DDLComplex ** new_struct,
|
||||
const a_util::xml::DOMElement& struct_element);
|
||||
|
||||
/**
|
||||
* Creates a DDL stream object from the given DOMElement.
|
||||
* @param[out] new_stream - Pointer to pointer to the newly created
|
||||
* stream object
|
||||
* @param[in] stream_element - The DOMElement with the information
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. struct)
|
||||
*/
|
||||
a_util::result::Result buildSingleStream(DDLStream ** new_stream,
|
||||
a_util::xml::DOMElement stream_element);
|
||||
|
||||
/**
|
||||
* Creates a DDL stream object from the given DOMElement.
|
||||
* @param[out] stream_meta_type_element
|
||||
* @param[in] stream_meta_types
|
||||
* @retval ERR_UNKNOWN_FORMAT Expected XML hierarchy not found
|
||||
* @retval ERR_NO_CLASS Cross reference not resolvable (e.g. struct)
|
||||
*/
|
||||
a_util::result::Result buildSingleStreamMetaType(const a_util::xml::DOMElement& stream_meta_type_element,
|
||||
DDLStreamMetaTypeVec& stream_meta_types);
|
||||
|
||||
/**
|
||||
* Helper method to create a message and save it in the appropriate
|
||||
* container.
|
||||
* @param[in] msg - Message text
|
||||
* @param[in] severity - Message severity
|
||||
* @return void
|
||||
*/
|
||||
void pushMessage(const std::string& msg, ImporterMsgSeverity severity);
|
||||
|
||||
/**
|
||||
* Helper method to find specific elements inside the given first_data by Name.
|
||||
* If not found there have a look in second_data.
|
||||
* @tparam T - Representation object type (e.g. DDLDataType)
|
||||
* @param[in] name - Name of the element to find
|
||||
* @param[in] first_data - Vector of representation objects to
|
||||
* search through
|
||||
* @param[in] second_data - second Vector of representation objects to
|
||||
* search through
|
||||
* @return pointer to the found element or \c NULL if not found
|
||||
*/
|
||||
template<typename T>
|
||||
T* tryToFind(const std::string& name,
|
||||
DDLContainer<T>& first_data,
|
||||
DDLContainer<T>& second_data);
|
||||
|
||||
private: // members
|
||||
a_util::xml::DOM _dom;
|
||||
DDLDescription *_ddl_desc;
|
||||
const DDLDescription *_current_ref_ddl;
|
||||
|
||||
DDLUnitVec _unknown_units;
|
||||
DDLComplexVec _unknown_structs;
|
||||
DDLStreamMetaTypeVec _unknown_stream_meta_types;
|
||||
bool _init_flag;
|
||||
int _creation_level;
|
||||
|
||||
bool _full_check;
|
||||
ImporterMsgList _errors;
|
||||
bool _basic_check;
|
||||
bool _merge_defaults;
|
||||
bool _sorted;
|
||||
bool _prefere_reference;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_IMPORTER_H_INCLUDED
|
1175
ddlrepresentation/ddlinspector.cpp
Normal file
1175
ddlrepresentation/ddlinspector.cpp
Normal file
File diff suppressed because it is too large
Load diff
287
ddlrepresentation/ddlinspector.h
Normal file
287
ddlrepresentation/ddlinspector.h
Normal file
|
@ -0,0 +1,287 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_INSPECTOR_H_INCLUDED
|
||||
#define DDL_INSPECTOR_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddlimporter.h"
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
enum WarningLevel
|
||||
/* see "rules for changing an enumeration" (#27200) before doing any change! */
|
||||
{
|
||||
/**
|
||||
* Inform about all warnings
|
||||
*/
|
||||
verbose = 0,
|
||||
/**
|
||||
* Suppress some minor warnings
|
||||
*/
|
||||
moderate = 1,
|
||||
/**
|
||||
* Suppress all warnings
|
||||
*/
|
||||
silent = 2
|
||||
};
|
||||
|
||||
/// Maximum depth of the hierarchy of a complex data type in a DDL File
|
||||
#define DDL_MAX_DESC_HIERARCHY 100
|
||||
|
||||
/**
|
||||
* Validation and correction class for ADTF DDL for use with the
|
||||
*/
|
||||
class DDLInspector : public IDDLChangeVisitor
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* CTOR.
|
||||
* @param[in] auto_correct - Flag for implicit auto-correction (optional)
|
||||
*/
|
||||
DDLInspector(bool auto_correct = false);
|
||||
|
||||
virtual a_util::result::Result visitDDL(DDLDescription* description);
|
||||
virtual a_util::result::Result visit(DDLHeader* header);
|
||||
virtual a_util::result::Result visit(DDLDataType* data_type);
|
||||
virtual a_util::result::Result visit(DDLComplex* complex);
|
||||
virtual a_util::result::Result visit(DDLStream* stream);
|
||||
virtual a_util::result::Result visit(DDLUnit* unit);
|
||||
virtual a_util::result::Result visit(DDLBaseunit* baseunit);
|
||||
virtual a_util::result::Result visit(DDLExtDeclaration* ext_declaration);
|
||||
virtual a_util::result::Result visit(DDLElement* element);
|
||||
virtual a_util::result::Result visit(DDLPrefix* prefix);
|
||||
virtual a_util::result::Result visit(DDLRefUnit* ref_unit);
|
||||
virtual a_util::result::Result visit(DDLStreamStruct* stream_struct);
|
||||
virtual a_util::result::Result visit(DDLEnum* ddl_enum);
|
||||
virtual a_util::result::Result visit(DDLStreamMetaType* stream_meta_type);
|
||||
virtual a_util::result::Result visit(DDLProperty* property);
|
||||
|
||||
/**
|
||||
* Setter for the auto-correction flag.
|
||||
* @param[in] auto_correct - New value of the flag
|
||||
* @return void
|
||||
*/
|
||||
void setAutoCorrect(bool auto_correct);
|
||||
|
||||
/**
|
||||
* Getter for the auto-correction flag.
|
||||
* @returns the flag
|
||||
*/
|
||||
bool getAutoCorrect() const;
|
||||
|
||||
/**
|
||||
* Setter for the auto-correction flag.
|
||||
* @param[in] auto_correct - New value of the flag
|
||||
* @return void
|
||||
*/
|
||||
void setWarningLevel(WarningLevel warning_level);
|
||||
|
||||
/**
|
||||
* Getter for the auto-correction flag.
|
||||
* @returns the flag
|
||||
*/
|
||||
WarningLevel getWarningLevel() const;
|
||||
|
||||
/**
|
||||
* Getter for the list of suggestions.
|
||||
* @returns the list of suggestions
|
||||
*/
|
||||
ImporterMsgList getSuggestions() const;
|
||||
|
||||
/**
|
||||
* Getter for the most recent error description.
|
||||
* @return The error description or \c a_util::strings::empty_string if there was none.
|
||||
* @remarks This method indeed returns the last \b error message (message with severity \c importer_error).
|
||||
*/
|
||||
std::string getLastErrorDesc() const;
|
||||
|
||||
/**
|
||||
* Init a new Check, clear all list and init all variables.
|
||||
*/
|
||||
void InitNewCheck();
|
||||
|
||||
/**
|
||||
* Check if the description contains dynamic arrays
|
||||
* @retval true if a dynamic array was found
|
||||
*/
|
||||
bool foundDynamicArrays();
|
||||
|
||||
/**
|
||||
* Returns the last corrected Bytepos position inclusive the
|
||||
* last Element size.
|
||||
* @param[in] struct_name - name of the Struct where you want the last element
|
||||
* @return Last corrected Bytepos position inclusive the last Element size.
|
||||
*/
|
||||
unsigned int getLastBytePosOfAStructCorrected(const std::string& struct_name);
|
||||
|
||||
/**
|
||||
* Returns the actual last Bytepos inclusive the last Element size.
|
||||
* @param[in] struct_name - name of the Struct where you want the last element
|
||||
* @return Actual last Bytepos inclusive the last Element size.
|
||||
*/
|
||||
unsigned int getLastBytePosOfAStructReal(const std::string& struct_name);
|
||||
|
||||
/**
|
||||
* Check the validy of nested structs.
|
||||
* @param[in] description - pointer of the Description within you want to check a vality of nested structs
|
||||
* @retval Error message list
|
||||
*/
|
||||
static ImporterMsgList checkValidyOfNestedStructs(const DDLDescription* description);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Method for derived classes to add an own suggestion.
|
||||
* @param [in] desc Suggestion message
|
||||
* @param [in] severity Message severity
|
||||
* @retval ERR_EMPTY The suggestion message must not be empty.
|
||||
* @retval ERR_INVALID_ARG The message severity must have a valid value
|
||||
* of type \c adtf::ImporterMsgSeverity.
|
||||
*/
|
||||
a_util::result::Result addSuggestion(std::string const &desc,
|
||||
ImporterMsgSeverity const severity);
|
||||
|
||||
/**
|
||||
* Helper method to check if the element is alignable.
|
||||
* @param[in] byte_pos - Current byte position inside the structure
|
||||
* @param[in] element_size - Size of the element
|
||||
* @retval true Element is alignable
|
||||
* @retval false Element is not alignable
|
||||
*/
|
||||
virtual bool isAlignable(size_t const byte_pos,
|
||||
size_t const element_size);
|
||||
|
||||
/**
|
||||
* Helper method which returns whether the left-hand-side argument
|
||||
* compares less than the right-hand-side one (as returned by operator <)
|
||||
* based on given DDL type information.
|
||||
*
|
||||
* @param [in] lhs String of the left-hand-side
|
||||
* @param [in] rhs String of the right-hand-side
|
||||
* @param [in] type Pointer to common type information
|
||||
*
|
||||
* @retval true LHS is lower than RHS
|
||||
* @retval false LHS is not lower than RHS or type is not interpretable
|
||||
*/
|
||||
static bool lessDDL (const std::string& lhs,
|
||||
const std::string& rhs,
|
||||
const DDLDataType* type);
|
||||
|
||||
private: // methods
|
||||
/**
|
||||
* Recursive helper function for check of the validy of nested structs within a struct.
|
||||
* @param[in] description - pointer of the Description within you want to check a vality of a struct
|
||||
* @param[in] struct_type_name - name of the Struct where you want to check for invalid nested structs
|
||||
* @param[in] nested_struct_type_name - name of the nested Struct
|
||||
* @param[out] log - Log of error message, if validy is failed
|
||||
* @param[in] struct_depth - Depth of the nested stuct
|
||||
* @retval true if valid
|
||||
* @retval false otherwise
|
||||
*/
|
||||
static bool checkValidyOfNestedStructs(const DDLDescription* description,
|
||||
const std::string& struct_type_name,
|
||||
const std::string& nested_struct_type_name,
|
||||
std::string& log,
|
||||
int struct_depth = 1);
|
||||
|
||||
private: // members
|
||||
DDLDescription* _ddl_desc;
|
||||
bool _auto_correct;
|
||||
/**
|
||||
* The list contains all warnings and errors.
|
||||
*/
|
||||
ImporterMsgList _suggestions;
|
||||
|
||||
/**
|
||||
* The set contains all names of the structs.
|
||||
* If the list contains two equal names, it will be set
|
||||
* an error in the ImporterMsgList.
|
||||
*/
|
||||
std::set<std::string> _complex_names;
|
||||
|
||||
/**
|
||||
* The list contains all names of the data types.
|
||||
* If the list contains two equal names, it will be set
|
||||
* an error in the ImporterMsgList.
|
||||
*/
|
||||
std::set<std::string> _data_types_names;
|
||||
|
||||
/**
|
||||
* The list contains all names of the enum.
|
||||
* If the list contains two equal names, it will be set
|
||||
* an error in the ImporterMsgList.
|
||||
*/
|
||||
std::set<std::string> _enum_names;
|
||||
|
||||
/**
|
||||
* The list contains all names of the base unit names.
|
||||
* If the list contains two equal names, it will be set
|
||||
* an error in the ImporterMsgList.
|
||||
*/
|
||||
std::set<std::string> _base_unit_names;
|
||||
|
||||
/**
|
||||
* The list contains all names of the streams.
|
||||
* If the list contains two equal names, it will be set
|
||||
* an error in the ImporterMsgList.
|
||||
*/
|
||||
std::set<std::string> _stream_names;
|
||||
|
||||
/**
|
||||
* The list contains all names of the prefixes.
|
||||
* If the list contains two equal names, it will be set
|
||||
* an error in the ImporterMsgList.
|
||||
*/
|
||||
std::set<std::string> _prefix_names;
|
||||
|
||||
/**
|
||||
* The list contains all names of the unit names.
|
||||
* If the list contains two equal names, it will be set
|
||||
* an error in the ImporterMsgList.
|
||||
*/
|
||||
std::set<std::string> _unit_names;
|
||||
|
||||
DDLVersion _version;
|
||||
|
||||
WarningLevel _warning_level;
|
||||
|
||||
/*
|
||||
* Boolean to know if a file contains a dynamic array
|
||||
*/
|
||||
bool _has_dynamic_arrays;
|
||||
/*
|
||||
* Boolean to know if a structure contains a dynamic array
|
||||
*/
|
||||
bool _has_struct_dynamic_arrays;
|
||||
|
||||
struct StructInfo
|
||||
{
|
||||
unsigned int size;
|
||||
unsigned int last_byte_pos_real;
|
||||
unsigned int last_byte_pos;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
std::map<const DDLComplex*, StructInfo> _struct_infos;
|
||||
};
|
||||
}
|
||||
#endif // DDL_INSPECTOR_H_INCLUDED
|
||||
|
107
ddlrepresentation/ddlprefix.cpp
Normal file
107
ddlrepresentation/ddlprefix.cpp
Normal file
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlprefix.h"
|
||||
#include <ddl.h>
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
DDLPrefix::DDLPrefix() :
|
||||
_name{},
|
||||
_symbol{},
|
||||
_power{},
|
||||
_init_flag{},
|
||||
_level{1}
|
||||
{
|
||||
}
|
||||
|
||||
DDLPrefix::DDLPrefix(const std::string& name, const std::string& symbol,
|
||||
int const power, int const creation_level) :
|
||||
_name(name), _symbol(symbol), _power(power),
|
||||
_init_flag(true), _level(creation_level)
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrefix::accept(IDDLVisitor *visitor) const
|
||||
{
|
||||
return visitor->visit(this);
|
||||
}
|
||||
a_util::result::Result DDLPrefix::accept(IDDLChangeVisitor *visitor)
|
||||
{
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLPrefix::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLPrefix::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
bool DDLPrefix::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrefix::create(const std::string& name, const std::string& symbol,
|
||||
int const power, int const creation_level)
|
||||
{
|
||||
_name = name;
|
||||
_symbol = symbol;
|
||||
_power = power;
|
||||
_init_flag = true;
|
||||
_level = creation_level;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
std::string DDLPrefix::getSymbol() const
|
||||
{
|
||||
return _symbol;
|
||||
}
|
||||
|
||||
void DDLPrefix::setSymbol(const std::string& symbol)
|
||||
{
|
||||
_symbol = symbol;
|
||||
}
|
||||
|
||||
|
||||
int DDLPrefix::getPower() const
|
||||
{
|
||||
return _power;
|
||||
}
|
||||
|
||||
void DDLPrefix::setPower(int const power)
|
||||
{
|
||||
_power = power;
|
||||
}
|
||||
|
||||
bool DDLPrefix::isPredefined() const
|
||||
{
|
||||
return -1 == _level; // cMediaManager::DL_AlwaysThere
|
||||
}
|
||||
|
||||
int DDLPrefix::getCreationLevel() const
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
} // namespace ddl
|
119
ddlrepresentation/ddlprefix.h
Normal file
119
ddlrepresentation/ddlprefix.h
Normal file
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLPREFIX_H_INCLUDED
|
||||
#define DDLPREFIX_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_type.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
/**
|
||||
* Representation of a prefix in a DDL description.
|
||||
*/
|
||||
class DDLPrefix : public DDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLPrefix();
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] name - Name of the prefix
|
||||
* @param[in] symbol - Represents the short symbol (e.g. "k")
|
||||
* @param[in] power - Power of the prefix
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
*/
|
||||
DDLPrefix(const std::string& name,
|
||||
const std::string& symbol,
|
||||
int const power,
|
||||
int const creation_level = 1);
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isPredefined() const;
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] name - Name of the prefix
|
||||
* @param[in] symbol - Represents the short symbol (e.g. "k")
|
||||
* @param[in] power - Power of the prefix
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
*/
|
||||
a_util::result::Result create(const std::string& name,
|
||||
const std::string& symbol,
|
||||
int const power,
|
||||
int const creation_level = 1);
|
||||
|
||||
/**
|
||||
* Getter for the name
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the name
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
|
||||
/**
|
||||
* Getter for the symbol
|
||||
* @return the symbol
|
||||
*/
|
||||
std::string getSymbol() const;
|
||||
|
||||
/**
|
||||
* Setter for the symbol
|
||||
*/
|
||||
void setSymbol(const std::string& symbol);
|
||||
|
||||
/**
|
||||
* Getter for the power
|
||||
* @return the power
|
||||
*/
|
||||
int getPower() const;
|
||||
|
||||
/**
|
||||
* Setter for the power
|
||||
*/
|
||||
void setPower(int const power);
|
||||
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
std::string _symbol;
|
||||
int _power;
|
||||
|
||||
bool _init_flag;
|
||||
int _level;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // _PREFIX_H_INCLUDED_
|
631
ddlrepresentation/ddlprinter.cpp
Normal file
631
ddlrepresentation/ddlprinter.cpp
Normal file
|
@ -0,0 +1,631 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlprinter.h"
|
||||
#include "a_util/result/error_def.h"
|
||||
#include "legacy_error_macros.h"
|
||||
|
||||
#include "ddlcontainer.h"
|
||||
|
||||
#include "ddldescription.h"
|
||||
#include "ddlunit.h"
|
||||
#include "ddlbaseunit.h"
|
||||
#include "ddlprefix.h"
|
||||
#include "ddldatatype.h"
|
||||
#include "ddlenum.h"
|
||||
#include "ddlcomplex.h"
|
||||
#include "ddlstream.h"
|
||||
#include "ddlstreammetatype.h"
|
||||
#include "ddlheader.h"
|
||||
#include "ddlextdeclaration.h"
|
||||
#include "ddlrefunit.h"
|
||||
#include "ddlelement.h"
|
||||
#include "ddlstreamstruct.h"
|
||||
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-16, ERR_NOT_IMPL)
|
||||
_MAKE_RESULT(-20, ERR_NOT_FOUND)
|
||||
_MAKE_RESULT(-38, ERR_FAILED)
|
||||
_MAKE_RESULT(-44, ERR_INVALID_VERSION)
|
||||
|
||||
DDLPrinter::DDLPrinter(const bool& full_out):
|
||||
_dom{},
|
||||
_version(DDLVersion::ddl_version_invalid),
|
||||
_full_out{full_out},
|
||||
_last_path{},
|
||||
_forced_version(DDLVersion::ddl_version_invalid)
|
||||
{
|
||||
#if defined(WIN32) && _MSC_VER < 1900
|
||||
_set_output_format(_TWO_DIGIT_EXPONENT);
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
template<typename T, typename V>
|
||||
a_util::result::Result AcceptAll(DDLContainer<T>& oElems, V* pVisitor)
|
||||
{
|
||||
for (typename DDLContainer<T>::iterator itElem = oElems.begin();
|
||||
itElem != oElems.end(); ++itElem)
|
||||
{
|
||||
RETURN_IF_FAILED((*itElem)->accept(pVisitor));
|
||||
}
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visitDDL(const DDLDescription* poDescription)
|
||||
{
|
||||
if (!poDescription) { return ERR_POINTER; }
|
||||
_dom.reset();
|
||||
_dom.fromString("<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"no\"?>\n \
|
||||
<adtf:ddl xmlns:adtf=\"adtf\"> \n \
|
||||
</adtf:ddl>");
|
||||
RETURN_IF_FAILED(poDescription->getHeader()->accept(this));
|
||||
|
||||
_dom.getRoot().createChild("units");
|
||||
|
||||
DDLContainer<DDLBaseunit> vecDDLBaseunits = poDescription->getBaseunits();
|
||||
RETURN_IF_FAILED(AcceptAll(vecDDLBaseunits, this));
|
||||
|
||||
DDLContainer<DDLPrefix> vecDDLPrefixes = poDescription->getPrefixes();
|
||||
RETURN_IF_FAILED(AcceptAll(vecDDLPrefixes, this));
|
||||
|
||||
DDLContainer<DDLUnit> vecDDLUnits = poDescription->getUnits();
|
||||
RETURN_IF_FAILED(AcceptAll(vecDDLUnits, this));
|
||||
|
||||
_dom.getRoot().createChild("datatypes");
|
||||
|
||||
DDLContainer<DDLDataType> vecDDLDataTypes = poDescription->getDatatypes();
|
||||
RETURN_IF_FAILED(AcceptAll(vecDDLDataTypes, this));
|
||||
|
||||
_dom.getRoot().createChild("enums");
|
||||
|
||||
DDLContainer<DDLEnum> vecDDLEnums = poDescription->getEnums();
|
||||
RETURN_IF_FAILED(AcceptAll(vecDDLEnums, this));
|
||||
|
||||
_dom.getRoot().createChild("structs");
|
||||
|
||||
DDLContainer<DDLComplex> vecStructs = poDescription->getStructs();
|
||||
RETURN_IF_FAILED(AcceptAll(vecStructs, this));
|
||||
|
||||
_dom.getRoot().createChild("streams");
|
||||
|
||||
DDLContainer<DDLStream> vecStreams = poDescription->getStreams();
|
||||
RETURN_IF_FAILED(AcceptAll(vecStreams, this));
|
||||
|
||||
if (poDescription->getHeader()->getLanguageVersion() >= DDLVersion::ddl_version_40)
|
||||
{
|
||||
_dom.getRoot().createChild("streammetatypes");
|
||||
|
||||
DDLContainer<DDLStreamMetaType> vecStreamMetaTypes = poDescription->getStreamMetaTypes();
|
||||
RETURN_IF_FAILED(AcceptAll(vecStreamMetaTypes, this));
|
||||
}
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLHeader* poHeader)
|
||||
{
|
||||
if (!poHeader) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oHeaderElem = _dom.getRoot().createChild("header");
|
||||
a_util::xml::DOMElement oLangElem = oHeaderElem.createChild("language_version");
|
||||
if (_forced_version == DDLVersion::ddl_version_invalid)
|
||||
{
|
||||
_version = poHeader->getLanguageVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
_version = _forced_version;
|
||||
}
|
||||
oLangElem.setData(_version.toString());
|
||||
a_util::xml::DOMElement oAutElem = oHeaderElem.createChild("author");
|
||||
oAutElem.setData(poHeader->getAuthor());
|
||||
a_util::xml::DOMElement oDateElem = oHeaderElem.createChild("date_creation");
|
||||
a_util::datetime::Date sDateTmp = poHeader->getDateCreation();
|
||||
oDateElem.setData(sDateTmp.format("%d.%m.%Y"));
|
||||
a_util::xml::DOMElement oChangeElem = oHeaderElem.createChild("date_change");
|
||||
sDateTmp = poHeader->getDateChange();
|
||||
oChangeElem.setData(sDateTmp.format("%d.%m.%Y"));
|
||||
a_util::xml::DOMElement oDescElem = oHeaderElem.createChild("description");
|
||||
oDescElem.setData(poHeader->getDescription());
|
||||
DDLExtDeclarationVec vecExtDecls = poHeader->getExtDeclarations();
|
||||
for (DDLExtDeclarationIt itED = vecExtDecls.begin();
|
||||
vecExtDecls.end() != itED; ++itED)
|
||||
{
|
||||
RETURN_IF_FAILED((*itED)->accept(this));
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLExtDeclaration* poExtDeclaration)
|
||||
{
|
||||
if (!poExtDeclaration) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oHeader;
|
||||
if (!_dom.getRoot().findNode("header", oHeader))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oEDElement = oHeader.createChild("ext_declaration");
|
||||
oEDElement.setAttribute("key", poExtDeclaration->getKey());
|
||||
oEDElement.setAttribute("value", poExtDeclaration->getValue());
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLBaseunit* poBaseunit)
|
||||
{
|
||||
if (!poBaseunit) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oUnits;
|
||||
if (!_dom.getRoot().findNode("units", oUnits))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oBUElement = oUnits.createChild("baseunit");
|
||||
oBUElement.setAttribute("name", poBaseunit->getName());
|
||||
oBUElement.setAttribute("symbol", poBaseunit->getSymbol());
|
||||
oBUElement.setAttribute("description", poBaseunit->getDescription());
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLPrefix* poPrefix)
|
||||
{
|
||||
if (!poPrefix) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oUnits;
|
||||
if (!_dom.getRoot().findNode("units", oUnits))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oPrefixElement = oUnits.createChild("prefixes");
|
||||
oPrefixElement.setAttribute("name", poPrefix->getName());
|
||||
oPrefixElement.setAttribute("symbol", poPrefix->getSymbol());
|
||||
oPrefixElement.setAttribute("power",
|
||||
a_util::strings::toString((int32_t)poPrefix->getPower()));
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLUnit* poUnit)
|
||||
{
|
||||
if (!poUnit) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oUnits;
|
||||
if (!_dom.getRoot().findNode("units", oUnits))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oUnitElement = oUnits.createChild("unit");
|
||||
oUnitElement.setAttribute("name", poUnit->getName());
|
||||
a_util::xml::DOMElement oTmpElement = oUnitElement.createChild("numerator");
|
||||
oTmpElement.setData(poUnit->getNumerator());
|
||||
oTmpElement = oUnitElement.createChild("denominator");
|
||||
oTmpElement.setData(poUnit->getDenominator());
|
||||
oTmpElement = oUnitElement.createChild("offset");
|
||||
oTmpElement.setData(a_util::strings::toString(static_cast<double>
|
||||
(poUnit->getOffset())));
|
||||
std::vector<DDLRefUnit*> vecDDLRefUnits = poUnit->getRefUnits();
|
||||
_last_path = a_util::strings::format("%s[@name='%s']",
|
||||
oUnitElement.getPath().c_str(),
|
||||
oUnitElement.getAttribute("name").c_str());
|
||||
for (size_t i = 0; i < vecDDLRefUnits.size(); i++)
|
||||
{
|
||||
RETURN_IF_FAILED(vecDDLRefUnits[i]->accept(this));
|
||||
}
|
||||
_last_path.clear();
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLRefUnit* poRefUnit)
|
||||
{
|
||||
if (!poRefUnit) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oParent;
|
||||
if (!_dom.findNode(_last_path, oParent))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oRUElement = oParent.createChild("refUnit");
|
||||
oRUElement.setAttribute("name", poRefUnit->getName());
|
||||
oRUElement.setAttribute("power",
|
||||
a_util::strings::toString((int32_t)poRefUnit->getPower()));
|
||||
oRUElement.setAttribute("prefix", poRefUnit->getPrefix());
|
||||
if (_full_out)
|
||||
{
|
||||
a_util::xml::DOMElement oElem;
|
||||
if (!_dom.findNode(a_util::strings::format("//units/prefixes[@name=\"%s\"]", poRefUnit->getPrefix().c_str()), oElem))
|
||||
{
|
||||
RETURN_IF_FAILED(poRefUnit->getPrefixObject()->accept(this));
|
||||
}
|
||||
if (!_dom.findNode(a_util::strings::format("//units/baseunit[@name=\"%s\"]", poRefUnit->getName().c_str()), oElem))
|
||||
{
|
||||
if (!_dom.findNode(a_util::strings::format("//units/unit[@name=\"%s\"]", poRefUnit->getName().c_str()), oElem))
|
||||
{
|
||||
RETURN_IF_FAILED(poRefUnit->getUnitObject()->accept(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLDataType* poDataType)
|
||||
{
|
||||
if (!poDataType) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oDatatypes;
|
||||
if (!_dom.getRoot().findNode("datatypes", oDatatypes))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oDTElement = oDatatypes.createChild("datatype");
|
||||
if (_version < DDLVersion::ddl_version_11)
|
||||
{
|
||||
oDTElement.setAttribute("type", poDataType->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
oDTElement.setAttribute("name", poDataType->getName());
|
||||
}
|
||||
oDTElement.setAttribute("size",
|
||||
a_util::strings::toString(static_cast<uint32_t>(poDataType->getNumBits())));
|
||||
if (!poDataType->getDescription().empty())
|
||||
{
|
||||
oDTElement.setAttribute("description",
|
||||
poDataType->getDescription());
|
||||
}
|
||||
if(poDataType->getArraysize() > 1)
|
||||
{
|
||||
oDTElement.setAttribute("arraysize",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poDataType->getArraysize())));
|
||||
}
|
||||
if (!poDataType->getUnit().empty())
|
||||
{
|
||||
oDTElement.setAttribute("unit", poDataType->getUnit());
|
||||
}
|
||||
if (_version >= DDLVersion::ddl_version_30)
|
||||
{
|
||||
// min and max values are supported since DDL 3.0
|
||||
if (poDataType->isMinValid())
|
||||
{
|
||||
oDTElement.setAttribute("min", poDataType->getMinValue());
|
||||
}
|
||||
if (poDataType->isMaxValid())
|
||||
{
|
||||
oDTElement.setAttribute("max", poDataType->getMaxValue());
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLComplex* poStruct)
|
||||
{
|
||||
if (!poStruct) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oStructs;
|
||||
if (_dom.findNode(a_util::strings::format("//structs/struct[@name=\"%s\"]", poStruct->getName().c_str()), oStructs))
|
||||
{
|
||||
//already added
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
if (!_dom.getRoot().findNode("structs", oStructs))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oStructElement = oStructs.createChild("struct");
|
||||
oStructElement.setAttribute("name", poStruct->getName());
|
||||
oStructElement.setAttribute("version",
|
||||
a_util::strings::toString(static_cast<uint32_t>(poStruct->getVersion())));
|
||||
if (!poStruct->getComment().empty())
|
||||
{
|
||||
oStructElement.setAttribute("comment", poStruct->getComment());
|
||||
}
|
||||
if (_version >= DDLVersion::ddl_version_11)
|
||||
{
|
||||
oStructElement.setAttribute("alignment",
|
||||
DDLAlignment::toString(poStruct->getAlignment()));
|
||||
}
|
||||
if (_version != poStruct->getDDLVersion())
|
||||
{
|
||||
oStructElement.setAttribute("ddlversion", poStruct->getDDLVersion().toString());
|
||||
}
|
||||
|
||||
std::vector<DDLElement*> vecDDLElements = poStruct->getElements();
|
||||
for (size_t i = 0; i < vecDDLElements.size(); i++)
|
||||
{
|
||||
_last_path = a_util::strings::format("%s[@name='%s']",
|
||||
oStructElement.getPath().c_str(), poStruct->getName().c_str());
|
||||
RETURN_IF_FAILED(vecDDLElements[i]->accept(this));
|
||||
}
|
||||
_last_path.clear();
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLElement* poElement)
|
||||
{
|
||||
if (!poElement) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oParent;
|
||||
a_util::xml::DOMElement oDomElem;
|
||||
if (!_dom.findNode(_last_path, oParent))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oElem = oParent.createChild("element");
|
||||
oElem.setAttribute("type", poElement->getType());
|
||||
oElem.setAttribute("name", poElement->getName());
|
||||
|
||||
if (_full_out)
|
||||
{
|
||||
if (!_dom.findNode(a_util::strings::format("//structs/struct[@name=\"%s\"]", poElement->getType().c_str()), oDomElem))
|
||||
{
|
||||
if (!_dom.findNode(a_util::strings::format("//datatypes/datatype[@name=\"%s\"]", poElement->getType().c_str()), oDomElem))
|
||||
{
|
||||
if (!_dom.findNode(a_util::strings::format("//enums/enum[@name=\"%s\"]", poElement->getType().c_str()), oDomElem))
|
||||
{
|
||||
RETURN_IF_FAILED(poElement->getTypeObject()->accept(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a_util::xml::DOMElement oDeserializedElement = oElem;
|
||||
a_util::xml::DOMElement oSerializedElement = oElem;
|
||||
if (_version >= DDLVersion::ddl_version_40)
|
||||
{
|
||||
oDeserializedElement = oElem.createChild("deserialized");
|
||||
oSerializedElement = oElem.createChild("serialized");
|
||||
}
|
||||
oSerializedElement.setAttribute("bytepos",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poElement->getBytepos())));
|
||||
if ((_version < DDLVersion::ddl_version_11 && poElement->getBitpos() != 1) ||
|
||||
(_version >= DDLVersion::ddl_version_11 && poElement->getBitpos() > 0))
|
||||
{
|
||||
oSerializedElement.setAttribute("bitpos",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poElement->getBitpos())));
|
||||
}
|
||||
if (poElement->getNumBits() > 0)
|
||||
{
|
||||
oSerializedElement.setAttribute("numbits",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poElement->getNumBits())));
|
||||
}
|
||||
oSerializedElement.setAttribute("byteorder",
|
||||
DDLByteorder::toString(poElement->getByteorder()));
|
||||
oDeserializedElement.setAttribute("alignment",
|
||||
DDLAlignment::toString(poElement->getAlignment()));
|
||||
|
||||
if (!poElement->getDescription().empty())
|
||||
{
|
||||
oElem.setAttribute("description", poElement->getDescription());
|
||||
}
|
||||
if(poElement->getArraysize() == 0 || !poElement->getArraySizeSource().empty())
|
||||
{
|
||||
oElem.setAttribute("arraysize", poElement->getArraySizeSource());
|
||||
}
|
||||
else
|
||||
{
|
||||
oElem.setAttribute("arraysize",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poElement->getArraysize())));
|
||||
}
|
||||
|
||||
if (!poElement->getUnit().empty())
|
||||
{
|
||||
oElem.setAttribute("unit", poElement->getUnit());
|
||||
}
|
||||
|
||||
if (!poElement->getComment().empty())
|
||||
{
|
||||
oElem.setAttribute("comment", poElement->getComment());
|
||||
}
|
||||
|
||||
if (!poElement->getConstantValue().empty())
|
||||
{
|
||||
oElem.setAttribute("value", poElement->getConstantValue());
|
||||
}
|
||||
|
||||
if (_version >= DDLVersion::ddl_version_30)
|
||||
{
|
||||
// min, max, default, scale, and offset values are supported since DDL 3.0
|
||||
if (poElement->isMinValid())
|
||||
{
|
||||
oElem.setAttribute("min", poElement->getMinValue());
|
||||
}
|
||||
|
||||
if (poElement->isMaxValid())
|
||||
{
|
||||
oElem.setAttribute("max", poElement->getMaxValue());
|
||||
}
|
||||
|
||||
if (poElement->isDefaultValid())
|
||||
{
|
||||
oElem.setAttribute("default", poElement->getDefaultValue());
|
||||
}
|
||||
|
||||
if (poElement->isScaleValid())
|
||||
{
|
||||
oElem.setAttribute("scale", poElement->getScaleValue());
|
||||
}
|
||||
|
||||
if (poElement->isOffsetValid())
|
||||
{
|
||||
oElem.setAttribute("offset", poElement->getOffsetValue());
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLStream* poStream)
|
||||
{
|
||||
if (!poStream) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oStreams;
|
||||
if (!_dom.getRoot().findNode("streams", oStreams))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oStreamElement = oStreams.createChild("stream");
|
||||
if (!poStream->getName().empty())
|
||||
{
|
||||
oStreamElement.setAttribute("name", poStream->getName());
|
||||
}
|
||||
oStreamElement.setAttribute("type", poStream->getType());
|
||||
if (_full_out)
|
||||
{
|
||||
a_util::xml::DOMElement oElem;
|
||||
if (!_dom.findNode(a_util::strings::format("//structs/struct[@name=\"%s\"]", poStream->getType().c_str()), oElem))
|
||||
{
|
||||
RETURN_IF_FAILED(poStream->getTypeObject()->accept(this));
|
||||
}
|
||||
}
|
||||
if (!poStream->getDescription().empty())
|
||||
{
|
||||
oStreamElement.setAttribute("description",
|
||||
poStream->getDescription());
|
||||
}
|
||||
std::vector<DDLStreamStruct*> vecStructs = poStream->getStructs();
|
||||
_last_path = a_util::strings::format("%s[@name='%s']",
|
||||
oStreamElement.getPath().c_str(),
|
||||
oStreamElement.getAttribute("name").c_str());
|
||||
for (size_t i = 0; i < vecStructs.size(); i++)
|
||||
{
|
||||
RETURN_IF_FAILED(vecStructs[i]->accept(this));
|
||||
}
|
||||
_last_path.clear();
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLStreamStruct* poStreamStruct)
|
||||
{
|
||||
if (!poStreamStruct) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oParent;
|
||||
if (!_dom.findNode(_last_path, oParent))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oStruct = oParent.createChild("struct");
|
||||
oStruct.setAttribute("type", poStreamStruct->getType());
|
||||
if (!poStreamStruct->getName().empty())
|
||||
{
|
||||
oStruct.setAttribute("name", poStreamStruct->getName());
|
||||
}
|
||||
if (_full_out)
|
||||
{
|
||||
a_util::xml::DOMElement oElem;
|
||||
if (!_dom.findNode(a_util::strings::format("//structs/struct[@name=\"%s\"]", poStreamStruct->getType().c_str()), oElem))
|
||||
{
|
||||
RETURN_IF_FAILED(poStreamStruct->getTypeObject()->accept(this));
|
||||
}
|
||||
}
|
||||
oStruct.setAttribute("bytepos",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poStreamStruct->getBytepos())));
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLEnum* poEnum )
|
||||
{
|
||||
if (!poEnum) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oEnums;
|
||||
if (_dom.findNode(a_util::strings::format("//enums/enum[@name=\"%s\"]", poEnum->getName().c_str()), oEnums))
|
||||
{
|
||||
//already added
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
if (!_dom.getRoot().findNode("enums", oEnums))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oEnumElement = oEnums.createChild("enum");
|
||||
oEnumElement.setAttribute("name", poEnum->getName());
|
||||
|
||||
if (!poEnum->getType().empty())
|
||||
{
|
||||
oEnumElement.setAttribute("type", poEnum->getType());
|
||||
}
|
||||
|
||||
EnumNameValueVec vecNameValues = poEnum->getValues();
|
||||
for (EnumNameValueVec::iterator itElement = vecNameValues.begin(); itElement != vecNameValues.end(); ++itElement)
|
||||
{
|
||||
a_util::xml::DOMElement oEnumValueElement = oEnumElement.createChild("element");
|
||||
|
||||
oEnumValueElement.setAttribute("name", itElement->first);
|
||||
oEnumValueElement.setAttribute("value", itElement->second);
|
||||
}
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLStreamMetaType* poStreamMetaType)
|
||||
{
|
||||
a_util::xml::DOMElement oStreamMetaTypes;
|
||||
if (!_dom.getRoot().findNode("streammetatypes", oStreamMetaTypes))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oElement = oStreamMetaTypes.createChild("streammetatype");
|
||||
oElement.setAttribute("name", poStreamMetaType->getName());
|
||||
oElement.setAttribute("version", poStreamMetaType->getVersion());
|
||||
if (poStreamMetaType->getParentObject())
|
||||
{
|
||||
oElement.setAttribute("parent", poStreamMetaType->getParent());
|
||||
}
|
||||
|
||||
const DDLPropertyVec& vecProperties = poStreamMetaType->getProperties();
|
||||
for (DDLPropertyVec::const_iterator it = vecProperties.cbegin(); it != vecProperties.cend(); ++it)
|
||||
{
|
||||
a_util::xml::DOMElement oPropertyNode = oElement.createChild("property");
|
||||
oPropertyNode.setAttribute("name", (*it)->getName());
|
||||
oPropertyNode.setAttribute("type", (*it)->getType());
|
||||
}
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::visit(const DDLProperty* poProperty)
|
||||
{
|
||||
return ERR_NOT_IMPL;
|
||||
}
|
||||
|
||||
std::string DDLPrinter::getXML() const
|
||||
{
|
||||
return std::string(_dom.toString());
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::toFile(const std::string& strFilename) const
|
||||
{
|
||||
if (!_dom.save(strFilename))
|
||||
{
|
||||
return ERR_FAILED;
|
||||
}
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLPrinter::forceVersion(const DDLVersion& forced_version)
|
||||
{
|
||||
if (!forced_version.isValidVersion())
|
||||
{
|
||||
return ERR_INVALID_VERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
_forced_version = forced_version;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
}
|
||||
} // namespace ddl
|
94
ddlrepresentation/ddlprinter.h
Normal file
94
ddlrepresentation/ddlprinter.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DDL_PRINTER_H_INCLUDED
|
||||
#define DDL_PRINTER_H_INCLUDED
|
||||
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddldescription.h"
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
/**
|
||||
* Concrete Visitor to collect the data of a DDL in object-representation
|
||||
* and convert it back to XML (string or file).
|
||||
*/
|
||||
class DDLPrinter : public IDDLVisitor
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
DDLPrinter(const bool& full_out=true);
|
||||
|
||||
public:
|
||||
a_util::result::Result visitDDL(const DDLDescription* description);
|
||||
a_util::result::Result visit(const DDLHeader* header);
|
||||
a_util::result::Result visit(const DDLDataType* data_type);
|
||||
a_util::result::Result visit(const DDLComplex* complex);
|
||||
a_util::result::Result visit(const DDLStream* stream);
|
||||
a_util::result::Result visit(const DDLUnit* unit);
|
||||
a_util::result::Result visit(const DDLBaseunit* baseunit);
|
||||
a_util::result::Result visit(const DDLExtDeclaration* ext_declaration);
|
||||
a_util::result::Result visit(const DDLElement* element);
|
||||
a_util::result::Result visit(const DDLPrefix* prefix);
|
||||
a_util::result::Result visit(const DDLRefUnit* ref_unit);
|
||||
a_util::result::Result visit(const DDLStreamStruct* stream_struct);
|
||||
a_util::result::Result visit(const DDLEnum* ddl_enum);
|
||||
a_util::result::Result visit(const DDLStreamMetaType* stream_meta_type);
|
||||
a_util::result::Result visit(const DDLProperty* property);
|
||||
|
||||
/**
|
||||
* Getter for the XML string of the collected DDL information.
|
||||
* @return the XML string containing the DDL description
|
||||
*/
|
||||
std::string getXML() const;
|
||||
|
||||
/**
|
||||
* Saves the collected DDL information as XML to the specified file.
|
||||
* @param[in] filename - Path to file to use
|
||||
* @retval ERR_FAILED Saving process failed
|
||||
*/
|
||||
a_util::result::Result toFile(const std::string& filename) const;
|
||||
|
||||
/**
|
||||
* The method forceVersion makes the printer ignore the DDL language version set in the
|
||||
* header of the description to be printed. To take effect, this method must be called
|
||||
* before calling visitDDL()
|
||||
*
|
||||
* @param [in] forced_version The version the printer use for output.
|
||||
* @returns Standard result code.
|
||||
* @retval a_util::result::SUCCESS Everything went fine
|
||||
* @retval ERR_INVALID_VERSION Unknown version passed.
|
||||
*/
|
||||
a_util::result::Result forceVersion(const DDLVersion& forced_version);
|
||||
|
||||
private: // members
|
||||
a_util::xml::DOM _dom;
|
||||
DDLVersion _version;
|
||||
bool _full_out;
|
||||
std::string _last_path;
|
||||
DDLVersion _forced_version;
|
||||
};
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_PRINTER_H_INCLUDED
|
73
ddlrepresentation/ddlproperty.cpp
Normal file
73
ddlrepresentation/ddlproperty.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlproperty.h"
|
||||
#include <ddl.h>
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLProperty::DDLProperty(const std::string& name, const std::string& type) :
|
||||
_name(name),
|
||||
_type(type),
|
||||
_init_flag{true}
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLProperty::accept(IDDLVisitor *visitor) const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLProperty::accept(IDDLChangeVisitor *visitor)
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return visitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLProperty::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
const std::string& DDLProperty::getType() const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
bool DDLProperty::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
int DDLProperty::getCreationLevel() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace ddl
|
76
ddlrepresentation/ddlproperty.h
Normal file
76
ddlrepresentation/ddlproperty.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_PROPERTY_H_INCLUDED
|
||||
#define DDL_PROPERTY_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddl_type.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Representation of a stream inside a DDL description.
|
||||
*/
|
||||
class DDLProperty : public DDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLProperty() = default;
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] name - Name of the property
|
||||
* @param[in] type - Type of the property
|
||||
*/
|
||||
DDLProperty(const std::string& name, const std::string& type);
|
||||
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Getter for the name.
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Getter for the type.
|
||||
* @return the type
|
||||
*/
|
||||
const std::string& getType() const;
|
||||
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
std::string _type;
|
||||
bool _init_flag;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif
|
130
ddlrepresentation/ddlrefunit.cpp
Normal file
130
ddlrepresentation/ddlrefunit.cpp
Normal file
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlrefunit.h"
|
||||
#include <ddl.h>
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLRefUnit::DDLRefUnit(IDDLUnit* poUnit, int const nPower, DDLPrefix* poPrefix) :
|
||||
_unit{poUnit},
|
||||
_power{nPower},
|
||||
_prefix{poPrefix},
|
||||
_init_flag{(NULL != poUnit) && (NULL != poPrefix)}
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRefUnit::accept(IDDLVisitor *poVisitor) const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRefUnit::accept(IDDLChangeVisitor *poVisitor)
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLRefUnit::getName() const
|
||||
{
|
||||
if (NULL == _unit)
|
||||
{
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return _unit->getName();
|
||||
}
|
||||
|
||||
IDDLUnit * DDLRefUnit::getUnitObject() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _unit;
|
||||
}
|
||||
|
||||
void DDLRefUnit::setUnitObject(IDDLUnit* pUnit)
|
||||
{
|
||||
_unit = pUnit;
|
||||
_init_flag = (NULL != _unit) &&
|
||||
(NULL != _prefix);
|
||||
}
|
||||
|
||||
int DDLRefUnit::getPower() const
|
||||
{
|
||||
return _power;
|
||||
}
|
||||
|
||||
void DDLRefUnit::setPower(int const nPower)
|
||||
{
|
||||
_power = nPower;
|
||||
}
|
||||
|
||||
std::string DDLRefUnit::getPrefix() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return _prefix->getName();
|
||||
}
|
||||
|
||||
DDLPrefix * DDLRefUnit::getPrefixObject() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _prefix;
|
||||
}
|
||||
|
||||
void DDLRefUnit::setPrefixObject(DDLPrefix* pPrefix)
|
||||
{
|
||||
_prefix = pPrefix;
|
||||
_init_flag = (NULL != _unit) &&
|
||||
(NULL != _prefix);
|
||||
}
|
||||
|
||||
|
||||
bool DDLRefUnit::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRefUnit::create(IDDLUnit* poUnit, int const nPower, DDLPrefix* poPrefix)
|
||||
{
|
||||
if (!poUnit || !poPrefix) { return ERR_POINTER; }
|
||||
_unit = poUnit;
|
||||
_power = nPower;
|
||||
_prefix = poPrefix;
|
||||
_init_flag = true;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
} // namespace ddl
|
124
ddlrepresentation/ddlrefunit.h
Normal file
124
ddlrepresentation/ddlrefunit.h
Normal file
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef REF_UNIT_H_INCLUDED
|
||||
#define REF_UNIT_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlunit_intf.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
/**
|
||||
* Decorator class for IDDLUnit objects to be used inside other DDLUnit objects.
|
||||
*/
|
||||
class DDLRefUnit : public DDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLRefUnit() = default;
|
||||
|
||||
/**
|
||||
* CTOR with unit object.
|
||||
* @param[in] unit - Pointer to the unit object
|
||||
* @param[in] power - Power of the new unit related to the base units
|
||||
* @param[in] prefix - Pointer to the prefix object
|
||||
*/
|
||||
DDLRefUnit(IDDLUnit* unit, int const power, DDLPrefix* prefix);
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] unit - Pointer to the unit object
|
||||
* @param[in] power - Power of the new unit related to the base units
|
||||
* @param[in] prefix - Pointer to the prefix object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
*/
|
||||
a_util::result::Result create(IDDLUnit* unit, int const power, DDLPrefix* prefix);
|
||||
|
||||
/**
|
||||
* Getter for the name.
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Getter for the unit object.
|
||||
* @return pointer to the unit object
|
||||
*/
|
||||
IDDLUnit * getUnitObject() const;
|
||||
|
||||
/**
|
||||
* Setter for the unit object.
|
||||
* @param unit the unit object to set
|
||||
* @return void
|
||||
*/
|
||||
void setUnitObject(IDDLUnit* const unit);
|
||||
|
||||
/**
|
||||
* Getter for the power.
|
||||
* @return the power
|
||||
*/
|
||||
int getPower() const;
|
||||
|
||||
/**
|
||||
* Setter for the power.
|
||||
* @param power the power
|
||||
* @return void
|
||||
*/
|
||||
void setPower(int const power);
|
||||
|
||||
/**
|
||||
* Getter for the prefix name.
|
||||
* @return the prefix name
|
||||
*/
|
||||
std::string getPrefix() const;
|
||||
|
||||
/**
|
||||
* Getter for the prefix object.
|
||||
* @return pointer to the prefix object
|
||||
*/
|
||||
DDLPrefix * getPrefixObject() const;
|
||||
|
||||
/**
|
||||
* Setter for the prefix object.
|
||||
* @param prefix pointer to the prefix object
|
||||
* @return void
|
||||
*/
|
||||
void setPrefixObject(DDLPrefix* const prefix);
|
||||
|
||||
private:
|
||||
IDDLUnit *_unit;
|
||||
int _power;
|
||||
DDLPrefix *_prefix;
|
||||
bool _init_flag;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // REF_UNIT_H_INCLUDED
|
359
ddlrepresentation/ddlrepair.cpp
Normal file
359
ddlrepresentation/ddlrepair.cpp
Normal file
|
@ -0,0 +1,359 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlrepair.h"
|
||||
#include "a_util/result/error_def.h"
|
||||
#include "legacy_error_macros.h"
|
||||
|
||||
#include "ddlcontainer.h"
|
||||
#include "ddldescription.h"
|
||||
#include "ddlunit.h"
|
||||
#include "ddlbaseunit.h"
|
||||
#include "ddlprefix.h"
|
||||
#include "ddldatatype.h"
|
||||
#include "ddlenum.h"
|
||||
#include "ddlcomplex.h"
|
||||
#include "ddlstream.h"
|
||||
#include "ddlstreammetatype.h"
|
||||
#include "ddlheader.h"
|
||||
#include "ddlextdeclaration.h"
|
||||
#include "ddlrefunit.h"
|
||||
#include "ddlelement.h"
|
||||
#include "ddlstreamstruct.h"
|
||||
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-8, ERR_INVALID_HANDLE)
|
||||
_MAKE_RESULT(-16, ERR_NOT_IMPL)
|
||||
|
||||
a_util::result::Result DDLRepair::visitDDL(DDLDescription* poDescription)
|
||||
{
|
||||
if (!poDescription) { return ERR_POINTER; }
|
||||
|
||||
_ref_ddl = poDescription;
|
||||
|
||||
DDLStreamVec vecStreams = poDescription->getStreams();
|
||||
for (DDLStreamIt itStream = vecStreams.begin();
|
||||
vecStreams.end() != itStream; )
|
||||
{
|
||||
if (isFailed((*itStream)->accept(this)))
|
||||
{
|
||||
_ref_ddl->removeStream((*itStream)->getName());
|
||||
vecStreams = poDescription->getStreams();
|
||||
itStream = vecStreams.begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
++itStream;
|
||||
}
|
||||
}
|
||||
|
||||
DDLUnitVec vecDDLUnits = poDescription->getUnits();
|
||||
for (DDLUnitIt itUnit = vecDDLUnits.begin(); vecDDLUnits.end() != itUnit;
|
||||
++itUnit)
|
||||
{
|
||||
RETURN_IF_FAILED((*itUnit)->accept(this));
|
||||
}
|
||||
|
||||
DDLComplexVec vecStructs = poDescription->getStructs();
|
||||
for (DDLComplexIt itStruct = vecStructs.begin();
|
||||
vecStructs.end() != itStruct; ++itStruct)
|
||||
{
|
||||
RETURN_IF_FAILED((*itStruct)->accept(this));
|
||||
}
|
||||
|
||||
DDLEnumVec vecEnums = poDescription->getEnums();
|
||||
for (DDLEnumIt itEnum = vecEnums.begin(); vecEnums.end() != itEnum; ++itEnum)
|
||||
{
|
||||
RETURN_IF_FAILED((*itEnum)->accept(this));
|
||||
}
|
||||
|
||||
|
||||
DDLDTVec vecDTs = poDescription->getDatatypes();
|
||||
for (DDLDTIt itDT = vecDTs.begin(); vecDTs.end() != itDT; ++itDT)
|
||||
{
|
||||
RETURN_IF_FAILED((*itDT)->accept(this));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// All representation objects are valid.
|
||||
_ref_ddl = NULL;
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLHeader* poHeader)
|
||||
{
|
||||
// Nothing to resolve/validate
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLExtDeclaration* poExtDeclaration)
|
||||
{
|
||||
// Nothing to resolve/validate
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLBaseunit* poBaseunit)
|
||||
{
|
||||
// Nothing to resolve/validate
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLPrefix* poPrefix)
|
||||
{
|
||||
// Nothing to resolve/validate
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLUnit* poUnit)
|
||||
{
|
||||
if (!poUnit ||! _ref_ddl) { return ERR_POINTER; }
|
||||
DDLRefUnitVec vecRUs = poUnit->getRefUnits();
|
||||
for (DDLRefUnitIt itRU = vecRUs.begin(); vecRUs.end() != itRU; )
|
||||
{
|
||||
if (isFailed((*itRU)->accept(this)))
|
||||
{
|
||||
poUnit->removeRefUnit((*itRU)->getName());
|
||||
vecRUs = poUnit->getRefUnits();
|
||||
itRU = vecRUs.begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
++itRU;
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLRefUnit* poRefUnit)
|
||||
{
|
||||
if (!poRefUnit || !_ref_ddl) { return ERR_POINTER; }
|
||||
IDDLUnit * poUnit = _ref_ddl->getBaseunitByName(poRefUnit->getName());
|
||||
if (NULL == poUnit)
|
||||
{
|
||||
poUnit = _ref_ddl->getUnitByName(poRefUnit->getName());
|
||||
if (NULL == poUnit)
|
||||
{
|
||||
return ERR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
poRefUnit->setUnitObject(poUnit);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
poRefUnit->setUnitObject(poUnit);
|
||||
}
|
||||
DDLPrefix * poPrefix = _ref_ddl->getPrefixByName(poRefUnit->getPrefix());
|
||||
if (NULL == poPrefix)
|
||||
{
|
||||
return ERR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
poRefUnit->setPrefixObject(poPrefix);
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLDataType* poDataType)
|
||||
{
|
||||
if (!poDataType || !_ref_ddl) { return ERR_POINTER; }
|
||||
std::string strUnit = poDataType->getUnit();
|
||||
if (!strUnit.empty())
|
||||
{
|
||||
IDDLUnit * poUnit = _ref_ddl->getBaseunitByName(strUnit);
|
||||
if (NULL == poUnit)
|
||||
{
|
||||
poUnit = _ref_ddl->getUnitByName(strUnit);
|
||||
if (NULL == poUnit)
|
||||
{
|
||||
poDataType->setUnit(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
poDataType->setUnit(poUnit);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
poDataType->setUnit(poUnit);
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLComplex* poComplex)
|
||||
{
|
||||
if (!poComplex) { return ERR_POINTER; }
|
||||
if (!_ref_ddl) { return ERR_POINTER; }
|
||||
DDLElementVec vecDDLElements = poComplex->getElements();
|
||||
for (DDLElementIt itElem = vecDDLElements.begin();
|
||||
vecDDLElements.end() != itElem; )
|
||||
{
|
||||
if (isFailed(((*itElem)->accept(this))))
|
||||
{
|
||||
poComplex->removeElement((*itElem)->getName());
|
||||
vecDDLElements = poComplex->getElements();
|
||||
itElem = vecDDLElements.begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
++itElem;
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLElement* poElement)
|
||||
{
|
||||
if (!poElement || !_ref_ddl) { return ERR_POINTER; }
|
||||
IDDLDataType * poDT = _ref_ddl->getDataTypeByName(poElement->getType());
|
||||
if (NULL == poDT)
|
||||
{
|
||||
poDT = _ref_ddl->getStructByName(poElement->getType());
|
||||
if (NULL == poDT)
|
||||
{
|
||||
poDT = _ref_ddl->getEnumByName(poElement->getType());
|
||||
if (NULL == poDT)
|
||||
{
|
||||
return ERR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
poElement->setType(poDT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
poElement->setType(poDT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
poElement->setType(poDT);
|
||||
}
|
||||
std::string strUnit = poElement->getUnit();
|
||||
if (!strUnit.empty())
|
||||
{
|
||||
IDDLUnit * poUnit = _ref_ddl->getBaseunitByName(strUnit);
|
||||
if (NULL == poUnit)
|
||||
{
|
||||
poUnit = _ref_ddl->getUnitByName(strUnit);
|
||||
if (NULL == poUnit)
|
||||
{
|
||||
poElement->setUnit(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
poElement->setUnit(poUnit);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
poElement->setUnit(poUnit);
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLStream* poStream)
|
||||
{
|
||||
if (!poStream || !_ref_ddl) { return ERR_POINTER; }
|
||||
IDDLDataType * poDT = _ref_ddl->getDataTypeByName(poStream->getType());
|
||||
if (NULL == poDT)
|
||||
{
|
||||
DDLComplex* poDTComp = _ref_ddl->getStructByName(poStream->getType());
|
||||
if (NULL == poDTComp)
|
||||
{
|
||||
return ERR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
poStream->setType(poDTComp);
|
||||
}
|
||||
}
|
||||
DDLStreamStructVec vecStrmStructs = poStream->getStructs();
|
||||
for (DDLStreamStructIt itStrmStruct = vecStrmStructs.begin();
|
||||
vecStrmStructs.end() != itStrmStruct; )
|
||||
{
|
||||
if (isFailed((*itStrmStruct)->accept(this)))
|
||||
{
|
||||
poStream->removeStruct((*itStrmStruct)->getName());
|
||||
vecStrmStructs = poStream->getStructs();
|
||||
itStrmStruct = vecStrmStructs.begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
++itStrmStruct;
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLStreamStruct* poStreamStruct)
|
||||
{
|
||||
if (!poStreamStruct || !_ref_ddl) { return ERR_POINTER; }
|
||||
IDDLDataType * poDT = _ref_ddl->getDataTypeByName(poStreamStruct->getType());
|
||||
if (NULL == poDT)
|
||||
{
|
||||
DDLComplex* poDTComp = _ref_ddl->getStructByName(poStreamStruct->getType());
|
||||
if (NULL == poDTComp)
|
||||
{
|
||||
return ERR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
poStreamStruct->setType(poDTComp);
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLEnum* poEnum )
|
||||
{
|
||||
if (!poEnum || !_ref_ddl) { return ERR_POINTER; }
|
||||
IDDLDataType * poDT = _ref_ddl->getDataTypeByName(poEnum->getType());
|
||||
if (NULL == poDT)
|
||||
{
|
||||
poEnum->setType(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
poEnum->setType(poDT);
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLStreamMetaType* poStreamMetaType)
|
||||
{
|
||||
return ERR_NOT_IMPL;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLRepair::visit(DDLProperty* poProperty)
|
||||
{
|
||||
return ERR_NOT_IMPL;
|
||||
}
|
||||
} // namespace ddl
|
57
ddlrepresentation/ddlrepair.h
Normal file
57
ddlrepresentation/ddlrepair.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_REPAIR_H_INCLUDED
|
||||
#define DDL_REPAIR_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Implementation of IDDLVisitor that will repair and update references after deleting.
|
||||
* I.e.: Deleting a Unit the DDLRepair will search for this unit within the elements of structs and resets the unit if set.
|
||||
*/
|
||||
class DDLRepair : public IDDLChangeVisitor
|
||||
{
|
||||
public:
|
||||
a_util::result::Result visitDDL(DDLDescription* description);
|
||||
a_util::result::Result visit(DDLHeader* header);
|
||||
a_util::result::Result visit(DDLDataType* data_type);
|
||||
a_util::result::Result visit(DDLComplex* complex);
|
||||
a_util::result::Result visit(DDLStream* stream);
|
||||
a_util::result::Result visit(DDLUnit* unit);
|
||||
a_util::result::Result visit(DDLBaseunit* baseunit);
|
||||
a_util::result::Result visit(DDLExtDeclaration* ext_declaration);
|
||||
a_util::result::Result visit(DDLElement* element);
|
||||
a_util::result::Result visit(DDLPrefix* prefix);
|
||||
a_util::result::Result visit(DDLRefUnit* ref_unit);
|
||||
a_util::result::Result visit(DDLStreamStruct* stream_struct);
|
||||
a_util::result::Result visit(DDLEnum* ddl_enum);
|
||||
a_util::result::Result visit(DDLStreamMetaType* stream_meta_type);
|
||||
a_util::result::Result visit(DDLProperty* property);
|
||||
|
||||
private:
|
||||
DDLDescription* _ref_ddl;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_REPAIR_H_INCLUDED
|
571
ddlrepresentation/ddlresolver.cpp
Normal file
571
ddlrepresentation/ddlresolver.cpp
Normal file
|
@ -0,0 +1,571 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlresolver.h"
|
||||
|
||||
#include "a_util/result/error_def.h"
|
||||
#include "legacy_error_macros.h"
|
||||
|
||||
#include "ddldescription.h"
|
||||
#include "ddlunit.h"
|
||||
#include "ddlbaseunit.h"
|
||||
#include "ddlprefix.h"
|
||||
#include "ddldatatype.h"
|
||||
#include "ddlenum.h"
|
||||
#include "ddlcomplex.h"
|
||||
#include "ddlstream.h"
|
||||
#include "ddlstreammetatype.h"
|
||||
#include "ddlheader.h"
|
||||
#include "ddlextdeclaration.h"
|
||||
#include "ddlrefunit.h"
|
||||
#include "ddlelement.h"
|
||||
#include "ddlstreamstruct.h"
|
||||
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-5, ERR_INVALID_ARG)
|
||||
_MAKE_RESULT(-16, ERR_NOT_IMPL)
|
||||
_MAKE_RESULT(-20, ERR_NOT_FOUND)
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLResolver::DDLResolver() :
|
||||
_dom{},
|
||||
_target{},
|
||||
_version(DDLVersion::ddl_version_invalid),
|
||||
_stack_parents{},
|
||||
_resolved_types{},
|
||||
_units{},
|
||||
_data_types{},
|
||||
_enums{},
|
||||
_structs{},
|
||||
_streams{}
|
||||
{
|
||||
#if defined(WIN32) && _MSC_VER < 1900
|
||||
_set_output_format(_TWO_DIGIT_EXPONENT);
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
DDLResolver::DDLResolver(const std::string& strTarget) :
|
||||
DDLResolver()
|
||||
{
|
||||
_target = strTarget;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::createBase(const DDLDescription* poDescription)
|
||||
{
|
||||
_resolved_types.clear();
|
||||
_dom.fromString("<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"no\"?>\n \
|
||||
<adtf:ddl xmlns:adtf=\"adtf\"> \n \
|
||||
</adtf:ddl>");
|
||||
RETURN_IF_FAILED(poDescription->getHeader()->accept(this));
|
||||
|
||||
_units = _dom.getRoot().createChild("units");
|
||||
_data_types = _dom.getRoot().createChild("datatypes");
|
||||
if (_version >= DDLVersion::ddl_version_20)
|
||||
{
|
||||
_enums = _dom.getRoot().createChild("enums");
|
||||
}
|
||||
_structs = _dom.getRoot().createChild("structs");
|
||||
_streams = _dom.getRoot().createChild("streams");
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visitDDL(const DDLDescription* poDescription)
|
||||
{
|
||||
if (!poDescription) { return ERR_POINTER; }
|
||||
if (_target.empty())
|
||||
{
|
||||
// no target specified
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
RETURN_IF_FAILED(createBase(poDescription));
|
||||
|
||||
a_util::result::Result nResult = ERR_NOT_FOUND;
|
||||
|
||||
DDLUnitVec vecDDLUnits = poDescription->getUnits();
|
||||
DDLUnitIt itUnitFound = std::find_if(vecDDLUnits.begin(), vecDDLUnits.end(),
|
||||
DDLCompareFunctor<>(_target));
|
||||
|
||||
if (vecDDLUnits.end() != itUnitFound)
|
||||
{
|
||||
nResult = (*itUnitFound)->accept(this);
|
||||
return nResult;
|
||||
}
|
||||
|
||||
DDLDTVec vecDTs = poDescription->getDatatypes();
|
||||
DDLDTIt itDTFound = std::find_if(vecDTs.begin(), vecDTs.end(), DDLCompareFunctor<>(_target));
|
||||
|
||||
if (itDTFound != vecDTs.end())
|
||||
{
|
||||
// primitive data type
|
||||
nResult = (*itDTFound)->accept(this);
|
||||
return nResult;
|
||||
}
|
||||
|
||||
DDLComplexVec vecStructs = poDescription->getStructs();
|
||||
DDLComplexIt itStructFound = std::find_if(vecStructs.begin(),
|
||||
vecStructs.end(), DDLCompareFunctor<>(_target));
|
||||
|
||||
if (itStructFound != vecStructs.end())
|
||||
{
|
||||
// complex data type
|
||||
nResult = (*itStructFound)->accept(this);
|
||||
return nResult;
|
||||
}
|
||||
|
||||
DDLStreamVec vecStreams = poDescription->getStreams();
|
||||
DDLStreamIt itStreamFound = std::find_if(vecStreams.begin(),
|
||||
vecStreams.end(), DDLCompareFunctor<>(_target));
|
||||
|
||||
if (itStreamFound != vecStreams.end())
|
||||
{
|
||||
// stream
|
||||
nResult = (*itStreamFound)->accept(this);
|
||||
return nResult;
|
||||
}
|
||||
return nResult;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLHeader* poHeader)
|
||||
{
|
||||
if (!poHeader) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oHeaderElement = _dom.getRoot().createChild("header");
|
||||
a_util::xml::DOMElement oTmpElement;
|
||||
oTmpElement = oHeaderElement.createChild("language_version");
|
||||
_version = poHeader->getLanguageVersion();
|
||||
oTmpElement.setData(_version.toString());
|
||||
oTmpElement = oHeaderElement.createChild("author");
|
||||
oTmpElement.setData(poHeader->getAuthor());
|
||||
// Use current date for creation and change date
|
||||
oTmpElement = oHeaderElement.createChild("date_creation");
|
||||
oTmpElement.setData(poHeader->getDateCreation().format("%d.%m.%Y"));
|
||||
oTmpElement = oHeaderElement.createChild("date_change");
|
||||
oTmpElement.setData(poHeader->getDateChange().format("%d.%m.%Y"));
|
||||
oTmpElement = oHeaderElement.createChild("description");
|
||||
oTmpElement.setData(poHeader->getDescription());
|
||||
DDLExtDeclarationVec vecExtDecls = poHeader->getExtDeclarations();
|
||||
for (DDLExtDeclarationIt itED = vecExtDecls.begin();
|
||||
vecExtDecls.end() != itED; ++itED)
|
||||
{
|
||||
RETURN_IF_FAILED((*itED)->accept(this));
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLExtDeclaration* poExtDeclaration)
|
||||
{
|
||||
if (!poExtDeclaration) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oHeader;
|
||||
if (!_dom.getRoot().findNode("header", oHeader))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
a_util::xml::DOMElement oEDElement = oHeader.createChild("ext_declaration");
|
||||
oEDElement.setAttribute("key", poExtDeclaration->getKey());
|
||||
oEDElement.setAttribute("value", poExtDeclaration->getValue());
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLBaseunit* poBaseunit)
|
||||
{
|
||||
if (!poBaseunit) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oBUElement;
|
||||
if (_units.findNode(a_util::strings::format("baseunit[@name='%s']",
|
||||
poBaseunit->getName().c_str()), oBUElement))
|
||||
{
|
||||
// this element was already visited
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
oBUElement = _units.createChild("baseunit");
|
||||
oBUElement.setAttribute("name", poBaseunit->getName());
|
||||
oBUElement.setAttribute("symbol", poBaseunit->getSymbol());
|
||||
oBUElement.setAttribute("description", poBaseunit->getDescription());
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLPrefix* poPrefix)
|
||||
{
|
||||
if (!poPrefix) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oUnits;
|
||||
a_util::xml::DOMElement oPrefixElement;
|
||||
if (!_dom.getRoot().findNode("units", oUnits))
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
if (oUnits.findNode(a_util::strings::format("prefixes[@name='%s']",
|
||||
poPrefix->getName().c_str()), oPrefixElement))
|
||||
{
|
||||
// this element was already visited
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
oPrefixElement = oUnits.createChild("prefixes");
|
||||
oPrefixElement.setAttribute("name", poPrefix->getName());
|
||||
oPrefixElement.setAttribute("symbol", poPrefix->getSymbol());
|
||||
oPrefixElement.setAttribute("power",
|
||||
a_util::strings::toString((int32_t)poPrefix->getPower()));
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLUnit* poUnit)
|
||||
{
|
||||
if (!poUnit) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oUnitElement;
|
||||
a_util::xml::DOMElement oTmpElement;
|
||||
if (_units.findNode(a_util::strings::format("unit[@name='%s']",
|
||||
poUnit->getName().c_str()), oUnitElement))
|
||||
{
|
||||
// this element was already visited
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
oUnitElement = _units.createChild("unit");
|
||||
oUnitElement.setAttribute("name", poUnit->getName());
|
||||
oTmpElement = oUnitElement.createChild("numerator");
|
||||
oTmpElement.setData(poUnit->getNumerator());
|
||||
oTmpElement = oUnitElement.createChild("denominator");
|
||||
oTmpElement.setData(poUnit->getDenominator());
|
||||
oTmpElement = oUnitElement.createChild("offset");
|
||||
oTmpElement.setData(a_util::strings::toString(static_cast<double>
|
||||
(poUnit->getOffset())));
|
||||
std::vector<DDLRefUnit*> vecDDLRefUnits = poUnit->getRefUnits();
|
||||
_stack_parents.push(oUnitElement);
|
||||
for (size_t i = 0; i < vecDDLRefUnits.size(); i++)
|
||||
{
|
||||
RETURN_IF_FAILED(vecDDLRefUnits[i]->accept(this));
|
||||
}
|
||||
_stack_parents.pop();
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLRefUnit* poRefUnit)
|
||||
{
|
||||
if (!poRefUnit) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oRUElement;
|
||||
oRUElement = _stack_parents.top().createChild("refUnit");
|
||||
oRUElement.setAttribute("name", poRefUnit->getName());
|
||||
RETURN_IF_FAILED(poRefUnit->getUnitObject()->accept(this));
|
||||
oRUElement.setAttribute("power",
|
||||
a_util::strings::toString((int32_t)poRefUnit->getPower()));
|
||||
oRUElement.setAttribute("prefix", poRefUnit->getPrefix());
|
||||
return poRefUnit->getPrefixObject()->accept(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLDataType* poDataType)
|
||||
{
|
||||
if (!poDataType) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oDTElement;
|
||||
if (_resolved_types.find(poDataType->getName()) != _resolved_types.end())
|
||||
{
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
_resolved_types.insert(poDataType->getName());
|
||||
|
||||
oDTElement = _data_types.createChild("datatype");
|
||||
if (_version < DDLVersion::ddl_version_11)
|
||||
{
|
||||
oDTElement.setAttribute("type", poDataType->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
oDTElement.setAttribute("name", poDataType->getName());
|
||||
}
|
||||
oDTElement.setAttribute("size",
|
||||
a_util::strings::toString(static_cast<uint32_t>(poDataType->getNumBits())));
|
||||
if (!poDataType->getDescription().empty())
|
||||
{
|
||||
oDTElement.setAttribute("description",
|
||||
poDataType->getDescription());
|
||||
}
|
||||
if (poDataType->getArraysize() > 1)
|
||||
{
|
||||
oDTElement.setAttribute("arraysize",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poDataType->getArraysize())));
|
||||
}
|
||||
if (!poDataType->getUnit().empty())
|
||||
{
|
||||
oDTElement.setAttribute("unit", poDataType->getUnit());
|
||||
RETURN_IF_FAILED(poDataType->getUnitObject()->accept(this));
|
||||
}
|
||||
if (_version >= DDLVersion::ddl_version_30)
|
||||
{
|
||||
// min and max values are supported since DDL 3.0
|
||||
if (poDataType->isMinValid())
|
||||
{
|
||||
oDTElement.setAttribute("min", poDataType->getMinValue());
|
||||
}
|
||||
if (poDataType->isMaxValid())
|
||||
{
|
||||
oDTElement.setAttribute("max", poDataType->getMaxValue());
|
||||
}
|
||||
}
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLComplex* poStruct)
|
||||
{
|
||||
if (!poStruct) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oStructElement;
|
||||
if (_resolved_types.find(poStruct->getName()) != _resolved_types.end())
|
||||
{
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
_resolved_types.insert(poStruct->getName());
|
||||
|
||||
oStructElement = _structs.createChild("struct");
|
||||
oStructElement.setAttribute("name", poStruct->getName());
|
||||
oStructElement.setAttribute("version",
|
||||
a_util::strings::toString(static_cast<uint32_t>(poStruct->getVersion())));
|
||||
if (!poStruct->getComment().empty())
|
||||
{
|
||||
oStructElement.setAttribute("comment", poStruct->getComment());
|
||||
}
|
||||
if (_version >= DDLVersion::ddl_version_11)
|
||||
{
|
||||
oStructElement.setAttribute("alignment",
|
||||
DDLAlignment::toString(poStruct->getAlignment()));
|
||||
}
|
||||
_stack_parents.push(oStructElement);
|
||||
std::vector<DDLElement*> vecDDLElements = poStruct->getElements();
|
||||
for (size_t i = 0; i < vecDDLElements.size(); i++)
|
||||
{
|
||||
RETURN_IF_FAILED(vecDDLElements[i]->accept(this));
|
||||
}
|
||||
_stack_parents.pop();
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLElement* poElement)
|
||||
{
|
||||
if (!poElement) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oElem;
|
||||
oElem = _stack_parents.top().createChild("element");
|
||||
oElem.setAttribute("type", poElement->getType());
|
||||
IDDLDataType* pTypeObject = poElement->getTypeObject();
|
||||
if (!pTypeObject)
|
||||
{
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
RETURN_IF_FAILED(pTypeObject->accept(this));
|
||||
oElem.setAttribute("name", poElement->getName());
|
||||
oElem.setAttribute("bytepos",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poElement->getBytepos())));
|
||||
if ((_version < DDLVersion::ddl_version_11 && poElement->getBitpos() != 1) ||
|
||||
(_version >= DDLVersion::ddl_version_11 && poElement->getBitpos() > 0))
|
||||
{
|
||||
oElem.setAttribute("bitpos",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poElement->getBitpos())));
|
||||
}
|
||||
if (poElement->getNumBits() > 0)
|
||||
{
|
||||
if (1 == poElement->getArraysize())
|
||||
{
|
||||
// only check the "numbits"-attribute for data-types (DDLDataType), because
|
||||
// "numbits"-attribute for complex-types (DDLComplex) may tempt to configuration errors
|
||||
DDLDataType *poDT = dynamic_cast<DDLDataType*>(pTypeObject);
|
||||
if (NULL != poDT)
|
||||
{
|
||||
if (poElement->getNumBits() == poDT->getNumBits())
|
||||
{
|
||||
oElem.setAttribute("numbits", a_util::strings::toString(static_cast<uint32_t>
|
||||
(poElement->getNumBits())));
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
if (!poElement->getDescription().empty())
|
||||
{
|
||||
oElem.setAttribute("description", poElement->getDescription());
|
||||
}
|
||||
if(poElement->getArraysize() == 0 || !poElement->getArraySizeSource().empty())
|
||||
{
|
||||
oElem.setAttribute("arraysize",poElement->getArraySizeSource());
|
||||
}
|
||||
else
|
||||
{
|
||||
oElem.setAttribute("arraysize",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poElement->getArraysize())));
|
||||
}
|
||||
if (!poElement->getUnit().empty())
|
||||
{
|
||||
oElem.setAttribute("unit", poElement->getUnit());
|
||||
RETURN_IF_FAILED(poElement->getUnitObject()->accept(this));
|
||||
}
|
||||
oElem.setAttribute("byteorder",
|
||||
DDLByteorder::toString(poElement->getByteorder()));
|
||||
oElem.setAttribute("alignment",
|
||||
DDLAlignment::toString(poElement->getAlignment()));
|
||||
if (!poElement->getComment().empty())
|
||||
{
|
||||
oElem.setAttribute("comment", poElement->getComment());
|
||||
}
|
||||
|
||||
std::string strConstValue = poElement->getConstantValue();
|
||||
if (!strConstValue.empty())
|
||||
{
|
||||
oElem.setAttribute("value", strConstValue);
|
||||
}
|
||||
|
||||
if (_version >= DDLVersion::ddl_version_30)
|
||||
{
|
||||
// min, max, default, scale, and offset values are supported since DDL 3.0
|
||||
if (poElement->isMinValid())
|
||||
{
|
||||
oElem.setAttribute("min", poElement->getMinValue());
|
||||
}
|
||||
|
||||
if (poElement->isMaxValid())
|
||||
{
|
||||
oElem.setAttribute("max", poElement->getMaxValue());
|
||||
}
|
||||
|
||||
if (poElement->isDefaultValid())
|
||||
{
|
||||
oElem.setAttribute("default", poElement->getDefaultValue());
|
||||
}
|
||||
|
||||
if (poElement->isScaleValid())
|
||||
{
|
||||
oElem.setAttribute("scale", poElement->getScaleValue());
|
||||
}
|
||||
|
||||
if (poElement->isOffsetValid())
|
||||
{
|
||||
oElem.setAttribute("offset", poElement->getOffsetValue());
|
||||
}
|
||||
}
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLStream* poStream)
|
||||
{
|
||||
if (!poStream) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oStreamElement;
|
||||
oStreamElement = _streams.createChild("stream");
|
||||
if (!poStream->getName().empty())
|
||||
{
|
||||
oStreamElement.setAttribute("name", poStream->getName());
|
||||
}
|
||||
oStreamElement.setAttribute("type", poStream->getType());
|
||||
RETURN_IF_FAILED(poStream->getTypeObject()->accept(this));
|
||||
if (!poStream->getDescription().empty())
|
||||
{
|
||||
oStreamElement.setAttribute("description",
|
||||
poStream->getDescription());
|
||||
}
|
||||
std::vector<DDLStreamStruct*> vecStructs = poStream->getStructs();
|
||||
_stack_parents.push(oStreamElement);
|
||||
for (size_t i = 0; i < vecStructs.size(); i++)
|
||||
{
|
||||
RETURN_IF_FAILED(vecStructs[i]->accept(this));
|
||||
}
|
||||
_stack_parents.pop();
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLStreamStruct* poStreamStruct)
|
||||
{
|
||||
if (!poStreamStruct) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oStruct;
|
||||
oStruct = _stack_parents.top().createChild("struct");
|
||||
oStruct.setAttribute("type", poStreamStruct->getType());
|
||||
RETURN_IF_FAILED(poStreamStruct->getTypeObject()->accept(this));
|
||||
if (!poStreamStruct->getName().empty())
|
||||
{
|
||||
oStruct.setAttribute("name", poStreamStruct->getName());
|
||||
}
|
||||
oStruct.setAttribute("bytepos",
|
||||
a_util::strings::toString(static_cast<uint32_t>
|
||||
(poStreamStruct->getBytepos())));
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLEnum* poEnum)
|
||||
{
|
||||
if (!poEnum) { return ERR_POINTER; }
|
||||
a_util::xml::DOMElement oDTElement;
|
||||
if (_enums.findNode(a_util::strings::format("enum[@name='%s']",
|
||||
poEnum->getName().c_str()), oDTElement))
|
||||
{
|
||||
// this element was already visited
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
oDTElement = _enums.createChild("enum");
|
||||
|
||||
oDTElement.setAttribute("name", poEnum->getName());
|
||||
// oDTElement->setAttribute("value", poEnum->getValue());
|
||||
oDTElement.setAttribute("type", poEnum->getType());
|
||||
|
||||
EnumNameValueVec vecNameValues = poEnum->getValues();
|
||||
a_util::xml::DOMElement oEnumElement;
|
||||
for (EnumNameValueVec::iterator itElem = vecNameValues.begin(); itElem != vecNameValues.end(); ++itElem)
|
||||
{
|
||||
oEnumElement = oDTElement.createChild("element");
|
||||
|
||||
oEnumElement.setAttribute("name", itElem->first);
|
||||
oEnumElement.setAttribute("value", itElem->second);
|
||||
}
|
||||
|
||||
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLStreamMetaType* poStreamMetaType)
|
||||
{
|
||||
return ERR_NOT_IMPL;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLResolver::visit(const DDLProperty* poProperty)
|
||||
{
|
||||
return ERR_NOT_IMPL;
|
||||
}
|
||||
|
||||
std::string DDLResolver::getResolvedXML() const
|
||||
{
|
||||
std::string strResult = _dom.toString().c_str();
|
||||
if (strResult == "<xml />")
|
||||
{
|
||||
// DOM is empty
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return strResult;
|
||||
}
|
||||
|
||||
void DDLResolver::setTargetName(const std::string& name)
|
||||
{
|
||||
_target = name;
|
||||
}
|
||||
|
||||
} // namespace ddl
|
103
ddlrepresentation/ddlresolver.h
Normal file
103
ddlrepresentation/ddlresolver.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_RESOLVER_H_INCLUDED
|
||||
#define DDL_RESOLVER_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Implementation of IDDLVisitor for resolving of a specified unit,
|
||||
* datatype, struct, or stream out of an existing DDL hierarchy.
|
||||
* So a minimal DDL description for the specified target is built.
|
||||
*/
|
||||
class DDLResolver : public IDDLVisitor
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLResolver();
|
||||
|
||||
/**
|
||||
* CTOR with target name.
|
||||
* @param[in] target - Name of the target to resolve
|
||||
*/
|
||||
DDLResolver(const std::string& target);
|
||||
|
||||
a_util::result::Result visitDDL(const DDLDescription* description);
|
||||
a_util::result::Result visit(const DDLHeader* header);
|
||||
a_util::result::Result visit(const DDLDataType* data_type);
|
||||
a_util::result::Result visit(const DDLComplex* complex);
|
||||
a_util::result::Result visit(const DDLStream* stream);
|
||||
a_util::result::Result visit(const DDLUnit* unit);
|
||||
a_util::result::Result visit(const DDLBaseunit* baseunit);
|
||||
a_util::result::Result visit(const DDLExtDeclaration* ext_declaration);
|
||||
a_util::result::Result visit(const DDLElement* element);
|
||||
a_util::result::Result visit(const DDLPrefix* prefix);
|
||||
a_util::result::Result visit(const DDLRefUnit* ref_unit);
|
||||
a_util::result::Result visit(const DDLStreamStruct* stream_struct);
|
||||
a_util::result::Result visit(const DDLEnum* ddl_enum);
|
||||
a_util::result::Result visit(const DDLStreamMetaType* stream_meta_type);
|
||||
a_util::result::Result visit(const DDLProperty* property);
|
||||
|
||||
/**
|
||||
* Getter for a minimalistic DDL which only resolves the specified DDL object.
|
||||
* @return the XML string containing the minimalistic DDL description
|
||||
*/
|
||||
std::string getResolvedXML() const;
|
||||
|
||||
/**
|
||||
* Setter for the name of the target to resolve.
|
||||
* @param[in] name - Name of the DDL object to resolve
|
||||
* @remarks Only targets of the types "unit", "datatype", "struct", and
|
||||
* "stream" are supported.
|
||||
* @return void
|
||||
*/
|
||||
void setTargetName(const std::string& name);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Create the base items
|
||||
* @param [in] description pointer to the DDL Description
|
||||
*
|
||||
* @return Standard result code.
|
||||
*/
|
||||
a_util::result::Result createBase(const DDLDescription* description);
|
||||
|
||||
protected: // members
|
||||
a_util::xml::DOM _dom; ///< Internal DOM for XML handling
|
||||
std::string _target; ///< Name of the resolving target
|
||||
DDLVersion _version; ///< DDL version (needed for some conversions for compatibility with DDL1.0)
|
||||
std::stack<a_util::xml::DOMElement> _stack_parents; ///< stack of parents
|
||||
std::set<std::string> _resolved_types; ///< set of the resolved types
|
||||
a_util::xml::DOMElement _units; ///< DOM-Element of type Unit
|
||||
a_util::xml::DOMElement _data_types; ///< DOM-Element of type DataType
|
||||
a_util::xml::DOMElement _enums; ///< DOM-Element of type Enum
|
||||
a_util::xml::DOMElement _structs; ///< DOM-Element of type Struct
|
||||
a_util::xml::DOMElement _streams; ///< DOM-Element of type Stream
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_RESOLVER_H_INCLUDED
|
28
ddlrepresentation/ddlserializable_intf.h
Normal file
28
ddlrepresentation/ddlserializable_intf.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef _DDL_SERIALIZABLE_INTF_H_INCLUDED_
|
||||
#define _DDL_SERIALIZABLE_INTF_H_INCLUDED_
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // _DDL_SERIALIZABLE_INTF_H_INCLUDED_
|
251
ddlrepresentation/ddlstream.cpp
Normal file
251
ddlrepresentation/ddlstream.cpp
Normal file
|
@ -0,0 +1,251 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlstream.h"
|
||||
#include <ddl.h>
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-20, ERR_NOT_FOUND)
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLStream::DDLStream() :
|
||||
_name{},
|
||||
_type{},
|
||||
_description{},
|
||||
_structs{},
|
||||
_init_flag{false},
|
||||
_level{4},
|
||||
_language_version(DDLVersion::ddl_version_invalid)
|
||||
{
|
||||
}
|
||||
|
||||
DDLStream::DDLStream(DDLComplex* poType,
|
||||
const std::string& name,
|
||||
const std::string& strDescription,
|
||||
DDLStreamStructVec vecStructs,
|
||||
int const nCreationLevel) :
|
||||
_name(name),
|
||||
_type{poType},
|
||||
_description(strDescription),
|
||||
_structs{},
|
||||
_init_flag{NULL != poType},
|
||||
_level{nCreationLevel},
|
||||
_language_version(DDLVersion::ddl_version_invalid)
|
||||
{
|
||||
cloneStructs(vecStructs);
|
||||
}
|
||||
|
||||
DDLStream::DDLStream(const DDLStream &oStream) :
|
||||
_name(oStream.getName()),
|
||||
_type{oStream.getTypeObject()},
|
||||
_description(oStream.getDescription()),
|
||||
_structs{},
|
||||
_init_flag{NULL != oStream.getTypeObject()},
|
||||
_level{oStream.getCreationLevel()},
|
||||
_language_version(oStream.getDDLVersion())
|
||||
{
|
||||
cloneStructs(oStream.getStructs());
|
||||
}
|
||||
|
||||
DDLStream& DDLStream::operator=(DDLStream other)
|
||||
{
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
DDLStream::DDLStream(DDLStream&& other)
|
||||
{
|
||||
swap(*this, other);
|
||||
}
|
||||
|
||||
DDLStream::~DDLStream()
|
||||
{
|
||||
std::transform(_structs.begin(), _structs.end(), _structs.begin(), deleteChild<DDLStreamStruct>);
|
||||
// The type object needs not to be deleted as this pointer only is a
|
||||
// reference to an object in the struct vector of the central
|
||||
// description object!
|
||||
_structs.clear();
|
||||
_type = NULL;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLStream::accept(IDDLVisitor *poVisitor) const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
a_util::result::Result DDLStream::accept(IDDLChangeVisitor *poVisitor)
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLStream::create(DDLComplex* poType,
|
||||
const std::string& name,
|
||||
const std::string& strDescription,
|
||||
DDLStreamStructVec vecStructs,
|
||||
int const nCreationLevel)
|
||||
{
|
||||
if (!poType) { return ERR_POINTER; }
|
||||
_type = poType;
|
||||
_name = name;
|
||||
_description = strDescription;
|
||||
cloneStructs(vecStructs);
|
||||
_init_flag = true;
|
||||
_level = nCreationLevel;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
std::string DDLStream::getType() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return _type->getName();
|
||||
}
|
||||
|
||||
void DDLStream::setType(DDLComplex* const pType)
|
||||
{
|
||||
_type = pType;
|
||||
_init_flag = (_type != NULL);
|
||||
}
|
||||
|
||||
DDLComplex * DDLStream::getTypeObject() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _type;
|
||||
}
|
||||
|
||||
DDLVersion DDLStream::getDDLVersion() const
|
||||
{
|
||||
return _language_version;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLStream::setDDLVersion(DDLVersion& language_version)
|
||||
{
|
||||
_language_version = language_version;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
void DDLStream::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
const std::string& DDLStream::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLStream::setDescription(const std::string& strDescription)
|
||||
{
|
||||
_description = strDescription;
|
||||
}
|
||||
|
||||
std::string DDLStream::getDescription() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
void DDLStream::cloneStructs(DDLStreamStructVec vecStructs)
|
||||
{
|
||||
std::transform(_structs.begin(), _structs.end(), _structs.begin(), DDLDescription::deleteChild<DDLStreamStruct>);
|
||||
_structs.clear();
|
||||
|
||||
_structs = vecStructs;
|
||||
std::transform(_structs.begin(), _structs.end(), _structs.begin(), DDLDescription::clone<DDLStreamStruct>);
|
||||
}
|
||||
|
||||
void DDLStream::refStructs(DDLStreamStructVec vecStructs)
|
||||
{
|
||||
std::transform(_structs.begin(), _structs.end(), _structs.begin(), DDLDescription::deleteChild<DDLStreamStruct>);
|
||||
_structs.clear();
|
||||
|
||||
_structs = vecStructs;
|
||||
}
|
||||
|
||||
|
||||
void DDLStream::addStruct(DDLStreamStruct* poStruct)
|
||||
{
|
||||
if (NULL != poStruct)
|
||||
{
|
||||
_structs.push_back(poStruct);
|
||||
}
|
||||
}
|
||||
a_util::result::Result DDLStream::removeStruct(const std::string& strStructName)
|
||||
{
|
||||
DDLStreamStructIt oIt = _structs.begin();
|
||||
while (oIt != _structs.end())
|
||||
{
|
||||
if ((*oIt)->getName() == strStructName)
|
||||
{
|
||||
DDLDescription::deleteChild(*oIt);
|
||||
_structs.erase(oIt);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
oIt++;
|
||||
}
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
DDLStreamStructVec& DDLStream::getStructs()
|
||||
{
|
||||
return _structs;
|
||||
}
|
||||
|
||||
const DDLStreamStructVec& DDLStream::getStructs() const
|
||||
{
|
||||
return _structs;
|
||||
}
|
||||
|
||||
bool DDLStream::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
int DDLStream::getCreationLevel() const
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
void swap(DDLStream& lhs, DDLStream& rhs) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(lhs._description, rhs._description);
|
||||
swap(lhs._init_flag, rhs._init_flag);
|
||||
swap(lhs._language_version, rhs._language_version);
|
||||
swap(lhs._level, rhs._level);
|
||||
swap(lhs._name, rhs._name);
|
||||
swap(lhs._structs, rhs._structs);
|
||||
swap(lhs._type, rhs._type);
|
||||
}
|
||||
} // namespace ddl
|
231
ddlrepresentation/ddlstream.h
Normal file
231
ddlrepresentation/ddlstream.h
Normal file
|
@ -0,0 +1,231 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_STREAM_H_INCLUDED
|
||||
#define DDL_STREAM_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlversion.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
class DDLStreamStruct;
|
||||
class DDLComplex;
|
||||
|
||||
/**
|
||||
* Container type of DDLStreamStruct objects
|
||||
*/
|
||||
typedef std::vector<DDLStreamStruct*> DDLStreamStructVec;
|
||||
/**
|
||||
* Iterator type for DDLStreamStructVec
|
||||
*/
|
||||
typedef DDLStreamStructVec::iterator DDLStreamStructIt;
|
||||
|
||||
/**
|
||||
* Representation of a stream inside a DDL description.
|
||||
*/
|
||||
class DDLStream : public DDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLStream();
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] type - Pointer to complex datatype object
|
||||
* @param[in] name - Name of the stream (optional)
|
||||
* @param[in] description - Description (optional)
|
||||
* @param[in] structs - Vector of \c DDLStreamStruct objects (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
*/
|
||||
DDLStream(DDLComplex* type,
|
||||
const std::string& name = a_util::strings::empty_string,
|
||||
const std::string& description = a_util::strings::empty_string,
|
||||
DDLStreamStructVec structs = DDLStreamStructVec(),
|
||||
int const creation_level = 4);
|
||||
|
||||
/**
|
||||
* Copy CTOR
|
||||
* @param[in] other - Reference to stream object to copy
|
||||
*/
|
||||
DDLStream(const DDLStream &other);
|
||||
|
||||
/**
|
||||
* Assignment operator (either copies or moves)
|
||||
* @param[in] other DDL stream object to copy from
|
||||
* @return @c *this
|
||||
*/
|
||||
DDLStream& operator=(DDLStream other);
|
||||
|
||||
/**
|
||||
* Move CTOR
|
||||
* @param[in,out] other DDL stream object to move from - empty but valid when finished
|
||||
*/
|
||||
DDLStream(DDLStream&& other);
|
||||
|
||||
/**
|
||||
* DTOR
|
||||
*/
|
||||
virtual ~DDLStream();
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] type - Pointer to complex datatype object
|
||||
* @param[in] name - Name of the stream (optional)
|
||||
* @param[in] description - Description (optional)
|
||||
* @param[in] structs - Vector of \c DDLStreamStruct objects (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
*/
|
||||
a_util::result::Result create(DDLComplex* type,
|
||||
const std::string& name = a_util::strings::empty_string,
|
||||
const std::string& description = a_util::strings::empty_string,
|
||||
DDLStreamStructVec structs = DDLStreamStructVec(),
|
||||
int const creation_level = 4);
|
||||
|
||||
/**
|
||||
* Getter for the name of the complex data type.
|
||||
* @return name of the complex data type
|
||||
*/
|
||||
std::string getType() const;
|
||||
|
||||
/**
|
||||
* Setter for the object of the complex data type.
|
||||
* @param[in] type - the type object referencing to
|
||||
* @return void
|
||||
*/
|
||||
void setType(DDLComplex* const type);
|
||||
|
||||
/**
|
||||
* Getter for the DDL version.
|
||||
* @return the DDL version
|
||||
*/
|
||||
DDLVersion getDDLVersion() const;
|
||||
|
||||
/**
|
||||
* Setter for the DDL version.
|
||||
* @param language_version the DDL version to set
|
||||
* @return Standard result code.
|
||||
* @retval a_util::result::SUCCESS
|
||||
*/
|
||||
a_util::result::Result setDDLVersion(DDLVersion& language_version);
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the complex data-type object.
|
||||
* @return pointer to the complex data-type object
|
||||
*/
|
||||
DDLComplex * getTypeObject() const;
|
||||
|
||||
/**
|
||||
* Setter for the name.
|
||||
* @param[in] name - Name of the stream
|
||||
* @return void
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
|
||||
/**
|
||||
* Getter for the name.
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the description.
|
||||
* @param[in] description - Description of the stream
|
||||
* @return void
|
||||
*/
|
||||
void setDescription(const std::string& description);
|
||||
|
||||
/**
|
||||
* Getter for the description.
|
||||
* @return the description
|
||||
*/
|
||||
std::string getDescription() const;
|
||||
|
||||
/**
|
||||
* Setter for the contained structs.
|
||||
* @param[in] structs - Vector of structures (complex data types)
|
||||
* @return void
|
||||
*/
|
||||
void cloneStructs(DDLStreamStructVec structs);
|
||||
|
||||
/**
|
||||
* Setter for the contained structs.
|
||||
* @param[in] structs - Vector of structures (complex data types)
|
||||
* @return void
|
||||
*/
|
||||
void refStructs(DDLStreamStructVec structs);
|
||||
|
||||
/**
|
||||
* Adder for a struct.
|
||||
* @param[in] ddl_struct - Pointer to the struct object to add
|
||||
* @return void
|
||||
*/
|
||||
void addStruct(DDLStreamStruct* ddl_struct);
|
||||
|
||||
/**
|
||||
* removal for a struct item.
|
||||
* @param[in] struct_name - name of struct object to remove
|
||||
* @retval ERR_NOT_FOUND if not exists
|
||||
*/
|
||||
a_util::result::Result removeStruct(const std::string& struct_name);
|
||||
|
||||
/**
|
||||
* Getter for the contained structs.
|
||||
* @return the vector of structs
|
||||
*/
|
||||
DDLStreamStructVec& getStructs();
|
||||
|
||||
/**
|
||||
* Getter for the contained structs.
|
||||
* @return the vector of structs
|
||||
*/
|
||||
const DDLStreamStructVec& getStructs() const;
|
||||
|
||||
/**
|
||||
* Add swap functionality, also enabling the copy-swap-idiom
|
||||
* @param[in,out] lhs Left-hand side ddl type
|
||||
* @param[in,out] rhs Right-hand side ddl type
|
||||
*/
|
||||
friend void swap(DDLStream& lhs, DDLStream& rhs) noexcept;
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
DDLComplex * _type;
|
||||
std::string _description;
|
||||
DDLStreamStructVec _structs;
|
||||
bool _init_flag;
|
||||
int _level;
|
||||
DDLVersion _language_version;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_STREAM_H_INCLUDED
|
151
ddlrepresentation/ddlstreammetatype.cpp
Normal file
151
ddlrepresentation/ddlstreammetatype.cpp
Normal file
|
@ -0,0 +1,151 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlstreammetatype.h"
|
||||
#include <ddl.h>
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLStreamMetaType::DDLStreamMetaType(const std::string& name,
|
||||
const std::string& strVersion,
|
||||
const DDLPropertyVec& vecProperties,
|
||||
const DDLStreamMetaType* pParent) :
|
||||
_name{name},
|
||||
_version{strVersion},
|
||||
_properties{vecProperties},
|
||||
_parent{pParent},
|
||||
_init_flag{true}
|
||||
{
|
||||
}
|
||||
|
||||
DDLStreamMetaType::DDLStreamMetaType(const DDLStreamMetaType &oStreamMetaType) :
|
||||
_name{oStreamMetaType._name},
|
||||
_version{oStreamMetaType._version},
|
||||
_properties{},
|
||||
_parent{oStreamMetaType._parent},
|
||||
_init_flag{true}
|
||||
{
|
||||
cloneProperties(oStreamMetaType._properties);
|
||||
}
|
||||
|
||||
DDLStreamMetaType& DDLStreamMetaType::operator=(DDLStreamMetaType other)
|
||||
{
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
DDLStreamMetaType::DDLStreamMetaType(DDLStreamMetaType&& other)
|
||||
{
|
||||
swap(*this, other);
|
||||
}
|
||||
|
||||
DDLStreamMetaType::~DDLStreamMetaType()
|
||||
{
|
||||
std::transform(_properties.begin(), _properties.end(), _properties.begin(), deleteChild<DDLProperty>);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLStreamMetaType::accept(IDDLVisitor *poVisitor) const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLStreamMetaType::accept(IDDLChangeVisitor *poVisitor)
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& DDLStreamMetaType::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLStreamMetaType::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
const std::string& DDLStreamMetaType::getVersion() const
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
void DDLStreamMetaType::cloneProperties(const DDLPropertyVec& vecProperties)
|
||||
{
|
||||
std::transform(_properties.begin(), _properties.end(), _properties.begin(), DDLDescription::deleteChild<DDLProperty>);
|
||||
_properties = vecProperties;
|
||||
std::transform(_properties.begin(), _properties.end(), _properties.begin(), DDLDescription::clone<DDLProperty>);
|
||||
}
|
||||
|
||||
DDLPropertyVec& DDLStreamMetaType::getProperties()
|
||||
{
|
||||
return _properties;
|
||||
}
|
||||
|
||||
const DDLPropertyVec& DDLStreamMetaType::getProperties() const
|
||||
{
|
||||
return _properties;
|
||||
}
|
||||
|
||||
const DDLStreamMetaType* DDLStreamMetaType::getParentObject() const
|
||||
{
|
||||
return _parent;
|
||||
}
|
||||
|
||||
const std::string& DDLStreamMetaType::getParent() const
|
||||
{
|
||||
if (_parent)
|
||||
{
|
||||
return _parent->getName();
|
||||
}
|
||||
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
|
||||
bool DDLStreamMetaType::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
int DDLStreamMetaType::getCreationLevel() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void swap(DDLStreamMetaType& lhs, DDLStreamMetaType& rhs) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(lhs._name, rhs._name);
|
||||
swap(lhs._version, rhs._version);
|
||||
swap(lhs._properties, rhs._properties);
|
||||
swap(lhs._parent, rhs._parent);
|
||||
swap(lhs._init_flag, rhs._init_flag);
|
||||
}
|
||||
|
||||
} // namespace ddl
|
150
ddlrepresentation/ddlstreammetatype.h
Normal file
150
ddlrepresentation/ddlstreammetatype.h
Normal file
|
@ -0,0 +1,150 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_STREAM_META_TYPE_H_INCLUDED
|
||||
#define DDL_STREAM_META_TYPE_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlproperty.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
typedef std::vector<DDLProperty*> DDLPropertyVec;
|
||||
|
||||
/**
|
||||
* Representation of a stream inside a DDL description.
|
||||
*/
|
||||
class DDLStreamMetaType : public DDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLStreamMetaType() = default;
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] name - Name of the stream meta type
|
||||
* @param[in] version - Version of the stream meta type
|
||||
* @param[in] properties - The properties.
|
||||
* @param[in] parent - the stream meta type parent (optional)
|
||||
*/
|
||||
DDLStreamMetaType(const std::string& name,
|
||||
const std::string& version,
|
||||
const DDLPropertyVec& properties = DDLPropertyVec(),
|
||||
const DDLStreamMetaType* parent = NULL);
|
||||
|
||||
/**
|
||||
* Copy CTOR
|
||||
* @param[in] other - Reference to stream meta type object to copy
|
||||
*/
|
||||
DDLStreamMetaType(const DDLStreamMetaType& other);
|
||||
|
||||
/**
|
||||
* Assignment operator (either copies or moves)
|
||||
* @param[in] other DDL stream meta type object to copy from
|
||||
* @return @c *this
|
||||
*/
|
||||
DDLStreamMetaType& operator=(DDLStreamMetaType other);
|
||||
|
||||
/**
|
||||
* Move CTOR
|
||||
* @param[in,out] other Stream meta type object to move from - empty but valid when finished
|
||||
*/
|
||||
DDLStreamMetaType(DDLStreamMetaType&& other);
|
||||
|
||||
/// DTOR
|
||||
virtual ~DDLStreamMetaType();
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Getter for the name.
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the name.
|
||||
* @param[in] name - Name of the stream
|
||||
* @return void
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
|
||||
/**
|
||||
* Getter for the version.
|
||||
* @return the version
|
||||
*/
|
||||
const std::string& getVersion() const;
|
||||
|
||||
/**
|
||||
* Setter for the contained structs.
|
||||
* @param[in] structs - Vector of structures (complex data types)
|
||||
* @return void
|
||||
*/
|
||||
void cloneProperties(const DDLPropertyVec& structs);
|
||||
|
||||
/**
|
||||
* Getter for the contained properties.
|
||||
* @return the vector of properties
|
||||
*/
|
||||
DDLPropertyVec& getProperties();
|
||||
|
||||
/**
|
||||
* Getter for the contained properties.
|
||||
* @return the vector of properties
|
||||
*/
|
||||
const DDLPropertyVec& getProperties() const;
|
||||
|
||||
/**
|
||||
* Pointer to the parent stream meta type.
|
||||
* @return Pointer to the parent stream meta type.
|
||||
*/
|
||||
const DDLStreamMetaType* getParentObject() const;
|
||||
|
||||
/**
|
||||
* Getter for the name of the parent.
|
||||
* @return The name of the parent.
|
||||
*/
|
||||
const std::string& getParent() const;
|
||||
|
||||
/**
|
||||
* Add swap functionality, also enabling the copy-swap-idiom
|
||||
* @param[in,out] lhs Left-hand side ddl type
|
||||
* @param[in,out] rhs Right-hand side ddl type
|
||||
*/
|
||||
friend void swap(DDLStreamMetaType& lhs, DDLStreamMetaType& rhs) noexcept;
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
std::string _version;
|
||||
DDLPropertyVec _properties;
|
||||
const DDLStreamMetaType* _parent;
|
||||
bool _init_flag;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_STREAM_META_TYPE_H_INCLUDED
|
121
ddlrepresentation/ddlstreamstruct.cpp
Normal file
121
ddlrepresentation/ddlstreamstruct.cpp
Normal file
|
@ -0,0 +1,121 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlstreamstruct.h"
|
||||
#include <ddl.h>
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-4, ERR_POINTER)
|
||||
_MAKE_RESULT(-37, ERR_NOT_INITIALIZED)
|
||||
|
||||
DDLStreamStruct::DDLStreamStruct(DDLComplex* poType,
|
||||
unsigned int const uiBytepos,
|
||||
const std::string& name) :
|
||||
|
||||
_type{poType},
|
||||
_bytes_pos{uiBytepos},
|
||||
_name{name},
|
||||
_init_flag{NULL != poType}
|
||||
{
|
||||
}
|
||||
|
||||
a_util::result::Result DDLStreamStruct::accept(IDDLVisitor *poVisitor) const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
a_util::result::Result DDLStreamStruct::accept(IDDLChangeVisitor *poVisitor)
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
a_util::result::Result DDLStreamStruct::create(DDLComplex* poType,
|
||||
unsigned int const uiBytepos,
|
||||
const std::string& name)
|
||||
{
|
||||
if (!poType) { return ERR_POINTER; }
|
||||
_type = poType;
|
||||
_bytes_pos = uiBytepos;
|
||||
_name = name;
|
||||
_init_flag = true;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
const std::string& DDLStreamStruct::getType() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return a_util::strings::empty_string;
|
||||
}
|
||||
return _type->getName();
|
||||
}
|
||||
|
||||
void DDLStreamStruct::setType(DDLComplex* const pType)
|
||||
{
|
||||
_type = pType;
|
||||
_init_flag = (_type != NULL);
|
||||
}
|
||||
|
||||
DDLComplex * DDLStreamStruct::getTypeObject() const
|
||||
{
|
||||
if (!_init_flag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return _type;
|
||||
}
|
||||
|
||||
void DDLStreamStruct::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
const std::string& DDLStreamStruct::getName() const
|
||||
{
|
||||
if (_name.empty())
|
||||
{
|
||||
return getType();
|
||||
}
|
||||
return _name;
|
||||
}
|
||||
|
||||
unsigned int DDLStreamStruct::getBytepos() const
|
||||
{
|
||||
return _bytes_pos;
|
||||
}
|
||||
|
||||
void DDLStreamStruct::setBytepos(unsigned int const uiBytepos)
|
||||
{
|
||||
_bytes_pos = uiBytepos;
|
||||
}
|
||||
|
||||
bool DDLStreamStruct::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
} // namespace ddl
|
125
ddlrepresentation/ddlstreamstruct.h
Normal file
125
ddlrepresentation/ddlstreamstruct.h
Normal file
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef STREAM_STRUCT_H_INCLUDED
|
||||
#define STREAM_STRUCT_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Decorator class for DDLComplex to be used inside DDLStream objects.
|
||||
*/
|
||||
class DDLStreamStruct : public DDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR.
|
||||
*/
|
||||
DDLStreamStruct() = default;
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] type - Pointer to complex datatype object
|
||||
* @param[in] byte_pos - Byte position of the complex datatype
|
||||
* @param[in] name - Name of the stream structure (optional)
|
||||
* @remarks If the name of the stream structure is not set then the
|
||||
* type name is used.
|
||||
*/
|
||||
DDLStreamStruct(DDLComplex* type,
|
||||
unsigned int const byte_pos,
|
||||
const std::string& name = a_util::strings::empty_string);
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] type - Pointer to complex datatype object
|
||||
* @param[in] byte_pos - Byte position of the complex datatype
|
||||
* @param[in] name - Name of the stream structure (optional)
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @remarks If the name of the stream structure is not set then the
|
||||
* type name is used.
|
||||
*/
|
||||
a_util::result::Result create(DDLComplex* type,
|
||||
unsigned int const byte_pos,
|
||||
const std::string& name = a_util::strings::empty_string);
|
||||
|
||||
/**
|
||||
* Getter for the name of the complex data type.
|
||||
* @return name of the type object
|
||||
*/
|
||||
const std::string& getType() const;
|
||||
|
||||
/**
|
||||
* Setter for the complex data-type object.
|
||||
* @param[in] type - complex data-type object
|
||||
* @return void
|
||||
*/
|
||||
void setType(DDLComplex* const type);
|
||||
|
||||
/**
|
||||
* Getter for the complex data-type object.
|
||||
* @return pointer to the complex data-type object
|
||||
*/
|
||||
DDLComplex * getTypeObject() const;
|
||||
|
||||
/**
|
||||
* Setter for the name.
|
||||
* @param[in] name - Name of the stream structure
|
||||
* @return void
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
|
||||
/**
|
||||
* Getter for the name.
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Getter for the byte position.
|
||||
* @return the byte position
|
||||
*/
|
||||
unsigned int getBytepos() const;
|
||||
|
||||
/**
|
||||
* Setter for the byte position.
|
||||
* @param[in] byte_pos - the byte position
|
||||
* @return void
|
||||
*/
|
||||
void setBytepos(unsigned int const byte_pos);
|
||||
|
||||
|
||||
private:
|
||||
DDLComplex * _type;
|
||||
unsigned int _bytes_pos;
|
||||
std::string _name;
|
||||
bool _init_flag;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // STREAM_STRUCT_H_INCLUDED
|
247
ddlrepresentation/ddlunit.cpp
Normal file
247
ddlrepresentation/ddlunit.cpp
Normal file
|
@ -0,0 +1,247 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlunit.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlrefunit.h"
|
||||
#include "ddldescription.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
//define all needed error types and values locally
|
||||
_MAKE_RESULT(-5, ERR_INVALID_ARG)
|
||||
_MAKE_RESULT(-20, ERR_NOT_FOUND)
|
||||
|
||||
DDLUnit::DDLUnit() :
|
||||
_name{},
|
||||
_numerator{},
|
||||
_denominator{},
|
||||
_offset{},
|
||||
_ddl_ref_units{},
|
||||
_init_flag{},
|
||||
_level{1}
|
||||
{
|
||||
}
|
||||
|
||||
DDLUnit::DDLUnit(DDLUnit&& other)
|
||||
{
|
||||
swap(*this, other);
|
||||
}
|
||||
|
||||
DDLUnit::~DDLUnit()
|
||||
{
|
||||
std::transform(_ddl_ref_units.begin(), _ddl_ref_units.end(),
|
||||
_ddl_ref_units.begin(), DDL::deleteChild<DDLRefUnit>);
|
||||
_ddl_ref_units.clear();
|
||||
}
|
||||
|
||||
DDLUnit::DDLUnit(const std::string& name,
|
||||
const std::string& strNumerator,
|
||||
const std::string& strDenominator,
|
||||
double const fOffset,
|
||||
DDLRefUnitVec vecDDLRefUnits,
|
||||
int const nCreationLevel) :
|
||||
_name{name},
|
||||
_numerator{strNumerator},
|
||||
_denominator{strDenominator},
|
||||
_offset{fOffset},
|
||||
_ddl_ref_units{},
|
||||
_init_flag{true},
|
||||
_level{nCreationLevel}
|
||||
{
|
||||
cloneRefUnits(vecDDLRefUnits);
|
||||
}
|
||||
|
||||
DDLUnit::DDLUnit(const DDLUnit& oUnit) :
|
||||
_name{oUnit.getName()},
|
||||
_numerator{oUnit.getNumerator()},
|
||||
_denominator{oUnit.getDenominator()},
|
||||
_offset{oUnit.getOffset()},
|
||||
_ddl_ref_units{},
|
||||
_init_flag{true},
|
||||
_level{oUnit.getCreationLevel()}
|
||||
{
|
||||
cloneRefUnits(oUnit.getRefUnits());
|
||||
}
|
||||
|
||||
DDLUnit& DDLUnit::operator=(DDLUnit other)
|
||||
{
|
||||
swap(*this, other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLUnit::accept(IDDLVisitor *poVisitor) const
|
||||
{
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
a_util::result::Result DDLUnit::accept(IDDLChangeVisitor *poVisitor)
|
||||
{
|
||||
return poVisitor->visit(this);
|
||||
}
|
||||
|
||||
bool DDLUnit::isInitialized() const
|
||||
{
|
||||
return _init_flag;
|
||||
}
|
||||
|
||||
bool DDLUnit::isPredefined() const
|
||||
{
|
||||
return -1 == _level; // cMediaManager::DL_AlwaysThere
|
||||
}
|
||||
|
||||
bool DDLUnit::isOverwriteable() const
|
||||
{
|
||||
return _level > 0;
|
||||
}
|
||||
|
||||
int DDLUnit::getCreationLevel() const
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
a_util::result::Result DDLUnit::create(const std::string& name,
|
||||
const std::string& strNumerator,
|
||||
const std::string& strDenominator,
|
||||
double const fOffset,
|
||||
DDLRefUnitVec vecDDLRefUnits,
|
||||
int const nCreationLevel)
|
||||
{
|
||||
if (name.empty())
|
||||
{
|
||||
return ERR_INVALID_ARG;
|
||||
}
|
||||
_name = name;
|
||||
_numerator = strNumerator;
|
||||
_denominator = strDenominator;
|
||||
_offset = fOffset;
|
||||
cloneRefUnits(vecDDLRefUnits);
|
||||
_init_flag = true;
|
||||
_level = nCreationLevel;
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
|
||||
const std::string& DDLUnit::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DDLUnit::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
|
||||
std::string DDLUnit::getNumerator() const
|
||||
{
|
||||
return _numerator;
|
||||
}
|
||||
|
||||
void DDLUnit::setNumerator(const std::string& strNumerator)
|
||||
{
|
||||
_numerator = strNumerator;
|
||||
}
|
||||
|
||||
std::string DDLUnit::getDenominator() const
|
||||
{
|
||||
return _denominator;
|
||||
}
|
||||
|
||||
void DDLUnit::setDenominator(const std::string& strDenominator)
|
||||
{
|
||||
_denominator = strDenominator;
|
||||
}
|
||||
|
||||
double DDLUnit::getOffset() const
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
void DDLUnit::setOffset(double const fOffset)
|
||||
{
|
||||
_offset = fOffset;
|
||||
}
|
||||
|
||||
DDLRefUnitVec& DDLUnit::getRefUnits()
|
||||
{
|
||||
return _ddl_ref_units;
|
||||
}
|
||||
|
||||
const DDLRefUnitVec& DDLUnit::getRefUnits() const
|
||||
{
|
||||
return _ddl_ref_units;
|
||||
}
|
||||
|
||||
void DDLUnit::addRefUnit(DDLRefUnit* poRefUnit, int nPos)
|
||||
{
|
||||
const DDLRefUnitVec::size_type szPos = static_cast<DDLRefUnitVec::size_type>(nPos);
|
||||
if (0 <= szPos && szPos < _ddl_ref_units.size())
|
||||
{
|
||||
_ddl_ref_units.insert(_ddl_ref_units.begin() + szPos,
|
||||
poRefUnit);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ddl_ref_units.push_back(poRefUnit);
|
||||
}
|
||||
}
|
||||
|
||||
a_util::result::Result DDLUnit:: removeRefUnit(const std::string& strRefUnit)
|
||||
{
|
||||
DDLRefUnitIt oIt = _ddl_ref_units.begin();
|
||||
while (oIt != _ddl_ref_units.end())
|
||||
{
|
||||
if ((*oIt)->getName() == strRefUnit)
|
||||
{
|
||||
delete (*oIt);
|
||||
_ddl_ref_units.erase(oIt);
|
||||
return a_util::result::SUCCESS;
|
||||
}
|
||||
oIt++;
|
||||
}
|
||||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
void DDLUnit::cloneRefUnits(DDLRefUnitVec vecDDLRefUnits)
|
||||
{
|
||||
std::transform(_ddl_ref_units.begin(), _ddl_ref_units.end(), _ddl_ref_units.begin(), DDLDescription::deleteChild<DDLRefUnit>);
|
||||
_ddl_ref_units.clear();
|
||||
_ddl_ref_units = vecDDLRefUnits;
|
||||
std::transform(_ddl_ref_units.begin(), _ddl_ref_units.end(), _ddl_ref_units.begin(), DDLDescription::clone<DDLRefUnit>);
|
||||
}
|
||||
|
||||
void DDLUnit::setRefUnits(DDLRefUnitVec vecDDLRefUnits)
|
||||
{
|
||||
std::transform(_ddl_ref_units.begin(), _ddl_ref_units.end(), _ddl_ref_units.begin(), DDLDescription::deleteChild<DDLRefUnit>);
|
||||
_ddl_ref_units.clear();
|
||||
_ddl_ref_units = vecDDLRefUnits;
|
||||
}
|
||||
|
||||
void swap(DDLUnit & lhs, DDLUnit & rhs) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(lhs._ddl_ref_units, rhs._ddl_ref_units);
|
||||
swap(lhs._denominator, rhs._denominator);
|
||||
swap(lhs._init_flag, rhs._init_flag);
|
||||
swap(lhs._level, rhs._level);
|
||||
swap(lhs._name, rhs._name);
|
||||
swap(lhs._numerator, rhs._numerator);
|
||||
swap(lhs._offset, rhs._offset);
|
||||
}
|
||||
|
||||
} // namespace ddl
|
228
ddlrepresentation/ddlunit.h
Normal file
228
ddlrepresentation/ddlunit.h
Normal file
|
@ -0,0 +1,228 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef UNIT_H_INCLUDED
|
||||
#define UNIT_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddlunit_intf.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
class DDLRefUnit;
|
||||
|
||||
/**
|
||||
* Container type of DDLRefUnit objects
|
||||
*/
|
||||
typedef std::vector<DDLRefUnit*> DDLRefUnitVec;
|
||||
/**
|
||||
* Iterator type for DDLRefUnitVec
|
||||
*/
|
||||
typedef DDLRefUnitVec::iterator DDLRefUnitIt;
|
||||
|
||||
/**
|
||||
* Representation object of a unit
|
||||
*/
|
||||
class DDLUnit : public IDDLUnit
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default CTOR
|
||||
*/
|
||||
DDLUnit();
|
||||
|
||||
/**
|
||||
* CTOR
|
||||
* @param[in] name - Name of the new unit
|
||||
* @param[in] numerator - Numerator of the new unit
|
||||
* @param[in] denominator - Denominator of the new unit
|
||||
* @param[in] offset - Offset to the base units
|
||||
* @param[in] ddl_ref_units - Vector of reference units (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
*/
|
||||
DDLUnit(const std::string& name,
|
||||
const std::string& numerator,
|
||||
const std::string& denominator,
|
||||
double const offset,
|
||||
DDLRefUnitVec ddl_ref_units = DDLRefUnitVec(),
|
||||
int const creation_level = 1);
|
||||
|
||||
/**
|
||||
* Copy CTOR
|
||||
* @param[in] other - Reference to unit object to copy
|
||||
*/
|
||||
DDLUnit(const DDLUnit& other);
|
||||
|
||||
/**
|
||||
* Assignment operator (either copies or moves)
|
||||
* @param[in] other DDL unit object to copy from
|
||||
* @return @c *this
|
||||
*/
|
||||
DDLUnit& operator=(DDLUnit other);
|
||||
|
||||
/**
|
||||
* Move CTOR
|
||||
* @param[in,out] other DDL unit object to move from - empty but valid when finished
|
||||
*/
|
||||
DDLUnit(DDLUnit&& other);
|
||||
|
||||
/**
|
||||
* DTOR
|
||||
*/
|
||||
virtual ~DDLUnit();
|
||||
|
||||
a_util::result::Result accept(IDDLVisitor *visitor) const;
|
||||
a_util::result::Result accept(IDDLChangeVisitor *visitor);
|
||||
|
||||
bool isInitialized() const;
|
||||
|
||||
bool isPredefined() const;
|
||||
bool isOverwriteable() const;
|
||||
|
||||
int getCreationLevel() const;
|
||||
|
||||
/**
|
||||
* Creation method to fill the object with data.
|
||||
* @param[in] name - Name of the new unit
|
||||
* @param[in] numerator - Numerator of the new unit
|
||||
* @param[in] denominator - Denominator of the new unit
|
||||
* @param[in] offset - Offset to the base units
|
||||
* @param[in] ddl_ref_units - Vector of reference units (optional)
|
||||
* @param[in] creation_level - Level at creation time (optional)
|
||||
* @retval ERR_INVALID_ARG Empty name committed
|
||||
*/
|
||||
a_util::result::Result create(const std::string& name,
|
||||
const std::string& numerator,
|
||||
const std::string& denominator,
|
||||
double const offset,
|
||||
DDLRefUnitVec ddl_ref_units = DDLRefUnitVec(),
|
||||
int const creation_level = 4);
|
||||
|
||||
/**
|
||||
* Getter for the name.
|
||||
* @return the name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Setter for the Name.
|
||||
*/
|
||||
void setName(const std::string& name);
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the numerator.
|
||||
* @return the numerator
|
||||
*/
|
||||
std::string getNumerator() const;
|
||||
|
||||
/**
|
||||
* Setter for the Denominator.
|
||||
*/
|
||||
void setNumerator(const std::string& numerator);
|
||||
|
||||
/**
|
||||
* Getter for the denominator.
|
||||
* @return the denominator
|
||||
*/
|
||||
std::string getDenominator() const;
|
||||
|
||||
/**
|
||||
* Setter for the Denominator.
|
||||
*/
|
||||
void setDenominator(const std::string& denominator);
|
||||
|
||||
/**
|
||||
* Getter for the offset.
|
||||
* @return the offset
|
||||
*/
|
||||
double getOffset() const;
|
||||
|
||||
/**
|
||||
* Setter for the offset.
|
||||
*/
|
||||
void setOffset(double const offset);
|
||||
|
||||
/**
|
||||
* Getter for the reference unit.
|
||||
* @return the reference unit
|
||||
*/
|
||||
DDLRefUnitVec& getRefUnits();
|
||||
|
||||
/**
|
||||
* Getter for the reference unit.
|
||||
* @return the reference unit
|
||||
*/
|
||||
const DDLRefUnitVec& getRefUnits() const;
|
||||
|
||||
/**
|
||||
* Adder for a reference unit.
|
||||
* @param[in] ref_unit - Pointer to the reference unit to add
|
||||
* @param[in] pos - Position to add the reference unit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void addRefUnit(DDLRefUnit* ref_unit, int pos = -1);
|
||||
|
||||
/**
|
||||
* Remover for a reference unit.
|
||||
* @param[in] ref_unit - name of the reference unit to remove
|
||||
* @retval ERR_NOT_FOUND Specified reference unit not found.
|
||||
*/
|
||||
a_util::result::Result removeRefUnit(const std::string& ref_unit);
|
||||
|
||||
/**
|
||||
* Setter for the reference units
|
||||
* @param[in] ddl_ref_units - Vector of reference units
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void cloneRefUnits(DDLRefUnitVec ddl_ref_units);
|
||||
|
||||
/**
|
||||
* Setter for the reference units
|
||||
* @param[in] ddl_ref_units - Vector of reference units
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void setRefUnits(DDLRefUnitVec ddl_ref_units);
|
||||
|
||||
/**
|
||||
* Add swap functionality, also enabling the copy-swap-idiom
|
||||
* @param[in,out] lhs Left-hand side ddl type
|
||||
* @param[in,out] rhs Right-hand side ddl type
|
||||
*/
|
||||
friend void swap(DDLUnit& lhs, DDLUnit& rhs) noexcept;
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
std::string _numerator;
|
||||
std::string _denominator;
|
||||
double _offset;
|
||||
DDLRefUnitVec _ddl_ref_units;
|
||||
|
||||
bool _init_flag;
|
||||
int _level;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // _UNIT_H_INCLUDED
|
43
ddlrepresentation/ddlunit_intf.h
Normal file
43
ddlrepresentation/ddlunit_intf.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLUNIT_INTF_H_INCLUDED
|
||||
#define DDLUNIT_INTF_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
#include "ddl_intf.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
/**
|
||||
* Interface for unit classes of the object representation for
|
||||
* DDL descriptions.
|
||||
*/
|
||||
class IDDLUnit : public IDDL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Virtual DTOR
|
||||
*/
|
||||
virtual ~IDDLUnit(){}
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // _UNIT_INTF_H_INCLUDED_
|
175
ddlrepresentation/ddlversion.cpp
Normal file
175
ddlrepresentation/ddlversion.cpp
Normal file
|
@ -0,0 +1,175 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#include "ddlversion.h"
|
||||
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
|
||||
const DDLVersion DDLVersion::ddl_version_invalid = DDLVersion(0, 0);
|
||||
const DDLVersion DDLVersion::ddl_version_10 = DDLVersion(1, 0);
|
||||
const DDLVersion DDLVersion::ddl_version_11 = DDLVersion(1, 1);
|
||||
const DDLVersion DDLVersion::ddl_version_12 = DDLVersion(1, 2);
|
||||
const DDLVersion DDLVersion::ddl_version_20 = DDLVersion(2, 0);
|
||||
const DDLVersion DDLVersion::ddl_version_30 = DDLVersion(3, 0);
|
||||
const DDLVersion DDLVersion::ddl_version_40 = DDLVersion(4, 0);
|
||||
const DDLVersion DDLVersion::ddl_version_41 = DDLVersion(4, 1);
|
||||
const DDLVersion DDLVersion::ddl_version_current = ddl_version_41;
|
||||
|
||||
DDLVersion::DDLVersion(): DDLVersion(DDLVersion::getDefaultVersion())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DDLVersion::DDLVersion(uint32_t major, uint32_t minor) :
|
||||
_major(major), _minor(minor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t DDLVersion::getMajor() const
|
||||
{
|
||||
return _major;
|
||||
}
|
||||
|
||||
uint32_t DDLVersion::getMinor() const
|
||||
{
|
||||
return _minor;
|
||||
}
|
||||
|
||||
std::string DDLVersion::toString() const
|
||||
{
|
||||
if (*this == DDLVersion(1, 1))
|
||||
{
|
||||
return std::string("1.0+");
|
||||
}
|
||||
return a_util::strings::format("%u.%02u", _major, _minor);
|
||||
}
|
||||
|
||||
DDLVersion DDLVersion::fromString(const std::string& version)
|
||||
{
|
||||
if (version.size() == 0)
|
||||
{
|
||||
return ddl_version_invalid;
|
||||
}
|
||||
auto tokens = a_util::strings::split(version, ".");
|
||||
|
||||
uint32_t major = 0, minor = 0;
|
||||
|
||||
if (a_util::strings::isUInt32(tokens.at(0)))
|
||||
{
|
||||
major = a_util::strings::toUInt32(tokens.at(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
return ddl_version_invalid;
|
||||
}
|
||||
|
||||
if (tokens.size() == 2)
|
||||
{
|
||||
//special case 1.0+
|
||||
if (tokens.at(1) == "0+" || tokens.at(1) == "00+")
|
||||
{
|
||||
minor = 1;
|
||||
}
|
||||
// standard case
|
||||
else if (a_util::strings::isUInt32(tokens.at(1)))
|
||||
{
|
||||
minor = a_util::strings::toUInt32(tokens.at(1));
|
||||
}
|
||||
}
|
||||
return DDLVersion(major, minor);
|
||||
}
|
||||
|
||||
bool DDLVersion::isValidVersion() const
|
||||
{
|
||||
if (*this < ddl_version_10)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*this > ddl_version_current)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DDLVersion::operator ==(const DDLVersion& other) const
|
||||
{
|
||||
if (_major == other._major && _minor == other._minor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DDLVersion::operator !=(const DDLVersion& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
bool DDLVersion::operator >(const DDLVersion& other) const
|
||||
{
|
||||
if (_major > other._major)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (_major < other._major)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_minor > other._minor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DDLVersion::operator <(const DDLVersion& other) const
|
||||
{
|
||||
if (_major < other._major)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (_major > other._major)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_minor < other._minor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DDLVersion::operator <=(const DDLVersion& other) const
|
||||
{
|
||||
return !(*this > other);
|
||||
}
|
||||
|
||||
bool DDLVersion::operator >=(const DDLVersion& other) const
|
||||
{
|
||||
return !(*this < other);
|
||||
}
|
||||
}
|
75
ddlrepresentation/ddlversion.h
Normal file
75
ddlrepresentation/ddlversion.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDLVERSION_H_INCLUDED
|
||||
#define DDLVERSION_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
class DDLVersion
|
||||
{
|
||||
public:
|
||||
DDLVersion();
|
||||
|
||||
DDLVersion(uint32_t major, uint32_t minor);
|
||||
|
||||
uint32_t getMajor() const;
|
||||
uint32_t getMinor() const;
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
bool isValidVersion() const;
|
||||
|
||||
static DDLVersion fromString(const std::string& version);
|
||||
|
||||
static const DDLVersion& getDefaultVersion()
|
||||
{
|
||||
return ddl_version_current;
|
||||
}
|
||||
|
||||
/* ignore patch version for all comparisons */
|
||||
bool operator ==(const DDLVersion& other) const;
|
||||
bool operator !=(const DDLVersion& other) const;
|
||||
bool operator >(const DDLVersion& other) const;
|
||||
bool operator <(const DDLVersion& other) const;
|
||||
bool operator <=(const DDLVersion& other) const;
|
||||
bool operator >=(const DDLVersion& other) const;
|
||||
|
||||
// known Versions
|
||||
static const DDLVersion ddl_version_invalid;
|
||||
static const DDLVersion ddl_version_10;
|
||||
static const DDLVersion ddl_version_11;
|
||||
static const DDLVersion ddl_version_12;
|
||||
static const DDLVersion ddl_version_20;
|
||||
static const DDLVersion ddl_version_30;
|
||||
static const DDLVersion ddl_version_40;
|
||||
static const DDLVersion ddl_version_41;
|
||||
static const DDLVersion ddl_version_current;
|
||||
|
||||
|
||||
private:
|
||||
uint32_t _major;
|
||||
uint32_t _minor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
291
ddlrepresentation/ddlvisitor_intf.h
Normal file
291
ddlrepresentation/ddlvisitor_intf.h
Normal file
|
@ -0,0 +1,291 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef DDL_VISITOR_H_INCLUDED
|
||||
#define DDL_VISITOR_H_INCLUDED
|
||||
|
||||
#include "ddl_common.h"
|
||||
|
||||
namespace ddl
|
||||
{
|
||||
class DDLHeader;
|
||||
class DDLDataType;
|
||||
class DDLComplex;
|
||||
class DDLStream;
|
||||
class DDLUnit;
|
||||
class DDLBaseunit;
|
||||
class DDLExtDeclaration;
|
||||
class DDLElement;
|
||||
class DDLDescription;
|
||||
class DDLPrefix;
|
||||
class DDLRefUnit;
|
||||
class DDLStreamStruct;
|
||||
class DDLEnum;
|
||||
class DDLStreamMetaType;
|
||||
class DDLProperty;
|
||||
|
||||
/**
|
||||
* Abstract base class/interface for Visitor design-pattern.
|
||||
*/
|
||||
class IDDLVisitor
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* DTOR
|
||||
*/
|
||||
virtual ~IDDLVisitor(){}
|
||||
|
||||
/**
|
||||
* Visitor for a whole DDL description.
|
||||
* @param[in] description - Pointer to the description object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
* @retval ERR_NOT_INITIALIZED Not yet initialized
|
||||
*/
|
||||
virtual a_util::result::Result visitDDL(const DDLDescription* description) = 0;
|
||||
/**
|
||||
* Visitor for DDL header objects.
|
||||
* @param[in] header - Pointer to the header object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLHeader* header) = 0;
|
||||
/**
|
||||
* Visitor for DDL datatype objects.
|
||||
* @param[in] data_type - Pointer to the datatype object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
* @retval ERR_NOT_SUPPORTED Data type detected which is not supported.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLDataType* data_type) = 0;
|
||||
/**
|
||||
* Visitor for DDL struct objects.
|
||||
* @param[in] ddl_struct - Pointer to the struct object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLComplex* ddl_struct) = 0;
|
||||
/**
|
||||
* Visitor for DDL stream objects.
|
||||
* @param[in] stream - Pointer to the stream object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLStream* stream) = 0;
|
||||
/**
|
||||
* Visitor for DDL unit objects.
|
||||
* @param[in] unit - Pointer to the unit object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLUnit* unit) = 0;
|
||||
/**
|
||||
* Visitor for DDL baseunit objects.
|
||||
* @param[in] baseunit - Pointer to the baseunit object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLBaseunit* baseunit) = 0;
|
||||
/**
|
||||
* Visitor for external DDL declaration objects.
|
||||
* @param[in] ext_declaration - Pointer to the extdeclaration object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLExtDeclaration* ext_declaration) = 0;
|
||||
/**
|
||||
* Visitor for DDL element objects.
|
||||
* @param[in] element - Pointer to the element object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLElement* element) = 0;
|
||||
/**
|
||||
* Visitor for DDL prefix objects.
|
||||
* @param[in] prefix - Pointer to the prefix object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLPrefix* prefix) = 0;
|
||||
/**
|
||||
* Visitor for DDL reference unit objects.
|
||||
* @param[in] ref_unit - Pointer to the refunit object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLRefUnit* ref_unit) = 0;
|
||||
/**
|
||||
* Visitor for DDL streamstruct objects.
|
||||
* @param[in] stream_struct - Pointer to the streamstruct object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLStreamStruct* stream_struct) = 0;
|
||||
|
||||
/**
|
||||
* Visitor for DDL enum objects.
|
||||
* @param[in] ddl_enum - Pointer to the enum object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLEnum* ddl_enum) = 0;
|
||||
|
||||
/**
|
||||
* Visitor for DDL stream meta type objects.
|
||||
* @param[in] stream_meta_type - Pointer to the object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLStreamMetaType* stream_meta_type) = 0;
|
||||
|
||||
/**
|
||||
* Visitor for DDL property objects.
|
||||
* @param[in] ddl_property - Pointer to the object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(const DDLProperty* ddl_property) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstract base class/interface for Visitor design-pattern.
|
||||
*/
|
||||
class IDDLChangeVisitor
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* DTOR
|
||||
*/
|
||||
virtual ~IDDLChangeVisitor() {}
|
||||
|
||||
/**
|
||||
* Visitor for a whole DDL description.
|
||||
* @param[in] description - Pointer to the description object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
* @retval ERR_NOT_INITIALIZED Not yet initialized
|
||||
*/
|
||||
virtual a_util::result::Result visitDDL(DDLDescription* description) = 0;
|
||||
/**
|
||||
* Visitor for DDL header objects.
|
||||
* @param[in] header - Pointer to the header object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLHeader* header) = 0;
|
||||
/**
|
||||
* Visitor for DDL datatype objects.
|
||||
* @param[in] data_type - Pointer to the datatype object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
* @retval ERR_NOT_SUPPORTED Data type detected which is not supported.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLDataType* data_type) = 0;
|
||||
/**
|
||||
* Visitor for DDL struct objects.
|
||||
* @param[in] ddl_struct - Pointer to the struct object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLComplex* ddl_struct) = 0;
|
||||
/**
|
||||
* Visitor for DDL stream objects.
|
||||
* @param[in] stream - Pointer to the stream object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLStream* stream) = 0;
|
||||
/**
|
||||
* Visitor for DDL unit objects.
|
||||
* @param[in] unit - Pointer to the unit object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLUnit* unit) = 0;
|
||||
/**
|
||||
* Visitor for DDL baseunit objects.
|
||||
* @param[in] baseunit - Pointer to the baseunit object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLBaseunit* baseunit) = 0;
|
||||
/**
|
||||
* Visitor for external DDL declaration objects.
|
||||
* @param[in] ext_declaration - Pointer to the extdeclaration object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLExtDeclaration* ext_declaration) = 0;
|
||||
/**
|
||||
* Visitor for DDL element objects.
|
||||
* @param[in] element - Pointer to the element object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLElement* element) = 0;
|
||||
/**
|
||||
* Visitor for DDL prefix objects.
|
||||
* @param[in] prefix - Pointer to the prefix object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLPrefix* prefix) = 0;
|
||||
/**
|
||||
* Visitor for DDL reference unit objects.
|
||||
* @param[in] ref_unit - Pointer to the refunit object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLRefUnit* ref_unit) = 0;
|
||||
/**
|
||||
* Visitor for DDL streamstruct objects.
|
||||
* @param[in] stream_struct - Pointer to the streamstruct object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLStreamStruct* stream_struct) = 0;
|
||||
|
||||
/**
|
||||
* Visitor for DDL enum objects.
|
||||
* @param[in] ddl_enum - Pointer to the enum object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLEnum* ddl_enum) = 0;
|
||||
|
||||
/**
|
||||
* Visitor for DDL stream meta type objects.
|
||||
* @param[in] stream_meta_type - Pointer to the object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLStreamMetaType* stream_meta_type) = 0;
|
||||
|
||||
/**
|
||||
* Visitor for DDL property objects.
|
||||
* @param[in] ddl_property - Pointer to the object
|
||||
* @retval ERR_POINTER Null-pointer committed
|
||||
* @retval ERR_NOT_FOUND Required node not found.
|
||||
*/
|
||||
virtual a_util::result::Result visit(DDLProperty* ddl_property) = 0;
|
||||
};
|
||||
|
||||
} // namespace ddl
|
||||
|
||||
#endif // DDL_VISITOR_H_INCLUDED
|
109
ddlrepresentation/pkg_ddlrepresentation.h
Normal file
109
ddlrepresentation/pkg_ddlrepresentation.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* @file
|
||||
* Package header for DDL
|
||||
* This package provides the DDL Represantations and Coder.
|
||||
*
|
||||
* @copyright
|
||||
* @verbatim
|
||||
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla
|
||||
Public License, v. 2.0. If a copy of the MPL was not distributed
|
||||
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
#ifndef _PACKAGE_DDL_REPRESENTATION_HEADER_
|
||||
#define _PACKAGE_DDL_REPRESENTATION_HEADER_
|
||||
|
||||
// forward declarations
|
||||
// very ugly hack, but linearizing all dependencies is not an option right now
|
||||
namespace ddl {
|
||||
class DDL;
|
||||
class DDLError;
|
||||
class IDDL;
|
||||
class DDLAlignment;
|
||||
class DDLBaseunit;
|
||||
class IDDLUnit;
|
||||
class DDLByteorder;
|
||||
class DDLCloner;
|
||||
class DDLCompare;
|
||||
class DDLComplex;
|
||||
class IDDLDataType;
|
||||
class DDLDataType;
|
||||
class DDLDescription;
|
||||
class DDLElement;
|
||||
class DDLEnum;
|
||||
class DDLExtDeclaration;
|
||||
class IDDLFactoryMethod;
|
||||
class DDLHeader;
|
||||
class DDLImporter;
|
||||
class DDLInspector;
|
||||
class DDLPrefix;
|
||||
class DDLPrinter;
|
||||
class DDLProperty;
|
||||
class DDLRefUnit;
|
||||
class DDLRepair;
|
||||
class DDLResolver;
|
||||
class DDLStream;
|
||||
class DDLStreamMetaType;
|
||||
class DDLStreamStruct;
|
||||
class DDLUnit;
|
||||
class IDDLUnit;
|
||||
class IDDLVisitor;
|
||||
}
|
||||
|
||||
|
||||
#include <stack>
|
||||
#include <algorithm>
|
||||
|
||||
//common errordefintion
|
||||
#include "ddl_error.h"
|
||||
//common supported versions
|
||||
#include "ddlversion.h"
|
||||
|
||||
// OO-DDL interfaces
|
||||
#include "ddl_intf.h"
|
||||
#include "ddl_type.h"
|
||||
#include "ddlalignment.h"
|
||||
|
||||
#include "ddlserializable_intf.h"
|
||||
#include "ddlunit_intf.h"
|
||||
#include "ddldatatype_intf.h"
|
||||
#include "ddlvisitor_intf.h"
|
||||
#include "ddlfactorymethod_intf.h"
|
||||
|
||||
// DDL object representation (OO-DDL)
|
||||
#include "ddlbyteorder.h"
|
||||
#include "ddlcomplex.h"
|
||||
#include "ddldatatype.h"
|
||||
#include "ddlheader.h"
|
||||
#include "ddlstream.h"
|
||||
#include "ddlenum.h"
|
||||
#include "ddlcontainer.h"
|
||||
#include "ddldescription.h"
|
||||
#include "ddlunit.h"
|
||||
#include "ddlrefunit.h"
|
||||
#include "ddlprefix.h"
|
||||
#include "ddlextdeclaration.h"
|
||||
#include "ddlelement.h"
|
||||
#include "ddlbaseunit.h"
|
||||
#include "ddlstreamstruct.h"
|
||||
#include "ddlstreammetatype.h"
|
||||
#include "ddlproperty.h"
|
||||
#include "ddlprinter.h"
|
||||
#include "ddlimporter.h"
|
||||
#include "ddlcloner.h"
|
||||
#include "ddlresolver.h"
|
||||
#include "ddlrepair.h"
|
||||
#include "ddlinspector.h"
|
||||
#include "ddlcompare.h"
|
||||
|
||||
#endif // _PACKAGE_DDL_REPRESENTATION_HEADER_
|
||||
|
82
ddlrepresentation/pkg_ddlrepresentation.sources
Normal file
82
ddlrepresentation/pkg_ddlrepresentation.sources
Normal file
|
@ -0,0 +1,82 @@
|
|||
set(DDLREPRESENTATION_DIR ddlrepresentation)
|
||||
|
||||
set(DDLREPRESENTATION_H
|
||||
${DDLREPRESENTATION_DIR}/ddl_common.h
|
||||
${DDLREPRESENTATION_DIR}/pkg_ddlrepresentation.h
|
||||
|
||||
${DDLREPRESENTATION_DIR}/ddl_error.h
|
||||
${DDLREPRESENTATION_DIR}/ddlversion.h
|
||||
|
||||
${DDLREPRESENTATION_DIR}/ddl_intf.h
|
||||
${DDLREPRESENTATION_DIR}/ddl_type.h
|
||||
${DDLREPRESENTATION_DIR}/ddlalignment.h
|
||||
|
||||
${DDLREPRESENTATION_DIR}/ddlserializable_intf.h
|
||||
${DDLREPRESENTATION_DIR}/ddlunit_intf.h
|
||||
${DDLREPRESENTATION_DIR}/ddldatatype_intf.h
|
||||
${DDLREPRESENTATION_DIR}/ddlvisitor_intf.h
|
||||
${DDLREPRESENTATION_DIR}/ddlfactorymethod_intf.h
|
||||
|
||||
${DDLREPRESENTATION_DIR}/ddlbyteorder.h
|
||||
${DDLREPRESENTATION_DIR}/ddlcomplex.h
|
||||
${DDLREPRESENTATION_DIR}/ddldatatype.h
|
||||
${DDLREPRESENTATION_DIR}/ddlheader.h
|
||||
${DDLREPRESENTATION_DIR}/ddlstream.h
|
||||
${DDLREPRESENTATION_DIR}/ddlenum.h
|
||||
${DDLREPRESENTATION_DIR}/ddlcontainer.h
|
||||
${DDLREPRESENTATION_DIR}/ddldescription.h
|
||||
${DDLREPRESENTATION_DIR}/ddlunit.h
|
||||
${DDLREPRESENTATION_DIR}/ddlrefunit.h
|
||||
${DDLREPRESENTATION_DIR}/ddlprefix.h
|
||||
${DDLREPRESENTATION_DIR}/ddlextdeclaration.h
|
||||
${DDLREPRESENTATION_DIR}/ddlelement.h
|
||||
${DDLREPRESENTATION_DIR}/ddlbaseunit.h
|
||||
${DDLREPRESENTATION_DIR}/ddlstreamstruct.h
|
||||
${DDLREPRESENTATION_DIR}/ddlprinter.h
|
||||
${DDLREPRESENTATION_DIR}/ddlimporter.h
|
||||
${DDLREPRESENTATION_DIR}/ddlcloner.h
|
||||
${DDLREPRESENTATION_DIR}/ddlresolver.h
|
||||
${DDLREPRESENTATION_DIR}/ddlrepair.h
|
||||
${DDLREPRESENTATION_DIR}/ddlinspector.h
|
||||
${DDLREPRESENTATION_DIR}/ddlcompare.h
|
||||
${DDLREPRESENTATION_DIR}/ddlstreammetatype.h
|
||||
${DDLREPRESENTATION_DIR}/ddlproperty.h
|
||||
)
|
||||
|
||||
set(DDLREPRESENTATION_CPP
|
||||
|
||||
${DDLREPRESENTATION_DIR}/ddl_error.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlversion.cpp
|
||||
|
||||
${DDLREPRESENTATION_DIR}/ddl_type.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlalignment.cpp
|
||||
|
||||
${DDLREPRESENTATION_DIR}/ddlbyteorder.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlcomplex.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddldatatype.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlheader.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlstream.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlenum.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlcontainer.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddldescription.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlunit.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlrefunit.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlprefix.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlextdeclaration.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlelement.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlbaseunit.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlstreamstruct.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlprinter.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlimporter.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlcloner.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlresolver.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlrepair.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlinspector.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlcompare.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlstreammetatype.cpp
|
||||
${DDLREPRESENTATION_DIR}/ddlproperty.cpp
|
||||
)
|
||||
|
||||
set(DDLREPRESENTATION_INSTALL ${DDLREPRESENTATION_H})
|
||||
source_group(${DDLREPRESENTATION_DIR} FILES ${DDLREPRESENTATION_H} ${DDLREPRESENTATION_CPP})
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue