# LocalPackage

<a id="localpackage"></a>

# LocalPackage

```cpp
#include <icy/pacm/package.h>

struct LocalPackage
```

[Defined in src/pacm/include/icy/pacm/package.h:189](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L189)

> **Inherits:** [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package)

[Package](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) metadata for an installed package on the local filesystem.

## List of all members

| Name | Kind | Owner |
|------|------|-------|
| [`LocalPackage`](#localpackage-1) | `function` | Declared here |
| [`LocalPackage`](#localpackage-2) | `function` | Declared here |
| [`LocalPackage`](#localpackage-3) | `function` | Declared here |
| [`~LocalPackage`](#localpackage-4) | `function` | Declared here |
| [`setState`](#setstate-3) | `function` | Declared here |
| [`setInstallState`](#setinstallstate) | `function` | Declared here |
| [`setInstallDir`](#setinstalldir) | `function` | Declared here |
| [`setInstalledAsset`](#setinstalledasset) | `function` | Declared here |
| [`setVersion`](#setversion-2) | `function` | Declared here |
| [`setVersionLock`](#setversionlock) | `function` | Declared here |
| [`setSDKVersionLock`](#setsdkversionlock) | `function` | Declared here |
| [`version`](#version-4) | `function` | Declared here |
| [`state`](#state-7) | `function` | Declared here |
| [`installState`](#installstate) | `function` | Declared here |
| [`installDir`](#installdir-1) | `function` | Declared here |
| [`versionLock`](#versionlock) | `function` | Declared here |
| [`sdkLockedVersion`](#sdklockedversion) | `function` | Declared here |
| [`asset`](#asset) | `function` | Declared here |
| [`isInstalled`](#isinstalled) | `function` | Declared here |
| [`isFailed`](#isfailed) | `function` | Declared here |
| [`manifest`](#manifest) | `function` | Declared here |
| [`verifyInstallManifest`](#verifyinstallmanifest) | `function` | Declared here |
| [`getInstalledFilePath`](#getinstalledfilepath) | `function` | Declared here |
| [`extensionEntryPointPath`](#extensionentrypointpath) | `function` | Declared here |
| [`errors`](#errors-2) | `function` | Declared here |
| [`addError`](#adderror) | `function` | Declared here |
| [`lastError`](#lasterror) | `function` | Declared here |
| [`clearErrors`](#clearerrors) | `function` | Declared here |
| [`valid`](#valid-3) | `function` | Declared here |
| [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package-1) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package-2) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`~Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package-3) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`id`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#id-7) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`name`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#name-10) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`type`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#type-14) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`author`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#author) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`description`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#description-1) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`hasExtension`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#hasextension) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`extension`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#extension) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`valid`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#valid-4) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`toJson`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#tojson) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |
| [`print`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#print-11) | `function` | Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package) |

## Inherited from [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package)

| Kind | Name | Description |
|------|------|-------------|
| `function` | [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package-1)  | Constructs an empty package. |
| `function` | [`Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package-2)  | Constructs a package from an existing JSON value. |
| `function` | [`~Package`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#package-3) `virtual` `noexcept` |  |
| `function` | [`id`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#id-7) `virtual` `const` | Returns the package unique identifier. |
| `function` | [`name`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#name-10) `virtual` `const` | Returns the package display name. |
| `function` | [`type`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#type-14) `virtual` `const` | Returns the package type (e.g. "plugin", "asset"). |
| `function` | [`author`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#author) `virtual` `const` | Returns the package author string. |
| `function` | [`description`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#description-1) `virtual` `const` | Returns the package description string. |
| `function` | [`hasExtension`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#hasextension) `virtual` `const` | Returns true when the package has an "extension" object. |
| `function` | [`extension`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#extension) `virtual` `const` | Returns a read-only view of the extension metadata. Throws if no extension object is present. |
| `function` | [`valid`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#valid-4) `virtual` `const` | Returns true if id, name and type are all non-empty. |
| `function` | [`toJson`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#tojson) `virtual` `const` | Returns a plain JSON copy of this package object. |
| `function` | [`print`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#print-11) `virtual` `const` | Dumps the JSON representation of this package to `ost`. |

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`LocalPackage`](#localpackage-1)  | Constructs an empty local package. |
|  | [`LocalPackage`](#localpackage-2)  | Constructs a local package from an existing JSON value. |
|  | [`LocalPackage`](#localpackage-3)  | Create the local package from the remote package reference with the following manipulations. 1) Add a local manifest element. 2) Remove asset mirror elements. |
|  | [`~LocalPackage`](#localpackage-4) `virtual` `noexcept` |  |
| `void` | [`setState`](#setstate-3) `virtual` | Set's the overall package state. Possible values are: Installing, Installed, Failed, Uninstalled. If the packages completes while still Installing, this means the package has yet to be finalized. |
| `void` | [`setInstallState`](#setinstallstate) `virtual` | Set's the package installation state. See [InstallationState](https://auscaster.com/icey/docs/api-reference/icy-pacm-InstallationState.md#installationstate) for possible values. |
| `void` | [`setInstallDir`](#setinstalldir) `virtual` | Set's the installation directory for this package. |
| `void` | [`setInstalledAsset`](#setinstalledasset) `virtual` | Sets the installed asset, once installed. This method also sets the version. |
| `void` | [`setVersion`](#setversion-2) `virtual` | Sets the current version of the local package. Installation must be complete. |
| `void` | [`setVersionLock`](#setversionlock) `virtual` | Locks the package at the given version. Once set this package will not be updated past the given version. Pass an empty string to remove the lock. |
| `void` | [`setSDKVersionLock`](#setsdkversionlock) `virtual` | Locks the package at the given SDK version. Once set this package will only update to the most recent version with given SDK version. Pass an empty string to remove the lock. |
| `std::string` | [`version`](#version-4) `virtual` `const` | Returns the installed package version. |
| `std::string` | [`state`](#state-7) `virtual` `const` | Returns the current state of this package. |
| `std::string` | [`installState`](#installstate) `virtual` `const` | Returns the installation state of this package. |
| `std::string` | [`installDir`](#installdir-1) `virtual` `const` | Returns the installation directory for this package. |
| `std::string` | [`versionLock`](#versionlock) `virtual` `const` | Returns the pinned version string, or empty if no lock is set. |
| `std::string` | [`sdkLockedVersion`](#sdklockedversion) `virtual` `const` | Returns the pinned SDK version string, or empty if no lock is set. |
| [`Asset`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package-Asset.md#asset-1) | [`asset`](#asset) `virtual` | Returns the currently installed asset, if any. If none, the returned asset will be empty(). |
| `bool` | [`isInstalled`](#isinstalled) `virtual` `const` | Returns true or false depending on weather or not the package is installed successfully. False if package is in Failed state. |
| `bool` | [`isFailed`](#isfailed) `virtual` `const` | Returns true if the package state is "Failed". |
| [`Manifest`](https://auscaster.com/icey/docs/api-reference/icy-pacm-LocalPackage-Manifest.md#manifest-1) | [`manifest`](#manifest) `virtual` | Returns the installation manifest. |
| `bool` | [`verifyInstallManifest`](#verifyinstallmanifest) `virtual` |  |
| `std::string` | [`getInstalledFilePath`](#getinstalledfilepath) `virtual` | Returns the full full path of the installed file. Thrown an exception if the install directory is unset. |
| `std::string` | [`extensionEntryPointPath`](#extensionentrypointpath) `virtual` `const` | Returns the install-relative extension entrypoint resolved against [installDir()](#installdir-1). Returns an empty string when no extension metadata is present. |
| [`json::Value`](https://auscaster.com/icey/docs/api-reference/icy-json.md#value) & | [`errors`](#errors-2) `virtual` | Returns a reference to the JSON array of accumulated error messages. |
| `void` | [`addError`](#adderror) `virtual` | Appends `message` to the errors array. |
| `std::string` | [`lastError`](#lasterror) `virtual` `const` | Returns the most recently added error message, or empty if none. |
| `void` | [`clearErrors`](#clearerrors) `virtual` | Clears all recorded error messages. |
| `bool` | [`valid`](#valid-3) `virtual` `const` | Returns true if id, name and type are all non-empty. |

---

<a id="localpackage-1"></a>

### LocalPackage

```cpp
LocalPackage()
```

[Defined in src/pacm/include/icy/pacm/package.h:213](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L213)

Constructs an empty local package.

---

<a id="localpackage-2"></a>

### LocalPackage

```cpp
LocalPackage(const json::Value & src)
```

[Defined in src/pacm/include/icy/pacm/package.h:217](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L217)

Constructs a local package from an existing JSON value.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `src` | const [`json::Value`](https://auscaster.com/icey/docs/api-reference/icy-json.md#value) & | JSON object containing local package fields. |

---

<a id="localpackage-3"></a>

### LocalPackage

```cpp
LocalPackage(const RemotePackage & src)
```

[Defined in src/pacm/include/icy/pacm/package.h:223](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L223)

Create the local package from the remote package reference with the following manipulations. 1) Add a local manifest element. 2) Remove asset mirror elements.

---

<a id="localpackage-4"></a>

### ~LocalPackage

`virtual` `noexcept`

```cpp
virtual ~LocalPackage() noexcept
```

[Defined in src/pacm/include/icy/pacm/package.h:226](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L226)

---

<a id="setstate-3"></a>

### setState

`virtual`

```cpp
virtual void setState(const std::string & state)
```

[Defined in src/pacm/include/icy/pacm/package.h:232](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L232)

Set's the overall package state. Possible values are: Installing, Installed, Failed, Uninstalled. If the packages completes while still Installing, this means the package has yet to be finalized.

---

<a id="setinstallstate"></a>

### setInstallState

`virtual`

```cpp
virtual void setInstallState(const std::string & state)
```

[Defined in src/pacm/include/icy/pacm/package.h:236](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L236)

Set's the package installation state. See [InstallationState](https://auscaster.com/icey/docs/api-reference/icy-pacm-InstallationState.md#installationstate) for possible values.

---

<a id="setinstalldir"></a>

### setInstallDir

`virtual`

```cpp
virtual void setInstallDir(const std::string & dir)
```

[Defined in src/pacm/include/icy/pacm/package.h:239](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L239)

Set's the installation directory for this package.

---

<a id="setinstalledasset"></a>

### setInstalledAsset

`virtual`

```cpp
virtual void setInstalledAsset(const Package::Asset & installedRemoteAsset)
```

[Defined in src/pacm/include/icy/pacm/package.h:243](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L243)

Sets the installed asset, once installed. This method also sets the version.

---

<a id="setversion-2"></a>

### setVersion

`virtual`

```cpp
virtual void setVersion(const std::string & version)
```

[Defined in src/pacm/include/icy/pacm/package.h:247](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L247)

Sets the current version of the local package. Installation must be complete.

---

<a id="setversionlock"></a>

### setVersionLock

`virtual`

```cpp
virtual void setVersionLock(const std::string & version)
```

[Defined in src/pacm/include/icy/pacm/package.h:253](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L253)

Locks the package at the given version. Once set this package will not be updated past the given version. Pass an empty string to remove the lock.

---

<a id="setsdkversionlock"></a>

### setSDKVersionLock

`virtual`

```cpp
virtual void setSDKVersionLock(const std::string & version)
```

[Defined in src/pacm/include/icy/pacm/package.h:259](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L259)

Locks the package at the given SDK version. Once set this package will only update to the most recent version with given SDK version. Pass an empty string to remove the lock.

---

<a id="version-4"></a>

### version

`virtual` `const`

```cpp
virtual std::string version() const
```

[Defined in src/pacm/include/icy/pacm/package.h:262](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L262)

Returns the installed package version.

---

<a id="state-7"></a>

### state

`virtual` `const`

```cpp
virtual std::string state() const
```

[Defined in src/pacm/include/icy/pacm/package.h:265](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L265)

Returns the current state of this package.

---

<a id="installstate"></a>

### installState

`virtual` `const`

```cpp
virtual std::string installState() const
```

[Defined in src/pacm/include/icy/pacm/package.h:268](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L268)

Returns the installation state of this package.

---

<a id="installdir-1"></a>

### installDir

`virtual` `const`

```cpp
virtual std::string installDir() const
```

[Defined in src/pacm/include/icy/pacm/package.h:271](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L271)

Returns the installation directory for this package.

---

<a id="versionlock"></a>

### versionLock

`virtual` `const`

```cpp
virtual std::string versionLock() const
```

[Defined in src/pacm/include/icy/pacm/package.h:275](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L275)

Returns the pinned version string, or empty if no lock is set.

---

<a id="sdklockedversion"></a>

### sdkLockedVersion

`virtual` `const`

```cpp
virtual std::string sdkLockedVersion() const
```

[Defined in src/pacm/include/icy/pacm/package.h:278](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L278)

Returns the pinned SDK version string, or empty if no lock is set.

---

<a id="asset"></a>

### asset

`virtual`

```cpp
virtual Asset asset()
```

[Defined in src/pacm/include/icy/pacm/package.h:282](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L282)

Returns the currently installed asset, if any. If none, the returned asset will be empty().

---

<a id="isinstalled"></a>

### isInstalled

`virtual` `const`

```cpp
virtual bool isInstalled() const
```

[Defined in src/pacm/include/icy/pacm/package.h:287](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L287)

Returns true or false depending on weather or not the package is installed successfully. False if package is in Failed state.

---

<a id="isfailed"></a>

### isFailed

`virtual` `const`

```cpp
virtual bool isFailed() const
```

[Defined in src/pacm/include/icy/pacm/package.h:290](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L290)

Returns true if the package state is "Failed".

---

<a id="manifest"></a>

### manifest

`virtual`

```cpp
virtual Manifest manifest()
```

[Defined in src/pacm/include/icy/pacm/package.h:293](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L293)

Returns the installation manifest.

---

<a id="verifyinstallmanifest"></a>

### verifyInstallManifest

`virtual`

```cpp
virtual bool verifyInstallManifest(bool allowEmpty = false)
```

[Defined in src/pacm/include/icy/pacm/package.h:295](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L295)

---

<a id="getinstalledfilepath"></a>

### getInstalledFilePath

`virtual`

```cpp
virtual std::string getInstalledFilePath(const std::string & fileName, bool whiny = false)
```

[Defined in src/pacm/include/icy/pacm/package.h:299](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L299)

Returns the full full path of the installed file. Thrown an exception if the install directory is unset.

---

<a id="extensionentrypointpath"></a>

### extensionEntryPointPath

`virtual` `const`

```cpp
virtual std::string extensionEntryPointPath(bool whiny = false) const
```

[Defined in src/pacm/include/icy/pacm/package.h:304](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L304)

Returns the install-relative extension entrypoint resolved against [installDir()](#installdir-1). Returns an empty string when no extension metadata is present.

---

<a id="errors-2"></a>

### errors

`virtual`

```cpp
virtual json::Value & errors()
```

[Defined in src/pacm/include/icy/pacm/package.h:307](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L307)

Returns a reference to the JSON array of accumulated error messages.

---

<a id="adderror"></a>

### addError

`virtual`

```cpp
virtual void addError(const std::string & message)
```

[Defined in src/pacm/include/icy/pacm/package.h:311](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L311)

Appends `message` to the errors array.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `message` | `const std::string &` | [Error](https://auscaster.com/icey/docs/api-reference/icy-Error.md#error) description to record. |

---

<a id="lasterror"></a>

### lastError

`virtual` `const`

```cpp
virtual std::string lastError() const
```

[Defined in src/pacm/include/icy/pacm/package.h:314](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L314)

Returns the most recently added error message, or empty if none.

---

<a id="clearerrors"></a>

### clearErrors

`virtual`

```cpp
virtual void clearErrors()
```

[Defined in src/pacm/include/icy/pacm/package.h:317](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L317)

Clears all recorded error messages.

---

<a id="valid-3"></a>

### valid

`virtual` `const`

```cpp
virtual bool valid() const
```

[Defined in src/pacm/include/icy/pacm/package.h:319](https://github.com/auscaster/icey/blob/main/src/pacm/include/icy/pacm/package.h#L319)

Returns true if id, name and type are all non-empty.

#### Reimplements

- [`Package::valid`](https://auscaster.com/icey/docs/api-reference/icy-pacm-Package.md#valid-4)
