text:
/*******************************************************************************
* Copyright (C) 2001-2004 Quest Software, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of source code must retain the above copyright notice,
*    this list of conditions and the following disclaimer.
*
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the documentation
*    and/or other materials provided with the distribution.
*
*  - Neither the name of Quest Software, Inc. nor the names of its
*    contributors may be used to endorse or promote products derived from this
*    software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Quest Software, Inc. OR THE CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

/**
 * @author Jon Carey
 * @author Dan Nuffer
 */

#ifndef OW_CIMINSTANCE_HPP_INCLUDE_GUARD_
#define OW_CIMINSTANCE_HPP_INCLUDE_GUARD_
#include "OW_config.h"
#include "blocxx/COWIntrusiveReference.hpp"
#include "OW_CIMElement.hpp"
#include "OW_CIMFwd.hpp"
#include "OW_CIMDataType.hpp" // for OW_CIMDataType::INVALID
#include "OW_WBEMFlags.hpp"
#include "OW_CIMName.hpp" // necessary for implicit conversion (const char* -> CIMName) to work
#include "blocxx/String.hpp" // for default parameter StringArray()
#include "blocxx/Array.hpp"
#include "blocxx/SafeBool.hpp"

namespace OW_NAMESPACE
{

/**
 * The CIMInstance class encapsulates all information pertinent to a
 * CIMInstance. CIMInstances are ref counted, copy on write objects.
 * It is possible to have an CIMInstance object that is NULL. The method
 * to check for this condition is as follows:
 *
 *		CIMInstance ci = ch.getInstance(...);
 *		if (!ci)
 *		{
 *			// Null instance
 *		}
 *		else
 *		{
 *			// Valid instance
 *		}
 *
 * Providers generally follow these steps to create a CIMInstance object:
 *
 * 1. Obtain a CIMOMHandleIFC object hdl.
 *
 * 2. Use hdl to create a CIMClass object of the desired CIM class:
 *
 * CIMClass cc = hdl.getClass(namespace, class_name);
 *
 * 3. Use CIMClass cc to create a CIMInstance of the desired CIM class:
 *
 * CIMInstance inst = cc.newInstance();
 *
 * 4. Assign properties of inst as desired using setProperty().
 *
 */
class OW_COMMON_API CIMInstance : public CIMElement
{
public:
	struct INSTData;

	enum { SERIALIZATION_VERSION = 2 };				// Version # for serialization

	enum EErrorCodes
	{
		E_INSTANCE_HAS_NO_SUCH_PROPERTY
	};

	/**
	 * Default ctor
	 */
	CIMInstance();
	/**
	 * This CIMInstance object will be NULL. All subsequent operations on
	 * an instance of this type will fail.
	 */
	explicit CIMInstance(CIMNULL_t);
	/**
	 * Copy ctor
	 * @param arg The CIMInstance that this object will be a copy of.
	 */
	CIMInstance(const CIMInstance& arg);
	/**
	 * Create an CIMInstance.
	 * @param name	The class name of this CIMInstance.
	 */
	explicit CIMInstance(const CIMName& name);
	/**
	 * Create an CIMInstance.
	 * @param name	The class name of this CIMInstance as a NULL terminated string.
	 */
	explicit CIMInstance(const char* name);
	/**
	 * Destroy this CIMInstance object.
	 */
	~CIMInstance();
	/**
	 * Set this to a null object. All subsequent operation will fail after this
	 * call is made.
	 */
	virtual void setNull();
	/**
	 * Assignment operator
	 * @param arg The CIMInstance to assign to this one.
	 * @return A reference to this object after the assignment is made.
	 */
	CIMInstance& operator= (const CIMInstance& arg);
	/**
	 * @return The name of the class for this instance.
	 */
	blocxx::String getClassName() const;
	/**
	 * Set the keys for this instance
	 * @return a reference to *this
	 */
	CIMInstance& setKeys(const CIMPropertyArray& keys);
	/**
	 * Sets the class name for this instance.
	 * @param name	The new class name for this instance.
	 * @return a reference to *this
	 */
	CIMInstance& setClassName(const CIMName& name);
	/**
	 * @return the language this CIMClass is using
	 */
	blocxx::String getLanguage() const;
	/**
	 * Set the language this CIMClass is using
	 * @param language The new language for this CIMClass
	 * @return a reference to *this
	 */
	CIMInstance& setLanguage(const blocxx::String& language);
	/**
	 * @return The qualifiers for this instance as an array of CIMQualifiers.
	 */
	CIMQualifierArray getQualifiers() const;
	/**
	 * Get the qualifier associated with the given name.
	 * @param qualName The name of the qualifier to retrieve.
	 * @return A valid CIMQalifier on success. Otherwise a null
	 * CIMQualifier
	 */
	CIMQualifier getQualifier(const CIMName& qualName) const;
	/**
	 * Remove the named qualifier from this CIMInstance.
	 * @param qualName The name of the qualifier to remove.
	 * @return a reference to *this
	 */
	CIMInstance& removeQualifier(const CIMName& qualName);
	/**
	 * Set the qualifiers for this instance. Any old qualifiers will removed.
	 * @param quals An CIMQualifierArray with the new qualifers for this
	 *		instance.
	 * @return a reference to *this
	 */
	CIMInstance& setQualifiers(const CIMQualifierArray& quals);
	/**
	 * Set/Add a qualifier to this instance's qualifier list
	 * @param qual	The qualifier to add to this instance.
	 * @return a reference to *this
	 */
	CIMInstance& setQualifier(const CIMQualifier& qual);
	/**
	 * Get all the properties of a specific datatype from this instance.
	 * @param valueDataType	All properties returned must have this datatype.
	 * 	If CIMDataType::INVALID is specified, all properties will be
	 *		returned.
	 * @return The properties associated with this instance if valueDataType is
	 * CIMDataType::INVALID. Otherwise only properties that have a values
	 * that have a data type specified by the valueDataType parameter.
	 */
	CIMPropertyArray getProperties(
		blocxx::Int32 valueDataType = CIMDataType::INVALID) const;
	/**
	 * Set the properties associated with this instance.
	 * Note: this will clobber qualifiers associated with the
	 *       properties which may already exist on the instance.
	 *       You may want to instead consider updatePropertyValues(),
	 *       which does not overwrite qualifiers.
	 * @param props An CIMPropertyArray that contains the new properties for
	 * 	this instance.
	 * @return a reference to *this
	 */
	CIMInstance& setProperties(const CIMPropertyArray& props);
	/**
	 * Get the property identified by a given name and origin class.
	 * @param name The name of the property to retrieve.
	 * @param originClass The name of the origin class of the property.
	 * @return The CIMProperty identified by the given parameters on success.
	 * Otherwise a null CIMProperty object.
	 */
	CIMProperty getProperty(const CIMName& name,
		const CIMName& originClass) const;
	/**
	 * Gets a property with the specified name.
	 * @param name The name of the property to retrieve.
	 * @return The CIMProperty identified by the name on success. Otherwise a
	 * null CIMProperty object.
	 */
	CIMProperty getProperty(const CIMName& name) const;
	/**
	 * Gets a property with the specified name.
	 * @param name The name of the property to retrieve.
	 * @return The CIMProperty identified by the name on success.
	 * @throws an NoSuchPropertyException (E_INSTANCE_HAS_NO_SUCH_PROPERTY) if the property is not found or NULL.
	 */
	CIMProperty getPropertyT(const CIMName& name) const;
	/**
	 * Gets a property's value.
	 * @param name The name of the property value to retrieve.
	 * @return The CIMValue of the specified property.  It will be NULL if the
	 * property doesn't exist or the property's value is NULL.
	 */
	CIMValue getPropertyValue(const CIMName& name) const;
	/**
	 * Test whether a property exists and has a non-NULL value.
	 * @param name The name of the property to test.
	 * @return bool true if the property exists and has a non-NULL value.
	 */
	bool propertyHasValue(const CIMName& name) const;
	/**
	 * @return An CIMPropertyArray that contains all of the keys for this
	 * instance.
	 */
	CIMPropertyArray getKeyValuePairs() const;
	/**
	 * Update the property values for this instance. Does not add properties
	 * if they don't exist.
	 * @param props An CIMPropertyArray that contains the properties to update
	 *		this instance's properties with.
	 * @return a reference to *this
	 */
	CIMInstance& updatePropertyValues(const CIMPropertyArray& props);
	/**
	 * Update a single property value. Does not add prop is it doesn't exist.
	 * @param prop	The CIMProperty to update in this instance. This
	 *		CIMProperty with contain the new value.
	 * @return a reference to *this
	 */
	CIMInstance& updatePropertyValue(const CIMProperty& prop);
	/**
	 * Update a single property value. Does not add prop is it doesn't exist.
	 * @param name	The name of the property to update.
	 * @param cv The new value for the property.
	 * @return a reference to *this
	 */
	CIMInstance& updatePropertyValue(const CIMName& name, const CIMValue& cv);
	/**
	 * Update the value of a property if it exists. Otherwise add a new one.
	 * In most cases, updatePropertyValue() should be called instead of this
	 * function, because it won't add a new property. An instance is
	 * initialized will all it's properties by CIMClass::newInstance().
	 * @param name	The name of the property to add or update.
	 * @param cv The CIMValue that contains the new value for the property.
	 * @return a reference to *this
	 */
	CIMInstance& setProperty(const CIMName& name, const CIMValue& cv);
	/**
	 * Update a property in the property list if it exists. Otherwise add a
	 * new one.
	 * In most cases, updatePropertyValue() should be called instead of this
	 * function, because it won't add a new property. An instance is
	 * initialized will all it's properties by CIMClass::newInstance().
	 * @param prop The property to add or update.
	 * @return a reference to *this
	 */
	CIMInstance& setProperty(const CIMProperty& prop);
	/**
	 * Remove a property from this CIMInstance
	 * @param propName The name of the property to remove.
	 * @return a reference to *this
	 */
	CIMInstance& removeProperty(const CIMName& propName);
	/**
	 * Create an CIMInstance with properties and qualifiers from this
	 * instance based on filtering criteria. All properties and qualifiers that
	 * designate keys will be retained.
	 * @param propertyList The list of property names to include in the instance
	 *		that is created.
	 * @param includeQualifiers If true, All qualifiers will be retained on the
	 *		instance and properties. Otherwise all qualifiers will be omitted,
	 *		except those that designate key properties.
	 * @param includeClassOrigin If true, the class origin will be included on
	 * 	all properties and qualifiers.
	 * @param ignorePropertyList If true the propertyList parameter will be
	 *		ignored.
	 * @return An CIMInstance with properties and qualifiers from this
	 * instance based on the filtering criteria. All properties and qualifiers
	 * that designate keys will be retained.
	 */
	CIMInstance filterProperties(const blocxx::StringArray& propertyList,
		WBEMFlags::EIncludeQualifiersFlag includeQualifiers, WBEMFlags::EIncludeClassOriginFlag includeClassOrigin,
		bool ignorePropertyList=false) const;
	/**
	 * Create a new CIMInstance from this CIMInstance using the specified
	 * criteria
	 * @param localOnly If true, all inherited properties and qualifiers will be
	 *		omitted.
	 * @param includeQualifiers If false, all quailifiers will be omitted.
	 * @param includeClassOrigin If true, all element names will include the
	 *		class origin.
	 * @param propertyList An array of property names that specifies the only
	 *		properties to be included in the returned instance.
	 * @param noProps If true, all properties will be omitted from the returned
	 *		CIMInstance object regardless of the property list parameter.
	 * @return An CIMInstance object based on this one, filtered according
	 *		to the specified criteria.
	 */
	CIMInstance clone(WBEMFlags::ELocalOnlyFlag localOnly, WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
		WBEMFlags::EIncludeClassOriginFlag includeClassOrigin,
		const blocxx::StringArray& propertyList = blocxx::StringArray(),
		bool noProps=false) const;
	/**
	 * Create a new CIMInstance from this CIMInstance using the specified
	 * criteria
	 * @param localOnly If true, all inherited properties and qualifiers will be
	 *		omitted.
	 * @param includeQualifiers If false, all quailifiers will be omitted.
	 * @param includeClassOrigin If true, all element names will include the
	 *		class origin.
	 * @param propertyList A pointer to an array of property names that
	 *		specifies the only properties to be included in the returned
	 *		instance. If NULL, all properties are included. If not NULL and
	 *		the array is empty, no properties are included. If not NULL and
	 *		the array is not empty, only those properties will be included.
	 * @return An CIMInstance object based on this one, filtered according
	 *		to the specified criteria.
	 */
	CIMInstance clone(WBEMFlags::ELocalOnlyFlag localOnly, WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
		WBEMFlags::EIncludeClassOriginFlag includeClassOrigin, const blocxx::StringArray* propertyList) const;
	/**
	 * Create a new CIMInstance from this CIMInstance using the specified
	 * criteria.  This is useful for implementing enumInstances correctly
	 * for the localOnly and deep parameters.
	 * @param localOnly If true, all inherited properties and qualifiers will be
	 *		omitted.
	 * @param deep If false, all derived properties and qualifiers will be omitted.
	 * @param includeQualifiers If false, all quailifiers will be omitted.
	 * @param includeClassOrigin If true, all element names will include the
	 *		class origin.
	 * @param propertyList A pointer to an array of property names that
	 *		specifies the only properties to be included in the returned
	 *		instance. If NULL, all properties are included. If not NULL and
	 *		the array is empty, no properties are included. If not NULL and
	 *		the array is not empty, only those properties will be included.
	 * @param requestedClass The class that was requested in the enumInstances
	 * 		call.  This is used in filtering the properties.
	 * @param cimClass The class of this instance. This is used in filtering
	 *		the properties.
	 * @return An CIMInstance object based on this one, filtered according
	 *		to the specified criteria.
	 */
	CIMInstance clone(WBEMFlags::ELocalOnlyFlag localOnly, WBEMFlags::EDeepFlag deep, WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
		WBEMFlags::EIncludeClassOriginFlag includeClassOrigin, const blocxx::StringArray* propertyList,
		const CIMClass& requestedClass, const CIMClass& cimClass) const;
	/**
	 * Synchronize this instance with the given class. This will ensure that
	 * all properties found on the class exist on this instance. It will also
	 * optionally move all qualifiers from the class to the instance.
	 * @param cc	The class to synchronize this instance with.
	 * @param includeQualifiers If E_EXCLUDE_QUALIFIERS, the instance will not contain any
	 *		qualifiers (except key designators) after the operation. If true, all
	 *		relevant qualifiers are copied from the class to the instance.
	 * @return a reference to *this
	 */
	CIMInstance& syncWithClass(const CIMClass& cc,
		WBEMFlags::EIncludeQualifiersFlag includeQualifiers = WBEMFlags::E_INCLUDE_QUALIFIERS);
	/**
	 * Create an instance with the set of changes that will occur for a
	 * modifyInstance call.  This instance is the new instance.  The
	 * previous instance is passed in.  The instance that is returned
	 * is what the new instance will be after modifyInstance is applied.
	 * @param previousInstance The instance before being modified.
	 * @param includeQualifiers "If the IncludeQualifiers input parameter
	 *	is true, this specifies that the Qualifiers are modified as specified
	 *	in the ModifiedInstance.  If false, Qualifiers in the ModifiedInstance
	 *	are ignored and no Qualifiers are explicitly modified in the specified
	 *	Instance."
	 * @param propertyList "If the PropertyList input parameter is not NULL,
	 *	the members of the array define one or more Property names.  Only those
	 *	properties specified in the PropertyList are modified as specified in
	 *	the ModifiedInstance.  Properties of the ModifiedInstance that are
	 *	missing from the PropertyList are ignored.  If the PropertyList input
	 *	parameter is an empty array this signifies that no Properties are
	 *	explicitly modified in the specified Instance. If the PropertyList
	 *	input parameter is NULL this specifies that all Properties are updated
	 *	in the specified Instance."
	 * @param theClass The class of this instance.
	 */
	CIMInstance createModifiedInstance(
		const CIMInstance& previousInstance,
		WBEMFlags::EIncludeQualifiersFlag includeQualifiers,
		const blocxx::StringArray* propertyList,
		const CIMClass& theClass) const;
	/**
	 * @return The name of the class for this instance.
	 */
	virtual blocxx::String getName() const;
	/**
	 * Sets the class name for this instance.
	 * @param name	The new class name for this instance.
	 * @return a reference to *this
	 */
	virtual void setName(const CIMName& name);
	/**
	 * Set the namespace on this instance.
	 * This allows providers to provide additional namespace information
	 * about an instance when the instance returned comes from a
	 * namespace that is different from the namespace specified on
	 * the client's request. Typically used in an associators call.
	 * @param ns Specifies the namespace this instance is from.
	 * @return a reference to *this
	 */
	CIMInstance& setNameSpace(const blocxx::String& ns);
	/**
	 * @return the Namespace this instance was retrieved from.
	 * If this is an empty string, the namespace is assumed to
	 * be from the namespace that was specified on the client
	 * request.
	 */
	blocxx::String getNameSpace() const;
	/**
	 * Read this CIMInstance from an input stream.
	 * @param istrm The input stream to read this object from.
	 */
	virtual void readObject(std::streambuf & istrm);
	/**
	 * Write this CIMInstance to an output stream.
	 * @param ostrm The output stream to write this object to.
	 */
	virtual void writeObject(std::streambuf & ostrm) const;
	/**
	 * @return The MOF representation of this CIMInstance as an String.
	 */
	virtual blocxx::String toMOF() const;
	/**
	 * @return The string representation of the CIMInstance object.
	 */
	virtual blocxx::String toString() const;
	/**
	 * This compares the properties of the instances, and returns true
	 * if they are equal.  It will sort the properties before comparing,
	 * so the order of the properties is irrelevant.
	 * @param other The instance to compare
	 * @return true if the properties are the same
	 */
	bool propertiesAreEqualTo(const CIMInstance& other) const;

	BLOCXX_SAFE_BOOL_IMPL(CIMInstance, blocxx::COWIntrusiveReference<INSTData>, CIMInstance::m_pdata, m_pdata)

protected:
	void _buildKeys();

#ifdef OW_WIN32
#pragma warning (push)
#pragma warning (disable: 4251)
#endif

	blocxx::COWIntrusiveReference<INSTData> m_pdata;

#ifdef OW_WIN32
#pragma warning (pop)
#endif

	friend OW_COMMON_API bool operator<(const CIMInstance& x, const CIMInstance& y);
};

} // end namespace OW_NAMESPACE

#endif

repository: kkaempf/openwbem

repo_name: kkaempf/openwbem

branch_name: refs/heads/main

extension: hpp


text:
<?xml version="1.0" encoding="UTF-8"?>
<drawing version="7">
    <attr value="spartan3a" name="DeviceFamilyName">
        <trait delete="all:0" />
        <trait editname="all:0" />
        <trait edittrait="all:0" />
    </attr>
    <netlist>
        <signal name="XLXN_1214" />
        <signal name="CLK" />
        <signal name="XLXN_1216" />
        <signal name="SAMPC(7:0)" />
        <signal name="LAA0" />
        <signal name="XLXN_1219" />
        <signal name="XLXN_1369" />
        <signal name="XLXN_8" />
        <signal name="XLXN_1370" />
        <signal name="XLXN_10" />
        <signal name="XLXN_11" />
        <signal name="SAMPC(3)" />
        <signal name="XLXN_1235" />
        <signal name="XLXN_1236" />
        <signal name="XLXN_1245" />
        <signal name="XLXN_1246" />
        <signal name="XLXN_1247" />
        <signal name="XLXN_1248" />
        <signal name="XLXN_1249" />
        <signal name="LED0" />
        <signal name="LED1" />
        <signal name="LED2" />
        <signal name="LED3" />
        <signal name="XLXN_24" />
        <signal name="XLXN_1374" />
        <signal name="XLXN_26" />
        <signal name="XLXN_27" />
        <signal name="XLXN_28" />
        <signal name="XLXN_29" />
        <signal name="XLXN_30" />
        <signal name="LA_CLK" />
        <signal name="PSW0" />
        <signal name="PSW1" />
        <port polarity="Input" name="CLK" />
        <port polarity="Output" name="LED0" />
        <port polarity="Output" name="LED1" />
        <port polarity="Output" name="LED2" />
        <port polarity="Output" name="LED3" />
        <port polarity="Input" name="PSW0" />
        <port polarity="Input" name="PSW1" />
        <blockdef name="cb16re">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="320" y1="-128" y2="-128" x1="384" />
            <line x2="64" y1="-192" y2="-192" x1="0" />
            <line x2="64" y1="-32" y2="-32" x1="192" />
            <line x2="192" y1="-64" y2="-32" x1="192" />
            <line x2="64" y1="-32" y2="-32" x1="0" />
            <line x2="64" y1="-128" y2="-144" x1="80" />
            <line x2="80" y1="-112" y2="-128" x1="64" />
            <line x2="64" y1="-128" y2="-128" x1="0" />
            <line x2="320" y1="-256" y2="-256" x1="384" />
            <rect width="64" x="320" y="-268" height="24" />
            <line x2="320" y1="-192" y2="-192" x1="384" />
            <rect width="256" x="64" y="-320" height="256" />
        </blockdef>
        <blockdef name="vcc">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="64" y1="-32" y2="-64" x1="64" />
            <line x2="64" y1="0" y2="-32" x1="64" />
            <line x2="32" y1="-64" y2="-64" x1="96" />
        </blockdef>
        <blockdef name="cb8re">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="320" y1="-192" y2="-192" x1="384" />
            <line x2="64" y1="-192" y2="-192" x1="0" />
            <line x2="64" y1="-32" y2="-32" x1="192" />
            <line x2="192" y1="-64" y2="-32" x1="192" />
            <line x2="64" y1="-32" y2="-32" x1="0" />
            <line x2="64" y1="-128" y2="-144" x1="80" />
            <line x2="80" y1="-112" y2="-128" x1="64" />
            <line x2="64" y1="-128" y2="-128" x1="0" />
            <line x2="320" y1="-256" y2="-256" x1="384" />
            <rect width="64" x="320" y="-268" height="24" />
            <line x2="320" y1="-128" y2="-128" x1="384" />
            <rect width="256" x="64" y="-320" height="256" />
        </blockdef>
        <blockdef name="ibufg">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="64" y1="0" y2="-64" x1="64" />
            <line x2="64" y1="-32" y2="0" x1="128" />
            <line x2="128" y1="-64" y2="-32" x1="64" />
            <line x2="128" y1="-32" y2="-32" x1="224" />
            <line x2="64" y1="-32" y2="-32" x1="0" />
        </blockdef>
        <blockdef name="ibuf">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="64" y1="0" y2="-64" x1="64" />
            <line x2="64" y1="-32" y2="0" x1="128" />
            <line x2="128" y1="-64" y2="-32" x1="64" />
            <line x2="128" y1="-32" y2="-32" x1="224" />
            <line x2="64" y1="-32" y2="-32" x1="0" />
        </blockdef>
        <blockdef name="and2">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="64" y1="-64" y2="-64" x1="0" />
            <line x2="64" y1="-128" y2="-128" x1="0" />
            <line x2="192" y1="-96" y2="-96" x1="256" />
            <arc ex="144" ey="-144" sx="144" sy="-48" r="48" cx="144" cy="-96" />
            <line x2="64" y1="-48" y2="-48" x1="144" />
            <line x2="144" y1="-144" y2="-144" x1="64" />
            <line x2="64" y1="-48" y2="-144" x1="64" />
        </blockdef>
        <blockdef name="fd">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <rect width="256" x="64" y="-320" height="256" />
            <line x2="64" y1="-128" y2="-128" x1="0" />
            <line x2="64" y1="-256" y2="-256" x1="0" />
            <line x2="320" y1="-256" y2="-256" x1="384" />
            <line x2="64" y1="-128" y2="-144" x1="80" />
            <line x2="80" y1="-112" y2="-128" x1="64" />
        </blockdef>
        <blockdef name="and2b1">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="64" y1="-48" y2="-144" x1="64" />
            <line x2="144" y1="-144" y2="-144" x1="64" />
            <line x2="64" y1="-48" y2="-48" x1="144" />
            <arc ex="144" ey="-144" sx="144" sy="-48" r="48" cx="144" cy="-96" />
            <line x2="192" y1="-96" y2="-96" x1="256" />
            <line x2="64" y1="-128" y2="-128" x1="0" />
            <line x2="40" y1="-64" y2="-64" x1="0" />
            <circle r="12" cx="52" cy="-64" />
        </blockdef>
        <blockdef name="gnd">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="64" y1="-64" y2="-96" x1="64" />
            <line x2="52" y1="-48" y2="-48" x1="76" />
            <line x2="60" y1="-32" y2="-32" x1="68" />
            <line x2="40" y1="-64" y2="-64" x1="88" />
            <line x2="64" y1="-64" y2="-80" x1="64" />
            <line x2="64" y1="-128" y2="-96" x1="64" />
        </blockdef>
        <blockdef name="cb4re">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="320" y1="-192" y2="-192" x1="384" />
            <line x2="64" y1="-32" y2="-32" x1="0" />
            <line x2="64" y1="-128" y2="-128" x1="0" />
            <line x2="320" y1="-256" y2="-256" x1="384" />
            <line x2="320" y1="-320" y2="-320" x1="384" />
            <line x2="320" y1="-384" y2="-384" x1="384" />
            <line x2="320" y1="-448" y2="-448" x1="384" />
            <line x2="64" y1="-128" y2="-144" x1="80" />
            <line x2="80" y1="-112" y2="-128" x1="64" />
            <line x2="320" y1="-128" y2="-128" x1="384" />
            <line x2="64" y1="-32" y2="-32" x1="192" />
            <line x2="192" y1="-64" y2="-32" x1="192" />
            <line x2="64" y1="-192" y2="-192" x1="0" />
            <rect width="256" x="64" y="-512" height="448" />
        </blockdef>
        <blockdef name="obuf4">
            <timestamp>2000-1-1T10:10:10</timestamp>
            <line x2="64" y1="0" y2="-64" x1="64" />
            <line x2="64" y1="-32" y2="0" x1="128" />
            <line x2="128" y1="-64" y2="-32" x1="64" />
            <line x2="64" y1="-128" y2="-192" x1="64" />
            <line x2="64" y1="-160" y2="-128" x1="128" />
            <line x2="128" y1="-192" y2="-160" x1="64" />
            <line x2="64" y1="-192" y2="-256" x1="64" />
            <line x2="64" y1="-224" y2="-192" x1="128" />
            <line x2="128" y1="-256" y2="-224" x1="64" />
            <line x2="128" y1="-224" y2="-224" x1="224" />
            <line x2="128" y1="-160" y2="-160" x1="224" />
            <line x2="64" y1="-96" y2="-96" x1="0" />
            <line x2="128" y1="-96" y2="-96" x1="224" />
            <line x2="64" y1="-64" y2="-128" x1="64" />
            <line x2="64" y1="-96" y2="-64" x1="128" />
            <line x2="128" y1="-128" y2="-96" x1="64" />
            <line x2="64" y1="-160" y2="-160" x1="0" />
            <line x2="64" y1="-224" y2="-224" x1="0" />
            <line x2="64" y1="-32" y2="-32" x1="0" />
            <line x2="128" y1="-32" y2="-32" x1="224" />
        </blockdef>
        <blockdef name="CHAT_FILTER_VHDL">
            <timestamp>2008-11-11T15:53:45</timestamp>
            <rect width="256" x="64" y="-192" height="192" />
            <line x2="0" y1="-160" y2="-160" x1="64" />
            <line x2="0" y1="-96" y2="-96" x1="64" />
            <line x2="0" y1="-32" y2="-32" x1="64" />
            <line x2="384" y1="-160" y2="-160" x1="320" />
        </blockdef>
        <block symbolname="cb16re" name="XLXI_247">
            <blockpin signalname="LA_CLK" name="C" />
            <blockpin signalname="XLXN_1214" name="CE" />
            <blockpin signalname="SAMPC(3)" name="R" />
            <blockpin signalname="XLXN_1216" name="CEO" />
            <blockpin name="Q(15:0)" />
            <blockpin name="TC" />
        </block>
        <block symbolname="vcc" name="XLXI_248">
            <blockpin signalname="XLXN_1214" name="P" />
        </block>
        <block symbolname="cb8re" name="XLXI_250">
            <blockpin signalname="LA_CLK" name="C" />
            <blockpin signalname="XLXN_1216" name="CE" />
            <blockpin signalname="SAMPC(3)" name="R" />
            <blockpin name="CEO" />
            <blockpin signalname="SAMPC(7:0)" name="Q(7:0)" />
            <blockpin name="TC" />
        </block>
        <block symbolname="ibufg" name="XLXI_263">
            <blockpin signalname="CLK" name="I" />
            <blockpin signalname="LA_CLK" name="O" />
        </block>
        <block symbolname="ibuf" name="XLXI_3">
            <blockpin signalname="PSW0" name="I" />
            <blockpin signalname="LAA0" name="O" />
        </block>
        <block symbolname="ibuf" name="XLXI_6">
            <blockpin signalname="PSW1" name="I" />
            <blockpin signalname="XLXN_1219" name="O" />
        </block>
        <block symbolname="and2" name="XLXI_278">
            <blockpin signalname="XLXN_1370" name="I0" />
            <blockpin signalname="XLXN_1369" name="I1" />
            <blockpin signalname="XLXN_1374" name="O" />
        </block>
        <block symbolname="fd" name="XLXI_258">
            <blockpin signalname="LA_CLK" name="C" />
            <blockpin signalname="XLXN_1374" name="D" />
            <blockpin signalname="XLXN_1235" name="Q" />
        </block>
        <block symbolname="and2b1" name="XLXI_259">
            <blockpin signalname="XLXN_1235" name="I0" />
            <blockpin signalname="XLXN_1374" name="I1" />
            <blockpin signalname="XLXN_1236" name="O" />
        </block>
        <block symbolname="gnd" name="XLXI_260">
            <blockpin signalname="XLXN_1249" name="G" />
        </block>
        <block symbolname="cb4re" name="XLXI_261">
            <blockpin signalname="LA_CLK" name="C" />
            <blockpin signalname="XLXN_1236" name="CE" />
            <blockpin signalname="XLXN_1249" name="R" />
            <blockpin name="CEO" />
            <blockpin signalname="XLXN_1245" name="Q0" />
            <blockpin signalname="XLXN_1246" name="Q1" />
            <blockpin signalname="XLXN_1247" name="Q2" />
            <blockpin signalname="XLXN_1248" name="Q3" />
            <blockpin name="TC" />
        </block>
        <block symbolname="obuf4" name="XLXI_262">
            <blockpin signalname="XLXN_1245" name="I0" />
            <blockpin signalname="XLXN_1246" name="I1" />
            <blockpin signalname="XLXN_1247" name="I2" />
            <blockpin signalname="XLXN_1248" name="I3" />
            <blockpin signalname="LED0" name="O0" />
            <blockpin signalname="LED1" name="O1" />
            <blockpin signalname="LED2" name="O2" />
            <blockpin signalname="LED3" name="O3" />
        </block>
        <block symbolname="CHAT_FILTER_VHDL" name="XLXI_282">
            <blockpin signalname="LAA0" name="DIN" />
            <blockpin signalname="SAMPC(3)" name="CE" />
            <blockpin signalname="LA_CLK" name="CLK" />
            <blockpin signalname="XLXN_1369" name="DOUT_ONE" />
        </block>
        <block symbolname="CHAT_FILTER_VHDL" name="XLXI_283">
            <blockpin signalname="XLXN_1219" name="DIN" />
            <blockpin signalname="SAMPC(3)" name="CE" />
            <blockpin signalname="LA_CLK" name="CLK" />
            <blockpin signalname="XLXN_1370" name="DOUT_ONE" />
        </block>
    </netlist>
    <sheet sheetnum="1" width="3776" height="1920">
        <attr value="CM" name="LengthUnitName" />
        <attr value="4" name="GridsPerUnit" />
        <branch name="XLXN_1214">
            <wire x2="592" y1="1296" y2="1328" x1="592" />
            <wire x2="640" y1="1328" y2="1328" x1="592" />
        </branch>
        <branch name="CLK">
            <wire x2="224" y1="1632" y2="1632" x1="192" />
        </branch>
        <branch name="XLXN_1216">
            <wire x2="1216" y1="1328" y2="1328" x1="1024" />
        </branch>
        <branch name="SAMPC(7:0)">
            <attrtext style="alignment:SOFT-BCENTER;fontsize:28;fontname:Arial" attrname="Name" x="1652" y="1264" type="branch" />
            <wire x2="1652" y1="1264" y2="1264" x1="1600" />
            <wire x2="1712" y1="1264" y2="1264" x1="1652" />
            <wire x2="1712" y1="1264" y2="1328" x1="1712" />
        </branch>
        <branch name="LAA0">
            <wire x2="896" y1="448" y2="448" x1="608" />
        </branch>
        <branch name="XLXN_1219">
            <wire x2="896" y1="800" y2="800" x1="608" />
        </branch>
        <branch name="XLXN_1369">
            <wire x2="1456" y1="448" y2="448" x1="1280" />
            <wire x2="1456" y1="448" y2="576" x1="1456" />
            <wire x2="1552" y1="576" y2="576" x1="1456" />
        </branch>
        <branch name="XLXN_1370">
            <wire x2="1456" y1="800" y2="800" x1="1280" />
            <wire x2="1552" y1="640" y2="640" x1="1456" />
            <wire x2="1456" y1="640" y2="800" x1="1456" />
        </branch>
        <branch name="SAMPC(3)">
            <attrtext style="alignment:SOFT-BCENTER;fontsize:28;fontname:Arial" attrname="Name" x="1937" y="1328" type="branch" />
            <wire x2="640" y1="1488" y2="1568" x1="640" />
            <wire x2="1216" y1="1568" y2="1568" x1="640" />
            <wire x2="2064" y1="1568" y2="1568" x1="1216" />
            <wire x2="768" y1="512" y2="864" x1="768" />
            <wire x2="896" y1="864" y2="864" x1="768" />
            <wire x2="768" y1="864" y2="1088" x1="768" />
            <wire x2="2064" y1="1088" y2="1088" x1="768" />
            <wire x2="2064" y1="1088" y2="1328" x1="2064" />
            <wire x2="2064" y1="1328" y2="1568" x1="2064" />
            <wire x2="896" y1="512" y2="512" x1="768" />
            <wire x2="1216" y1="1488" y2="1568" x1="1216" />
            <wire x2="1937" y1="1328" y2="1328" x1="1808" />
            <wire x2="2064" y1="1328" y2="1328" x1="1937" />
        </branch>
        <branch name="XLXN_1235">
            <wire x2="2464" y1="608" y2="608" x1="2384" />
        </branch>
        <branch name="XLXN_1236">
            <wire x2="2864" y1="576" y2="576" x1="2720" />
        </branch>
        <branch name="XLXN_1245">
            <wire x2="3328" y1="320" y2="320" x1="3248" />
        </branch>
        <branch name="XLXN_1246">
            <wire x2="3328" y1="384" y2="384" x1="3248" />
        </branch>
        <branch name="XLXN_1247">
            <wire x2="3328" y1="448" y2="448" x1="3248" />
        </branch>
        <branch name="XLXN_1248">
            <wire x2="3328" y1="512" y2="512" x1="3248" />
        </branch>
        <branch name="XLXN_1249">
            <wire x2="2864" y1="736" y2="736" x1="2832" />
            <wire x2="2832" y1="736" y2="768" x1="2832" />
        </branch>
        <branch name="LED0">
            <wire x2="3584" y1="320" y2="320" x1="3552" />
        </branch>
        <branch name="LED1">
            <wire x2="3584" y1="384" y2="384" x1="3552" />
        </branch>
        <branch name="LED2">
            <wire x2="3584" y1="448" y2="448" x1="3552" />
        </branch>
        <branch name="LED3">
            <wire x2="3584" y1="512" y2="512" x1="3552" />
        </branch>
        <branch name="XLXN_1374">
            <wire x2="1904" y1="608" y2="608" x1="1808" />
            <wire x2="2000" y1="608" y2="608" x1="1904" />
            <wire x2="2400" y1="432" y2="432" x1="1904" />
            <wire x2="2400" y1="432" y2="544" x1="2400" />
            <wire x2="2464" y1="544" y2="544" x1="2400" />
            <wire x2="1904" y1="432" y2="608" x1="1904" />
        </branch>
        <branch name="LA_CLK">
            <wire x2="512" y1="1632" y2="1632" x1="448" />
            <wire x2="1104" y1="1632" y2="1632" x1="512" />
            <wire x2="688" y1="928" y2="928" x1="512" />
            <wire x2="896" y1="928" y2="928" x1="688" />
            <wire x2="512" y1="928" y2="1008" x1="512" />
            <wire x2="512" y1="1008" y2="1392" x1="512" />
            <wire x2="640" y1="1392" y2="1392" x1="512" />
            <wire x2="512" y1="1392" y2="1632" x1="512" />
            <wire x2="1920" y1="1008" y2="1008" x1="512" />
            <wire x2="896" y1="576" y2="576" x1="688" />
            <wire x2="688" y1="576" y2="928" x1="688" />
            <wire x2="1216" y1="1392" y2="1392" x1="1104" />
            <wire x2="1104" y1="1392" y2="1632" x1="1104" />
            <wire x2="2000" y1="736" y2="736" x1="1920" />
            <wire x2="1920" y1="736" y2="896" x1="1920" />
            <wire x2="2720" y1="896" y2="896" x1="1920" />
            <wire x2="1920" y1="896" y2="1008" x1="1920" />
            <wire x2="2864" y1="640" y2="640" x1="2720" />
            <wire x2="2720" y1="640" y2="896" x1="2720" />
        </branch>
        <branch name="PSW0">
            <wire x2="384" y1="448" y2="448" x1="272" />
        </branch>
        <branch name="PSW1">
            <wire x2="384" y1="800" y2="800" x1="272" />
        </branch>
        <instance x="640" y="1520" name="XLXI_247" orien="R0" />
        <instance x="528" y="1296" name="XLXI_248" orien="R0" />
        <instance x="1216" y="1520" name="XLXI_250" orien="R0" />
        <bustap x2="1808" y1="1328" y2="1328" x1="1712" />
        <instance x="224" y="1664" name="XLXI_263" orien="R0" />
        <instance x="384" y="480" name="XLXI_3" orien="R0" />
        <text style="fontsize:48;fontname:Arial" x="192" y="212">SW_COUNT2b</text>
        <instance x="384" y="832" name="XLXI_6" orien="R0" />
        <instance x="1552" y="704" name="XLXI_278" orien="R0" />
        <instance x="2000" y="864" name="XLXI_258" orien="R0" />
        <instance x="2464" y="672" name="XLXI_259" orien="R0" />
        <instance x="2768" y="896" name="XLXI_260" orien="R0" />
        <instance x="2864" y="768" name="XLXI_261" orien="R0" />
        <instance x="3328" y="544" name="XLXI_262" orien="R0" />
        <text style="fontsize:48;fontname:Arial" x="3064" y="1556">by Susutawari</text>
        <iomarker fontsize="28" x="192" y="1632" name="CLK" orien="R180" />
        <iomarker fontsize="28" x="272" y="448" name="PSW0" orien="R180" />
        <iomarker fontsize="28" x="272" y="800" name="PSW1" orien="R180" />
        <iomarker fontsize="28" x="3584" y="320" name="LED0" orien="R0" />
        <iomarker fontsize="28" x="3584" y="384" name="LED1" orien="R0" />
        <iomarker fontsize="28" x="3584" y="448" name="LED2" orien="R0" />
        <iomarker fontsize="28" x="3584" y="512" name="LED3" orien="R0" />
        <instance x="896" y="608" name="XLXI_282" orien="R0">
        </instance>
        <instance x="896" y="960" name="XLXI_283" orien="R0">
        </instance>
    </sheet>
</drawing>

repository: shohei/susubook

license_type: permissive

repo_name: shohei/susubook

branch_name: refs/heads/master

extension: sch


text:
package gounity_test

import (
	"testing"

	"github.com/Murray-LIANG/gounity/testutil"
	"github.com/stretchr/testify/assert"
)

func TestGetHostById(t *testing.T) {
	ctx, err := testutil.NewTestContext()
	assert.Nil(t, err, "failed to setup rest client to mock server")
	defer ctx.TearDown()

	host, err := ctx.Unity.GetHostById("Host_1")

	assert.Nil(t, err)

	assert.Equal(t, "Host_1", host.Id)
}

func TestGetHosts(t *testing.T) {
	ctx, err := testutil.NewTestContext()
	assert.Nil(t, err, "failed to setup rest client to mock server")
	defer ctx.TearDown()

	hosts, err := ctx.Unity.GetHosts()
	assert.Nil(t, err)

	assert.Equal(t, 4, len(hosts))
	ids := []string{}
	for _, host := range hosts {
		ids = append(ids, host.Id)
	}
	assert.EqualValues(t, []string{"Host_1", "Host_2", "Host_3", "Host_4"}, ids)
}

func TestAttach(t *testing.T) {
	ctx, err := testutil.NewTestContext()
	assert.Nil(t, err, "failed to setup rest client to mock server")
	defer ctx.TearDown()

	host, err := ctx.Unity.GetHostById("Host_1")
	assert.Nil(t, err)

	lun, err := ctx.Unity.GetLunById("sv_1")
	assert.Nil(t, err)

	hlu, err := host.Attach(lun)
	assert.Nil(t, err)

	assert.Equal(t, uint16(1), hlu)
}

repository: Murray-LIANG/gounity

repo_name: Murray-LIANG/gounity

branch_name: refs/heads/develop

gha_language: Go

extension: go


text:
@article{dornelas2018biotime,
 author = {Dornelas, Maria and Antao, Laura H and Moyes, Faye and Bates, Amanda E and Magurran, Anne E and Adam, Dušan and Akhmetzhanova, Asem A and Appeltans, Ward and Arcos, Jose Manuel and Arnold, Haley and others},
 journal = {Global Ecology and Biogeography},
 number = {7},
 pages = {760--786},
 title = {BioTIME: A database of biodiversity time series for the Anthropocene},
 volume = {27},
 year = {2018}
}

license: MIT

repository: weecology/website

repo_name: weecology/website

gha_license_id: MIT

gha_language: TeX

extension: bib


text:
import { Vector as VectorLayer } from 'ol/layer';
import VectorSource from 'ol/source/Vector';
import Feature from 'ol/Feature';
import Polygon from 'ol/geom/Polygon';
import { Style, Fill } from 'ol/style';
import { Frame, GeoJSON, FeatureGeojson } from '../types';

const percentageToHsl = (percentage: number) => {
  const hue = percentage * -120 + 120;
  return 'hsla(' + hue + ', 100%, 50%, 0.45)';
};

const createPolygon = (feature: FeatureGeojson, value: string, color: string) => {
  let coordinates: number[][][] = [];
  if (feature.geometry.type == 'Polygon') {
    coordinates = feature.geometry.coordinates;
  } else if (feature.geometry.type == 'LineString') {
    // @ts-ignore
    coordinates = [feature.geometry.coordinates];
  }
  const polygonFeature = new Feature({
    type: 'Polygon',
    geometry: new Polygon(coordinates).transform('EPSG:4326', 'EPSG:3857'),
  });
  polygonFeature.set('value', value);
  polygonFeature.set('color', color);
  polygonFeature.setStyle(
    new Style({
      fill: new Fill({
        color: color,
      }),
    })
  );
  return polygonFeature;
};

export const createHeatLayer = (series: Frame[], geojson: GeoJSON) => {
  const assignValueToStore: { [key: string]: number } = {};
  const assignValueToStoreLog: { [key: string]: number } = {};

  series.map(item => {
    const sumValue = item.fields[0].values.buffer.slice(-1)[0] || 0;
    if (item.name) {
      assignValueToStore[item.name] = sumValue;
      assignValueToStoreLog[item.name] = Math.log2(sumValue + 1);
    }
  });

  const heatValues = Object.values(assignValueToStoreLog);
  const max = Math.max(...heatValues);
  const min = Math.min(...heatValues);
  const range = max - min;

  const polygons: Feature[] = [];

  geojson.features.map(feature => {
    if (feature.properties && feature.properties.id /* && stores.includes(feature.properties.id) */) {
      if (assignValueToStore[feature.properties.id]) {
        const percentage = range != 0 ? (assignValueToStoreLog[feature.properties.id] - min) / range : 0;
        polygons.push(
          createPolygon(feature, assignValueToStore[feature.properties.id].toFixed(3), percentageToHsl(percentage))
        );
      } else {
        polygons.push(createPolygon(feature, '', 'rgba(125, 126, 126, 0.2)'));
      }
      // const valueLabel = assignValueToStore[feature.properties.id] || 0;
      // let percentage = 0;
      // if (assignValueToStoreLog[feature.properties.id] && range != 0) {
      //   percentage = (assignValueToStoreLog[feature.properties.id] - min) / range;
      // }
      // polygons.push(createPolygon(feature, valueLabel.toFixed(3), percentageToHsl(percentage)));
    }
  });

  return new VectorLayer({
    source: new VectorSource({
      features: polygons,
    }),
    zIndex: 2,
  });
};

extension: ts