Skip to content

Commit

Permalink
Encapsulate init in the aux constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Mar 18, 2024
1 parent fd27b0c commit 06fa549
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ String json =
var pipeline = new Pipeline(json, LogLevel.Error());
pipeline.initialize(); // initialize the pipeline
pipeline.execute(); // execute the pipeline
var metadata = pipeline.getMetadata(); // retrieve metadata
Expand Down
9 changes: 5 additions & 4 deletions core/src/main/scala/io/pdal/Pipeline.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import com.github.sbt.jni.syntax.NativeLoader
class Pipeline private (val json: String, val logLevel: Int) extends Native {
Pipeline // reference companion object so nativeLoader loads the JNI native libraries

def this(json: String, logLevel: LogLevel.Value = LogLevel.Error) = this(json, logLevel.id)
def this(json: String, logLevel: LogLevel.Value = LogLevel.Error) = {
this(json, logLevel.id); initialize()
}

@native def initialize(): Unit
@native def execute(): Unit
Expand All @@ -46,7 +48,6 @@ class Pipeline private (val json: String, val logLevel: Int) extends Native {
}

object Pipeline extends NativeLoader("pdaljni.2.6") {
def apply(json: String, logLevel: LogLevel.Value = LogLevel.Error): Pipeline = {
val p = new Pipeline(json, logLevel); p.initialize(); p
}
def apply(json: String, logLevel: LogLevel.Value = LogLevel.Error): Pipeline =
new Pipeline(json, logLevel)
}

0 comments on commit 06fa549

Please sign in to comment.