text:
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file TypesPubSubTypes.h
 * This header file contains the declaration of the serialization functions.
 *
 * This file was generated by the tool fastcdrgen.
 */

#ifndef _TYPES_PUBSUBTYPES_H_
#define _TYPES_PUBSUBTYPES_H_

#include <fastrtps/config.h>
#include <fastrtps/TopicDataType.h>

#include "Types.h"

#if !defined(GEN_API_VER) || (GEN_API_VER != 1)
#error Generated Types is not compatible with current installed Fast-RTPS. Please, regenerate it with fastrtpsgen.
#endif

/*!
 * @brief This class represents the TopicDataType of the type MyEnumStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MyEnumStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MyEnumStruct type;

	MyEnumStructPubSubType();
	virtual ~MyEnumStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type MyBadEnumStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MyBadEnumStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MyBadEnumStruct type;

	MyBadEnumStructPubSubType();
	virtual ~MyBadEnumStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
typedef MyEnum MyAliasEnum;
/*!
 * @brief This class represents the TopicDataType of the type MyAliasEnumStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MyAliasEnumStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MyAliasEnumStruct type;

	MyAliasEnumStructPubSubType();
	virtual ~MyAliasEnumStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type BasicStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class BasicStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef BasicStruct type;

	BasicStructPubSubType();
	virtual ~BasicStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type BasicNamesStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class BasicNamesStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef BasicNamesStruct type;

	BasicNamesStructPubSubType();
	virtual ~BasicNamesStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type BasicBadStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class BasicBadStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef BasicBadStruct type;

	BasicBadStructPubSubType();
	virtual ~BasicBadStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type BasicWideStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class BasicWideStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef BasicWideStruct type;

	BasicWideStructPubSubType();
	virtual ~BasicWideStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type BadBasicWideStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class BadBasicWideStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef BadBasicWideStruct type;

	BadBasicWideStructPubSubType();
	virtual ~BadBasicWideStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type StringStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class StringStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef StringStruct type;

	StringStructPubSubType();
	virtual ~StringStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type LargeStringStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class LargeStringStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef LargeStringStruct type;

	LargeStringStructPubSubType();
	virtual ~LargeStringStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type WStringStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class WStringStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef WStringStruct type;

	WStringStructPubSubType();
	virtual ~WStringStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type LargeWStringStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class LargeWStringStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef LargeWStringStruct type;

	LargeWStringStructPubSubType();
	virtual ~LargeWStringStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type ArrayStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class ArrayStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef ArrayStruct type;

	ArrayStructPubSubType();
	virtual ~ArrayStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type ArrayStructEqual defined by the user in the IDL file.
 * @ingroup TYPES
 */
class ArrayStructEqualPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef ArrayStructEqual type;

	ArrayStructEqualPubSubType();
	virtual ~ArrayStructEqualPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type ArrayBadStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class ArrayBadStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef ArrayBadStruct type;

	ArrayBadStructPubSubType();
	virtual ~ArrayBadStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type ArrayDimensionsStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class ArrayDimensionsStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef ArrayDimensionsStruct type;

	ArrayDimensionsStructPubSubType();
	virtual ~ArrayDimensionsStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type ArraySizeStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class ArraySizeStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef ArraySizeStruct type;

	ArraySizeStructPubSubType();
	virtual ~ArraySizeStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SequenceStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SequenceStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SequenceStruct type;

	SequenceStructPubSubType();
	virtual ~SequenceStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SequenceStructEqual defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SequenceStructEqualPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SequenceStructEqual type;

	SequenceStructEqualPubSubType();
	virtual ~SequenceStructEqualPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SequenceBadStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SequenceBadStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SequenceBadStruct type;

	SequenceBadStructPubSubType();
	virtual ~SequenceBadStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SequenceBoundsStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SequenceBoundsStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SequenceBoundsStruct type;

	SequenceBoundsStructPubSubType();
	virtual ~SequenceBoundsStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SequenceSequenceStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SequenceSequenceStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SequenceSequenceStruct type;

	SequenceSequenceStructPubSubType();
	virtual ~SequenceSequenceStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SequenceSequenceBoundsStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SequenceSequenceBoundsStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SequenceSequenceBoundsStruct type;

	SequenceSequenceBoundsStructPubSubType();
	virtual ~SequenceSequenceBoundsStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type MapStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MapStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MapStruct type;

	MapStructPubSubType();
	virtual ~MapStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type MapStructEqual defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MapStructEqualPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MapStructEqual type;

	MapStructEqualPubSubType();
	virtual ~MapStructEqualPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type MapBadKeyStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MapBadKeyStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MapBadKeyStruct type;

	MapBadKeyStructPubSubType();
	virtual ~MapBadKeyStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type MapBadElemStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MapBadElemStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MapBadElemStruct type;

	MapBadElemStructPubSubType();
	virtual ~MapBadElemStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type MapBoundsStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MapBoundsStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MapBoundsStruct type;

	MapBoundsStructPubSubType();
	virtual ~MapBoundsStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type MapMapStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MapMapStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MapMapStruct type;

	MapMapStructPubSubType();
	virtual ~MapMapStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type MapMapBoundsStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class MapMapBoundsStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef MapMapBoundsStruct type;

	MapMapBoundsStructPubSubType();
	virtual ~MapMapBoundsStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};

/*!
 * @brief This class represents the TopicDataType of the type SimpleUnionStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SimpleUnionStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SimpleUnionStruct type;

	SimpleUnionStructPubSubType();
	virtual ~SimpleUnionStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SimpleUnionStructEqual defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SimpleUnionStructEqualPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SimpleUnionStructEqual type;

	SimpleUnionStructEqualPubSubType();
	virtual ~SimpleUnionStructEqualPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SimpleUnionNamesStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SimpleUnionNamesStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SimpleUnionNamesStruct type;

	SimpleUnionNamesStructPubSubType();
	virtual ~SimpleUnionNamesStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SimpleTypeUnionStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SimpleTypeUnionStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SimpleTypeUnionStruct type;

	SimpleTypeUnionStructPubSubType();
	virtual ~SimpleTypeUnionStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SimpleBadUnionStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SimpleBadUnionStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SimpleBadUnionStruct type;

	SimpleBadUnionStructPubSubType();
	virtual ~SimpleBadUnionStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};
/*!
 * @brief This class represents the TopicDataType of the type SimplBadDiscUnionStruct defined by the user in the IDL file.
 * @ingroup TYPES
 */
class SimplBadDiscUnionStructPubSubType : public eprosima::fastrtps::TopicDataType {
public:
        typedef SimplBadDiscUnionStruct type;

	SimplBadDiscUnionStructPubSubType();
	virtual ~SimplBadDiscUnionStructPubSubType();
	virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override;
	virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override;
    virtual std::function<uint32_t()> getSerializedSizeProvider(void* data) override;
	virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle,
		bool force_md5 = false) override;
	virtual void* createData() override;
	virtual void deleteData(void * data) override;
	MD5 m_md5;
	unsigned char* m_keyBuffer;
};

#endif // _TYPES_PUBSUBTYPES_H_


text:
/*
 *  Prepare an ECMAScript or API testcase file for execution.
 */

'use strict';

const { assert } = require('../../util/assert');
const { minifyBestAvailable } = require('./minify');
const { ecmascriptTestFrameworkSource } = require('./ecma_test_framework');
const { cTestFrameworkSource, cTestcaseMain } = require('./c_test_framework');
const { readFileUtf8, pathJoin, dirname } = require('../../util/fs');
const { parseTestcaseMetadata } = require('./parse_test_meta');
const { logInfo, logDebug } = require('../../util/logging');

function prepareCTestcase({ sourceString }) {
    assert(typeof sourceString === 'string');

    // Prepend some defines to the testcase, and a main() function.
    let result = cTestFrameworkSource + sourceString + '\n' + cTestcaseMain;

    return result;
}
exports.prepareCTestcase = prepareCTestcase;

function prepareEcmascriptTestcase({ sourceString, includeDirectory, testcaseMetadata, polyfillFilenames, promiseHack, tryCatchWrapper, tryCatchRethrow, uglifyJsExePath, uglifyJs2ExePath, closureJarPath }) {
    assert(typeof sourceString === 'string');
    var meta = testcaseMetadata || {};
    var parts = [];
    var sourceWithIncludes;

    function minify(sourceString) {
        let { result } = minifyBestAvailable({
            sourceString,
            uglifyJsExePath,
            uglifyJs2ExePath,
            closureJarPath
        });
        return result;
    }

    // Process include files.  Replace each include with a one-line
    // minified version of the include file, thus preserving line
    // numbers.
    sourceWithIncludes = sourceString.replace(/^\/\*@include\s+(.*?)\s*@\*\/$/gm, (m, a) => {
        assert(typeof includeDirectory === 'string');
        let fn = pathJoin(includeDirectory, a);
        let data = readFileUtf8(fn);
        return '/* Included: ' + a + ' -> ' + fn + ' */ ' + minify(data);
    });

    // If the testcase needs to run strict program level code, prepend
    // a 'use strict' declaration.
    if (meta.use_strict) {
        parts.push("/* FORCE STRICT START */ 'use strict'; /* FORCE STRICT END */ ");
    }

    // Inject shared engine prefix and a possible try-catch wrapper,
    // without disturbing line numbers.
    parts.push(minify(ecmascriptTestFrameworkSource), ' ');
    if (tryCatchWrapper) {
        parts.push('/* TRY-CATCH WRAPPER START */ try { /* TRY-CATCH WRAPPER END */ ');
    }

    // Insert polyfills.
    if (Array.isArray(polyfillFilenames)) {
        for (let fn of polyfillFilenames) {
            let data = readFileUtf8(fn);
            parts.push('/* START POLYFILL: ' + fn + ' */ ', minify(data), ' /* END POLYFILL: ' + fn + ' */ ');
        }
    }

    // Prepared source code, still preserving line numbers.
    parts.push(sourceWithIncludes);

    // Promise hack; run job queue to completion at end of file.
    if (promiseHack) {
        parts.push("/* START PROMISE HACK */ if (typeof Promise === 'function' && typeof Promise.runQueue === 'function') { Promise.runQueue(); } /* END PROMISE HACK */ ");
    }

    // End of try-catch wrapper.
    if (tryCatchWrapper) {
        parts.push('/* TRY-CATCH WRAPPER START */ } catch (wrapperError) { console.log(wrapperError.stack || wrapperError);');
        if (tryCatchRethrow) {
            parts.push(' throw(wrapperError);');
        } else {
            parts.push(' /*tryCatchRethrow disabled, eat error silently*/');
        }
        parts.push(' } /* TRY-CATCH WRAPPER END */');
    }

    let result = parts.join('');
    return result;
}
exports.prepareEcmascriptTestcase = prepareEcmascriptTestcase;

function prepareTestcase({ testcaseFilename, testcaseType, testcaseSource, testcaseMetadata, repoDirectory, includeDirectory, polyfillFilenames = [], promiseHack = true, tryCatchWrapper = true, tryCatchRethrow = false, uglifyJsExePath, uglifyJs2ExePath, closureJarPath }) {
    if (testcaseFilename) {
        assert(typeof testcaseFilename === 'string');
        if (testcaseFilename.endsWith('.js')) {
            testcaseType = testcaseType || 'ecmascript';
        } else if (testcaseFilename.endsWith('.c')) {
            testcaseType = testcaseType || 'c';
        } else {
            throw new TypeError('cannot determine testcase type for file: ' + testcaseFilename);
        }
        testcaseSource = readFileUtf8(testcaseFilename);
        includeDirectory = includeDirectory || dirname(testcaseFilename);
    } else if (testcaseSource && testcaseType) {
        // Keep as is.
        assert(typeof testcaseSource === 'string');
        assert(typeof testcaseType === 'string');
    } else {
        throw new TypeError('must provide testcaseFilename or testcaseSource and testcaseType');
    }

    let preparedSource;
    testcaseMetadata = testcaseMetadata || parseTestcaseMetadata({ sourceString: testcaseSource });

    let pfNames = [...polyfillFilenames];
    if (testcaseMetadata.duktape_polyfills) {
        let pfMap = testcaseMetadata.duktape_polyfills;
        for (let polyfillName of Object.getOwnPropertyNames(pfMap)) {
            if (polyfillName === 'promise' && pfMap[polyfillName] === true) {
                logDebug('add polyfill based on test metadata:', polyfillName);
                pfNames.push(pathJoin(repoDirectory, 'polyfills', 'promise.js'));
            }
        }
    }

    if (testcaseType === 'ecmascript') {
        preparedSource = prepareEcmascriptTestcase({
            sourceString: testcaseSource,
            includeDirectory,
            testcaseMetadata,
            polyfillFilenames: pfNames,
            promiseHack,
            tryCatchWrapper,
            tryCatchRethrow,
            uglifyJsExePath,
            uglifyJs2ExePath,
            closureJarPath
        });
    } else if (testcaseType === 'c') {
        preparedSource = prepareCTestcase({
            sourceString: testcaseSource,
            includeDirectory,
            testcaseMetadata
        });
    } else {
        throw new TypeError('unknown testcase type: ' + testcaseType);
    }

    return { preparedSource, testcaseMetadata, testcaseSource, testcaseFilename, testcaseType, includeDirectory };
}
exports.prepareTestcase = prepareTestcase;

redpajama_set_name: RedPajamaGithub


text:
/****************************************************************************************/
/*                                                                                */
/*                                       Pegasus                                        */
/*                                                                                */
/****************************************************************************************/

//! \file	TesselationTable.h
//! \author	Kleber Garcia
//! \date	29th June 2014
//! \brief	Class representing a table stored compact in memory, to increase cache access
//!         efficiency. Use this table to store values that have been generated from two parent
//!         indices. This table stores values independently on their index orders. Its
//!         best application is to be used as a double sided connectivity graph.

#ifndef PEGASUS_UTILS_TESSELATION_TABLE
#define PEGASUS_UTILS_TESSELATION_TABLE

namespace Pegasus
{

namespace Alloc
{
    class IAllocator;
}

namespace Utils
{

//! Compact Table - a table representing connectivity of a double linked graph
class TesselationTable
{
public:
    //! Constructor
    //! \param alloc - allocator for dynamic memory
    //! \param elementSize - the size of each node to be stored. Use the sizeof
    //!        operator to store structs or classes
    TesselationTable(Alloc::IAllocator * alloc, int elementSize, int maxBucketSize = 512);

    //! Destructor
    virtual ~TesselationTable();

    //! \brief Inserts an element (piece of information) on a connection between
    //!        two nodes (or vertex indices). The order in which i or j are inserted is
    //!        independent. Meaning that Insert(i,j,e) == Insert(j,i,e) is the same operation
    //! \param i the first index
    //! \param j the second index
    //! \param element the element to store
    template <class T>
    void Insert(int i, int j, const T& element);

    //! \brief Gets a particular element and inserts it in the element pointer passed.
    //!        the order of the indexes is irrelevant of the location, meaning that
    //!        Get(i,j,e) is an isoform of Get(j,i.e)
    //! \param i the first index
    //! \param j the second index
    //! \param piece of memory to retrieve
    //! \return true if the particular element has been found, false otherwise.
    //!         be warry, since elements are stored in order, if we insert two elements that are
    //!         very apart (i.e. indexes (0,0) and (89,0)) then we might have to fill data inbetween,
    //!         therefor this function will return true, with element filled with 0s.
    template <class T>
    bool Get(int i, int j, T& element);

    //! clears all data from the table
    void Clear();

private:

    //! internal implementation of insert
    //! \param i first index
    //! \param j second index
    //! \param element the element to insert
    void Insert(int i, int j, const char * element);

    //! internal implementation of Get
    //! \param i first index
    //! \param j second index
    //! \param element the element to fill with data
    //! \return true if the element found, false otherwise.
    bool Get(int i, int j, char * element);

    //! Allocation convenience function
    //! \param size in bytes to allocate
    void * Allocate(int size);

    //! Free convenience function
    //! \param ptr the pointer to free
    void   Free(void * ptr);

    //! retrieves the bucketIndex and bucketOffset which the memory requested
    //! belongs to.
    //! \param i - the first index
    //! \param j - the second index
    //! \param bucketIndex - output parameter of the bucket index
    //! \param bucketOffset - output parameter of the bucket offset
    void  ConstructIndices(int i, int j, int& bucketIndex, int& bucketOffset) const;

    //! allocator reference
    Alloc::IAllocator * mAllocator;

    //! actual data of the table
    void ** mRoot;

    //! the size of the leafs, in bytes
    int mElementSize;

    //! the size of each bucket, a bucket being a set of elements.
    //! size is in number of elements (not bytes)
    int mMaxBucketSize;

    //! maximum number of buckets this structure can hold in a master
    //! bucket list.
    int mBucketListCapacity;
};

template <class T>
void TesselationTable::Insert(int i, int j, const T& element)
{
    PG_ASSERTSTR(sizeof(T) == mElementSize, "FATAL! this will copy garbage to the target bucket");
    Insert(i, j, reinterpret_cast<const char*>(&element));
}

template <class T>
bool TesselationTable::Get(int i, int j, T& element)
{
    PG_ASSERTSTR(sizeof(T) == mElementSize, "FATAL! be ready to have the stack trashed.");
    return Get(i, j, reinterpret_cast<char*>(&element));
}

}
}

#endif


text:
using System;
using System.Collections.Generic;
using System.Text;
using Core.Basic;
using Core.Var;

namespace Core.CodeGeneration.Code
{
    public class SwizzleExpression : Expression
    {
        public SwizzleExpression(Expression e, params VectorMembers[] m)
        {
            //check parameters
            if (m.Length > 4)
                throw new ArgumentException("too many swizzle's");

            //swizzle dont work with float
            if (e.OutputFormat == Format.FLOAT)
                throw new ArgumentException("swizzle dont work with float");

            //no 'VectorMembers.None' inside 'm'
            for (int i = 0; i < m.Length; i++)
                if (m[i] == VectorMembers.None)
                    throw new ArgumentException("no 'VectorMembers.None' inside 'm'");

            //set data
            Expression = e;

            for (int i = 0; i < m.Length; i++)
                Swizzle[i] = m[i];
        }

        protected override Format CalculateOutputFormat()
        {
            if (Swizzle[3] != VectorMembers.None)
                return Format.FLOAT4;

            if (Swizzle[2] != VectorMembers.None)
                return Format.FLOAT3;

            if (Swizzle[1] != VectorMembers.None)
                return Format.FLOAT2;

            return Format.FLOAT;
        }

        public readonly Expression Expression;
        public readonly VectorMembers[] Swizzle = new VectorMembers[4]{VectorMembers.None,VectorMembers.None,VectorMembers.None,VectorMembers.None};

        public override IList<Variable> ReadVariables
        {
            get { return Expression.ReadVariables; }
        }
        public override bool Linear
        {
            get { return Expression.Linear; }
        }
        public override bool Const
        {
            get { return Expression.Const; }
        }
    }
}


text:
package experiment.effort.noseine.bitthief;

import peersim.core.Node;

/**
 *	Class type of the queues's items in {@link example.bitthief.BitTorrent#incomingPieces}
 *	and {@link example.bitthief.BitTorrent#requestToServe}.
 */
class Queue{
	int maxSize;
	int head = 0;
	int tail = 0;
	int dim = 0;
	Request queue[];

	/**
	 *	Public constructor. Creates a queue of size <tt>size</tt>.
	 */
	public Queue(int size){
		maxSize = size;
		queue = new Request[size];
		for(int i=0; i< size; i++)
			queue[i]= new Request();
	}

	/**
	 *	Enqueues the request of the block <tt>id</tt> and its <tt>sender</tt>
	 *	@param id the id of the block in the request
	 *	@param sender a reference to the sender of the request
	 *	@return <tt>true</tt> if the request has been correctly added, <tt>false</tt>
	 *	otherwise.
	 */
	public boolean enqueue(int id, Node sender){
		if(dim < maxSize){
			queue[tail%maxSize].id = id;
			queue[tail%maxSize].sender = sender;
			tail++;
			dim++;
			return true;
		}
		else return false;
	}

	/**
	 *	Returns the {@link Request} in the head of the queue.
	 *	@return the element in the head.<br/>
	 *			<tt>null</tt> if the queue is empty.
	 */
	public Request dequeue(){
		Request value;
		if(dim > 0){
			value = queue[head%maxSize];
			head++;
			dim--;
			return value;
		}
		else return null; //empty queue
	}

	/**
	 *	Returns the status of the queue.
	 *	@return <tt>true</tt> if the queue is empty, <tt>false</tt>
	 *	otherwise.
	 */
	public boolean empty(){
		return (dim == 0);
	}

	/**
	 *	Returns <tt>true</tt> if block given as parameter is in.
	 *	@param	value the id of the block to search.
	 *	@return <tt>true</tt> if the block <tt>value</tt> is in the queue, <tt>false</tt>
	 *	otherwise.
	 */
	public boolean contains(int value){
		if(empty())
			return false;
		for(int i=head; i<head+dim; i++){
			if(queue[i%maxSize].id == value)
				return true;
		}
		return false;
	}

	/**
	 *	Removes a request from the queue.
	 *	@param sender the sender of the request.
	 *	@param value the id of the block requested.
	 *	@return <tt>true</tt> if the request has been correctly removed, <tt>false</tt>
	 *	otherwise.
	 */
	public boolean remove(Node sender, int value){
		if(empty())
			return false;
		for(int i=head; i<head+dim; i++){
			if(queue[i%maxSize].id == value && queue[i%maxSize].sender == sender){
				for(int j=i; j>head; j--){ // Shifts the elements for the removal
					queue[j%maxSize]= queue[(j-1)%maxSize];
				}
				head++;
				dim--;
				return true;
			}
		}
		return false;
	}
}


text:
package foam.nanos.crunch.crunchtest;

import foam.dao.*;
import foam.core.*;
import foam.nanos.auth.*;
import foam.nanos.crunch.*;

public class CapabilityReopenTest extends foam.nanos.test.Test {
  public void runTest(X x) {
    DAO capabilityDAO = (DAO) x.get("localCapabilityDAO");
    DAO userCapabilityJunctionDAO = (DAO) x.get("bareUserCapabilityJunctionDAO");
    DAO prerequisiteCapabilityJunctionDAO = (DAO) x.get("prerequisiteCapabilityJunctionDAO");
    DAO userDAO = (DAO) x.get("bareUserDAO");

    User user = new User.Builder(x).setId(888L).build();
    user = (User) userDAO.put(user);

    Capability c = new Capability.Builder(x).setId("c").build();
    Capability prereq1 = new Capability.Builder(x).setId("prereq1").build();
    Capability prereq2 = new Capability.Builder(x).setId("prereq2").build();
    c = (Capability) capabilityDAO.put(c);
    prereq1 = (Capability) capabilityDAO.put(prereq1);
    prereq2 = (Capability) capabilityDAO.put(prereq2);

    MinMaxCapability mmc = new MinMaxCapability.Builder(x).setId("mmc").setMin(1).setMax(2).build();
    MinMaxCapability mmp1 = new MinMaxCapability.Builder(x).setId("mmp1").build();
    MinMaxCapability mmp2 = new MinMaxCapability.Builder(x).setId("mmp2").build();
    mmc = (MinMaxCapability) capabilityDAO.put(mmc);
    mmp1 = (MinMaxCapability) capabilityDAO.put(mmp1);
    mmp2 = (MinMaxCapability) capabilityDAO.put(mmp2);

    CapabilityCapabilityJunction cprereq1 = new CapabilityCapabilityJunction.Builder(x).setSourceId("c").setTargetId("prereq1").build();
    CapabilityCapabilityJunction cprereq2 = new CapabilityCapabilityJunction.Builder(x).setSourceId("c").setTargetId("prereq2").build();
    CapabilityCapabilityJunction mmcmmp1 = new CapabilityCapabilityJunction.Builder(x).setSourceId("mmc").setTargetId("mmp1").build();
    CapabilityCapabilityJunction mmcmmp2 = new CapabilityCapabilityJunction.Builder(x).setSourceId("mmc").setTargetId("mmp2").build();
    prerequisiteCapabilityJunctionDAO.put(cprereq1);
    prerequisiteCapabilityJunctionDAO.put(cprereq2);
    prerequisiteCapabilityJunctionDAO.put(mmcmmp1);
    prerequisiteCapabilityJunctionDAO.put(mmcmmp2);

    UserCapabilityJunction ucjC = new UserCapabilityJunction.Builder(x)
      .setSourceId(user.getId())
      .setTargetId(c.getId())
      .setStatus(CapabilityJunctionStatus.GRANTED)
      .build();
    UserCapabilityJunction ucjPrereq1 = new UserCapabilityJunction.Builder(x)
      .setSourceId(user.getId())
      .setTargetId(prereq1.getId())
      .setStatus(CapabilityJunctionStatus.GRANTED)
      .build();
    UserCapabilityJunction ucjPrereq2 = new UserCapabilityJunction.Builder(x)
      .setSourceId(user.getId())
      .setTargetId(prereq2.getId())
      .setStatus(CapabilityJunctionStatus.GRANTED)
      .build();
    UserCapabilityJunction ucjMmc = new UserCapabilityJunction.Builder(x)
    .setSourceId(user.getId())
      .setTargetId(mmc.getId())
      .setStatus(CapabilityJunctionStatus.GRANTED)
      .build();
    UserCapabilityJunction ucjMmp1 = new UserCapabilityJunction.Builder(x)
      .setSourceId(user.getId())
      .setTargetId(mmp1.getId())
      .setStatus(CapabilityJunctionStatus.GRANTED)
      .build();
    UserCapabilityJunction ucjMmp2 = new UserCapabilityJunction.Builder(x)
      .setSourceId(user.getId())
      .setTargetId(mmp2.getId())
      .setStatus(CapabilityJunctionStatus.GRANTED)
      .build();
    ucjC = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjC);
    ucjPrereq1 = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjPrereq1);
    ucjPrereq2 = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjPrereq2);
    ucjMmc = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjMmc);
    ucjMmp1 = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjMmp1);
    ucjMmp2 = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjMmp2);

    CrunchService crunchService = (CrunchService) x.get("crunchService");
    Subject subject = new Subject.Builder(x).setUser(user).build();
    X userX = (X) x.put("subject", subject);

    boolean shouldReopenC = crunchService.maybeReopen(userX, "c");
    boolean shouldReopenMmc = crunchService.maybeReopen(userX, "mmc");
    test( ! shouldReopenC, "should not be able to reopen granted Capability");
    test( ! shouldReopenMmc, "should not be able to reopen granted MinmaxCapability");

    // try setting isrenewable on prereqs so c can be reopened but mmc should not be since it still has
    // one granted capability
    ((Renewable) ucjPrereq1).setIsInRenewablePeriod(true);
    ucjPrereq1 = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjPrereq1);
    ((Renewable) ucjMmp1).setIsInRenewablePeriod(true);
    ucjMmp1 = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjMmp1);

    shouldReopenC = crunchService.maybeReopen(userX, "c");
    shouldReopenMmc = crunchService.maybeReopen(userX, "mmc");
    test( shouldReopenC, "should be able to reopen capability missing prereq");
    test( ! shouldReopenMmc, "should still not be able to reopen granted MinmaxCapability");

    ((Renewable) ucjMmp2).setIsInRenewablePeriod(true);
    ucjMmp2 = (UserCapabilityJunction) userCapabilityJunctionDAO.put(ucjMmp2);
    shouldReopenMmc = crunchService.maybeReopen(userX, "mmc");
    test( shouldReopenMmc, "should be able to reopen granted MinmaxCapability");

  }
}


text:
import { UserResolver } from './../utils/user.resolver';
import { CreateAdvertismentComponent } from './../components/create.advertisment/create.advertisment.component';
import { AuthGuardService } from './../services/auth.guard.service';
import { LoginComponent } from './../auth/components/login/login.component';
import { SignUpComponent } from '../auth/components/signup/signup.component';
import { DummyComponent } from '../dummy/dummy.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const appRoutes: Routes = [
  { path: 'advertisements', component: DummyComponent },
  { path: 'advertisment', resolve: { users: UserResolver }, component: CreateAdvertismentComponent, canActivate: [AuthGuardService] },
];

@NgModule({
  imports: [
    RouterModule.forRoot(
      appRoutes
    )
  ],
  exports: [RouterModule]
})
export class RoutingModule { }


text:
class Invisionsync < Cask
  version :latest
  sha256 :no_check

  url 'http://www.invisionapp.com/app/InVisionSync.zip'
  homepage 'http://invisionapp.com/'

  app 'InVisionSync.app'
end


text:
package simulacao.controle;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import simulacao.modelo.ResultadoDTO;

public class SimuladorUnitTest
{
	@Test
	public void testPopularTaxasR4()
	{
		Simulador simulador = new Simulador(null, null);

		List<Double> taxasR4 = simulador.popularTaxasR4();

		assertEquals(100, taxasR4.size());

		verificarValorDeCadaTaxa(taxasR4);
	}

	@Test
	public void testCalcularMedia()
	{
		Simulador simulador = new Simulador(null, null);

		double media = simulador.calcularMedia(100, 10);

		assertEquals(10, media, 0);
	}

	@Test
	public void testCalcularDistanciaMedia()
	{
		Simulador simulador = new Simulador(null, null);

		List<ResultadoDTO> amostras = popularAmostras();

		double distanciaMediaAmostral = simulador.calcularSomatorioDeDistanciasDaMedia(amostras, 20);

		assertEquals(360, distanciaMediaAmostral, 0);
	}

	@Test
	public void testCalcularVarianciaAmostral()
	{
		Simulador simulador = new Simulador(null, null);

		double varianciaAmostral = simulador.calcularVarianciaAmostral(20, 10);

		assertEquals(20.0/9.0, varianciaAmostral, 0);
	}

	private List<ResultadoDTO> popularAmostras()
	{
		List<ResultadoDTO> amostras = new ArrayList<ResultadoDTO>();

		for (int i = 0; i < 10; i++)
		{
			ResultadoDTO resultado = new ResultadoDTO(13, 13, 0, 0, 0, 0);
			amostras.add(resultado);
		}

		return amostras;
	}

	private void verificarValorDeCadaTaxa(List<Double> taxasR4)
	{
		for (Double taxa : taxasR4)
		{
			int indice = taxasR4.indexOf(taxa);

			assertEquals(0.01 + indice * 0.01, taxa, 0.01);
		}
	}
}


text:
clear
$tool_version = "2"
# by Cooper

$IIS_log_path = "C:\Windows\System32\LogFiles\HTTPERR\" #lomítko na konci NUTNÉ
$IIS_outdir = "M:\weby\Dropbox\old"
$reg_basepath = "HKLM:\Software\BSS\IIS_ERROR_logrotator"
$file_filter = "*.log"

IF(!(Test-Path $reg_basepath)) { New-Item -Path $reg_basepath -Force | Out-Null }
New-ItemProperty -Path $reg_basepath -Name version -Value $tool_version -PropertyType DWord -Force | Out-Null

function fNewfile {
	$global:reg_instancepath = $reg_basepath
	$file_old = (Get-ItemProperty -Path $reg_instancepath -Name LastFile -ErrorAction SilentlyContinue).LastFile

	$latest = (Get-ChildItem -Path $IIS_log_path -Filter $file_filter | Sort-Object CreationTime -Descending | Select-Object -First 1).name
	Write-Host "old file" $file_old "new-file" $latest
	IF(!(Test-Path $reg_instancepath)) { New-Item -Path $reg_instancepath -Force | Out-Null }
	New-ItemProperty -Path $reg_instancepath -Name LastFile -Value $latest -PropertyType STRING -Force | Out-Null

	IF (!$file_old ) {
		#Write-Host "nic v registru"
		}
	elseif ($file_old -ne $latest ) {
		Write-Host "v regu je starý soubor, tak se na něj ještě jednou podívám" $file_old "vs" $latest
		$latest = $file_old
		}
	else {
		#Write-Host "vše OK"
		}

	$global:IISfile = $IIS_log_path + "\" + $latest
	#Write-Host $IISfile

	#output
	$global:IISoutfile = $IIS_outdir + "\IIS_Err_" + $env:computername + "_" + $(Get-Date -format "yyMMdd-HHmmss") + ".log"
	}

function Counting
	{
	$global:lines_old = (Get-ItemProperty -Path $reg_instancepath -Name Counter -ErrorAction SilentlyContinue).Counter
	$global:lines_act = (Get-Content $IISfile | Measure-Object -Line |Select-Object Lines).Lines
	$global:lines_delta = $lines_act - $lines_old
	Write-Host $lines_act "-" $lines_old "=" $lines_delta
	}

function Foutput {
	Get-Content -Path $IISfile | select -First $lines_act | select -Last $lines_delta | Out-file $IISoutfile
	IF(!(Test-Path $reg_instancepath)) { New-Item -Path $reg_instancepath -Force | Out-Null }
    New-ItemProperty -Path $reg_instancepath -Name Counter -Value $lines_act -PropertyType STRING -Force | Out-Null

	#Write-Host $new_log_lines
   }

	fNewFile
	Counting

	if ($lines_delta -gt 0) {
		Foutput
		}
	elseif ($lines_delta -lt 0) {
		Write-Host "nesedí počty řádků, žádný výstup, resetuji počítadlo pro" $IIS_instance
		New-ItemProperty -Path $reg_instancepath -Name Counter -Value 0 -PropertyType STRING -Force | Out-Null
		}
	else {
		Write-Host "no new lines = no output file $IISoutfile"
		$no_lines = (Get-ItemProperty -Path $reg_basepath -Name NoLines -ErrorAction SilentlyContinue ).NoLines
		$no_lines ++
		IF(!(Test-Path $reg_basepath)) { New-Item -Path $reg_basepath -Force | Out-Null }
	    New-ItemProperty -Path $reg_basepath -Name NoLines -Value $no_lines -PropertyType DWORD -Force | Out-Null
		}


text:
local Class = require 'lib.hump.class'
local ModelComponent = getClass 'wyx.component.ModelComponent'
local property = require 'wyx.component.property'
local message = require 'wyx.component.message'

-- TimeComponent
--
local TimeComponent = Class{name='TimeComponent',
	inherits=ModelComponent,
	function(self, properties)
		ModelComponent._addRequiredProperties(self, {
			'AttackCost',
			'AttackCostBonus',
			'MoveCost',
			'MoveCostBonus',
			'WaitCost',
			'WaitCostBonus',
			'DefaultCost',
			'Speed',
			'SpeedBonus',
			'IsExhausted',
			'DoTick',
		})
		ModelComponent.construct(self, properties)
		self:_addMessages('TIME_AUTO')
	end
}

-- destructor
function TimeComponent:destroy()
	ModelComponent.destroy(self)
end

function TimeComponent:_setProperty(prop, data)
	prop = property(prop)
	if nil == prop then return end
	if nil == data then data = property.default(prop) end

	if   prop == property('AttackCost')
		or prop == property('AttackCostBonus')
		or prop == property('MoveCost')
		or prop == property('MoveCostBonus')
		or prop == property('WaitCost')
		or prop == property('WaitCostBonus')
		or prop == property('DefaultCost')
		or prop == property('Speed')
		or prop == property('SpeedBonus')
	then
		verifyAny(data, 'number', 'expression')
	elseif prop == property('IsExhausted')
		or   prop == property('DoTick')
	then
		verifyAny(data, 'boolean', 'expression')
	else
		error('TimeComponent does not support property: '..tostring(prop))
	end

	ModelComponent._setProperty(self, prop, data)
end

function TimeComponent:isExhausted()
	return self:getProperty(property('IsExhausted'))
end

function TimeComponent:exhaust()
	self:_setProperty('IsExhausted', true)
end

function TimeComponent:shouldTick()
	return self._mediator:query(property('DoTick'))
end

function TimeComponent:getTotalSpeed()
	local speed = self._mediator:query(property('Speed'))
	speed = speed + self._mediator:query(property('SpeedBonus'))
	return speed
end

function TimeComponent:onPreTick(ap)
	self._mediator:send(message('TIME_PRETICK'), ap)
end

function TimeComponent:onPostTick(ap)
	self._mediator:send(message('TIME_POSTTICK'), ap)
end

function TimeComponent:onPreExecute(ap)
	self._mediator:send(message('TIME_PREEXECUTE'), ap)
end

function TimeComponent:onPostExecute(ap)
	self._mediator:send(message('TIME_POSTEXECUTE'), ap)
end

function TimeComponent:getProperty(p, intermediate, ...)
	if p == property('DoTick') then
		local prop = self:_evaluate(p)
		if nil == intermediate then return prop end
		return (prop or intermediate)
	else
		return ModelComponent.getProperty(self, p, intermediate, ...)
	end
end

function TimeComponent:receive(sender, msg, ...)
	if msg == message('TIME_AUTO') and sender == self._mediator then
		self:_setProperty(property('DoTick'), select(1, ...))
	end
	ModelComponent.receive(self, sender, msg, ...)
end

-- the class
return TimeComponent


text:
<?php

namespace phpManufaktur\TemplateTools\Data\Setup;

use Silex\Application;
use Symfony\Component\Finder\Finder;

class Uninstall
{
    protected $app = null;

    /**
     * Uninstall the template examples
     *
     */
    protected function uninstall_templates()
    {
        // initialize the Finder
        $finder = new Finder();
        // we need only the top level
        $finder->depth('== 0');
        // get all directories in the /Examples
        $finder->directories()->in(MANUFAKTUR_PATH.'/TemplateTools/Examples');

        foreach ($finder as $directory) {
            $template_name = $directory->getFilename();
            $target_directory = CMS_PATH.'/templates/'.$template_name;

            if ($this->app['filesystem']->exists($target_directory)) {
                // the template exists - remove it
                $this->app['filesystem']->remove($target_directory);
            }

            $this->app['db']->delete(CMS_TABLE_PREFIX.'addons',
                array('type' => 'template', 'directory' => $template_name));
        }
    }

    /**
     * Uninstall the TemplateTools
     *
     * @param Application $app
     */
    public function exec(Application $app)
    {
        $this->app = $app;

        // uninstall the templates
        $this->uninstall_templates();
        $this->app['monolog']->addDebug('Successfull removed the TemplateTools Example Templates.');

        return $app['translator']->trans('Successfull uninstalled the extension %extension%.',
            array('%extension%' => 'TemplateTools'));
    }
}


text:
title: Repl no.2
layout: post
author: joseph.brocksom
permalink: /repl-no.2/
source-id: 1lIiW_PwRGkxJ2Fm043N4mLBAV-h2I48a3ccJPqKVwMU
published: true
---

    Title
     Repl no.2

    Date
    07/09/16

    Starting point:
    Having a working conversation

    Target for this
    to learn some key coding shortcuts

    Did I reach my target?
(add details to "Lesson Review")
    mostly

    Lesson Review

    How did I learn? What strategies were effective?

    We were again listening alot to mr keen as we were starting another project and learn a lot of key terms / shortcuts before we start to begin a project or excise.Concentration was very important as if we did not listen it would mean we could not do as well as other people who listened.And we would fall behind alot as we go onto another aspect of the project.

    What limited my learning? Which habits do I need to work on?

    I did fairly good this listen so there is not that much that I can do to improve apart from maybe listen a little  bit better as I was drifting of sometimes because I was really tired so I could of possibly missed something that would help me later. So apart from being very tired I did fairly good.Although i had forgot a lot of the stuff we talked about last lesson.

    What will I change for next time? How will I improve my learning?

    next week I need to go to bed at a sensible time so I don't get really tired the next day before schools because otherwise I get really tired and stuff like this happens.this will help because then I will be able to actually concentrate and remember everything that is going on.


text:
namespace rgen {

	// returns a random value between Lo and Hi
	int GetRandVal( int Lo, int Hi);

   // initialize random seed
   void Init();
}

#endif


text:
    <md-whiteframe class="md-whiteframe-z1 relative max-40" layout="row" layout-align="space-between center" layout-margin layout-padding layout-wrap>

Register with email

        <form class="no-margin-or-padding" flex="100" name="loginForm">
            <fieldset>

                    <md-input-container flex>
                        Email
                        <input type="email" ng-model="email" required/>
                    </md-input-container>
                    <md-input-container flex>
                        Password
                        <input type="password" ng-model="password" required/>
                    </md-input-container>

                    <md-button class="min-10" id="login-button" class="md-primary" flex ng-click="register(email, password)" ng-disabled="loginForm.$invalid">Register</md-button>
                    <md-button class="adjust-line-height min-10" flex ui-sref="master.nav.login">Login</md-button>
                    <md-button class="adjust-line-height min-10" flex ui-sref="master.nav.reset">Reset Password</md-button>

            </fieldset>
        </form>

            <md-progress-circular md-mode="indeterminate"></md-progress-circular>

    </md-whiteframe>


text:
#include "httpd.h"
#include "http_log.h"
#include "http_request.h"
#include "http_config.h"
#include "http_protocol.h"
#include "mod_status.h"

#include "apr_strings.h"
#include "apr_time.h"

#include "ap_socache.h"

#include "distcache/dc_client.h"

#if !defined(DISTCACHE_CLIENT_API) || (DISTCACHE_CLIENT_API < 0x0001)
#error "You must compile with a more recent version of the distcache-base package"
#endif

struct ap_socache_instance_t {
    /* Configured target server: */
    const char *target;
    /* distcache client context: */
    DC_CTX *dc;
};

static const char *socache_dc_create(ap_socache_instance_t **context,
                                     const char *arg,
                                     apr_pool_t *tmp, apr_pool_t *p)
{
    struct ap_socache_instance_t *ctx;

    ctx = *context = apr_palloc(p, sizeof *ctx);

    ctx->target = apr_pstrdup(p, arg);

    return NULL;
}

static apr_status_t socache_dc_init(ap_socache_instance_t *ctx,
                                    const char *namespace,
                                    const struct ap_socache_hints *hints,
                                    server_rec *s, apr_pool_t *p)
{
#if 0
    /* If a "persistent connection" mode of operation is preferred, you *must*
     * also use the PIDCHECK flag to ensure fork()'d processes don't interlace
     * comms on the same connection as each other. */
#define SESSION_CTX_FLAGS        SESSION_CTX_FLAG_PERSISTENT | \
                                 SESSION_CTX_FLAG_PERSISTENT_PIDCHECK | \
                                 SESSION_CTX_FLAG_PERSISTENT_RETRY | \
                                 SESSION_CTX_FLAG_PERSISTENT_LATE
#else
    /* This mode of operation will open a temporary connection to the 'target'
     * for each cache operation - this makes it safe against fork()
     * automatically. This mode is preferred when running a local proxy (over
     * unix domain sockets) because overhead is negligable and it reduces the
     * performance/stability danger of file-descriptor bloatage. */
#define SESSION_CTX_FLAGS        0
#endif
    ctx->dc = DC_CTX_new(ctx->target, SESSION_CTX_FLAGS);
    if (!ctx->dc) {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00738) "distributed scache failed to obtain context");
        return APR_EGENERAL;
    }
    ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(00739) "distributed scache context initialised");

    return APR_SUCCESS;
}

static void socache_dc_destroy(ap_socache_instance_t *ctx, server_rec *s)
{
    if (ctx && ctx->dc) {
        DC_CTX_free(ctx->dc);
        ctx->dc = NULL;
    }
}

static apr_status_t socache_dc_store(ap_socache_instance_t *ctx, server_rec *s,
                                     const unsigned char *id, unsigned int idlen,
                                     apr_time_t expiry,
                                     unsigned char *der, unsigned int der_len,
                                     apr_pool_t *p)
{
    /* !@#$%^ - why do we deal with *absolute* time anyway???
     * Uhm - because most things expire things at a specific time?
     * Were the API were thought out expiry - r->request_time is a good approximation
     */
    expiry -= apr_time_now();
    /* Send the serialised session to the distributed cache context */
    if (!DC_CTX_add_session(ctx->dc, id, idlen, der, der_len,
                            apr_time_msec(expiry))) {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00740) "distributed scache 'store' failed");
        return APR_EGENERAL;
    }
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00741) "distributed scache 'store' successful");
    return APR_SUCCESS;
}

static apr_status_t socache_dc_retrieve(ap_socache_instance_t *ctx, server_rec *s,
                                        const unsigned char *id, unsigned int idlen,
                                        unsigned char *dest, unsigned int *destlen,
                                        apr_pool_t *p)
{
    unsigned int data_len;

    /* Retrieve any corresponding session from the distributed cache context */
    if (!DC_CTX_get_session(ctx->dc, id, idlen, dest, *destlen, &data_len)) {
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00742) "distributed scache 'retrieve' MISS");
        return APR_NOTFOUND;
    }
    if (data_len > *destlen) {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00743) "distributed scache 'retrieve' OVERFLOW");
        return APR_ENOSPC;
    }
    *destlen = data_len;
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00744) "distributed scache 'retrieve' HIT");
    return APR_SUCCESS;
}

static apr_status_t socache_dc_remove(ap_socache_instance_t *ctx,
                                      server_rec *s, const unsigned char *id,
                                      unsigned int idlen, apr_pool_t *p)
{
    /* Remove any corresponding session from the distributed cache context */
    if (!DC_CTX_remove_session(ctx->dc, id, idlen)) {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00745) "distributed scache 'remove' MISS");
        return APR_NOTFOUND;
    }
    else {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00746) "distributed scache 'remove' HIT");
        return APR_SUCCESS;
    }
}

static void socache_dc_status(ap_socache_instance_t *ctx, request_rec *r, int flags)
{
    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00747)
                  "distributed scache 'socache_dc_status'");
    if (!(flags & AP_STATUS_SHORT)) {
        ap_rprintf(r, "cache type: DC (Distributed Cache), "
                   " target: %s
", ctx->target);
    }
    else {
        ap_rputs("CacheType: DC\n", r);
        ap_rvputs(r, "CacheTarget: ", ctx->target, "\n", NULL);
    }
}

static apr_status_t socache_dc_iterate(ap_socache_instance_t *instance,
                                       server_rec *s, void *userctx,
                                       ap_socache_iterator_t *iterator,
                                       apr_pool_t *pool)
{
    return APR_ENOTIMPL;
}

static const ap_socache_provider_t socache_dc = {
    "distcache",
    0,
    socache_dc_create,
    socache_dc_init,
    socache_dc_destroy,
    socache_dc_store,
    socache_dc_retrieve,
    socache_dc_remove,
    socache_dc_status,
    socache_dc_iterate
};

static void register_hooks(apr_pool_t *p)
{
    ap_register_provider(p, AP_SOCACHE_PROVIDER_GROUP, "dc",
                         AP_SOCACHE_PROVIDER_VERSION,
                         &socache_dc);
}

AP_DECLARE_MODULE(socache_dc) = {
    STANDARD20_MODULE_STUFF,
    NULL, NULL, NULL, NULL, NULL,
    register_hooks
};


text:
class Committee < ActiveRecord::Base
  # The line below was inserted by uix.
  resourcify

  serialize :member_ids, Array
  belongs_to :committee_status
end


text:
package skuber.ext

import org.specs2.mutable.Specification
import play.api.libs.json.Json

import skuber.LabelSelector.dsl._
import skuber._
import skuber.json.ext.format._

/**
 * @author David O'Riordan
 */
class DeploymentSpec extends Specification {
  "This is a unit specification for the skuber Deployment class. ".txt

  "A Deployment object can be constructed from a name and pod template spec" >> {
    val container=Container(name="example",image="example")
    val template=Pod.Template.Spec.named("example").addContainer(container)
    val deployment=Deployment("example")
      .withReplicas(200)
      .withTemplate(template)
    deployment.spec.get.template mustEqual Some(template)
    deployment.spec.get.replicas mustEqual Some(200)
    deployment.name mustEqual "example"
    deployment.status mustEqual None
  }

  "A Deployment object can be written to Json and then read back again successfully" >> {
      val container=Container(name="example",image="example")
      val template=Pod.Template.Spec.named("example").addContainer(container)
      val deployment=Deployment("example")
        .withTemplate(template)
          .withLabelSelector(LabelSelector("live" doesNotExist, "microservice", "tier" is "cache", "env" isNotIn List("dev", "test")))

      val readDepl = Json.fromJson[Deployment](Json.toJson(deployment)).get
      readDepl mustEqual deployment
  }

  "A Deployment object properly writes with zero replicas" >> {
    val deployment=Deployment("example").withReplicas(0)

    val writeDepl = Json.toJson(deployment)
    (writeDepl \ "spec" \ "replicas").asOpt[Int] must beSome(0)
  }

  "A Deployment object can be read directly from a JSON string" >> {
    val deplJsonStr = """
{
  "apiVersion": "extensions/v1beta1",
  "kind": "Deployment",
  "metadata": {
    "name": "nginx-deployment"
  },
  "spec": {
    "replicas": 3,
    "selector": {
      "matchLabels" : {
        "domain": "www.example.com",
        "proxies": "microservices"
      },
      "matchExpressions": [
        {"key": "env", "operator": "NotIn", "values": ["dev"]},
        {"key": "tier","operator": "In", "values": ["frontend"]}
      ]
    },
    "strategy": {
      "rollingUpdate": {
        "maxUnavailable": 1
      }
    },
    "template": {
      "metadata": {
        "labels": {
          "app": "nginx"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "nginx",
            "image": "nginx:1.7.9",
            "ports": [
              {
                "containerPort": 80
              }
            ]
          }
        ]
      }
    }
  }
}
"""
    val depl = Json.parse(deplJsonStr).as[Deployment]
    depl.kind mustEqual "Deployment"
    depl.name mustEqual "nginx-deployment"
    depl.spec.get.replicas mustEqual Some(3)
    depl.spec.get.template.get.metadata.labels mustEqual Map("app" -> "nginx")
    depl.spec.get.template.get.spec.get.containers.length mustEqual 1
    depl.spec.get.selector.get.requirements.size mustEqual 4
    depl.spec.get.selector.get.requirements.find(r => (r.key == "env")) mustEqual Some("env" isNotIn List("dev"))
    depl.spec.get.selector.get.requirements.find(r => (r.key == "domain")) mustEqual Some("domain" is "www.example.com")
  }
}


text:
app.controller('ScrollController', ['$scope', '$location', '$anchorScroll',
    function ($scope, $location, $anchorScroll) {

        $scope.gotoBottom = function () {
            // 将location.hash的值设置为
            // 你想要滚动到的元素的id
         //   $location.hash('bottom');
            // 调用 $anchorScroll()
            $anchorScroll('bottom');
        };
    }]);


text:
using GRA.Domain.Model;
using GRA.Domain.Model.Filters;
using GRA.Domain.Repository;
using GRA.Domain.Service.Abstract;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GRA.Domain.Service
{
    public class QuestionnaireService : BaseUserService<QuestionnaireService>
    {
        private readonly IAnswerRepository _answerRepository;
        private readonly IBadgeRepository _badgeRepository;
        private readonly INotificationRepository _notificationRepository;
        private readonly IQuestionRepository _questionRepository;
        private readonly IQuestionnaireRepository _questionnaireRepository;
        private readonly IRequiredQuestionnaireRepository _requiredQuestionnaireRepository;
        private readonly IUserLogRepository _userLogRepository;
        public QuestionnaireService(ILogger<QuestionnaireService> logger,
            GRA.Abstract.IDateTimeProvider dateTimeProvider,
            IUserContextProvider userContextProvider,
            IAnswerRepository answerRepository,
            IBadgeRepository badgeRepository,
            INotificationRepository notificationRepository,
            IQuestionRepository questionRepository,
            IQuestionnaireRepository questionnaireRepository,
            IRequiredQuestionnaireRepository requiredQuestionnaireRepository,
            IUserLogRepository userLogRepository)
            : base(logger, dateTimeProvider, userContextProvider)
        {
            SetManagementPermission(Permission.ManageQuestionnaires);
            _answerRepository = Require.IsNotNull(answerRepository, nameof(answerRepository));
            _badgeRepository = Require.IsNotNull(badgeRepository, nameof(badgeRepository));
            _notificationRepository = Require.IsNotNull(notificationRepository,
                nameof(notificationRepository));
            _questionRepository = Require.IsNotNull(questionRepository,
                nameof(questionRepository));
            _questionnaireRepository = Require.IsNotNull(questionnaireRepository,
                nameof(questionnaireRepository));
            _requiredQuestionnaireRepository = Require.IsNotNull(requiredQuestionnaireRepository,
                nameof(requiredQuestionnaireRepository));
            _userLogRepository = Require.IsNotNull(userLogRepository, nameof(userLogRepository));
        }

        public async Task<DataWithCount<ICollection<Questionnaire>>> GetPaginatedListAsync(
            BaseFilter filter)
        {
            VerifyManagementPermission();
            filter.SiteId = GetCurrentSiteId();
            return new DataWithCount<ICollection<Questionnaire>>
            {
                Data = await _questionnaireRepository.PageAsync(filter),
                Count = await _questionnaireRepository.CountAsync(filter)
            };
        }

        // add questionnaire
        public async Task<Questionnaire> AddAsync(Questionnaire questionnaire)
        {
            VerifyManagementPermission();

            questionnaire.SiteId = GetCurrentSiteId();
            questionnaire.RelatedBranchId = GetClaimId(ClaimType.BranchId);
            questionnaire.RelatedSystemId = GetClaimId(ClaimType.SystemId);

            var addedQuestionnaire = await _questionnaireRepository.AddSaveAsync(
                GetClaimId(ClaimType.UserId),
                questionnaire);

            if (questionnaire.Questions != null && questionnaire.Questions.Count > 0)
            {
                return await AddQuestionsAsync(addedQuestionnaire.Id, questionnaire.Questions);
            }
            else
            {
                return addedQuestionnaire;
            }
        }

        public async Task<Questionnaire> UpdateAsync(Questionnaire questionnaire)
        {
            VerifyManagementPermission();
            int authId = GetClaimId(ClaimType.UserId);

            var currentQuestionnaire = await _questionnaireRepository.GetByIdAsync(questionnaire.Id);
            if (currentQuestionnaire.IsLocked)
            {
                _logger.LogError($"User {authId} cannot update locked questionnaire {currentQuestionnaire.Id}.");
                throw new GraException("Questionnaire is locked and cannot be edited.");
            }

            currentQuestionnaire.Name = questionnaire.Name;
            currentQuestionnaire.IsLocked = questionnaire.IsLocked;
            return await _questionnaireRepository.UpdateSaveAsync(authId, currentQuestionnaire);
        }

        public async Task UpdateQuestionListAsync(int questionnaireId, List<int> questionOrderList)
        {
            VerifyManagementPermission();
            int authId = GetClaimId(ClaimType.UserId);

            var questionnaire = await _questionnaireRepository.GetByIdAsync(questionnaireId, false);
            if (questionnaire.IsLocked)
            {
                _logger.LogError($"User {authId} cannot update locked questionnaire {questionnaire.Id}.");
                throw new GraException("Questionnaire is locked and cannot be edited.");
            }

            var questions = questionnaire.Questions;
            var questionsIdList = questions.Select(_ => _.Id);
            var invalidQuestions = questionOrderList.Except(questionsIdList);
            if (invalidQuestions.Any())
            {
                _logger.LogError($"User {authId} cannot update question {invalidQuestions.First()} for questionnaire {questionnaireId}.");
                throw new GraException("Invalid question selection.");
            }

            var questionUpdateList = questions.Where(_ => questionOrderList.Contains(_.Id));
            foreach (var question in questionUpdateList)
            {
                question.SortOrder = questionOrderList.IndexOf(question.Id);
                await _questionRepository.UpdateSaveAsync(authId, question);
            }

            var questionDeleteList = questions.Except(questionUpdateList);
            foreach (var question in questionDeleteList)
            {
                await _questionRepository.RemoveSaveAsync(authId, question.Id);
            }
        }

        // add question and answers to questionnaire
        public async Task<Questionnaire> AddQuestionsAsync(int questionnaireId,
            IEnumerable<Question> questions)
        {
            VerifyManagementPermission();
            int authId = GetClaimId(ClaimType.UserId);

            foreach (var question in questions)
            {
                question.QuestionnaireId = questionnaireId;
                var addedQuestion = await _questionRepository.AddSaveAsync(authId, question);
                foreach (var answer in question.Answers)
                {
                    answer.QuestionId = addedQuestion.Id;
                    await _answerRepository.AddAsync(authId, answer);
                }
                await _answerRepository.SaveAsync();
            }

            return await _questionnaireRepository.GetByIdAsync(questionnaireId);
        }

        public async Task RemoveAsync(int id)
        {
            VerifyManagementPermission();
            await _questionnaireRepository.RemoveSaveAsync(GetClaimId(ClaimType.UserId), id);
        }

        public async Task<Questionnaire> GetByIdAsync(int questionnaireId, bool includeAnswers)
        {
            var questionnaire = await _questionnaireRepository
                .GetByIdAsync(questionnaireId, includeAnswers);

            if (questionnaire == null)
            {
                throw new GraException("The requested questionnaire could not be accessed or does not exist.");
            }

            return questionnaire;
        }

        public async Task<ICollection<Answer>> GetAnswersByQuestionIdAsync(int questionId)
        {
            return await _answerRepository.GetByQuestionIdAsync(questionId);
        }

        public async Task<Question> GetQuestionByIdAsync(int questionId)
        {
            return await _questionRepository.GetByIdAsync(questionId);
        }

        public async Task<IList<Question>> GetQuestionsByQuestionnaireIdAsync(int questionnaireId,
            bool includeAnswers)
        {
            return await _questionRepository.GetByQuestionnaireIdAsync(questionnaireId, includeAnswers);
        }

        public async Task<Question> AddQuestionAsync(Question question)
        {
            VerifyManagementPermission();
            return await _questionRepository.AddSaveAsync(GetClaimId(ClaimType.UserId), question);
        }

        public async Task<Question> UpdateQuestionAsync(Question question)
        {
            VerifyManagementPermission();
            int authId = GetClaimId(ClaimType.UserId);

            return await _questionRepository.UpdateSaveAsync(authId, question);
        }

        public async Task<Answer> AddAnswerAsync(Answer answer)
        {
            VerifyManagementPermission();
            return await _answerRepository.AddSaveAsync(GetClaimId(ClaimType.UserId), answer);
        }

        public async Task UpdateAnswerAsync(Answer answer)
        {
            VerifyManagementPermission();
            await _answerRepository.UpdateSaveAsync(GetClaimId(ClaimType.UserId), answer);
        }

        public async Task RemoveAnswerAsync(int answerId)
        {
            VerifyManagementPermission();
            await _answerRepository.RemoveSaveAsync(GetClaimId(ClaimType.UserId), answerId);
        }

        public async Task<int?> GetRequiredQuestionnaire(int userId, int? userAge)
        {
            var questionnaires = await _requiredQuestionnaireRepository
                .GetForUser(GetCurrentSiteId(), userId, userAge);
            if (questionnaires.Count > 0)
            {
                return questionnaires.First();
            }
            else
            {
                return null;
            }
        }
        public async Task<bool> HasRequiredQuestionnaire(int userId, int? userAge,
            int questionnaireId)
        {
            return await _requiredQuestionnaireRepository
                .UserHasRequiredQuestionnaire(GetCurrentSiteId(), userId, userAge, questionnaireId);
        }

        public async Task SubmitQuestionnaire(int questionnaireId, int userId, int? userAge,
            IList<Question> questions)
        {
            var requiredQuestionnaires = await _requiredQuestionnaireRepository.
                GetForUser(GetCurrentSiteId(), userId, userAge);
            if (!requiredQuestionnaires.Contains(questionnaireId))
            {
                _logger.LogError($"User {userId} is not eligible to answer questionnaire {questionnaireId}.");
                throw new GraException("Not eligible to answer that questionnaire.");
            }

            var questionnaire = await _questionnaireRepository.GetByIdAsync(questionnaireId, true);
            var questionnaireQuestions = questionnaire.Questions.Where(_ => _.Answers.Count > 0);

            if (questions.Select(_ => _.Id).Except(questionnaireQuestions.Select(_ => _.Id)).Any()
                || questionnaireQuestions.Count() != questions.Count)
            {
                _logger.LogError($"User {userId} submitted invalid questions for questionnaire {questionnaireId}.");
                throw new GraException("Invalid questions answered.");
            }

            foreach (var question in questionnaireQuestions)
            {
                if (!question.Answers.Select(_ => _.Id).Contains(questions
                    .Where(_ => _.Id == question.Id)
                    .Select(_ => _.ParticipantAnswer)
                    .SingleOrDefault()))
                {
                    _logger.LogError($"User {userId} submitted invalid answers for question {question.Id}.");
                    throw new GraException("Invalid answer selected.");
                }
            }

            await _requiredQuestionnaireRepository.SubmitQuestionnaire(questionnaireId, userId,
                questions);

            if (questionnaire.BadgeId.HasValue)
            {
                await QuestionnaireNotificationBadge(questionnaire, userId);
                var badge = await _badgeRepository.GetByIdAsync(questionnaire.BadgeId.Value);
                await _badgeRepository.AddUserBadge(userId, questionnaire.BadgeId.Value);
            }
        }

        private async Task QuestionnaireNotificationBadge(Questionnaire questionnaire, int userId)
        {
            var badge = await _badgeRepository.GetByIdAsync(questionnaire.BadgeId.Value);
            await _badgeRepository.AddUserBadge(userId, badge.Id);
            await _userLogRepository.AddAsync(userId, new UserLog
            {
                UserId = userId,
                PointsEarned = 0,
                IsDeleted = false,
                BadgeId = badge.Id,
                Description = string.IsNullOrEmpty(questionnaire.BadgeNotificationMessage)
                    ? $"You completed the questionnaire: {questionnaire.Name}"
                    : questionnaire.BadgeNotificationMessage
            });
            var notification = new Notification
            {
                PointsEarned = 0,
                Text = questionnaire.BadgeNotificationMessage,
                UserId = userId,
                BadgeId = badge.Id,
                BadgeFilename = badge.Filename
            };

            await _notificationRepository.AddSaveAsync(userId, notification);
        }
    }
}


text:
using System;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Reflection.Runtime.PropertyInfos;

namespace System.Reflection.Runtime.ParameterInfos
{
    //
    // This implements ParameterInfo objects returned by PropertyInfo.GetIndexParameters(). Basically, they're identical to the underling accessor method's
    // ParameterInfo's except that the Member property returns the PropertyInfo rather than a MethodBase.
    //
    internal sealed partial class RuntimePropertyIndexParameterInfo : RuntimeParameterInfo
    {
        private RuntimePropertyIndexParameterInfo(RuntimePropertyInfo member, RuntimeParameterInfo backingParameter)
            : base(member, backingParameter.Position)
        {
            _backingParameter = backingParameter;
        }

        public sealed override ParameterAttributes Attributes
        {
            get
            {
                return _backingParameter.Attributes;
            }
        }

        public sealed override IEnumerable<CustomAttributeData> CustomAttributes
        {
            get
            {
                return _backingParameter.CustomAttributes;
            }
        }

        public sealed override Object DefaultValue
        {
            get
            {
                return _backingParameter.DefaultValue;
            }
        }

        public sealed override Type[] GetOptionalCustomModifiers()
        {
            return _backingParameter.GetOptionalCustomModifiers();
        }

        public sealed override Type[] GetRequiredCustomModifiers()
        {
            return _backingParameter.GetRequiredCustomModifiers();
        }

        public sealed override bool HasDefaultValue
        {
            get
            {
                return _backingParameter.HasDefaultValue;
            }
        }

        public sealed override String Name
        {
            get
            {
                return _backingParameter.Name;
            }
        }

        public sealed override Type ParameterType
        {
            get
            {
                return _backingParameter.ParameterType;
            }
        }

        internal sealed override String ParameterTypeString
        {
            get
            {
                return _backingParameter.ParameterTypeString;
            }
        }

        public sealed override int MetadataToken
        {
            get
            {
                return _backingParameter.MetadataToken;
            }
        }

        private readonly RuntimeParameterInfo _backingParameter;
    }
}